aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa1997-05-16 00:43:27 +0000
committerKenichi Handa1997-05-16 00:43:27 +0000
commitbd4c6dd02f88a13a645eac527c1b92c9fb5b1bdb (patch)
tree6d9c4cc4b017d060ce10adc59b12d03666360bfa /src
parentc6112b99dc8fe272b0413f2dba94eef2e606d44a (diff)
downloademacs-bd4c6dd02f88a13a645eac527c1b92c9fb5b1bdb.tar.gz
emacs-bd4c6dd02f88a13a645eac527c1b92c9fb5b1bdb.zip
(non_ascii_char_to_string): Signal error if the
argument C is an invalid character code. (Fconcat_chars): Use alloca instead of malloc.
Diffstat (limited to 'src')
-rw-r--r--src/charset.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/charset.c b/src/charset.c
index 3b599e1fe69..c0394110661 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -96,7 +96,8 @@ int _fetch_multibyte_char_len;
96 is not a composite character, the multi-byte form is set in WORKBUF 96 is not a composite character, the multi-byte form is set in WORKBUF
97 and STR points WORKBUF. The caller should allocate at least 4-byte 97 and STR points WORKBUF. The caller should allocate at least 4-byte
98 area at WORKBUF in advance. Returns the length of the multi-byte 98 area at WORKBUF in advance. Returns the length of the multi-byte
99 form. 99 form. If C is an invalid character to have a multi-byte form,
100 signal an error.
100 101
101 Use macro `CHAR_STRING (C, WORKBUF, STR)' instead of calling this 102 Use macro `CHAR_STRING (C, WORKBUF, STR)' instead of calling this
102 function directly if C can be an ASCII character. */ 103 function directly if C can be an ASCII character. */
@@ -119,12 +120,16 @@ non_ascii_char_to_string (c, workbuf, str)
119 } 120 }
120 else 121 else
121 { 122 {
122 *str = workbuf; 123 error ("Invalid characer: %d", c);
123 return 0;
124 } 124 }
125 } 125 }
126 126
127 SPLIT_NON_ASCII_CHAR (c, charset, c1, c2); 127 SPLIT_NON_ASCII_CHAR (c, charset, c1, c2);
128 if (!charset
129 || ! CHARSET_DEFINED_P (charset)
130 || c1 >= 0 && c1 < 32
131 || c2 >= 0 && c2 < 32)
132 error ("Invalid characer: %d", c);
128 133
129 *str = workbuf; 134 *str = workbuf;
130 *workbuf++ = CHARSET_LEADING_CODE_BASE (charset); 135 *workbuf++ = CHARSET_LEADING_CODE_BASE (charset);
@@ -926,7 +931,7 @@ DEFUN ("concat-chars", Fconcat_chars, Sconcat_chars, 1, MANY, 0,
926{ 931{
927 int i; 932 int i;
928 unsigned char *buf 933 unsigned char *buf
929 = (unsigned char *) malloc (MAX_LENGTH_OF_MULTI_BYTE_FORM * n); 934 = (unsigned char *) alloca (MAX_LENGTH_OF_MULTI_BYTE_FORM * n);
930 unsigned char *p = buf; 935 unsigned char *p = buf;
931 Lisp_Object val; 936 Lisp_Object val;
932 937
@@ -949,7 +954,6 @@ DEFUN ("concat-chars", Fconcat_chars, Sconcat_chars, 1, MANY, 0,
949 } 954 }
950 955
951 val = make_string (buf, p - buf); 956 val = make_string (buf, p - buf);
952 free (buf);
953 return val; 957 return val;
954} 958}
955 959