diff options
author | Richard M. Stallman <rms@gnu.org> | 1998-01-01 06:40:47 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1998-01-01 06:40:47 +0000 |
commit | 55c7fc699db88364b0cdddfc03e857565696241d (patch) | |
tree | 28fcce9434a2e281d42de2e9052ccf2687783854 /src/print.c | |
parent | 5b4aa574771ac41757caab97e516c35f4b5136b4 (diff) | |
download | emacs-55c7fc699db88364b0cdddfc03e857565696241d.tar.gz |
(PRINTDECLARE): Declare old_point_byte and start_point_byte.
(PRINTPREPARE): For a marker, set old_point_byte and start_point_byte.
Set both kinds of PT from the marker.
(PRINTFINISH): For a marker, use set_marker_both.
Restore both kinds of PT.
(print): For strings and symbols, handle multibyte chars.
Diffstat (limited to 'src/print.c')
-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) #define PRINTDECLARE \ struct buffer *old = current_buffer; \ int old_point = -1, start_point; \ + int old_point_byte, start_point_byte; \ int specpdl_count = specpdl_ptr - specpdl; \ int free_print_buffer = 0; \ Lisp_Object original @@ -242,8 +243,11 @@ glyph_to_str_cpy (glyphs, str) if (XMARKER (original)->buffer != current_buffer) \ set_buffer_internal (XMARKER (original)->buffer); \ old_point = PT; \ - SET_PT (marker_position (printcharfun)); \ + old_point_byte = PT_BYTE; \ + SET_PT_BOTH (marker_position (printcharfun), \ + marker_byte_position (printcharfun)); \ start_point = PT; \ + start_point_byte = PT_BYTE; \ printcharfun = Qnil; \ } \ if (NILP (printcharfun)) \ @@ -273,10 +277,12 @@ glyph_to_str_cpy (glyphs, str) } \ unbind_to (specpdl_count, Qnil); \ if (MARKERP (original)) \ - Fset_marker (original, make_number (PT), Qnil); \ + set_marker_both (original, Qnil, PT, PT_BYTE); \ if (old_point >= 0) \ - SET_PT (old_point + (old_point >= start_point \ - ? PT - start_point : 0)); \ + SET_PT_BOTH (old_point + (old_point >= start_point \ + ? PT - start_point : 0), \ + old_point_byte + (old_point_byte >= start_point_byte \ + ? PT_BYTE - start_point_byte : 0)); \ if (old != current_buffer) \ set_buffer_internal (old); \ if (!CONSP (Vprint_gensym)) \ @@ -1067,6 +1073,7 @@ print (obj, printcharfun, escapeflag) register int i; register unsigned char c; struct gcpro gcpro1; + int size; GCPRO1 (obj); @@ -1079,10 +1086,17 @@ print (obj, printcharfun, escapeflag) #endif PRINTCHAR ('\"'); - for (i = 0; i < XSTRING (obj)->size; i++) + size = XSTRING (obj)->size; + for (i = 0; i < size;) { + /* Here, we must convert each multi-byte form to the + corresponding character code before handing it to PRINTCHAR. */ + int len; + int c = STRING_CHAR_AND_LENGTH (&XSTRING (obj)->data[i], + size - i, len); + i += len; QUIT; - c = XSTRING (obj)->data[i]; + if (c == '\n' && print_escape_newlines) { PRINTCHAR ('\\'); @@ -1121,7 +1135,7 @@ print (obj, printcharfun, escapeflag) register unsigned char *p = XSYMBOL (obj)->name->data; register unsigned char *end = p + XSYMBOL (obj)->name->size; register unsigned char c; - int i; + int i, size; if (p != end && (*p == '-' || *p == '+')) p++; if (p == end) @@ -1178,10 +1192,16 @@ print (obj, printcharfun, escapeflag) PRINTCHAR (':'); } - for (i = 0; i < XSYMBOL (obj)->name->size; i++) + size = XSYMBOL (obj)->name->size; + for (i = 0; i < size;) { + /* Here, we must convert each multi-byte form to the + corresponding character code before handing it to PRINTCHAR. */ + int len; + int c = STRING_CHAR_AND_LENGTH (&XSYMBOL (obj)->name->data[i], + size - i, len); + i += len; QUIT; - c = XSYMBOL (obj)->name->data[i]; if (escapeflag) { |