Mercurial > emacs
changeset 23647:d87960db41e9
(display_text_line): Check validity of a multibyte
character.
(display_string): Likewise. Handle an invalid character
correctly.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 06 Nov 1998 00:44:16 +0000 |
parents | 595d8a052b71 |
children | 06e645781762 |
files | src/xdisp.c |
diffstat | 1 files changed, 64 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- 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++; } } }