aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa1998-11-06 00:44:16 +0000
committerKenichi Handa1998-11-06 00:44:16 +0000
commita688bb2444e34a484d013400e6e5e6f5afdd9550 (patch)
tree527e3f6a54689c5b9b32c15ba802e413e7d0b560 /src
parent101e446fa00b3fec42efd784d3a21ce16cba6bbd (diff)
downloademacs-a688bb2444e34a484d013400e6e5e6f5afdd9550.tar.gz
emacs-a688bb2444e34a484d013400e6e5e6f5afdd9550.zip
(display_text_line): Check validity of a multibyte
character. (display_string): Likewise. Handle an invalid character correctly.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c112
1 files changed, 61 insertions, 51 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index f2551fc1cbd..a5a86071f1a 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -3819,7 +3819,7 @@ display_text_line (w, start, start_byte, vpos, hpos, taboffset, ovstr_done)
3819 by octal form. */ 3819 by octal form. */
3820 int remaining_bytes = len; 3820 int remaining_bytes = len;
3821 3821
3822 if (c >= 0400) 3822 if (c >= 0400 && CHAR_VALID_P (c, 0))
3823 { 3823 {
3824 /* C is a multibyte character. */ 3824 /* C is a multibyte character. */
3825 int charset = CHAR_CHARSET (c); 3825 int charset = CHAR_CHARSET (c);
@@ -5249,66 +5249,76 @@ display_string (w, vpos, string, length, hpos, truncate,
5249 *p1 = c ^ 0100; 5249 *p1 = c ^ 0100;
5250 p1++; 5250 p1++;
5251 } 5251 }
5252 else if (len == 1)
5253 {
5254 /* C is a control character or a binary byte data. */
5255 if (p1 >= start)
5256 *p1 = (fix_glyph
5257 (f, (dp && INTEGERP (DISP_ESCAPE_GLYPH (dp))
5258 && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (dp)))
5259 ? XINT (DISP_ESCAPE_GLYPH (dp)) : '\\'),
5260 0));
5261 p1++;
5262 if (p1 >= start && p1 < end)
5263 *p1 = (c >> 6) + '0';
5264 p1++;
5265 if (p1 >= start && p1 < end)
5266 *p1 = (7 & (c >> 3)) + '0';
5267 p1++;
5268 if (p1 >= start && p1 < end)
5269 *p1 = (7 & c) + '0';
5270 p1++;
5271 }
5272 else 5252 else
5273 { 5253 {
5274 /* C is a multibyte character. */ 5254 /* C is a multibyte character, control character or a binary
5275 int charset = CHAR_CHARSET (c); 5255 byte data. */
5276 int columns = (charset == CHARSET_COMPOSITION 5256 int remaining_bytes = len;
5277 ? cmpchar_table[COMPOSITE_CHAR_ID (c)]->width
5278 : CHARSET_WIDTH (charset));
5279 5257
5280 if (p1 < start) 5258 if (c >= 0400 && CHAR_VALID_P (c, 0))
5281 { 5259 {
5282 /* Since we can't show the left part of C, fill all 5260 /* C is a multibyte character. */
5283 columns with spaces. */ 5261 int charset = CHAR_CHARSET (c);
5284 columns -= start - p1; 5262 int columns = (charset == CHARSET_COMPOSITION
5285 p1 = start; 5263 ? cmpchar_table[COMPOSITE_CHAR_ID (c)]->width
5286 while (columns--) 5264 : CHARSET_WIDTH (charset));
5265
5266 remaining_bytes -= CHARSET_BYTES (charset);
5267 if (p1 < start)
5287 { 5268 {
5288 if (p1 < end) 5269 /* Since we can't show the left part of C, fill all
5289 *p1 = SPACEGLYPH; 5270 columns with spaces. */
5290 p1++; 5271 columns -= start - p1;
5272 p1 = start;
5273 while (columns--)
5274 {
5275 if (p1 < end)
5276 *p1 = SPACEGLYPH;
5277 p1++;
5278 }
5291 } 5279 }
5292 } 5280 else if (p1 + columns > end)
5293 else if (p1 + columns > end)
5294 {
5295 /* Since we can't show the right part of C, fill all
5296 columns with TRUNCATE if TRUNCATE is specified. */
5297 if (truncate)
5298 { 5281 {
5299 while (p1 < end) 5282 /* Since we can't show the right part of C, fill all
5300 *p1++ = fix_glyph (f, truncate, 0); 5283 columns with TRUNCATE if TRUNCATE is specified. */
5301 /* And tell the line is truncated. */ 5284 if (truncate)
5302 truncated = 1; 5285 {
5286 while (p1 < end)
5287 *p1++ = fix_glyph (f, truncate, 0);
5288 /* And tell the line is truncated. */
5289 truncated = 1;
5290 }
5291 break;
5292 }
5293 else
5294 {
5295 /* We can show the whole glyph of C. */
5296 *p1++ = c;
5297 while (--columns)
5298 *p1++ = c | GLYPH_MASK_PADDING;
5303 } 5299 }
5304 break;
5305 } 5300 }
5306 else 5301
5302 while (remaining_bytes > 0)
5307 { 5303 {
5308 /* We can show the whole glyph of C. */ 5304 c = *(string - remaining_bytes--);
5309 *p1++ = c; 5305
5310 while (--columns) 5306 if (p1 >= start)
5311 *p1++ = c | GLYPH_MASK_PADDING; 5307 *p1 = (fix_glyph
5308 (f, (dp && INTEGERP (DISP_ESCAPE_GLYPH (dp))
5309 && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (dp)))
5310 ? XINT (DISP_ESCAPE_GLYPH (dp)) : '\\'),
5311 0));
5312 p1++;
5313 if (p1 >= start && p1 < end)
5314 *p1 = (c >> 6) + '0';
5315 p1++;
5316 if (p1 >= start && p1 < end)
5317 *p1 = (7 & (c >> 3)) + '0';
5318 p1++;
5319 if (p1 >= start && p1 < end)
5320 *p1 = (7 & c) + '0';
5321 p1++;
5312 } 5322 }
5313 } 5323 }
5314 } 5324 }