diff options
| -rw-r--r-- | src/print.c | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/print.c b/src/print.c index ecfec6b3a8b..c6c6c2b5294 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -222,6 +222,7 @@ glyph_to_str_cpy (glyphs, str) | |||
| 222 | #define PRINTDECLARE \ | 222 | #define PRINTDECLARE \ |
| 223 | struct buffer *old = current_buffer; \ | 223 | struct buffer *old = current_buffer; \ |
| 224 | int old_point = -1, start_point; \ | 224 | int old_point = -1, start_point; \ |
| 225 | int old_point_byte, start_point_byte; \ | ||
| 225 | int specpdl_count = specpdl_ptr - specpdl; \ | 226 | int specpdl_count = specpdl_ptr - specpdl; \ |
| 226 | int free_print_buffer = 0; \ | 227 | int free_print_buffer = 0; \ |
| 227 | Lisp_Object original | 228 | Lisp_Object original |
| @@ -242,8 +243,11 @@ glyph_to_str_cpy (glyphs, str) | |||
| 242 | if (XMARKER (original)->buffer != current_buffer) \ | 243 | if (XMARKER (original)->buffer != current_buffer) \ |
| 243 | set_buffer_internal (XMARKER (original)->buffer); \ | 244 | set_buffer_internal (XMARKER (original)->buffer); \ |
| 244 | old_point = PT; \ | 245 | old_point = PT; \ |
| 245 | SET_PT (marker_position (printcharfun)); \ | 246 | old_point_byte = PT_BYTE; \ |
| 247 | SET_PT_BOTH (marker_position (printcharfun), \ | ||
| 248 | marker_byte_position (printcharfun)); \ | ||
| 246 | start_point = PT; \ | 249 | start_point = PT; \ |
| 250 | start_point_byte = PT_BYTE; \ | ||
| 247 | printcharfun = Qnil; \ | 251 | printcharfun = Qnil; \ |
| 248 | } \ | 252 | } \ |
| 249 | if (NILP (printcharfun)) \ | 253 | if (NILP (printcharfun)) \ |
| @@ -273,10 +277,12 @@ glyph_to_str_cpy (glyphs, str) | |||
| 273 | } \ | 277 | } \ |
| 274 | unbind_to (specpdl_count, Qnil); \ | 278 | unbind_to (specpdl_count, Qnil); \ |
| 275 | if (MARKERP (original)) \ | 279 | if (MARKERP (original)) \ |
| 276 | Fset_marker (original, make_number (PT), Qnil); \ | 280 | set_marker_both (original, Qnil, PT, PT_BYTE); \ |
| 277 | if (old_point >= 0) \ | 281 | if (old_point >= 0) \ |
| 278 | SET_PT (old_point + (old_point >= start_point \ | 282 | SET_PT_BOTH (old_point + (old_point >= start_point \ |
| 279 | ? PT - start_point : 0)); \ | 283 | ? PT - start_point : 0), \ |
| 284 | old_point_byte + (old_point_byte >= start_point_byte \ | ||
| 285 | ? PT_BYTE - start_point_byte : 0)); \ | ||
| 280 | if (old != current_buffer) \ | 286 | if (old != current_buffer) \ |
| 281 | set_buffer_internal (old); \ | 287 | set_buffer_internal (old); \ |
| 282 | if (!CONSP (Vprint_gensym)) \ | 288 | if (!CONSP (Vprint_gensym)) \ |
| @@ -1067,6 +1073,7 @@ print (obj, printcharfun, escapeflag) | |||
| 1067 | register int i; | 1073 | register int i; |
| 1068 | register unsigned char c; | 1074 | register unsigned char c; |
| 1069 | struct gcpro gcpro1; | 1075 | struct gcpro gcpro1; |
| 1076 | int size; | ||
| 1070 | 1077 | ||
| 1071 | GCPRO1 (obj); | 1078 | GCPRO1 (obj); |
| 1072 | 1079 | ||
| @@ -1079,10 +1086,17 @@ print (obj, printcharfun, escapeflag) | |||
| 1079 | #endif | 1086 | #endif |
| 1080 | 1087 | ||
| 1081 | PRINTCHAR ('\"'); | 1088 | PRINTCHAR ('\"'); |
| 1082 | for (i = 0; i < XSTRING (obj)->size; i++) | 1089 | size = XSTRING (obj)->size; |
| 1090 | for (i = 0; i < size;) | ||
| 1083 | { | 1091 | { |
| 1092 | /* Here, we must convert each multi-byte form to the | ||
| 1093 | corresponding character code before handing it to PRINTCHAR. */ | ||
| 1094 | int len; | ||
| 1095 | int c = STRING_CHAR_AND_LENGTH (&XSTRING (obj)->data[i], | ||
| 1096 | size - i, len); | ||
| 1097 | i += len; | ||
| 1084 | QUIT; | 1098 | QUIT; |
| 1085 | c = XSTRING (obj)->data[i]; | 1099 | |
| 1086 | if (c == '\n' && print_escape_newlines) | 1100 | if (c == '\n' && print_escape_newlines) |
| 1087 | { | 1101 | { |
| 1088 | PRINTCHAR ('\\'); | 1102 | PRINTCHAR ('\\'); |
| @@ -1121,7 +1135,7 @@ print (obj, printcharfun, escapeflag) | |||
| 1121 | register unsigned char *p = XSYMBOL (obj)->name->data; | 1135 | register unsigned char *p = XSYMBOL (obj)->name->data; |
| 1122 | register unsigned char *end = p + XSYMBOL (obj)->name->size; | 1136 | register unsigned char *end = p + XSYMBOL (obj)->name->size; |
| 1123 | register unsigned char c; | 1137 | register unsigned char c; |
| 1124 | int i; | 1138 | int i, size; |
| 1125 | 1139 | ||
| 1126 | if (p != end && (*p == '-' || *p == '+')) p++; | 1140 | if (p != end && (*p == '-' || *p == '+')) p++; |
| 1127 | if (p == end) | 1141 | if (p == end) |
| @@ -1178,10 +1192,16 @@ print (obj, printcharfun, escapeflag) | |||
| 1178 | PRINTCHAR (':'); | 1192 | PRINTCHAR (':'); |
| 1179 | } | 1193 | } |
| 1180 | 1194 | ||
| 1181 | for (i = 0; i < XSYMBOL (obj)->name->size; i++) | 1195 | size = XSYMBOL (obj)->name->size; |
| 1196 | for (i = 0; i < size;) | ||
| 1182 | { | 1197 | { |
| 1198 | /* Here, we must convert each multi-byte form to the | ||
| 1199 | corresponding character code before handing it to PRINTCHAR. */ | ||
| 1200 | int len; | ||
| 1201 | int c = STRING_CHAR_AND_LENGTH (&XSYMBOL (obj)->name->data[i], | ||
| 1202 | size - i, len); | ||
| 1203 | i += len; | ||
| 1183 | QUIT; | 1204 | QUIT; |
| 1184 | c = XSYMBOL (obj)->name->data[i]; | ||
| 1185 | 1205 | ||
| 1186 | if (escapeflag) | 1206 | if (escapeflag) |
| 1187 | { | 1207 | { |