Mercurial > emacs
comparison src/alloc.c @ 21084:371ed7bdfd2b
(Fmake_string): Handle the case INIT is a multibyte character correctly.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Fri, 06 Mar 1998 21:50:44 +0000 |
| parents | 3b2f72ed135c |
| children | ce12eac1ee45 |
comparison
equal
deleted
inserted
replaced
| 21083:a5a15ce66e98 | 21084:371ed7bdfd2b |
|---|---|
| 30 #include "buffer.h" | 30 #include "buffer.h" |
| 31 #include "window.h" | 31 #include "window.h" |
| 32 #include "frame.h" | 32 #include "frame.h" |
| 33 #include "blockinput.h" | 33 #include "blockinput.h" |
| 34 #include "keyboard.h" | 34 #include "keyboard.h" |
| 35 #include "charset.h" | |
| 35 #endif | 36 #endif |
| 36 | 37 |
| 37 #include "syssignal.h" | 38 #include "syssignal.h" |
| 38 | 39 |
| 39 extern char *sbrk (); | 40 extern char *sbrk (); |
| 1184 Both LENGTH and INIT must be numbers.") | 1185 Both LENGTH and INIT must be numbers.") |
| 1185 (length, init) | 1186 (length, init) |
| 1186 Lisp_Object length, init; | 1187 Lisp_Object length, init; |
| 1187 { | 1188 { |
| 1188 register Lisp_Object val; | 1189 register Lisp_Object val; |
| 1189 register unsigned char *p, *end, c; | 1190 register unsigned char *p, *end; |
| 1191 int c, nbytes; | |
| 1190 | 1192 |
| 1191 CHECK_NATNUM (length, 0); | 1193 CHECK_NATNUM (length, 0); |
| 1192 CHECK_NUMBER (init, 1); | 1194 CHECK_NUMBER (init, 1); |
| 1193 val = make_uninit_string (XFASTINT (length)); | 1195 |
| 1194 c = XINT (init); | 1196 c = XINT (init); |
| 1195 p = XSTRING (val)->data; | 1197 if (SINGLE_BYTE_CHAR_P (c)) |
| 1196 end = p + XSTRING (val)->size; | 1198 { |
| 1197 while (p != end) | 1199 nbytes = XINT (length); |
| 1198 *p++ = c; | 1200 val = make_uninit_multibyte_string (nbytes, nbytes); |
| 1201 p = XSTRING (val)->data; | |
| 1202 end = p + XSTRING (val)->size; | |
| 1203 while (p != end) | |
| 1204 *p++ = c; | |
| 1205 } | |
| 1206 else | |
| 1207 { | |
| 1208 unsigned char work[4], *str; | |
| 1209 int len = CHAR_STRING (c, work, str); | |
| 1210 | |
| 1211 nbytes = len * XINT (length); | |
| 1212 val = make_uninit_multibyte_string (XINT (length), nbytes); | |
| 1213 p = XSTRING (val)->data; | |
| 1214 end = p + nbytes; | |
| 1215 while (p != end) | |
| 1216 { | |
| 1217 bcopy (str, p, len); | |
| 1218 p += len; | |
| 1219 } | |
| 1220 } | |
| 1199 *p = 0; | 1221 *p = 0; |
| 1200 return val; | 1222 return val; |
| 1201 } | 1223 } |
| 1202 | 1224 |
| 1203 DEFUN ("make-bool-vector", Fmake_bool_vector, Smake_bool_vector, 2, 2, 0, | 1225 DEFUN ("make-bool-vector", Fmake_bool_vector, Smake_bool_vector, 2, 2, 0, |
