Mercurial > emacs
comparison src/coding.c @ 89858:23cb9ed79225
(get_translation_table): Declare it as Lisp_Object.
(LOOKUP_TRANSLATION_TABLE): New macro.
(produce_chars): Use LOOKUP_TRANSLATION_TABLE instead of
CHAR_TABLE_REF.
(consume_chars): Likewise.
| author | Kenichi Handa <handa@m17n.org> |
|---|---|
| date | Thu, 11 Mar 2004 05:54:58 +0000 |
| parents | 18b52da60a76 |
| children | b706c5ee6492 |
comparison
equal
deleted
inserted
replaced
| 89857:b7584a65f2b8 | 89858:23cb9ed79225 |
|---|---|
| 5505 | 5505 |
| 5506 /* Return a translation table (or list of them) from coding system | 5506 /* Return a translation table (or list of them) from coding system |
| 5507 attribute vector ATTRS for encoding (ENCODEP is nonzero) or | 5507 attribute vector ATTRS for encoding (ENCODEP is nonzero) or |
| 5508 decoding (ENCODEP is zero). */ | 5508 decoding (ENCODEP is zero). */ |
| 5509 | 5509 |
| 5510 static INLINE | 5510 static Lisp_Object |
| 5511 get_translation_table (attrs, encodep) | 5511 get_translation_table (attrs, encodep) |
| 5512 { | 5512 { |
| 5513 Lisp_Object standard, translation_table; | 5513 Lisp_Object standard, translation_table; |
| 5514 | 5514 |
| 5515 if (encodep) | 5515 if (encodep) |
| 5538 else | 5538 else |
| 5539 translation_table = Fcons (translation_table, Fcons (standard, Qnil)); | 5539 translation_table = Fcons (translation_table, Fcons (standard, Qnil)); |
| 5540 } | 5540 } |
| 5541 return translation_table; | 5541 return translation_table; |
| 5542 } | 5542 } |
| 5543 | |
| 5544 #define LOOKUP_TRANSLATION_TABLE(table, c, trans) \ | |
| 5545 do { \ | |
| 5546 if (CHAR_TABLE_P (table)) \ | |
| 5547 { \ | |
| 5548 trans = CHAR_TABLE_REF (table, c); \ | |
| 5549 if (CHARACTERP (trans)) \ | |
| 5550 c = XFASTINT (trans), trans = Qnil; \ | |
| 5551 } \ | |
| 5552 else \ | |
| 5553 { \ | |
| 5554 Lisp_Object tail = table; \ | |
| 5555 \ | |
| 5556 for (; CONSP (tail); tail = XCDR (tail)) \ | |
| 5557 if (CHAR_TABLE_P (XCAR (tail))) \ | |
| 5558 { \ | |
| 5559 trans = CHAR_TABLE_REF (table, c); \ | |
| 5560 if (CHARACTERP (trans)) \ | |
| 5561 c = XFASTINT (trans), trans = Qnil; \ | |
| 5562 else if (! NILP (trans)) \ | |
| 5563 break; \ | |
| 5564 } \ | |
| 5565 } \ | |
| 5566 } while (0) | |
| 5543 | 5567 |
| 5544 | 5568 |
| 5545 static Lisp_Object | 5569 static Lisp_Object |
| 5546 get_translation (val, buf, buf_end, last_block, from_nchars, to_nchars) | 5570 get_translation (val, buf, buf_end, last_block, from_nchars, to_nchars) |
| 5547 Lisp_Object val; | 5571 Lisp_Object val; |
| 5619 if (c >= 0) | 5643 if (c >= 0) |
| 5620 { | 5644 { |
| 5621 int from_nchars = 1, to_nchars = 1; | 5645 int from_nchars = 1, to_nchars = 1; |
| 5622 Lisp_Object trans = Qnil; | 5646 Lisp_Object trans = Qnil; |
| 5623 | 5647 |
| 5624 if (! NILP (translation_table) | 5648 if (! NILP (translation_table)) |
| 5625 && ! NILP (trans = CHAR_TABLE_REF (translation_table, c))) | 5649 LOOKUP_TRANSLATION_TABLE (translation_table, c, trans); |
| 5650 if (! NILP (trans)) | |
| 5626 { | 5651 { |
| 5627 trans = get_translation (trans, buf, buf_end, last_block, | 5652 trans = get_translation (trans, buf, buf_end, last_block, |
| 5628 &from_nchars, &to_nchars); | 5653 &from_nchars, &to_nchars); |
| 5629 if (EQ (trans, Qt)) | 5654 if (EQ (trans, Qt)) |
| 5630 break; | 5655 break; |
| 6262 else | 6287 else |
| 6263 c = '\r'; | 6288 c = '\r'; |
| 6264 } | 6289 } |
| 6265 } | 6290 } |
| 6266 | 6291 |
| 6267 if (NILP (translation_table) | 6292 trans = Qnil; |
| 6268 || NILP (trans = CHAR_TABLE_REF (translation_table, c))) | 6293 if (! NILP (translation_table)) |
| 6294 LOOKUP_TRANSLATION_TABLE (translation_table, c, trans); | |
| 6295 if (NILP (trans)) | |
| 6269 *buf++ = c; | 6296 *buf++ = c; |
| 6270 else | 6297 else |
| 6271 { | 6298 { |
| 6272 int from_nchars = 1, to_nchars = 1; | 6299 int from_nchars = 1, to_nchars = 1; |
| 6273 int *lookup_buf_end; | 6300 int *lookup_buf_end; |
