diff options
| author | Richard M. Stallman | 1998-03-06 21:50:44 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-03-06 21:50:44 +0000 |
| commit | e54daa22b060568e8d8e1b07eee3ed6905c3279c (patch) | |
| tree | e81ebd1c057868ad00fa2756d9fbad0502899408 /src/alloc.c | |
| parent | 846f93fd7dc8527bdaeb549298f42aecaf14038a (diff) | |
| download | emacs-e54daa22b060568e8d8e1b07eee3ed6905c3279c.tar.gz emacs-e54daa22b060568e8d8e1b07eee3ed6905c3279c.zip | |
(Fmake_string): Handle the case INIT is a multibyte character correctly.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/alloc.c b/src/alloc.c index fa5a3461fd7..5ae44416943 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -32,6 +32,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 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" |
| @@ -1186,16 +1187,37 @@ Both LENGTH and INIT must be numbers.") | |||
| 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 | } |