diff options
| author | Richard M. Stallman | 1998-04-05 19:18:32 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-04-05 19:18:32 +0000 |
| commit | 453fa9876f5ddb40ac2ade3c0b719130cec0961b (patch) | |
| tree | 21b0cb0d79b6455d3dffeae26b0bdf944e022a71 /src | |
| parent | 8f152ad40de34edc3eb19777bcb3d753a8ed9c80 (diff) | |
| download | emacs-453fa9876f5ddb40ac2ade3c0b719130cec0961b.tar.gz emacs-453fa9876f5ddb40ac2ade3c0b719130cec0961b.zip | |
(print) <Lisp_String>: Follow a hex escape with `\ ' if nec.
Diffstat (limited to 'src')
| -rw-r--r-- | src/print.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/print.c b/src/print.c index 60fc95b234d..69b1e28fea0 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -1151,6 +1151,9 @@ print (obj, printcharfun, escapeflag) | |||
| 1151 | register unsigned char c; | 1151 | register unsigned char c; |
| 1152 | struct gcpro gcpro1; | 1152 | struct gcpro gcpro1; |
| 1153 | int size_byte; | 1153 | int size_byte; |
| 1154 | /* 1 means we must ensure that the next character we output | ||
| 1155 | cannot be taken as part of a hex character escape. */ | ||
| 1156 | int need_nonhex = 0; | ||
| 1154 | 1157 | ||
| 1155 | GCPRO1 (obj); | 1158 | GCPRO1 (obj); |
| 1156 | 1159 | ||
| @@ -1197,6 +1200,7 @@ print (obj, printcharfun, escapeflag) | |||
| 1197 | unsigned char outbuf[50]; | 1200 | unsigned char outbuf[50]; |
| 1198 | sprintf (outbuf, "\\x%x", c); | 1201 | sprintf (outbuf, "\\x%x", c); |
| 1199 | strout (outbuf, -1, -1, printcharfun, 0); | 1202 | strout (outbuf, -1, -1, printcharfun, 0); |
| 1203 | need_nonhex = 1; | ||
| 1200 | } | 1204 | } |
| 1201 | else if (SINGLE_BYTE_CHAR_P (c) | 1205 | else if (SINGLE_BYTE_CHAR_P (c) |
| 1202 | && ! ASCII_BYTE_P (c) | 1206 | && ! ASCII_BYTE_P (c) |
| @@ -1211,6 +1215,15 @@ print (obj, printcharfun, escapeflag) | |||
| 1211 | } | 1215 | } |
| 1212 | else | 1216 | else |
| 1213 | { | 1217 | { |
| 1218 | /* If we just had a hex escape, and this character | ||
| 1219 | could be taken as part of it, | ||
| 1220 | output `\ ' to prevent that. */ | ||
| 1221 | if (need_nonhex | ||
| 1222 | && ((c >= 'a' && c <= 'f') | ||
| 1223 | || (c >= 'A' && c <= 'F') | ||
| 1224 | || (c >= '0' && c <= '9'))) | ||
| 1225 | strout ("\\ ", -1, -1, printcharfun, 0); | ||
| 1226 | |||
| 1214 | if (c == '\"' || c == '\\') | 1227 | if (c == '\"' || c == '\\') |
| 1215 | PRINTCHAR ('\\'); | 1228 | PRINTCHAR ('\\'); |
| 1216 | PRINTCHAR (c); | 1229 | PRINTCHAR (c); |