aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorDaniel Colascione2012-10-07 14:31:58 -0800
committerDaniel Colascione2012-10-07 14:31:58 -0800
commit36a305a723c63fd345be65c536c52fe9765c14be (patch)
treefb89d9e103552863214c60297a65320917109357 /src/coding.c
parent2ab329f3b5d52a39f0a45c3d9c129f1c19560142 (diff)
parent795b1482a9e314cda32d62ac2988f573d359366e (diff)
downloademacs-36a305a723c63fd345be65c536c52fe9765c14be.tar.gz
emacs-36a305a723c63fd345be65c536c52fe9765c14be.zip
Merge from trunk
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c90
1 files changed, 30 insertions, 60 deletions
diff --git a/src/coding.c b/src/coding.c
index 4b3d22f956c..d9606cf5710 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -920,65 +920,18 @@ record_conversion_result (struct coding_system *coding,
920 920
921 921
922/* Store multibyte form of the character C in P, and advance P to the 922/* Store multibyte form of the character C in P, and advance P to the
923 end of the multibyte form. This is like CHAR_STRING_ADVANCE but it 923 end of the multibyte form. This used to be like CHAR_STRING_ADVANCE
924 never calls MAYBE_UNIFY_CHAR. */ 924 without ever calling MAYBE_UNIFY_CHAR, but nowadays we don't call
925 925 MAYBE_UNIFY_CHAR in CHAR_STRING_ADVANCE. */
926#define CHAR_STRING_ADVANCE_NO_UNIFY(c, p) \
927 do { \
928 if ((c) <= MAX_1_BYTE_CHAR) \
929 *(p)++ = (c); \
930 else if ((c) <= MAX_2_BYTE_CHAR) \
931 *(p)++ = (0xC0 | ((c) >> 6)), \
932 *(p)++ = (0x80 | ((c) & 0x3F)); \
933 else if ((c) <= MAX_3_BYTE_CHAR) \
934 *(p)++ = (0xE0 | ((c) >> 12)), \
935 *(p)++ = (0x80 | (((c) >> 6) & 0x3F)), \
936 *(p)++ = (0x80 | ((c) & 0x3F)); \
937 else if ((c) <= MAX_4_BYTE_CHAR) \
938 *(p)++ = (0xF0 | (c >> 18)), \
939 *(p)++ = (0x80 | ((c >> 12) & 0x3F)), \
940 *(p)++ = (0x80 | ((c >> 6) & 0x3F)), \
941 *(p)++ = (0x80 | (c & 0x3F)); \
942 else if ((c) <= MAX_5_BYTE_CHAR) \
943 *(p)++ = 0xF8, \
944 *(p)++ = (0x80 | ((c >> 18) & 0x0F)), \
945 *(p)++ = (0x80 | ((c >> 12) & 0x3F)), \
946 *(p)++ = (0x80 | ((c >> 6) & 0x3F)), \
947 *(p)++ = (0x80 | (c & 0x3F)); \
948 else \
949 (p) += BYTE8_STRING ((c) - 0x3FFF80, p); \
950 } while (0)
951 926
927#define CHAR_STRING_ADVANCE_NO_UNIFY(c, p) CHAR_STRING_ADVANCE(c, p)
952 928
953/* Return the character code of character whose multibyte form is at 929/* Return the character code of character whose multibyte form is at
954 P, and advance P to the end of the multibyte form. This is like 930 P, and advance P to the end of the multibyte form. This used to be
955 STRING_CHAR_ADVANCE, but it never calls MAYBE_UNIFY_CHAR. */ 931 like STRING_CHAR_ADVANCE without ever calling MAYBE_UNIFY_CHAR, but
956 932 nowadays STRING_CHAR_ADVANCE doesn't call MAYBE_UNIFY_CHAR. */
957#define STRING_CHAR_ADVANCE_NO_UNIFY(p) \
958 (!((p)[0] & 0x80) \
959 ? *(p)++ \
960 : ! ((p)[0] & 0x20) \
961 ? ((p) += 2, \
962 ((((p)[-2] & 0x1F) << 6) \
963 | ((p)[-1] & 0x3F) \
964 | ((unsigned char) ((p)[-2]) < 0xC2 ? 0x3FFF80 : 0))) \
965 : ! ((p)[0] & 0x10) \
966 ? ((p) += 3, \
967 ((((p)[-3] & 0x0F) << 12) \
968 | (((p)[-2] & 0x3F) << 6) \
969 | ((p)[-1] & 0x3F))) \
970 : ! ((p)[0] & 0x08) \
971 ? ((p) += 4, \
972 ((((p)[-4] & 0xF) << 18) \
973 | (((p)[-3] & 0x3F) << 12) \
974 | (((p)[-2] & 0x3F) << 6) \
975 | ((p)[-1] & 0x3F))) \
976 : ((p) += 5, \
977 ((((p)[-4] & 0x3F) << 18) \
978 | (((p)[-3] & 0x3F) << 12) \
979 | (((p)[-2] & 0x3F) << 6) \
980 | ((p)[-1] & 0x3F))))
981 933
934#define STRING_CHAR_ADVANCE_NO_UNIFY(p) STRING_CHAR_ADVANCE(p)
982 935
983/* Set coding->source from coding->src_object. */ 936/* Set coding->source from coding->src_object. */
984 937
@@ -5106,6 +5059,7 @@ decode_coding_ccl (struct coding_system *coding)
5106 while (1) 5059 while (1)
5107 { 5060 {
5108 const unsigned char *p = src; 5061 const unsigned char *p = src;
5062 ptrdiff_t offset;
5109 int i = 0; 5063 int i = 0;
5110 5064
5111 if (multibytep) 5065 if (multibytep)
@@ -5123,8 +5077,17 @@ decode_coding_ccl (struct coding_system *coding)
5123 5077
5124 if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK) 5078 if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK)
5125 ccl->last_block = 1; 5079 ccl->last_block = 1;
5080 /* As ccl_driver calls DECODE_CHAR, buffer may be relocated. */
5081 charset_map_loaded = 0;
5126 ccl_driver (ccl, source_charbuf, charbuf, i, charbuf_end - charbuf, 5082 ccl_driver (ccl, source_charbuf, charbuf, i, charbuf_end - charbuf,
5127 charset_list); 5083 charset_list);
5084 if (charset_map_loaded
5085 && (offset = coding_change_source (coding)))
5086 {
5087 p += offset;
5088 src += offset;
5089 src_end += offset;
5090 }
5128 charbuf += ccl->produced; 5091 charbuf += ccl->produced;
5129 if (multibytep) 5092 if (multibytep)
5130 src += source_byteidx[ccl->consumed]; 5093 src += source_byteidx[ccl->consumed];
@@ -5177,8 +5140,15 @@ encode_coding_ccl (struct coding_system *coding)
5177 5140
5178 do 5141 do
5179 { 5142 {
5143 ptrdiff_t offset;
5144
5145 /* As ccl_driver calls DECODE_CHAR, buffer may be relocated. */
5146 charset_map_loaded = 0;
5180 ccl_driver (ccl, charbuf, destination_charbuf, 5147 ccl_driver (ccl, charbuf, destination_charbuf,
5181 charbuf_end - charbuf, 1024, charset_list); 5148 charbuf_end - charbuf, 1024, charset_list);
5149 if (charset_map_loaded
5150 && (offset = coding_change_destination (coding)))
5151 dst += offset;
5182 if (multibytep) 5152 if (multibytep)
5183 { 5153 {
5184 ASSURE_DESTINATION (ccl->produced * 2); 5154 ASSURE_DESTINATION (ccl->produced * 2);
@@ -6852,7 +6822,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6852 [ -LENGTH ANNOTATION_MASK NCHARS NBYTES METHOD [ COMPONENTS... ] ] 6822 [ -LENGTH ANNOTATION_MASK NCHARS NBYTES METHOD [ COMPONENTS... ] ]
6853 */ 6823 */
6854 6824
6855static inline void 6825static void
6856produce_composition (struct coding_system *coding, int *charbuf, ptrdiff_t pos) 6826produce_composition (struct coding_system *coding, int *charbuf, ptrdiff_t pos)
6857{ 6827{
6858 int len; 6828 int len;
@@ -6896,7 +6866,7 @@ produce_composition (struct coding_system *coding, int *charbuf, ptrdiff_t pos)
6896 [ -LENGTH ANNOTATION_MASK NCHARS CHARSET-ID ] 6866 [ -LENGTH ANNOTATION_MASK NCHARS CHARSET-ID ]
6897 */ 6867 */
6898 6868
6899static inline void 6869static void
6900produce_charset (struct coding_system *coding, int *charbuf, ptrdiff_t pos) 6870produce_charset (struct coding_system *coding, int *charbuf, ptrdiff_t pos)
6901{ 6871{
6902 ptrdiff_t from = pos - charbuf[2]; 6872 ptrdiff_t from = pos - charbuf[2];
@@ -7131,7 +7101,7 @@ decode_coding (struct coding_system *coding)
7131 position of a composition after POS (if any) or to LIMIT, and 7101 position of a composition after POS (if any) or to LIMIT, and
7132 return BUF. */ 7102 return BUF. */
7133 7103
7134static inline int * 7104static int *
7135handle_composition_annotation (ptrdiff_t pos, ptrdiff_t limit, 7105handle_composition_annotation (ptrdiff_t pos, ptrdiff_t limit,
7136 struct coding_system *coding, int *buf, 7106 struct coding_system *coding, int *buf,
7137 ptrdiff_t *stop) 7107 ptrdiff_t *stop)
@@ -7214,7 +7184,7 @@ handle_composition_annotation (ptrdiff_t pos, ptrdiff_t limit,
7214 If the property value is nil, set *STOP to the position where the 7184 If the property value is nil, set *STOP to the position where the
7215 property value is non-nil (limiting by LIMIT), and return BUF. */ 7185 property value is non-nil (limiting by LIMIT), and return BUF. */
7216 7186
7217static inline int * 7187static int *
7218handle_charset_annotation (ptrdiff_t pos, ptrdiff_t limit, 7188handle_charset_annotation (ptrdiff_t pos, ptrdiff_t limit,
7219 struct coding_system *coding, int *buf, 7189 struct coding_system *coding, int *buf,
7220 ptrdiff_t *stop) 7190 ptrdiff_t *stop)
@@ -8459,7 +8429,7 @@ highest priority. */)
8459} 8429}
8460 8430
8461 8431
8462static inline bool 8432static bool
8463char_encodable_p (int c, Lisp_Object attrs) 8433char_encodable_p (int c, Lisp_Object attrs)
8464{ 8434{
8465 Lisp_Object tail; 8435 Lisp_Object tail;