aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Schwab2009-11-21 11:52:23 +0000
committerAndreas Schwab2009-11-21 11:52:23 +0000
commit62a6e103dd7b9d940565639d6a47c8bdee3f24ce (patch)
tree0e2ab8777e97932d73a91e328683bef10dbf7c8d /src
parentc3b616a940d9dab7f8fe4376755a8a8f9a2ba290 (diff)
downloademacs-62a6e103dd7b9d940565639d6a47c8bdee3f24ce.tar.gz
emacs-62a6e103dd7b9d940565639d6a47c8bdee3f24ce.zip
* character.h (STRING_CHAR, STRING_CHAR_AND_LENGTH): Remove
ignored second argument. All callers changed. * regex.c (STRING_CHAR, STRING_CHAR_AND_LENGTH, RE_STRING_CHAR) (RE_STRING_CHAR_AND_LENGTH): Likewise. * xdisp.c (string_char_and_length): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/buffer.c2
-rw-r--r--src/buffer.h4
-rw-r--r--src/casefiddle.c2
-rw-r--r--src/character.c6
-rw-r--r--src/character.h20
-rw-r--r--src/composite.c8
-rw-r--r--src/data.c3
-rw-r--r--src/doc.c6
-rw-r--r--src/editfns.c9
-rw-r--r--src/fileio.c2
-rw-r--r--src/fns.c12
-rw-r--r--src/font.c2
-rw-r--r--src/indent.c2
-rw-r--r--src/insdel.c2
-rw-r--r--src/lread.c6
-rw-r--r--src/print.c10
-rw-r--r--src/process.c2
-rw-r--r--src/regex.c51
-rw-r--r--src/search.c14
-rw-r--r--src/syntax.c23
-rw-r--r--src/xdisp.c35
-rw-r--r--src/xterm.c3
23 files changed, 107 insertions, 125 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 452cee484f2..7f6891e0710 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12009-11-21 Andreas Schwab <schwab@linux-m68k.org>
2
3 * character.h (STRING_CHAR, STRING_CHAR_AND_LENGTH): Remove
4 ignored second argument. All callers changed.
5 * regex.c (STRING_CHAR, STRING_CHAR_AND_LENGTH, RE_STRING_CHAR)
6 (RE_STRING_CHAR_AND_LENGTH): Likewise.
7 * xdisp.c (string_char_and_length): Likewise.
8
12009-11-21 Dan Nicolaescu <dann@ics.uci.edu> 92009-11-21 Dan Nicolaescu <dann@ics.uci.edu>
2 10
3 * xterm.c (x_new_font): 11 * xterm.c (x_new_font):
diff --git a/src/buffer.c b/src/buffer.c
index 8edea2d8728..8657fd8cdff 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2409,7 +2409,7 @@ current buffer is cleared. */)
2409 p++, pos++; 2409 p++, pos++;
2410 else if (CHAR_BYTE8_HEAD_P (*p)) 2410 else if (CHAR_BYTE8_HEAD_P (*p))
2411 { 2411 {
2412 c = STRING_CHAR_AND_LENGTH (p, stop - pos, bytes); 2412 c = STRING_CHAR_AND_LENGTH (p, bytes);
2413 /* Delete all bytes for this 8-bit character but the 2413 /* Delete all bytes for this 8-bit character but the
2414 last one, and change the last one to the charcter 2414 last one, and change the last one to the charcter
2415 code. */ 2415 code. */
diff --git a/src/buffer.h b/src/buffer.h
index 2a04f49ea48..9f57a292053 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -330,7 +330,7 @@ extern unsigned char *_fetch_multibyte_char_p;
330#define FETCH_MULTIBYTE_CHAR(pos) \ 330#define FETCH_MULTIBYTE_CHAR(pos) \
331 (_fetch_multibyte_char_p = (((pos) >= GPT_BYTE ? GAP_SIZE : 0) \ 331 (_fetch_multibyte_char_p = (((pos) >= GPT_BYTE ? GAP_SIZE : 0) \
332 + (pos) + BEG_ADDR - BEG_BYTE), \ 332 + (pos) + BEG_ADDR - BEG_BYTE), \
333 STRING_CHAR (_fetch_multibyte_char_p, 0)) 333 STRING_CHAR (_fetch_multibyte_char_p))
334 334
335/* Return character at position POS. If the current buffer is unibyte 335/* Return character at position POS. If the current buffer is unibyte
336 and the character is not ASCII, make the returning character 336 and the character is not ASCII, make the returning character
@@ -389,7 +389,7 @@ extern unsigned char *_fetch_multibyte_char_p;
389 (_fetch_multibyte_char_p \ 389 (_fetch_multibyte_char_p \
390 = (((pos) >= BUF_GPT_BYTE (buf) ? BUF_GAP_SIZE (buf) : 0) \ 390 = (((pos) >= BUF_GPT_BYTE (buf) ? BUF_GAP_SIZE (buf) : 0) \
391 + (pos) + BUF_BEG_ADDR (buf) - BEG_BYTE), \ 391 + (pos) + BUF_BEG_ADDR (buf) - BEG_BYTE), \
392 STRING_CHAR (_fetch_multibyte_char_p, 0)) 392 STRING_CHAR (_fetch_multibyte_char_p))
393 393
394/* Define the actual buffer data structures. */ 394/* Define the actual buffer data structures. */
395 395
diff --git a/src/casefiddle.c b/src/casefiddle.c
index f9f19927313..9963c1e90c5 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -133,7 +133,7 @@ casify_object (flag, obj)
133 bcopy (old_dst, dst, o - old_dst); 133 bcopy (old_dst, dst, o - old_dst);
134 o = dst + (o - old_dst); 134 o = dst + (o - old_dst);
135 } 135 }
136 c = STRING_CHAR_AND_LENGTH (SDATA (obj) + i_byte, 0, len); 136 c = STRING_CHAR_AND_LENGTH (SDATA (obj) + i_byte, len);
137 if (inword && flag != CASE_CAPITALIZE_UP) 137 if (inword && flag != CASE_CAPITALIZE_UP)
138 c = DOWNCASE (c); 138 c = DOWNCASE (c);
139 else if (!UPPERCASEP (c) 139 else if (!UPPERCASEP (c)
diff --git a/src/character.c b/src/character.c
index ff2f4a716d8..396a9c2728d 100644
--- a/src/character.c
+++ b/src/character.c
@@ -405,7 +405,7 @@ c_string_width (const unsigned char *str, int len, int precision, int *nchars, i
405 { 405 {
406 int bytes, thiswidth; 406 int bytes, thiswidth;
407 Lisp_Object val; 407 Lisp_Object val;
408 int c = STRING_CHAR_AND_LENGTH (str + i_byte, len - i_byte, bytes); 408 int c = STRING_CHAR_AND_LENGTH (str + i_byte, bytes);
409 409
410 if (dp) 410 if (dp)
411 { 411 {
@@ -495,7 +495,7 @@ lisp_string_width (string, precision, nchars, nbytes)
495 int c; 495 int c;
496 496
497 if (multibyte) 497 if (multibyte)
498 c = STRING_CHAR_AND_LENGTH (str + i_byte, len - i_byte, bytes); 498 c = STRING_CHAR_AND_LENGTH (str + i_byte, bytes);
499 else 499 else
500 c = str[i_byte], bytes = 1; 500 c = str[i_byte], bytes = 1;
501 chars = 1; 501 chars = 1;
@@ -1061,7 +1061,7 @@ character is not ASCII nor 8-bit character, an error is signalled. */)
1061 if (! STRING_MULTIBYTE (string)) 1061 if (! STRING_MULTIBYTE (string))
1062 return make_number (*p); 1062 return make_number (*p);
1063 } 1063 }
1064 c = STRING_CHAR (p, 0); 1064 c = STRING_CHAR (p);
1065 if (CHAR_BYTE8_P (c)) 1065 if (CHAR_BYTE8_P (c))
1066 c = CHAR_TO_BYTE8 (c); 1066 c = CHAR_TO_BYTE8 (c);
1067 else if (! ASCII_CHAR_P (c)) 1067 else if (! ASCII_CHAR_P (c))
diff --git a/src/character.h b/src/character.h
index 78065597532..77c1d8cded2 100644
--- a/src/character.h
+++ b/src/character.h
@@ -311,10 +311,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
311 } while (0) 311 } while (0)
312 312
313/* Return the character code of character whose multibyte form is at 313/* Return the character code of character whose multibyte form is at
314 P. The argument LEN is ignored. It will be removed in the 314 P. */
315 future. */
316 315
317#define STRING_CHAR(p, len) \ 316#define STRING_CHAR(p) \
318 (!((p)[0] & 0x80) \ 317 (!((p)[0] & 0x80) \
319 ? (p)[0] \ 318 ? (p)[0] \
320 : ! ((p)[0] & 0x20) \ 319 : ! ((p)[0] & 0x20) \
@@ -329,10 +328,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
329 328
330 329
331/* Like STRING_CHAR, but set ACTUAL_LEN to the length of multibyte 330/* Like STRING_CHAR, but set ACTUAL_LEN to the length of multibyte
332 form. The argument LEN is ignored. It will be removed in the 331 form. */
333 future. */
334 332
335#define STRING_CHAR_AND_LENGTH(p, len, actual_len) \ 333#define STRING_CHAR_AND_LENGTH(p, actual_len) \
336 (!((p)[0] & 0x80) \ 334 (!((p)[0] & 0x80) \
337 ? ((actual_len) = 1, (p)[0]) \ 335 ? ((actual_len) = 1, (p)[0]) \
338 : ! ((p)[0] & 0x20) \ 336 : ! ((p)[0] & 0x20) \
@@ -382,7 +380,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
382 unsigned char *ptr = &SDATA (STRING)[BYTEIDX]; \ 380 unsigned char *ptr = &SDATA (STRING)[BYTEIDX]; \
383 int len; \ 381 int len; \
384 \ 382 \
385 OUTPUT = STRING_CHAR_AND_LENGTH (ptr, 0, len); \ 383 OUTPUT = STRING_CHAR_AND_LENGTH (ptr, len); \
386 BYTEIDX += len; \ 384 BYTEIDX += len; \
387 } \ 385 } \
388 else \ 386 else \
@@ -405,7 +403,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
405 unsigned char *ptr = &SDATA (STRING)[BYTEIDX]; \ 403 unsigned char *ptr = &SDATA (STRING)[BYTEIDX]; \
406 int len; \ 404 int len; \
407 \ 405 \
408 OUTPUT = STRING_CHAR_AND_LENGTH (ptr, 0, len); \ 406 OUTPUT = STRING_CHAR_AND_LENGTH (ptr, len); \
409 BYTEIDX += len; \ 407 BYTEIDX += len; \
410 } \ 408 } \
411 else \ 409 else \
@@ -426,7 +424,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
426 unsigned char *ptr = &SDATA (STRING)[BYTEIDX]; \ 424 unsigned char *ptr = &SDATA (STRING)[BYTEIDX]; \
427 int len; \ 425 int len; \
428 \ 426 \
429 OUTPUT = STRING_CHAR_AND_LENGTH (ptr, 0, len); \ 427 OUTPUT = STRING_CHAR_AND_LENGTH (ptr, len); \
430 BYTEIDX += len; \ 428 BYTEIDX += len; \
431 CHARIDX++; \ 429 CHARIDX++; \
432 } \ 430 } \
@@ -445,7 +443,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
445 unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX); \ 443 unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX); \
446 int len; \ 444 int len; \
447 \ 445 \
448 OUTPUT= STRING_CHAR_AND_LENGTH (ptr, 0, len); \ 446 OUTPUT= STRING_CHAR_AND_LENGTH (ptr, len); \
449 BYTEIDX += len; \ 447 BYTEIDX += len; \
450 } \ 448 } \
451 else \ 449 else \
@@ -465,7 +463,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
465 unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX); \ 463 unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX); \
466 int len; \ 464 int len; \
467 \ 465 \
468 OUTPUT= STRING_CHAR_AND_LENGTH (ptr, 0, len); \ 466 OUTPUT = STRING_CHAR_AND_LENGTH (ptr, len); \
469 BYTEIDX += len; \ 467 BYTEIDX += len; \
470 CHARIDX++; \ 468 CHARIDX++; \
471 } \ 469 } \
diff --git a/src/composite.c b/src/composite.c
index f7bfc28973a..33dd4ba1abd 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -1321,7 +1321,7 @@ find_automatic_composition (pos, limit, start, end, gstring, string)
1321 retry: 1321 retry:
1322 check_val = Qnil; 1322 check_val = Qnil;
1323 /* At first, check if POS is composable. */ 1323 /* At first, check if POS is composable. */
1324 c = STRING_CHAR (cur.p, 0); 1324 c = STRING_CHAR (cur.p);
1325 if (! CHAR_COMPOSABLE_P (c)) 1325 if (! CHAR_COMPOSABLE_P (c))
1326 { 1326 {
1327 if (limit < 0) 1327 if (limit < 0)
@@ -1347,7 +1347,7 @@ find_automatic_composition (pos, limit, start, end, gstring, string)
1347 fore_check_limit = cur.pos; 1347 fore_check_limit = cur.pos;
1348 break; 1348 break;
1349 } 1349 }
1350 c = STRING_CHAR (cur.p, 0); 1350 c = STRING_CHAR (cur.p);
1351 if (! CHAR_COMPOSABLE_P (c)) 1351 if (! CHAR_COMPOSABLE_P (c))
1352 break; 1352 break;
1353 val = CHAR_TABLE_REF (Vcomposition_function_table, c); 1353 val = CHAR_TABLE_REF (Vcomposition_function_table, c);
@@ -1368,7 +1368,7 @@ find_automatic_composition (pos, limit, start, end, gstring, string)
1368 if (get_property_and_range (cur.pos, Qcomposition, &val, &b, &e, Qnil) 1368 if (get_property_and_range (cur.pos, Qcomposition, &val, &b, &e, Qnil)
1369 && COMPOSITION_VALID_P (b, e, val)) 1369 && COMPOSITION_VALID_P (b, e, val))
1370 break; 1370 break;
1371 c = STRING_CHAR (cur.p, 0); 1371 c = STRING_CHAR (cur.p);
1372 if (! CHAR_COMPOSABLE_P (c)) 1372 if (! CHAR_COMPOSABLE_P (c))
1373 break; 1373 break;
1374 val = CHAR_TABLE_REF (Vcomposition_function_table, c); 1374 val = CHAR_TABLE_REF (Vcomposition_function_table, c);
@@ -1391,7 +1391,7 @@ find_automatic_composition (pos, limit, start, end, gstring, string)
1391 1391
1392 if (NILP (check_val)) 1392 if (NILP (check_val))
1393 { 1393 {
1394 c = STRING_CHAR (cur.p, 0); 1394 c = STRING_CHAR (cur.p);
1395 check_val = CHAR_TABLE_REF (Vcomposition_function_table, c); 1395 check_val = CHAR_TABLE_REF (Vcomposition_function_table, c);
1396 } 1396 }
1397 for (; CONSP (check_val); check_val = XCDR (check_val)) 1397 for (; CONSP (check_val); check_val = XCDR (check_val))
diff --git a/src/data.c b/src/data.c
index 7110fb7eae7..ce2d842de44 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2007,8 +2007,7 @@ or a byte-code object. IDX starts at 0. */)
2007 return make_number ((unsigned char) SREF (array, idxval)); 2007 return make_number ((unsigned char) SREF (array, idxval));
2008 idxval_byte = string_char_to_byte (array, idxval); 2008 idxval_byte = string_char_to_byte (array, idxval);
2009 2009
2010 c = STRING_CHAR (SDATA (array) + idxval_byte, 2010 c = STRING_CHAR (SDATA (array) + idxval_byte);
2011 SBYTES (array) - idxval_byte);
2012 return make_number (c); 2011 return make_number (c);
2013 } 2012 }
2014 else if (BOOL_VECTOR_P (array)) 2013 else if (BOOL_VECTOR_P (array))
diff --git a/src/doc.c b/src/doc.c
index 30b909b8ce8..750e0ca7b43 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -767,9 +767,8 @@ a new string, without any text properties, is returned. */)
767 if (multibyte) 767 if (multibyte)
768 { 768 {
769 int len; 769 int len;
770 int maxlen = SDATA (string) + SBYTES (string) - strp;
771 770
772 STRING_CHAR_AND_LENGTH (strp, maxlen, len); 771 STRING_CHAR_AND_LENGTH (strp, len);
773 if (len == 1) 772 if (len == 1)
774 *bufp = *strp; 773 *bufp = *strp;
775 else 774 else
@@ -931,9 +930,8 @@ a new string, without any text properties, is returned. */)
931 else 930 else
932 { 931 {
933 int len; 932 int len;
934 int maxlen = SDATA (string) + SBYTES (string) - strp;
935 933
936 STRING_CHAR_AND_LENGTH (strp, maxlen, len); 934 STRING_CHAR_AND_LENGTH (strp, len);
937 if (len == 1) 935 if (len == 1)
938 *bufp = *strp; 936 *bufp = *strp;
939 else 937 else
diff --git a/src/editfns.c b/src/editfns.c
index 8cf182dff0f..c2c5d265cb5 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -231,7 +231,7 @@ A multibyte character is handled correctly. */)
231 if (SCHARS (string)) 231 if (SCHARS (string))
232 { 232 {
233 if (STRING_MULTIBYTE (string)) 233 if (STRING_MULTIBYTE (string))
234 XSETFASTINT (val, STRING_CHAR (SDATA (string), SBYTES (string))); 234 XSETFASTINT (val, STRING_CHAR (SDATA (string)));
235 else 235 else
236 XSETFASTINT (val, SREF (string, 0)); 236 XSETFASTINT (val, SREF (string, 0));
237 } 237 }
@@ -2983,7 +2983,7 @@ check_translation (pos, pos_byte, end, val)
2983 memcpy (newbuf, buf, sizeof (int) * buf_used); 2983 memcpy (newbuf, buf, sizeof (int) * buf_used);
2984 buf = newbuf; 2984 buf = newbuf;
2985 } 2985 }
2986 buf[buf_used++] = STRING_CHAR_AND_LENGTH (p, 0, len); 2986 buf[buf_used++] = STRING_CHAR_AND_LENGTH (p, len);
2987 pos_byte += len; 2987 pos_byte += len;
2988 } 2988 }
2989 if (XINT (AREF (elt, i)) != buf[i]) 2989 if (XINT (AREF (elt, i)) != buf[i])
@@ -3052,7 +3052,7 @@ It returns the number of characters changed. */)
3052 Lisp_Object val; 3052 Lisp_Object val;
3053 3053
3054 if (multibyte) 3054 if (multibyte)
3055 oc = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, len); 3055 oc = STRING_CHAR_AND_LENGTH (p, len);
3056 else 3056 else
3057 oc = *p, len = 1; 3057 oc = *p, len = 1;
3058 if (oc < size) 3058 if (oc < size)
@@ -3064,8 +3064,7 @@ It returns the number of characters changed. */)
3064 if (string_multibyte) 3064 if (string_multibyte)
3065 { 3065 {
3066 str = tt + string_char_to_byte (table, oc); 3066 str = tt + string_char_to_byte (table, oc);
3067 nc = STRING_CHAR_AND_LENGTH (str, MAX_MULTIBYTE_LENGTH, 3067 nc = STRING_CHAR_AND_LENGTH (str, str_len);
3068 str_len);
3069 } 3068 }
3070 else 3069 else
3071 { 3070 {
diff --git a/src/fileio.c b/src/fileio.c
index 1625c3d2547..b815c38956e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -277,7 +277,7 @@ report_file_error (string, data)
277 int c; 277 int c;
278 278
279 str = (char *) SDATA (errstring); 279 str = (char *) SDATA (errstring);
280 c = STRING_CHAR (str, 0); 280 c = STRING_CHAR (str);
281 Faset (errstring, make_number (0), make_number (DOWNCASE (c))); 281 Faset (errstring, make_number (0), make_number (DOWNCASE (c)));
282 } 282 }
283 283
diff --git a/src/fns.c b/src/fns.c
index c453d05662b..8355c6c2913 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -1711,8 +1711,7 @@ to be sure of changing the value of `foo'. */)
1711 { 1711 {
1712 if (STRING_MULTIBYTE (seq)) 1712 if (STRING_MULTIBYTE (seq))
1713 { 1713 {
1714 c = STRING_CHAR (SDATA (seq) + ibyte, 1714 c = STRING_CHAR (SDATA (seq) + ibyte);
1715 SBYTES (seq) - ibyte);
1716 cbytes = CHAR_BYTES (c); 1715 cbytes = CHAR_BYTES (c);
1717 } 1716 }
1718 else 1717 else
@@ -1742,8 +1741,7 @@ to be sure of changing the value of `foo'. */)
1742 { 1741 {
1743 if (STRING_MULTIBYTE (seq)) 1742 if (STRING_MULTIBYTE (seq))
1744 { 1743 {
1745 c = STRING_CHAR (SDATA (seq) + ibyte, 1744 c = STRING_CHAR (SDATA (seq) + ibyte);
1746 SBYTES (seq) - ibyte);
1747 cbytes = CHAR_BYTES (c); 1745 cbytes = CHAR_BYTES (c);
1748 } 1746 }
1749 else 1747 else
@@ -3363,7 +3361,7 @@ base64_encode_1 (from, to, length, line_break, multibyte)
3363 { 3361 {
3364 if (multibyte) 3362 if (multibyte)
3365 { 3363 {
3366 c = STRING_CHAR_AND_LENGTH (from + i, length - i, bytes); 3364 c = STRING_CHAR_AND_LENGTH (from + i, bytes);
3367 if (CHAR_BYTE8_P (c)) 3365 if (CHAR_BYTE8_P (c))
3368 c = CHAR_TO_BYTE8 (c); 3366 c = CHAR_TO_BYTE8 (c);
3369 else if (c >= 256) 3367 else if (c >= 256)
@@ -3403,7 +3401,7 @@ base64_encode_1 (from, to, length, line_break, multibyte)
3403 3401
3404 if (multibyte) 3402 if (multibyte)
3405 { 3403 {
3406 c = STRING_CHAR_AND_LENGTH (from + i, length - i, bytes); 3404 c = STRING_CHAR_AND_LENGTH (from + i, bytes);
3407 if (CHAR_BYTE8_P (c)) 3405 if (CHAR_BYTE8_P (c))
3408 c = CHAR_TO_BYTE8 (c); 3406 c = CHAR_TO_BYTE8 (c);
3409 else if (c >= 256) 3407 else if (c >= 256)
@@ -3427,7 +3425,7 @@ base64_encode_1 (from, to, length, line_break, multibyte)
3427 3425
3428 if (multibyte) 3426 if (multibyte)
3429 { 3427 {
3430 c = STRING_CHAR_AND_LENGTH (from + i, length - i, bytes); 3428 c = STRING_CHAR_AND_LENGTH (from + i, bytes);
3431 if (CHAR_BYTE8_P (c)) 3429 if (CHAR_BYTE8_P (c))
3432 c = CHAR_TO_BYTE8 (c); 3430 c = CHAR_TO_BYTE8 (c);
3433 else if (c >= 256) 3431 else if (c >= 256)
diff --git a/src/font.c b/src/font.c
index 1c0a9dfb236..aa07c7805d1 100644
--- a/src/font.c
+++ b/src/font.c
@@ -3863,7 +3863,7 @@ font_at (c, pos, face, w, string)
3863 EMACS_INT pos_byte = string_char_to_byte (string, pos); 3863 EMACS_INT pos_byte = string_char_to_byte (string, pos);
3864 3864
3865 str = SDATA (string) + pos_byte; 3865 str = SDATA (string) + pos_byte;
3866 c = STRING_CHAR (str, 0); 3866 c = STRING_CHAR (str);
3867 } 3867 }
3868 else 3868 else
3869 c = SDATA (string)[pos]; 3869 c = SDATA (string)[pos];
diff --git a/src/indent.c b/src/indent.c
index 5a73fa1b211..c8c486a48fa 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -295,7 +295,7 @@ skip_invisible (pos, next_boundary_p, to, window)
295 int c; \ 295 int c; \
296 \ 296 \
297 wide_column = 0; \ 297 wide_column = 0; \
298 c = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, bytes); \ 298 c = STRING_CHAR_AND_LENGTH (p, bytes); \
299 if (BYTES_BY_CHAR_HEAD (*p) != bytes) \ 299 if (BYTES_BY_CHAR_HEAD (*p) != bytes) \
300 width = bytes * 4; \ 300 width = bytes * 4; \
301 else \ 301 else \
diff --git a/src/insdel.c b/src/insdel.c
index 0faf3c07227..0ab199ab1c7 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -648,7 +648,7 @@ copy_text (const unsigned char *from_addr, unsigned char *to_addr,
648 while (bytes_left > 0) 648 while (bytes_left > 0)
649 { 649 {
650 int thislen, c; 650 int thislen, c;
651 c = STRING_CHAR_AND_LENGTH (from_addr, bytes_left, thislen); 651 c = STRING_CHAR_AND_LENGTH (from_addr, thislen);
652 if (! ASCII_CHAR_P (c)) 652 if (! ASCII_CHAR_P (c))
653 c &= 0xFF; 653 c &= 0xFF;
654 *to_addr++ = c; 654 *to_addr++ = c;
diff --git a/src/lread.c b/src/lread.c
index c565ce9fd5d..97b9410b038 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -303,7 +303,7 @@ readchar (readcharfun, multibyte)
303 /* Fetch the character code from the buffer. */ 303 /* Fetch the character code from the buffer. */
304 unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, pt_byte); 304 unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, pt_byte);
305 BUF_INC_POS (inbuffer, pt_byte); 305 BUF_INC_POS (inbuffer, pt_byte);
306 c = STRING_CHAR (p, pt_byte - orig_pt_byte); 306 c = STRING_CHAR (p);
307 if (multibyte) 307 if (multibyte)
308 *multibyte = 1; 308 *multibyte = 1;
309 } 309 }
@@ -332,7 +332,7 @@ readchar (readcharfun, multibyte)
332 /* Fetch the character code from the buffer. */ 332 /* Fetch the character code from the buffer. */
333 unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, bytepos); 333 unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, bytepos);
334 BUF_INC_POS (inbuffer, bytepos); 334 BUF_INC_POS (inbuffer, bytepos);
335 c = STRING_CHAR (p, bytepos - orig_bytepos); 335 c = STRING_CHAR (p);
336 if (multibyte) 336 if (multibyte)
337 *multibyte = 1; 337 *multibyte = 1;
338 } 338 }
@@ -439,7 +439,7 @@ readchar (readcharfun, multibyte)
439 } 439 }
440 buf[i++] = c; 440 buf[i++] = c;
441 } 441 }
442 return STRING_CHAR (buf, i); 442 return STRING_CHAR (buf);
443} 443}
444 444
445/* Unread the character C in the way appropriate for the stream READCHARFUN. 445/* Unread the character C in the way appropriate for the stream READCHARFUN.
diff --git a/src/print.c b/src/print.c
index 613660b582c..a011cb885fa 100644
--- a/src/print.c
+++ b/src/print.c
@@ -401,7 +401,7 @@ strout (ptr, size, size_byte, printcharfun, multibyte)
401 int len; 401 int len;
402 for (i = 0; i < size_byte; i += len) 402 for (i = 0; i < size_byte; i += len)
403 { 403 {
404 int ch = STRING_CHAR_AND_LENGTH (ptr + i, size_byte - i, len); 404 int ch = STRING_CHAR_AND_LENGTH (ptr + i, len);
405 insert_char (ch); 405 insert_char (ch);
406 } 406 }
407 } 407 }
@@ -427,7 +427,7 @@ strout (ptr, size, size_byte, printcharfun, multibyte)
427 corresponding character code before handing it to 427 corresponding character code before handing it to
428 PRINTCHAR. */ 428 PRINTCHAR. */
429 int len; 429 int len;
430 int ch = STRING_CHAR_AND_LENGTH (ptr + i, size_byte - i, len); 430 int ch = STRING_CHAR_AND_LENGTH (ptr + i, len);
431 PRINTCHAR (ch); 431 PRINTCHAR (ch);
432 i += len; 432 i += len;
433 } 433 }
@@ -519,8 +519,7 @@ print_string (string, printcharfun)
519 /* Here, we must convert each multi-byte form to the 519 /* Here, we must convert each multi-byte form to the
520 corresponding character code before handing it to PRINTCHAR. */ 520 corresponding character code before handing it to PRINTCHAR. */
521 int len; 521 int len;
522 int ch = STRING_CHAR_AND_LENGTH (SDATA (string) + i, 522 int ch = STRING_CHAR_AND_LENGTH (SDATA (string) + i, len);
523 size_byte - i, len);
524 PRINTCHAR (ch); 523 PRINTCHAR (ch);
525 i += len; 524 i += len;
526 } 525 }
@@ -1645,8 +1644,7 @@ print_object (obj, printcharfun, escapeflag)
1645 1644
1646 if (multibyte) 1645 if (multibyte)
1647 { 1646 {
1648 c = STRING_CHAR_AND_LENGTH (str + i_byte, 1647 c = STRING_CHAR_AND_LENGTH (str + i_byte, len);
1649 size_byte - i_byte, len);
1650 i_byte += len; 1648 i_byte += len;
1651 } 1649 }
1652 else 1650 else
diff --git a/src/process.c b/src/process.c
index b604f97cffc..5c6875520e6 100644
--- a/src/process.c
+++ b/src/process.c
@@ -477,7 +477,7 @@ status_message (p)
477 if (! NILP (Vlocale_coding_system)) 477 if (! NILP (Vlocale_coding_system))
478 string = (code_convert_string_norecord 478 string = (code_convert_string_norecord
479 (string, Vlocale_coding_system, 0)); 479 (string, Vlocale_coding_system, 0));
480 c1 = STRING_CHAR ((char *) SDATA (string), 0); 480 c1 = STRING_CHAR ((char *) SDATA (string));
481 c2 = DOWNCASE (c1); 481 c2 = DOWNCASE (c1);
482 if (c1 != c2) 482 if (c1 != c2)
483 Faset (string, make_number (0), make_number (c2)); 483 Faset (string, make_number (0), make_number (c2));
diff --git a/src/regex.c b/src/regex.c
index ac7b7510a67..b3e1430fa31 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -147,10 +147,10 @@
147 147
148# define RE_MULTIBYTE_P(bufp) ((bufp)->multibyte) 148# define RE_MULTIBYTE_P(bufp) ((bufp)->multibyte)
149# define RE_TARGET_MULTIBYTE_P(bufp) ((bufp)->target_multibyte) 149# define RE_TARGET_MULTIBYTE_P(bufp) ((bufp)->target_multibyte)
150# define RE_STRING_CHAR(p, s, multibyte) \ 150# define RE_STRING_CHAR(p, multibyte) \
151 (multibyte ? (STRING_CHAR (p, s)) : (*(p))) 151 (multibyte ? (STRING_CHAR (p)) : (*(p)))
152# define RE_STRING_CHAR_AND_LENGTH(p, s, len, multibyte) \ 152# define RE_STRING_CHAR_AND_LENGTH(p, len, multibyte) \
153 (multibyte ? (STRING_CHAR_AND_LENGTH (p, s, len)) : ((len) = 1, *(p))) 153 (multibyte ? (STRING_CHAR_AND_LENGTH (p, len)) : ((len) = 1, *(p)))
154 154
155# define RE_CHAR_TO_MULTIBYTE(c) UNIBYTE_TO_CHAR (c) 155# define RE_CHAR_TO_MULTIBYTE(c) UNIBYTE_TO_CHAR (c)
156 156
@@ -166,7 +166,7 @@
166 re_char *dtemp = (p) == (str2) ? (end1) : (p); \ 166 re_char *dtemp = (p) == (str2) ? (end1) : (p); \
167 re_char *dlimit = ((p) > (str2) && (p) <= (end2)) ? (str2) : (str1); \ 167 re_char *dlimit = ((p) > (str2) && (p) <= (end2)) ? (str2) : (str1); \
168 while (dtemp-- > dlimit && !CHAR_HEAD_P (*dtemp)); \ 168 while (dtemp-- > dlimit && !CHAR_HEAD_P (*dtemp)); \
169 c = STRING_CHAR (dtemp, (p) - dtemp); \ 169 c = STRING_CHAR (dtemp); \
170 } \ 170 } \
171 else \ 171 else \
172 { \ 172 { \
@@ -180,7 +180,7 @@
180# define GET_CHAR_AFTER(c, p, len) \ 180# define GET_CHAR_AFTER(c, p, len) \
181 do { \ 181 do { \
182 if (target_multibyte) \ 182 if (target_multibyte) \
183 (c) = STRING_CHAR_AND_LENGTH (p, 0, len); \ 183 (c) = STRING_CHAR_AND_LENGTH (p, len); \
184 else \ 184 else \
185 { \ 185 { \
186 (c) = *p; \ 186 (c) = *p; \
@@ -302,11 +302,11 @@ enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 };
302# define SAME_CHARSET_P(c1, c2) (1) 302# define SAME_CHARSET_P(c1, c2) (1)
303# define MULTIBYTE_FORM_LENGTH(p, s) (1) 303# define MULTIBYTE_FORM_LENGTH(p, s) (1)
304# define PREV_CHAR_BOUNDARY(p, limit) ((p)--) 304# define PREV_CHAR_BOUNDARY(p, limit) ((p)--)
305# define STRING_CHAR(p, s) (*(p)) 305# define STRING_CHAR(p) (*(p))
306# define RE_STRING_CHAR(p, s, multibyte) STRING_CHAR ((p), (s)) 306# define RE_STRING_CHAR(p, multibyte) STRING_CHAR (p)
307# define CHAR_STRING(c, s) (*(s) = (c), 1) 307# define CHAR_STRING(c, s) (*(s) = (c), 1)
308# define STRING_CHAR_AND_LENGTH(p, s, actual_len) ((actual_len) = 1, *(p)) 308# define STRING_CHAR_AND_LENGTH(p, actual_len) ((actual_len) = 1, *(p))
309# define RE_STRING_CHAR_AND_LENGTH(p, s, len, multibyte) STRING_CHAR_AND_LENGTH ((p), (s), (len)) 309# define RE_STRING_CHAR_AND_LENGTH(p, len, multibyte) STRING_CHAR_AND_LENGTH (p, len)
310# define RE_CHAR_TO_MULTIBYTE(c) (c) 310# define RE_CHAR_TO_MULTIBYTE(c) (c)
311# define RE_CHAR_TO_UNIBYTE(c) (c) 311# define RE_CHAR_TO_UNIBYTE(c) (c)
312# define GET_CHAR_BEFORE_2(c, p, str1, end1, str2, end2) \ 312# define GET_CHAR_BEFORE_2(c, p, str1, end1, str2, end2) \
@@ -1757,7 +1757,7 @@ static int analyse_first _RE_ARGS ((re_char *p, re_char *pend,
1757 do { \ 1757 do { \
1758 int len; \ 1758 int len; \
1759 if (p == pend) return REG_EEND; \ 1759 if (p == pend) return REG_EEND; \
1760 c = RE_STRING_CHAR_AND_LENGTH (p, pend - p, len, multibyte); \ 1760 c = RE_STRING_CHAR_AND_LENGTH (p, len, multibyte); \
1761 p += len; \ 1761 p += len; \
1762 } while (0) 1762 } while (0)
1763 1763
@@ -4541,8 +4541,7 @@ re_search_2 (bufp, str1, size1, str2, size2, startpos, range, regs, stop)
4541 { 4541 {
4542 int buf_charlen; 4542 int buf_charlen;
4543 4543
4544 buf_ch = STRING_CHAR_AND_LENGTH (d, range - lim, 4544 buf_ch = STRING_CHAR_AND_LENGTH (d, buf_charlen);
4545 buf_charlen);
4546 buf_ch = RE_TRANSLATE (translate, buf_ch); 4545 buf_ch = RE_TRANSLATE (translate, buf_ch);
4547 if (fastmap[CHAR_LEADING_CODE (buf_ch)]) 4546 if (fastmap[CHAR_LEADING_CODE (buf_ch)])
4548 break; 4547 break;
@@ -4574,8 +4573,7 @@ re_search_2 (bufp, str1, size1, str2, size2, startpos, range, regs, stop)
4574 { 4573 {
4575 int buf_charlen; 4574 int buf_charlen;
4576 4575
4577 buf_ch = STRING_CHAR_AND_LENGTH (d, range - lim, 4576 buf_ch = STRING_CHAR_AND_LENGTH (d, buf_charlen);
4578 buf_charlen);
4579 if (fastmap[CHAR_LEADING_CODE (buf_ch)]) 4577 if (fastmap[CHAR_LEADING_CODE (buf_ch)])
4580 break; 4578 break;
4581 range -= buf_charlen; 4579 range -= buf_charlen;
@@ -4592,12 +4590,9 @@ re_search_2 (bufp, str1, size1, str2, size2, startpos, range, regs, stop)
4592 } 4590 }
4593 else /* Searching backwards. */ 4591 else /* Searching backwards. */
4594 { 4592 {
4595 int room = (startpos >= size1
4596 ? size2 + size1 - startpos
4597 : size1 - startpos);
4598 if (multibyte) 4593 if (multibyte)
4599 { 4594 {
4600 buf_ch = STRING_CHAR (d, room); 4595 buf_ch = STRING_CHAR (d);
4601 buf_ch = TRANSLATE (buf_ch); 4596 buf_ch = TRANSLATE (buf_ch);
4602 if (! fastmap[CHAR_LEADING_CODE (buf_ch)]) 4597 if (! fastmap[CHAR_LEADING_CODE (buf_ch)])
4603 goto advance; 4598 goto advance;
@@ -4888,11 +4883,11 @@ mutually_exclusive_p (bufp, p1, p2)
4888 { 4883 {
4889 register re_wchar_t c 4884 register re_wchar_t c
4890 = (re_opcode_t) *p2 == endline ? '\n' 4885 = (re_opcode_t) *p2 == endline ? '\n'
4891 : RE_STRING_CHAR (p2 + 2, pend - p2 - 2, multibyte); 4886 : RE_STRING_CHAR (p2 + 2, multibyte);
4892 4887
4893 if ((re_opcode_t) *p1 == exactn) 4888 if ((re_opcode_t) *p1 == exactn)
4894 { 4889 {
4895 if (c != RE_STRING_CHAR (p1 + 2, pend - p1 - 2, multibyte)) 4890 if (c != RE_STRING_CHAR (p1 + 2, multibyte))
4896 { 4891 {
4897 DEBUG_PRINT3 (" '%c' != '%c' => fast loop.\n", c, p1[2]); 4892 DEBUG_PRINT3 (" '%c' != '%c' => fast loop.\n", c, p1[2]);
4898 return 1; 4893 return 1;
@@ -5543,13 +5538,13 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
5543 5538
5544 PREFETCH (); 5539 PREFETCH ();
5545 if (multibyte) 5540 if (multibyte)
5546 pat_ch = STRING_CHAR_AND_LENGTH (p, pend - p, pat_charlen); 5541 pat_ch = STRING_CHAR_AND_LENGTH (p, pat_charlen);
5547 else 5542 else
5548 { 5543 {
5549 pat_ch = RE_CHAR_TO_MULTIBYTE (*p); 5544 pat_ch = RE_CHAR_TO_MULTIBYTE (*p);
5550 pat_charlen = 1; 5545 pat_charlen = 1;
5551 } 5546 }
5552 buf_ch = STRING_CHAR_AND_LENGTH (d, dend - d, buf_charlen); 5547 buf_ch = STRING_CHAR_AND_LENGTH (d, buf_charlen);
5553 5548
5554 if (TRANSLATE (buf_ch) != pat_ch) 5549 if (TRANSLATE (buf_ch) != pat_ch)
5555 { 5550 {
@@ -5571,7 +5566,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
5571 PREFETCH (); 5566 PREFETCH ();
5572 if (multibyte) 5567 if (multibyte)
5573 { 5568 {
5574 pat_ch = STRING_CHAR_AND_LENGTH (p, pend - p, pat_charlen); 5569 pat_ch = STRING_CHAR_AND_LENGTH (p, pat_charlen);
5575 pat_ch = RE_CHAR_TO_UNIBYTE (pat_ch); 5570 pat_ch = RE_CHAR_TO_UNIBYTE (pat_ch);
5576 } 5571 }
5577 else 5572 else
@@ -5611,7 +5606,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
5611 DEBUG_PRINT1 ("EXECUTING anychar.\n"); 5606 DEBUG_PRINT1 ("EXECUTING anychar.\n");
5612 5607
5613 PREFETCH (); 5608 PREFETCH ();
5614 buf_ch = RE_STRING_CHAR_AND_LENGTH (d, dend - d, buf_charlen, 5609 buf_ch = RE_STRING_CHAR_AND_LENGTH (d, buf_charlen,
5615 target_multibyte); 5610 target_multibyte);
5616 buf_ch = TRANSLATE (buf_ch); 5611 buf_ch = TRANSLATE (buf_ch);
5617 5612
@@ -5659,7 +5654,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
5659 } 5654 }
5660 5655
5661 PREFETCH (); 5656 PREFETCH ();
5662 c = RE_STRING_CHAR_AND_LENGTH (d, dend - d, len, target_multibyte); 5657 c = RE_STRING_CHAR_AND_LENGTH (d, len, target_multibyte);
5663 if (target_multibyte) 5658 if (target_multibyte)
5664 { 5659 {
5665 int c1; 5660 int c1;
@@ -6257,7 +6252,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
6257 UPDATE_SYNTAX_TABLE (charpos); 6252 UPDATE_SYNTAX_TABLE (charpos);
6258#endif 6253#endif
6259 PREFETCH (); 6254 PREFETCH ();
6260 c2 = RE_STRING_CHAR (d, dend - d, target_multibyte); 6255 c2 = RE_STRING_CHAR (d, target_multibyte);
6261 s2 = SYNTAX (c2); 6256 s2 = SYNTAX (c2);
6262 6257
6263 /* Case 2: S2 is neither Sword nor Ssymbol. */ 6258 /* Case 2: S2 is neither Sword nor Ssymbol. */
@@ -6310,7 +6305,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
6310 if (!AT_STRINGS_END (d)) 6305 if (!AT_STRINGS_END (d))
6311 { 6306 {
6312 PREFETCH_NOLIMIT (); 6307 PREFETCH_NOLIMIT ();
6313 c2 = RE_STRING_CHAR (d, dend - d, target_multibyte); 6308 c2 = RE_STRING_CHAR (d, target_multibyte);
6314#ifdef emacs 6309#ifdef emacs
6315 UPDATE_SYNTAX_TABLE_FORWARD (charpos + 1); 6310 UPDATE_SYNTAX_TABLE_FORWARD (charpos + 1);
6316#endif 6311#endif
diff --git a/src/search.c b/src/search.c
index e0546f4f998..fd45d316a46 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1387,7 +1387,7 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n,
1387 base_pat++; 1387 base_pat++;
1388 } 1388 }
1389 1389
1390 c = STRING_CHAR_AND_LENGTH (base_pat, len_byte, in_charlen); 1390 c = STRING_CHAR_AND_LENGTH (base_pat, in_charlen);
1391 1391
1392 if (NILP (trt)) 1392 if (NILP (trt))
1393 { 1393 {
@@ -1527,7 +1527,6 @@ simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte)
1527 EMACS_INT this_pos = pos; 1527 EMACS_INT this_pos = pos;
1528 EMACS_INT this_pos_byte = pos_byte; 1528 EMACS_INT this_pos_byte = pos_byte;
1529 int this_len = len; 1529 int this_len = len;
1530 int this_len_byte = len_byte;
1531 unsigned char *p = pat; 1530 unsigned char *p = pat;
1532 if (pos + len > lim || pos_byte + len_byte > lim_byte) 1531 if (pos + len > lim || pos_byte + len_byte > lim_byte)
1533 goto stop; 1532 goto stop;
@@ -1537,16 +1536,14 @@ simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte)
1537 int charlen, buf_charlen; 1536 int charlen, buf_charlen;
1538 int pat_ch, buf_ch; 1537 int pat_ch, buf_ch;
1539 1538
1540 pat_ch = STRING_CHAR_AND_LENGTH (p, this_len_byte, charlen); 1539 pat_ch = STRING_CHAR_AND_LENGTH (p, charlen);
1541 buf_ch = STRING_CHAR_AND_LENGTH (BYTE_POS_ADDR (this_pos_byte), 1540 buf_ch = STRING_CHAR_AND_LENGTH (BYTE_POS_ADDR (this_pos_byte),
1542 ZV_BYTE - this_pos_byte,
1543 buf_charlen); 1541 buf_charlen);
1544 TRANSLATE (buf_ch, trt, buf_ch); 1542 TRANSLATE (buf_ch, trt, buf_ch);
1545 1543
1546 if (buf_ch != pat_ch) 1544 if (buf_ch != pat_ch)
1547 break; 1545 break;
1548 1546
1549 this_len_byte -= charlen;
1550 this_len--; 1547 this_len--;
1551 p += charlen; 1548 p += charlen;
1552 1549
@@ -1615,7 +1612,6 @@ simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte)
1615 EMACS_INT this_pos = pos - len; 1612 EMACS_INT this_pos = pos - len;
1616 EMACS_INT this_pos_byte; 1613 EMACS_INT this_pos_byte;
1617 int this_len = len; 1614 int this_len = len;
1618 int this_len_byte = len_byte;
1619 unsigned char *p = pat; 1615 unsigned char *p = pat;
1620 1616
1621 if (this_pos < lim || (pos_byte - len_byte) < lim_byte) 1617 if (this_pos < lim || (pos_byte - len_byte) < lim_byte)
@@ -1628,16 +1624,14 @@ simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte)
1628 int charlen, buf_charlen; 1624 int charlen, buf_charlen;
1629 int pat_ch, buf_ch; 1625 int pat_ch, buf_ch;
1630 1626
1631 pat_ch = STRING_CHAR_AND_LENGTH (p, this_len_byte, charlen); 1627 pat_ch = STRING_CHAR_AND_LENGTH (p, charlen);
1632 buf_ch = STRING_CHAR_AND_LENGTH (BYTE_POS_ADDR (this_pos_byte), 1628 buf_ch = STRING_CHAR_AND_LENGTH (BYTE_POS_ADDR (this_pos_byte),
1633 ZV_BYTE - this_pos_byte,
1634 buf_charlen); 1629 buf_charlen);
1635 TRANSLATE (buf_ch, trt, buf_ch); 1630 TRANSLATE (buf_ch, trt, buf_ch);
1636 1631
1637 if (buf_ch != pat_ch) 1632 if (buf_ch != pat_ch)
1638 break; 1633 break;
1639 1634
1640 this_len_byte -= charlen;
1641 this_len--; 1635 this_len--;
1642 p += charlen; 1636 p += charlen;
1643 this_pos_byte += buf_charlen; 1637 this_pos_byte += buf_charlen;
@@ -1841,7 +1835,7 @@ boyer_moore (n, base_pat, len, len_byte, trt, inverse_trt,
1841 1835
1842 while (! (CHAR_HEAD_P (*charstart))) 1836 while (! (CHAR_HEAD_P (*charstart)))
1843 charstart--; 1837 charstart--;
1844 ch = STRING_CHAR (charstart, ptr - charstart + 1); 1838 ch = STRING_CHAR (charstart);
1845 if (char_base != (ch & ~0x3F)) 1839 if (char_base != (ch & ~0x3F))
1846 ch = -1; 1840 ch = -1;
1847 } 1841 }
diff --git a/src/syntax.c b/src/syntax.c
index 203792960ca..e19bfc15d1c 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -911,8 +911,7 @@ text property. */)
911 if (*p) 911 if (*p)
912 { 912 {
913 int len; 913 int len;
914 int character = (STRING_CHAR_AND_LENGTH 914 int character = STRING_CHAR_AND_LENGTH (p, len);
915 (p, SBYTES (string) - 1, len));
916 XSETINT (match, character); 915 XSETINT (match, character);
917 if (XFASTINT (match) == ' ') 916 if (XFASTINT (match) == ' ')
918 match = Qnil; 917 match = Qnil;
@@ -1588,12 +1587,12 @@ skip_chars (forwardp, string, lim, handle_iso_classes)
1588 unsigned char leading_code; 1587 unsigned char leading_code;
1589 1588
1590 leading_code = str[i_byte]; 1589 leading_code = str[i_byte];
1591 c = STRING_CHAR_AND_LENGTH (str + i_byte, size_byte-i_byte, len); 1590 c = STRING_CHAR_AND_LENGTH (str + i_byte, len);
1592 i_byte += len; 1591 i_byte += len;
1593 1592
1594 if (handle_iso_classes && c == '[' 1593 if (handle_iso_classes && c == '['
1595 && i_byte < size_byte 1594 && i_byte < size_byte
1596 && STRING_CHAR (str + i_byte, size_byte - i_byte) == ':') 1595 && STRING_CHAR (str + i_byte) == ':')
1597 { 1596 {
1598 const unsigned char *class_beg = str + i_byte + 1; 1597 const unsigned char *class_beg = str + i_byte + 1;
1599 const unsigned char *class_end = class_beg; 1598 const unsigned char *class_end = class_beg;
@@ -1633,8 +1632,7 @@ skip_chars (forwardp, string, lim, handle_iso_classes)
1633 break; 1632 break;
1634 1633
1635 leading_code = str[i_byte]; 1634 leading_code = str[i_byte];
1636 c = STRING_CHAR_AND_LENGTH (str + i_byte, 1635 c = STRING_CHAR_AND_LENGTH (str + i_byte, len);
1637 size_byte - i_byte, len);
1638 i_byte += len; 1636 i_byte += len;
1639 } 1637 }
1640 /* Treat `-' as range character only if another character 1638 /* Treat `-' as range character only if another character
@@ -1650,15 +1648,14 @@ skip_chars (forwardp, string, lim, handle_iso_classes)
1650 1648
1651 /* Get the end of the range. */ 1649 /* Get the end of the range. */
1652 leading_code2 = str[i_byte]; 1650 leading_code2 = str[i_byte];
1653 c2 = STRING_CHAR_AND_LENGTH (str + i_byte, 1651 c2 = STRING_CHAR_AND_LENGTH (str + i_byte, len);
1654 size_byte - i_byte, len);
1655 i_byte += len; 1652 i_byte += len;
1656 1653
1657 if (c2 == '\\' 1654 if (c2 == '\\'
1658 && i_byte < size_byte) 1655 && i_byte < size_byte)
1659 { 1656 {
1660 leading_code2 = str[i_byte]; 1657 leading_code2 = str[i_byte];
1661 c2 =STRING_CHAR_AND_LENGTH (str + i_byte, size_byte-i_byte, len); 1658 c2 =STRING_CHAR_AND_LENGTH (str + i_byte, len);
1662 i_byte += len; 1659 i_byte += len;
1663 } 1660 }
1664 1661
@@ -1764,7 +1761,7 @@ skip_chars (forwardp, string, lim, handle_iso_classes)
1764 p = GAP_END_ADDR; 1761 p = GAP_END_ADDR;
1765 stop = endp; 1762 stop = endp;
1766 } 1763 }
1767 c = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, nbytes); 1764 c = STRING_CHAR_AND_LENGTH (p, nbytes);
1768 if (! NILP (iso_classes) && in_classes (c, iso_classes)) 1765 if (! NILP (iso_classes) && in_classes (c, iso_classes))
1769 { 1766 {
1770 if (negate) 1767 if (negate)
@@ -1835,7 +1832,7 @@ skip_chars (forwardp, string, lim, handle_iso_classes)
1835 } 1832 }
1836 prev_p = p; 1833 prev_p = p;
1837 while (--p >= stop && ! CHAR_HEAD_P (*p)); 1834 while (--p >= stop && ! CHAR_HEAD_P (*p));
1838 c = STRING_CHAR (p, MAX_MULTIBYTE_LENGTH); 1835 c = STRING_CHAR (p);
1839 1836
1840 if (! NILP (iso_classes) && in_classes (c, iso_classes)) 1837 if (! NILP (iso_classes) && in_classes (c, iso_classes))
1841 { 1838 {
@@ -1989,7 +1986,7 @@ skip_syntaxes (forwardp, string, lim)
1989 p = GAP_END_ADDR; 1986 p = GAP_END_ADDR;
1990 stop = endp; 1987 stop = endp;
1991 } 1988 }
1992 c = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, nbytes); 1989 c = STRING_CHAR_AND_LENGTH (p, nbytes);
1993 if (! fastmap[(int) SYNTAX (c)]) 1990 if (! fastmap[(int) SYNTAX (c)])
1994 break; 1991 break;
1995 p += nbytes, pos++, pos_byte += nbytes; 1992 p += nbytes, pos++, pos_byte += nbytes;
@@ -2032,7 +2029,7 @@ skip_syntaxes (forwardp, string, lim)
2032 UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1); 2029 UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1);
2033 prev_p = p; 2030 prev_p = p;
2034 while (--p >= stop && ! CHAR_HEAD_P (*p)); 2031 while (--p >= stop && ! CHAR_HEAD_P (*p));
2035 c = STRING_CHAR (p, MAX_MULTIBYTE_LENGTH); 2032 c = STRING_CHAR (p);
2036 if (! fastmap[(int) SYNTAX (c)]) 2033 if (! fastmap[(int) SYNTAX (c)])
2037 break; 2034 break;
2038 pos--, pos_byte -= prev_p - p; 2035 pos--, pos_byte -= prev_p - p;
diff --git a/src/xdisp.c b/src/xdisp.c
index d2ae9a18fe2..9612f5cc9cf 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -919,7 +919,7 @@ static int display_echo_area P_ ((struct window *));
919static int display_echo_area_1 P_ ((EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT)); 919static int display_echo_area_1 P_ ((EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT));
920static int resize_mini_window_1 P_ ((EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT)); 920static int resize_mini_window_1 P_ ((EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT));
921static Lisp_Object unwind_redisplay P_ ((Lisp_Object)); 921static Lisp_Object unwind_redisplay P_ ((Lisp_Object));
922static int string_char_and_length P_ ((const unsigned char *, int, int *)); 922static int string_char_and_length P_ ((const unsigned char *, int *));
923static struct text_pos display_prop_end P_ ((struct it *, Lisp_Object, 923static struct text_pos display_prop_end P_ ((struct it *, Lisp_Object,
924 struct text_pos)); 924 struct text_pos));
925static int compute_window_start_on_continuation_line P_ ((struct window *)); 925static int compute_window_start_on_continuation_line P_ ((struct window *));
@@ -1485,13 +1485,13 @@ pos_visible_p (w, charpos, x, y, rtop, rbot, rowh, vpos)
1485 character. */ 1485 character. */
1486 1486
1487static INLINE int 1487static INLINE int
1488string_char_and_length (str, maxlen, len) 1488string_char_and_length (str, len)
1489 const unsigned char *str; 1489 const unsigned char *str;
1490 int maxlen, *len; 1490 int *len;
1491{ 1491{
1492 int c; 1492 int c;
1493 1493
1494 c = STRING_CHAR_AND_LENGTH (str, maxlen, *len); 1494 c = STRING_CHAR_AND_LENGTH (str, *len);
1495 if (!CHAR_VALID_P (c, 1)) 1495 if (!CHAR_VALID_P (c, 1))
1496 /* We may not change the length here because other places in Emacs 1496 /* We may not change the length here because other places in Emacs
1497 don't use this function, i.e. they silently accept invalid 1497 don't use this function, i.e. they silently accept invalid
@@ -1522,7 +1522,7 @@ string_pos_nchars_ahead (pos, string, nchars)
1522 1522
1523 while (nchars--) 1523 while (nchars--)
1524 { 1524 {
1525 string_char_and_length (p, rest, &len); 1525 string_char_and_length (p, &len);
1526 p += len, rest -= len; 1526 p += len, rest -= len;
1527 xassert (rest >= 0); 1527 xassert (rest >= 0);
1528 CHARPOS (pos) += 1; 1528 CHARPOS (pos) += 1;
@@ -1574,7 +1574,7 @@ c_string_pos (charpos, s, multibyte_p)
1574 SET_TEXT_POS (pos, 0, 0); 1574 SET_TEXT_POS (pos, 0, 0);
1575 while (charpos--) 1575 while (charpos--)
1576 { 1576 {
1577 string_char_and_length (s, rest, &len); 1577 string_char_and_length (s, &len);
1578 s += len, rest -= len; 1578 s += len, rest -= len;
1579 xassert (rest >= 0); 1579 xassert (rest >= 0);
1580 CHARPOS (pos) += 1; 1580 CHARPOS (pos) += 1;
@@ -1605,7 +1605,7 @@ number_of_chars (s, multibyte_p)
1605 1605
1606 for (nchars = 0; rest > 0; ++nchars) 1606 for (nchars = 0; rest > 0; ++nchars)
1607 { 1607 {
1608 string_char_and_length (p, rest, &len); 1608 string_char_and_length (p, &len);
1609 rest -= len, p += len; 1609 rest -= len, p += len;
1610 } 1610 }
1611 } 1611 }
@@ -3648,7 +3648,7 @@ face_before_or_after_it_pos (it, before_p)
3648 int c, len; 3648 int c, len;
3649 struct face *face = FACE_FROM_ID (it->f, face_id); 3649 struct face *face = FACE_FROM_ID (it->f, face_id);
3650 3650
3651 c = string_char_and_length (p, rest, &len); 3651 c = string_char_and_length (p, &len);
3652 face_id = FACE_FOR_CHAR (it->f, face, c, CHARPOS (pos), it->string); 3652 face_id = FACE_FOR_CHAR (it->f, face, c, CHARPOS (pos), it->string);
3653 } 3653 }
3654 } 3654 }
@@ -4650,7 +4650,7 @@ handle_composition_prop (it)
4650 pos_byte = IT_STRING_BYTEPOS (*it); 4650 pos_byte = IT_STRING_BYTEPOS (*it);
4651 string = it->string; 4651 string = it->string;
4652 s = SDATA (string) + pos_byte; 4652 s = SDATA (string) + pos_byte;
4653 it->c = STRING_CHAR (s, 0); 4653 it->c = STRING_CHAR (s);
4654 } 4654 }
4655 else 4655 else
4656 { 4656 {
@@ -6312,7 +6312,7 @@ next_element_from_string (it)
6312 int remaining = SBYTES (it->string) - IT_STRING_BYTEPOS (*it); 6312 int remaining = SBYTES (it->string) - IT_STRING_BYTEPOS (*it);
6313 const unsigned char *s = (SDATA (it->string) 6313 const unsigned char *s = (SDATA (it->string)
6314 + IT_STRING_BYTEPOS (*it)); 6314 + IT_STRING_BYTEPOS (*it));
6315 it->c = string_char_and_length (s, remaining, &it->len); 6315 it->c = string_char_and_length (s, &it->len);
6316 } 6316 }
6317 else 6317 else
6318 { 6318 {
@@ -6348,7 +6348,7 @@ next_element_from_string (it)
6348 int maxlen = SBYTES (it->string) - IT_STRING_BYTEPOS (*it); 6348 int maxlen = SBYTES (it->string) - IT_STRING_BYTEPOS (*it);
6349 const unsigned char *s = (SDATA (it->string) 6349 const unsigned char *s = (SDATA (it->string)
6350 + IT_STRING_BYTEPOS (*it)); 6350 + IT_STRING_BYTEPOS (*it));
6351 it->c = string_char_and_length (s, maxlen, &it->len); 6351 it->c = string_char_and_length (s, &it->len);
6352 } 6352 }
6353 else 6353 else
6354 { 6354 {
@@ -6404,8 +6404,7 @@ next_element_from_c_string (it)
6404 performance problem because there is no noticeable performance 6404 performance problem because there is no noticeable performance
6405 difference between Emacs running in unibyte or multibyte mode. */ 6405 difference between Emacs running in unibyte or multibyte mode. */
6406 int maxlen = strlen (it->s) - IT_BYTEPOS (*it); 6406 int maxlen = strlen (it->s) - IT_BYTEPOS (*it);
6407 it->c = string_char_and_length (it->s + IT_BYTEPOS (*it), 6407 it->c = string_char_and_length (it->s + IT_BYTEPOS (*it), &it->len);
6408 maxlen, &it->len);
6409 } 6408 }
6410 else 6409 else
6411 it->c = it->s[IT_BYTEPOS (*it)], it->len = 1; 6410 it->c = it->s[IT_BYTEPOS (*it)], it->len = 1;
@@ -6535,7 +6534,7 @@ next_element_from_buffer (it)
6535 /* Get the next character, maybe multibyte. */ 6534 /* Get the next character, maybe multibyte. */
6536 p = BYTE_POS_ADDR (IT_BYTEPOS (*it)); 6535 p = BYTE_POS_ADDR (IT_BYTEPOS (*it));
6537 if (it->multibyte_p && !ASCII_BYTE_P (*p)) 6536 if (it->multibyte_p && !ASCII_BYTE_P (*p))
6538 it->c = STRING_CHAR_AND_LENGTH (p, 0, it->len); 6537 it->c = STRING_CHAR_AND_LENGTH (p, it->len);
6539 else 6538 else
6540 it->c = *p, it->len = 1; 6539 it->c = *p, it->len = 1;
6541 6540
@@ -7756,7 +7755,7 @@ message_dolog (m, nbytes, nlflag, multibyte)
7756 for the *Message* buffer. */ 7755 for the *Message* buffer. */
7757 for (i = 0; i < nbytes; i += char_bytes) 7756 for (i = 0; i < nbytes; i += char_bytes)
7758 { 7757 {
7759 c = string_char_and_length (m + i, nbytes - i, &char_bytes); 7758 c = string_char_and_length (m + i, &char_bytes);
7760 work[0] = (ASCII_CHAR_P (c) 7759 work[0] = (ASCII_CHAR_P (c)
7761 ? c 7760 ? c
7762 : multibyte_char_to_unibyte (c, Qnil)); 7761 : multibyte_char_to_unibyte (c, Qnil));
@@ -9061,7 +9060,7 @@ set_message_1 (a1, a2, nbytes, multibyte_p)
9061 /* Convert a multibyte string to single-byte. */ 9060 /* Convert a multibyte string to single-byte. */
9062 for (i = 0; i < nbytes; i += n) 9061 for (i = 0; i < nbytes; i += n)
9063 { 9062 {
9064 c = string_char_and_length (s + i, nbytes - i, &n); 9063 c = string_char_and_length (s + i, &n);
9065 work[0] = (ASCII_CHAR_P (c) 9064 work[0] = (ASCII_CHAR_P (c)
9066 ? c 9065 ? c
9067 : multibyte_char_to_unibyte (c, Qnil)); 9066 : multibyte_char_to_unibyte (c, Qnil));
@@ -15903,7 +15902,7 @@ get_overlay_arrow_glyph_row (w, overlay_arrow_string)
15903 15902
15904 /* Get the next character. */ 15903 /* Get the next character. */
15905 if (multibyte_p) 15904 if (multibyte_p)
15906 it.c = string_char_and_length (p, arrow_len, &it.len); 15905 it.c = string_char_and_length (p, &it.len);
15907 else 15906 else
15908 it.c = *p, it.len = 1; 15907 it.c = *p, it.len = 1;
15909 p += it.len; 15908 p += it.len;
@@ -20930,7 +20929,7 @@ produce_stretch_glyph (it)
20930 { 20929 {
20931 int maxlen = ((IT_BYTEPOS (*it) >= GPT ? ZV : GPT) 20930 int maxlen = ((IT_BYTEPOS (*it) >= GPT ? ZV : GPT)
20932 - IT_BYTEPOS (*it)); 20931 - IT_BYTEPOS (*it));
20933 it2.c = STRING_CHAR_AND_LENGTH (p, maxlen, it2.len); 20932 it2.c = STRING_CHAR_AND_LENGTH (p, it2.len);
20934 } 20933 }
20935 else 20934 else
20936 it2.c = *p, it2.len = 1; 20935 it2.c = *p, it2.len = 1;
diff --git a/src/xterm.c b/src/xterm.c
index c4cf3de12fc..f18b8105c02 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -6578,8 +6578,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6578 if (nchars == nbytes) 6578 if (nchars == nbytes)
6579 c = copy_bufptr[i], len = 1; 6579 c = copy_bufptr[i], len = 1;
6580 else 6580 else
6581 c = STRING_CHAR_AND_LENGTH (copy_bufptr + i, 6581 c = STRING_CHAR_AND_LENGTH (copy_bufptr + i, len);
6582 nbytes - i, len);
6583 inev.ie.kind = (SINGLE_BYTE_CHAR_P (c) 6582 inev.ie.kind = (SINGLE_BYTE_CHAR_P (c)
6584 ? ASCII_KEYSTROKE_EVENT 6583 ? ASCII_KEYSTROKE_EVENT
6585 : MULTIBYTE_CHAR_KEYSTROKE_EVENT); 6584 : MULTIBYTE_CHAR_KEYSTROKE_EVENT);