# HG changeset patch # User Kenichi Handa # Date 910313056 0 # Node ID d87960db41e9b25a4ddb321ee7885850d83be4a1 # Parent 595d8a052b715744f1d47bd1b4ceb0a803054f19 (display_text_line): Check validity of a multibyte character. (display_string): Likewise. Handle an invalid character correctly. diff -r 595d8a052b71 -r d87960db41e9 src/xdisp.c --- a/src/xdisp.c Thu Nov 05 20:06:22 1998 +0000 +++ b/src/xdisp.c Fri Nov 06 00:44:16 1998 +0000 @@ -3819,7 +3819,7 @@ by octal form. */ int remaining_bytes = len; - if (c >= 0400) + if (c >= 0400 && CHAR_VALID_P (c, 0)) { /* C is a multibyte character. */ int charset = CHAR_CHARSET (c); @@ -5249,66 +5249,76 @@ *p1 = c ^ 0100; p1++; } - else if (len == 1) - { - /* C is a control character or a binary byte data. */ - if (p1 >= start) - *p1 = (fix_glyph - (f, (dp && INTEGERP (DISP_ESCAPE_GLYPH (dp)) - && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (dp))) - ? XINT (DISP_ESCAPE_GLYPH (dp)) : '\\'), - 0)); - p1++; - if (p1 >= start && p1 < end) - *p1 = (c >> 6) + '0'; - p1++; - if (p1 >= start && p1 < end) - *p1 = (7 & (c >> 3)) + '0'; - p1++; - if (p1 >= start && p1 < end) - *p1 = (7 & c) + '0'; - p1++; - } else { - /* C is a multibyte character. */ - int charset = CHAR_CHARSET (c); - int columns = (charset == CHARSET_COMPOSITION - ? cmpchar_table[COMPOSITE_CHAR_ID (c)]->width - : CHARSET_WIDTH (charset)); - - if (p1 < start) + /* C is a multibyte character, control character or a binary + byte data. */ + int remaining_bytes = len; + + if (c >= 0400 && CHAR_VALID_P (c, 0)) { - /* Since we can't show the left part of C, fill all - columns with spaces. */ - columns -= start - p1; - p1 = start; - while (columns--) + /* C is a multibyte character. */ + int charset = CHAR_CHARSET (c); + int columns = (charset == CHARSET_COMPOSITION + ? cmpchar_table[COMPOSITE_CHAR_ID (c)]->width + : CHARSET_WIDTH (charset)); + + remaining_bytes -= CHARSET_BYTES (charset); + if (p1 < start) { - if (p1 < end) - *p1 = SPACEGLYPH; - p1++; + /* Since we can't show the left part of C, fill all + columns with spaces. */ + columns -= start - p1; + p1 = start; + while (columns--) + { + if (p1 < end) + *p1 = SPACEGLYPH; + p1++; + } + } + else if (p1 + columns > end) + { + /* Since we can't show the right part of C, fill all + columns with TRUNCATE if TRUNCATE is specified. */ + if (truncate) + { + while (p1 < end) + *p1++ = fix_glyph (f, truncate, 0); + /* And tell the line is truncated. */ + truncated = 1; + } + break; + } + else + { + /* We can show the whole glyph of C. */ + *p1++ = c; + while (--columns) + *p1++ = c | GLYPH_MASK_PADDING; } } - else if (p1 + columns > end) + + while (remaining_bytes > 0) { - /* Since we can't show the right part of C, fill all - columns with TRUNCATE if TRUNCATE is specified. */ - if (truncate) - { - while (p1 < end) - *p1++ = fix_glyph (f, truncate, 0); - /* And tell the line is truncated. */ - truncated = 1; - } - break; - } - else - { - /* We can show the whole glyph of C. */ - *p1++ = c; - while (--columns) - *p1++ = c | GLYPH_MASK_PADDING; + c = *(string - remaining_bytes--); + + if (p1 >= start) + *p1 = (fix_glyph + (f, (dp && INTEGERP (DISP_ESCAPE_GLYPH (dp)) + && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (dp))) + ? XINT (DISP_ESCAPE_GLYPH (dp)) : '\\'), + 0)); + p1++; + if (p1 >= start && p1 < end) + *p1 = (c >> 6) + '0'; + p1++; + if (p1 >= start && p1 < end) + *p1 = (7 & (c >> 3)) + '0'; + p1++; + if (p1 >= start && p1 < end) + *p1 = (7 & c) + '0'; + p1++; } } }