Mercurial > hg > xemacs-beta
comparison src/mule-coding.c @ 867:804517e16990
[xemacs-hg @ 2002-06-05 09:54:39 by ben]
Textual renaming: text/char names
abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, callint.c, casefiddle.c, casetab.c, charset.h, chartab.c, chartab.h, cmds.c, console-gtk.h, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console-x.h, console.h, data.c, device-msw.c, device-x.c, dialog-msw.c, dired-msw.c, dired.c, doc.c, doprnt.c, editfns.c, eldap.c, emodules.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-unixoid.c, events.c, events.h, file-coding.c, file-coding.h, fileio.c, filelock.c, fns.c, font-lock.c, frame-gtk.c, frame-msw.c, frame-x.c, frame.c, glyphs-eimage.c, glyphs-msw.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-x.c, gui-x.h, gui.c, gui.h, hpplay.c, indent.c, insdel.c, insdel.h, intl-win32.c, keymap.c, line-number.c, line-number.h, lisp-disunion.h, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, md5.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, mule-ccl.c, mule-charset.c, mule-coding.c, mule-wnnfns.c, ndir.h, nt.c, objects-gtk.c, objects-gtk.h, objects-msw.c, objects-tty.c, objects-x.c, objects.c, objects.h, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, procimpl.h, realpath.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-tty.c, redisplay-x.c, redisplay.c, redisplay.h, regex.c, search.c, select-common.h, select-gtk.c, select-x.c, sound.h, symbols.c, syntax.c, syntax.h, sysdep.c, sysdep.h, sysdir.h, sysfile.h, sysproc.h, syspwd.h, systime.h, syswindows.h, termcap.c, tests.c, text.c, text.h, toolbar-common.c, tooltalk.c, ui-gtk.c, unexnt.c, unicode.c, win32.c: Text/char naming rationalization.
[a] distinguish between "charptr" when it refers to operations on
the pointer itself and when it refers to operations on text; and
[b] use consistent naming for everything referring to internal
format, i.e.
Itext == text in internal format
Ibyte == a byte in such text
Ichar == a char as represented in internal character format
thus e.g.
set_charptr_emchar -> set_itext_ichar
The pre and post tags on either side of this change are:
pre-internal-format-textual-renaming
post-internal-format-textual-renaming
See the Internals Manual for details of exactly how this was done,
how to handle the change in your workspace, etc.
author | ben |
---|---|
date | Wed, 05 Jun 2002 09:58:45 +0000 |
parents | 5d09ddada9ae |
children | 7f62a956b825 |
comparison
equal
deleted
inserted
replaced
866:613552a02607 | 867:804517e16990 |
---|---|
114 if (ch) | 114 if (ch) |
115 { | 115 { |
116 /* Previous character was first byte of Shift-JIS Kanji char. */ | 116 /* Previous character was first byte of Shift-JIS Kanji char. */ |
117 if (byte_shift_jis_two_byte_2_p (c)) | 117 if (byte_shift_jis_two_byte_2_p (c)) |
118 { | 118 { |
119 Intbyte e1, e2; | 119 Ibyte e1, e2; |
120 | 120 |
121 Dynarr_add (dst, LEADING_BYTE_JAPANESE_JISX0208); | 121 Dynarr_add (dst, LEADING_BYTE_JAPANESE_JISX0208); |
122 DECODE_SHIFT_JIS (ch, c, e1, e2); | 122 DECODE_SHIFT_JIS (ch, c, e1, e2); |
123 Dynarr_add (dst, e1); | 123 Dynarr_add (dst, e1); |
124 Dynarr_add (dst, e2); | 124 Dynarr_add (dst, e2); |
149 } | 149 } |
150 else | 150 else |
151 { | 151 { |
152 while (n--) | 152 while (n--) |
153 { | 153 { |
154 Intbyte c = *src++; | 154 Ibyte c = *src++; |
155 if (byte_ascii_p (c)) | 155 if (byte_ascii_p (c)) |
156 { | 156 { |
157 Dynarr_add (dst, c); | 157 Dynarr_add (dst, c); |
158 ch = 0; | 158 ch = 0; |
159 } | 159 } |
160 else if (intbyte_leading_byte_p (c)) | 160 else if (ibyte_leading_byte_p (c)) |
161 ch = (c == LEADING_BYTE_KATAKANA_JISX0201 || | 161 ch = (c == LEADING_BYTE_KATAKANA_JISX0201 || |
162 c == LEADING_BYTE_JAPANESE_JISX0208_1978 || | 162 c == LEADING_BYTE_JAPANESE_JISX0208_1978 || |
163 c == LEADING_BYTE_JAPANESE_JISX0208) ? c : 0; | 163 c == LEADING_BYTE_JAPANESE_JISX0208) ? c : 0; |
164 else if (ch) | 164 else if (ch) |
165 { | 165 { |
204 s2 = XINT (XCDR (code)); | 204 s2 = XINT (XCDR (code)); |
205 if (byte_shift_jis_two_byte_1_p (s1) && | 205 if (byte_shift_jis_two_byte_1_p (s1) && |
206 byte_shift_jis_two_byte_2_p (s2)) | 206 byte_shift_jis_two_byte_2_p (s2)) |
207 { | 207 { |
208 DECODE_SHIFT_JIS (s1, s2, c1, c2); | 208 DECODE_SHIFT_JIS (s1, s2, c1, c2); |
209 return make_char (make_emchar (Vcharset_japanese_jisx0208, | 209 return make_char (make_ichar (Vcharset_japanese_jisx0208, |
210 c1 & 0x7F, c2 & 0x7F)); | 210 c1 & 0x7F, c2 & 0x7F)); |
211 } | 211 } |
212 else | 212 else |
213 return Qnil; | 213 return Qnil; |
214 } | 214 } |
221 { | 221 { |
222 Lisp_Object charset; | 222 Lisp_Object charset; |
223 int c1, c2, s1, s2; | 223 int c1, c2, s1, s2; |
224 | 224 |
225 CHECK_CHAR_COERCE_INT (character); | 225 CHECK_CHAR_COERCE_INT (character); |
226 BREAKUP_EMCHAR (XCHAR (character), charset, c1, c2); | 226 BREAKUP_ICHAR (XCHAR (character), charset, c1, c2); |
227 if (EQ (charset, Vcharset_japanese_jisx0208)) | 227 if (EQ (charset, Vcharset_japanese_jisx0208)) |
228 { | 228 { |
229 ENCODE_SHIFT_JIS (c1 | 0x80, c2 | 0x80, s1, s2); | 229 ENCODE_SHIFT_JIS (c1 | 0x80, c2 | 0x80, s1, s2); |
230 return Fcons (make_int (s1), make_int (s2)); | 230 return Fcons (make_int (s1), make_int (s2)); |
231 } | 231 } |
449 if (ch) | 449 if (ch) |
450 { | 450 { |
451 /* Previous character was first byte of Big5 char. */ | 451 /* Previous character was first byte of Big5 char. */ |
452 if (byte_big5_two_byte_2_p (c)) | 452 if (byte_big5_two_byte_2_p (c)) |
453 { | 453 { |
454 Intbyte b1, b2, b3; | 454 Ibyte b1, b2, b3; |
455 DECODE_BIG5 (ch, c, b1, b2, b3); | 455 DECODE_BIG5 (ch, c, b1, b2, b3); |
456 Dynarr_add (dst, b1); | 456 Dynarr_add (dst, b1); |
457 Dynarr_add (dst, b2); | 457 Dynarr_add (dst, b2); |
458 Dynarr_add (dst, b3); | 458 Dynarr_add (dst, b3); |
459 } | 459 } |
478 } | 478 } |
479 else | 479 else |
480 { | 480 { |
481 while (n--) | 481 while (n--) |
482 { | 482 { |
483 Intbyte c = *src++; | 483 Ibyte c = *src++; |
484 if (byte_ascii_p (c)) | 484 if (byte_ascii_p (c)) |
485 { | 485 { |
486 /* ASCII. */ | 486 /* ASCII. */ |
487 Dynarr_add (dst, c); | 487 Dynarr_add (dst, c); |
488 } | 488 } |
489 else if (intbyte_leading_byte_p (c)) | 489 else if (ibyte_leading_byte_p (c)) |
490 { | 490 { |
491 if (c == LEADING_BYTE_CHINESE_BIG5_1 || | 491 if (c == LEADING_BYTE_CHINESE_BIG5_1 || |
492 c == LEADING_BYTE_CHINESE_BIG5_2) | 492 c == LEADING_BYTE_CHINESE_BIG5_2) |
493 { | 493 { |
494 /* A recognized leading byte. */ | 494 /* A recognized leading byte. */ |
520 | 520 |
521 str->ch = ch; | 521 str->ch = ch; |
522 return orign; | 522 return orign; |
523 } | 523 } |
524 | 524 |
525 Emchar | 525 Ichar |
526 decode_big5_char (int b1, int b2) | 526 decode_big5_char (int b1, int b2) |
527 { | 527 { |
528 if (byte_big5_two_byte_1_p (b1) && | 528 if (byte_big5_two_byte_1_p (b1) && |
529 byte_big5_two_byte_2_p (b2)) | 529 byte_big5_two_byte_2_p (b2)) |
530 { | 530 { |
532 Lisp_Object charset; | 532 Lisp_Object charset; |
533 int c1, c2; | 533 int c1, c2; |
534 | 534 |
535 DECODE_BIG5 (b1, b2, leading_byte, c1, c2); | 535 DECODE_BIG5 (b1, b2, leading_byte, c1, c2); |
536 charset = charset_by_leading_byte (leading_byte); | 536 charset = charset_by_leading_byte (leading_byte); |
537 return make_emchar (charset, c1 & 0x7F, c2 & 0x7F); | 537 return make_ichar (charset, c1 & 0x7F, c2 & 0x7F); |
538 } | 538 } |
539 else | 539 else |
540 return -1; | 540 return -1; |
541 } | 541 } |
542 | 542 |
550 converting them to a character is analogous to any other operation that | 550 converting them to a character is analogous to any other operation that |
551 decodes an external representation. | 551 decodes an external representation. |
552 */ | 552 */ |
553 (code)) | 553 (code)) |
554 { | 554 { |
555 Emchar ch; | 555 Ichar ch; |
556 | 556 |
557 CHECK_CONS (code); | 557 CHECK_CONS (code); |
558 CHECK_INT (XCAR (code)); | 558 CHECK_INT (XCAR (code)); |
559 CHECK_INT (XCDR (code)); | 559 CHECK_INT (XCDR (code)); |
560 ch = decode_big5_char (XINT (XCAR (code)), XINT (XCDR (code))); | 560 ch = decode_big5_char (XINT (XCAR (code)), XINT (XCDR (code))); |
574 { | 574 { |
575 Lisp_Object charset; | 575 Lisp_Object charset; |
576 int c1, c2, b1, b2; | 576 int c1, c2, b1, b2; |
577 | 577 |
578 CHECK_CHAR_COERCE_INT (character); | 578 CHECK_CHAR_COERCE_INT (character); |
579 BREAKUP_EMCHAR (XCHAR (character), charset, c1, c2); | 579 BREAKUP_ICHAR (XCHAR (character), charset, c1, c2); |
580 if (EQ (charset, Vcharset_chinese_big5_1) || | 580 if (EQ (charset, Vcharset_chinese_big5_1) || |
581 EQ (charset, Vcharset_chinese_big5_2)) | 581 EQ (charset, Vcharset_chinese_big5_2)) |
582 { | 582 { |
583 ENCODE_BIG5 (XCHARSET_LEADING_BYTE (charset), c1 | 0x80, c2 | 0x80, | 583 ENCODE_BIG5 (XCHARSET_LEADING_BYTE (charset), c1 | 0x80, c2 | 0x80, |
584 b1, b2); | 584 b1, b2); |
1221 return 0; | 1221 return 0; |
1222 } | 1222 } |
1223 } | 1223 } |
1224 | 1224 |
1225 static Lisp_Object | 1225 static Lisp_Object |
1226 charset_by_attributes_or_create_one (int type, Intbyte final, int dir) | 1226 charset_by_attributes_or_create_one (int type, Ibyte final, int dir) |
1227 { | 1227 { |
1228 Lisp_Object charset = charset_by_attributes (type, final, dir); | 1228 Lisp_Object charset = charset_by_attributes (type, final, dir); |
1229 | 1229 |
1230 if (NILP (charset)) | 1230 if (NILP (charset)) |
1231 { | 1231 { |
1800 data->composite_chars = Dynarr_new (unsigned_char); | 1800 data->composite_chars = Dynarr_new (unsigned_char); |
1801 dst = data->composite_chars; | 1801 dst = data->composite_chars; |
1802 break; | 1802 break; |
1803 case ISO_ESC_END_COMPOSITE: | 1803 case ISO_ESC_END_COMPOSITE: |
1804 { | 1804 { |
1805 Intbyte comstr[MAX_EMCHAR_LEN]; | 1805 Ibyte comstr[MAX_ICHAR_LEN]; |
1806 Bytecount len; | 1806 Bytecount len; |
1807 Emchar emch = lookup_composite_char (Dynarr_atp (dst, 0), | 1807 Ichar emch = lookup_composite_char (Dynarr_atp (dst, 0), |
1808 Dynarr_length (dst)); | 1808 Dynarr_length (dst)); |
1809 dst = real_dst; | 1809 dst = real_dst; |
1810 len = set_charptr_emchar (comstr, emch); | 1810 len = set_itext_ichar (comstr, emch); |
1811 Dynarr_add_many (dst, comstr, len); | 1811 Dynarr_add_many (dst, comstr, len); |
1812 break; | 1812 break; |
1813 } | 1813 } |
1814 #else | 1814 #else |
1815 case ISO_ESC_START_COMPOSITE: | 1815 case ISO_ESC_START_COMPOSITE: |
1816 { | 1816 { |
1817 Intbyte comstr[MAX_EMCHAR_LEN]; | 1817 Ibyte comstr[MAX_ICHAR_LEN]; |
1818 Bytecount len; | 1818 Bytecount len; |
1819 Emchar emch = make_emchar (Vcharset_composite, c - '0' + ' ', | 1819 Ichar emch = make_ichar (Vcharset_composite, c - '0' + ' ', |
1820 0); | 1820 0); |
1821 len = set_charptr_emchar (comstr, emch); | 1821 len = set_itext_ichar (comstr, emch); |
1822 Dynarr_add_many (dst, comstr, len); | 1822 Dynarr_add_many (dst, comstr, len); |
1823 break; | 1823 break; |
1824 } | 1824 } |
1825 #endif /* ENABLE_COMPOSITE_CHARS */ | 1825 #endif /* ENABLE_COMPOSITE_CHARS */ |
1826 | 1826 |
2099 } | 2099 } |
2100 | 2100 |
2101 /* Convert internally-formatted data to ISO2022 format. */ | 2101 /* Convert internally-formatted data to ISO2022 format. */ |
2102 | 2102 |
2103 static Bytecount | 2103 static Bytecount |
2104 iso2022_encode (struct coding_stream *str, const Intbyte *src, | 2104 iso2022_encode (struct coding_stream *str, const Ibyte *src, |
2105 unsigned_char_dynarr *dst, Bytecount n) | 2105 unsigned_char_dynarr *dst, Bytecount n) |
2106 { | 2106 { |
2107 unsigned char charmask; | 2107 unsigned char charmask; |
2108 Intbyte c; | 2108 Ibyte c; |
2109 unsigned char char_boundary; | 2109 unsigned char char_boundary; |
2110 unsigned int ch = str->ch; | 2110 unsigned int ch = str->ch; |
2111 Lisp_Object codesys = str->codesys; | 2111 Lisp_Object codesys = str->codesys; |
2112 int i; | 2112 int i; |
2113 Lisp_Object charset; | 2113 Lisp_Object charset; |
2119 | 2119 |
2120 #ifdef ENABLE_COMPOSITE_CHARS | 2120 #ifdef ENABLE_COMPOSITE_CHARS |
2121 /* flags for handling composite chars. We do a little switcheroo | 2121 /* flags for handling composite chars. We do a little switcheroo |
2122 on the source while we're outputting the composite char. */ | 2122 on the source while we're outputting the composite char. */ |
2123 Bytecount saved_n = 0; | 2123 Bytecount saved_n = 0; |
2124 const Intbyte *saved_src = NULL; | 2124 const Ibyte *saved_src = NULL; |
2125 int in_composite = 0; | 2125 int in_composite = 0; |
2126 #endif /* ENABLE_COMPOSITE_CHARS */ | 2126 #endif /* ENABLE_COMPOSITE_CHARS */ |
2127 | 2127 |
2128 char_boundary = data->current_char_boundary; | 2128 char_boundary = data->current_char_boundary; |
2129 charset = data->current_charset; | 2129 charset = data->current_charset; |
2182 Dynarr_add (dst, ISO_CODE_ESC); | 2182 Dynarr_add (dst, ISO_CODE_ESC); |
2183 Dynarr_add (dst, c); | 2183 Dynarr_add (dst, c); |
2184 char_boundary = 1; | 2184 char_boundary = 1; |
2185 } | 2185 } |
2186 | 2186 |
2187 else if (intbyte_leading_byte_p (c) || intbyte_leading_byte_p (ch)) | 2187 else if (ibyte_leading_byte_p (c) || ibyte_leading_byte_p (ch)) |
2188 { /* Processing Leading Byte */ | 2188 { /* Processing Leading Byte */ |
2189 ch = 0; | 2189 ch = 0; |
2190 charset = charset_by_leading_byte (c); | 2190 charset = charset_by_leading_byte (c); |
2191 if (leading_byte_prefix_p (c)) | 2191 if (leading_byte_prefix_p (c)) |
2192 ch = c; | 2192 ch = c; |
2331 handle this yet. */ | 2331 handle this yet. */ |
2332 Dynarr_add (dst, '~'); | 2332 Dynarr_add (dst, '~'); |
2333 } | 2333 } |
2334 else | 2334 else |
2335 { | 2335 { |
2336 Emchar emch = make_emchar (Vcharset_composite, | 2336 Ichar emch = make_ichar (Vcharset_composite, |
2337 ch & 0x7F, c & 0x7F); | 2337 ch & 0x7F, c & 0x7F); |
2338 Lisp_Object lstr = composite_char_string (emch); | 2338 Lisp_Object lstr = composite_char_string (emch); |
2339 saved_n = n; | 2339 saved_n = n; |
2340 saved_src = src; | 2340 saved_src = src; |
2341 in_composite = 1; | 2341 in_composite = 1; |