aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2002-09-03 04:10:19 +0000
committerKenichi Handa2002-09-03 04:10:19 +0000
commitb7dbcc196d61d25d8bf82617bc951b98f0f24de7 (patch)
treebe4bad67aa9a7958bb75c6983c58929cc8734991 /src
parent93daa011b35d0397b4503eff0d7d80e1b50a9bed (diff)
downloademacs-b7dbcc196d61d25d8bf82617bc951b98f0f24de7.tar.gz
emacs-b7dbcc196d61d25d8bf82617bc951b98f0f24de7.zip
(char_quoted): Use FETCH_CHAR_AS_MULTIBYTE to convert
unibyte chars to multibyte. (back_comment): Likewise. (scan_words): Likewise. (skip_chars): The arg syntaxp is deleted, and the code for handling syntaxes is moved to skip_syntaxes. Callers changed. Fix the case that the multibyteness of STRING and the current buffer doesn't match. (skip_syntaxes): New function. (SYNTAX_WITH_MULTIBYTE_CHECK): Check C by ASCII_CHAR_P, not by SINGLE_BYTE_CHAR_P. (Fforward_comment): Use FETCH_CHAR_AS_MULTIBYTE to convert unibyte chars to multibyte. (scan_lists): Likewise. (Fbackward_prefix_chars): Likewise. (scan_sexps_forward): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/syntax.c636
1 files changed, 397 insertions, 239 deletions
diff --git a/src/syntax.c b/src/syntax.c
index 716b3be6f6c..1795e588583 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -97,7 +97,8 @@ static int find_start_modiff;
97static int find_defun_start P_ ((int, int)); 97static int find_defun_start P_ ((int, int));
98static int back_comment P_ ((int, int, int, int, int, int *, int *)); 98static int back_comment P_ ((int, int, int, int, int, int *, int *));
99static int char_quoted P_ ((int, int)); 99static int char_quoted P_ ((int, int));
100static Lisp_Object skip_chars P_ ((int, int, Lisp_Object, Lisp_Object)); 100static Lisp_Object skip_chars P_ ((int, Lisp_Object, Lisp_Object));
101static Lisp_Object skip_syntaxes P_ ((int, Lisp_Object, Lisp_Object));
101static Lisp_Object scan_lists P_ ((int, int, int, int)); 102static Lisp_Object scan_lists P_ ((int, int, int, int));
102static void scan_sexps_forward P_ ((struct lisp_parse_state *, 103static void scan_sexps_forward P_ ((struct lisp_parse_state *,
103 int, int, int, int, 104 int, int, int, int,
@@ -293,7 +294,7 @@ char_quoted (charpos, bytepos)
293 while (bytepos >= beg) 294 while (bytepos >= beg)
294 { 295 {
295 UPDATE_SYNTAX_TABLE_BACKWARD (charpos); 296 UPDATE_SYNTAX_TABLE_BACKWARD (charpos);
296 code = SYNTAX (FETCH_CHAR (bytepos)); 297 code = SYNTAX (FETCH_CHAR_AS_MULTIBYTE (bytepos));
297 if (! (code == Scharquote || code == Sescape)) 298 if (! (code == Scharquote || code == Sescape))
298 break; 299 break;
299 300
@@ -378,10 +379,10 @@ find_defun_start (pos, pos_byte)
378 { 379 {
379 /* Open-paren at start of line means we may have found our 380 /* Open-paren at start of line means we may have found our
380 defun-start. */ 381 defun-start. */
381 if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen) 382 if (SYNTAX (FETCH_CHAR_AS_MULTIBYTE (PT_BYTE)) == Sopen)
382 { 383 {
383 SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ 384 SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */
384 if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen) 385 if (SYNTAX (FETCH_CHAR_AS_MULTIBYTE (PT_BYTE)) == Sopen)
385 break; 386 break;
386 /* Now fallback to the default value. */ 387 /* Now fallback to the default value. */
387 gl_state.current_syntax_table = current_buffer->syntax_table; 388 gl_state.current_syntax_table = current_buffer->syntax_table;
@@ -502,7 +503,7 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p
502 UPDATE_SYNTAX_TABLE_BACKWARD (from); 503 UPDATE_SYNTAX_TABLE_BACKWARD (from);
503 504
504 prev_syntax = syntax; 505 prev_syntax = syntax;
505 c = FETCH_CHAR (from_byte); 506 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
506 syntax = SYNTAX_WITH_FLAGS (c); 507 syntax = SYNTAX_WITH_FLAGS (c);
507 code = SYNTAX (c); 508 code = SYNTAX (c);
508 509
@@ -531,7 +532,7 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p
531 int next = from, next_byte = from_byte, next_c, next_syntax; 532 int next = from, next_byte = from_byte, next_c, next_syntax;
532 DEC_BOTH (next, next_byte); 533 DEC_BOTH (next, next_byte);
533 UPDATE_SYNTAX_TABLE_BACKWARD (next); 534 UPDATE_SYNTAX_TABLE_BACKWARD (next);
534 next_c = FETCH_CHAR (next_byte); 535 next_c = FETCH_CHAR_AS_MULTIBYTE (next_byte);
535 next_syntax = SYNTAX_WITH_FLAGS (next_c); 536 next_syntax = SYNTAX_WITH_FLAGS (next_c);
536 if (((com2start || comnested) 537 if (((com2start || comnested)
537 && SYNTAX_FLAGS_COMEND_SECOND (syntax) 538 && SYNTAX_FLAGS_COMEND_SECOND (syntax)
@@ -1195,7 +1196,7 @@ scan_words (from, count)
1195 return 0; 1196 return 0;
1196 } 1197 }
1197 UPDATE_SYNTAX_TABLE_FORWARD (from); 1198 UPDATE_SYNTAX_TABLE_FORWARD (from);
1198 ch0 = FETCH_CHAR (from_byte); 1199 ch0 = FETCH_CHAR_AS_MULTIBYTE (from_byte);
1199 code = SYNTAX (ch0); 1200 code = SYNTAX (ch0);
1200 INC_BOTH (from, from_byte); 1201 INC_BOTH (from, from_byte);
1201 if (words_include_escapes 1202 if (words_include_escapes
@@ -1224,7 +1225,7 @@ scan_words (from, count)
1224 { 1225 {
1225 if (from == end) break; 1226 if (from == end) break;
1226 UPDATE_SYNTAX_TABLE_FORWARD (from); 1227 UPDATE_SYNTAX_TABLE_FORWARD (from);
1227 ch1 = FETCH_CHAR (from_byte); 1228 ch1 = FETCH_CHAR_AS_MULTIBYTE (from_byte);
1228 code = SYNTAX (ch1); 1229 code = SYNTAX (ch1);
1229 if ((code != Sword 1230 if ((code != Sword
1230 && (! words_include_escapes 1231 && (! words_include_escapes
@@ -1251,7 +1252,7 @@ scan_words (from, count)
1251 } 1252 }
1252 DEC_BOTH (from, from_byte); 1253 DEC_BOTH (from, from_byte);
1253 UPDATE_SYNTAX_TABLE_BACKWARD (from); 1254 UPDATE_SYNTAX_TABLE_BACKWARD (from);
1254 ch1 = FETCH_CHAR (from_byte); 1255 ch1 = FETCH_CHAR_AS_MULTIBYTE (from_byte);
1255 code = SYNTAX (ch1); 1256 code = SYNTAX (ch1);
1256 if (words_include_escapes 1257 if (words_include_escapes
1257 && (code == Sescape || code == Scharquote)) 1258 && (code == Sescape || code == Scharquote))
@@ -1283,7 +1284,7 @@ scan_words (from, count)
1283 break; 1284 break;
1284 temp_byte = dec_bytepos (from_byte); 1285 temp_byte = dec_bytepos (from_byte);
1285 UPDATE_SYNTAX_TABLE_BACKWARD (from); 1286 UPDATE_SYNTAX_TABLE_BACKWARD (from);
1286 ch0 = FETCH_CHAR (temp_byte); 1287 ch0 = FETCH_CHAR_AS_MULTIBYTE (temp_byte);
1287 code = SYNTAX (ch0); 1288 code = SYNTAX (ch0);
1288 if ((code != Sword 1289 if ((code != Sword
1289 && (! words_include_escapes 1290 && (! words_include_escapes
@@ -1339,7 +1340,7 @@ Returns the distance traveled, either zero or positive. */)
1339 (string, lim) 1340 (string, lim)
1340 Lisp_Object string, lim; 1341 Lisp_Object string, lim;
1341{ 1342{
1342 return skip_chars (1, 0, string, lim); 1343 return skip_chars (1, string, lim);
1343} 1344}
1344 1345
1345DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0, 1346DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0,
@@ -1349,7 +1350,7 @@ Returns the distance traveled, either zero or negative. */)
1349 (string, lim) 1350 (string, lim)
1350 Lisp_Object string, lim; 1351 Lisp_Object string, lim;
1351{ 1352{
1352 return skip_chars (0, 0, string, lim); 1353 return skip_chars (0, string, lim);
1353} 1354}
1354 1355
1355DEFUN ("skip-syntax-forward", Fskip_syntax_forward, Sskip_syntax_forward, 1, 2, 0, 1356DEFUN ("skip-syntax-forward", Fskip_syntax_forward, Sskip_syntax_forward, 1, 2, 0,
@@ -1361,7 +1362,7 @@ This function returns the distance traveled, either zero or positive. */)
1361 (syntax, lim) 1362 (syntax, lim)
1362 Lisp_Object syntax, lim; 1363 Lisp_Object syntax, lim;
1363{ 1364{
1364 return skip_chars (1, 1, syntax, lim); 1365 return skip_syntaxes (1, syntax, lim);
1365} 1366}
1366 1367
1367DEFUN ("skip-syntax-backward", Fskip_syntax_backward, Sskip_syntax_backward, 1, 2, 0, 1368DEFUN ("skip-syntax-backward", Fskip_syntax_backward, Sskip_syntax_backward, 1, 2, 0,
@@ -1373,53 +1374,32 @@ This function returns the distance traveled, either zero or negative. */)
1373 (syntax, lim) 1374 (syntax, lim)
1374 Lisp_Object syntax, lim; 1375 Lisp_Object syntax, lim;
1375{ 1376{
1376 return skip_chars (0, 1, syntax, lim); 1377 return skip_syntaxes (0, syntax, lim);
1377} 1378}
1378 1379
1379static Lisp_Object 1380static Lisp_Object
1380skip_chars (forwardp, syntaxp, string, lim) 1381skip_chars (forwardp, string, lim)
1381 int forwardp, syntaxp; 1382 int forwardp;
1382 Lisp_Object string, lim; 1383 Lisp_Object string, lim;
1383{ 1384{
1384 register unsigned int c; 1385 register unsigned int c;
1385 unsigned char fastmap[0400]; 1386 unsigned char fastmap[0400];
1386 /* If SYNTAXP is 0, STRING may contain multi-byte form of characters 1387 /* Store the ranges of non-ASCII characters. */
1387 of which codes don't fit in FASTMAP. In that case, set the
1388 ranges of characters in CHAR_RANGES. */
1389 int *char_ranges; 1388 int *char_ranges;
1390 int n_char_ranges = 0; 1389 int n_char_ranges = 0;
1391 int negate = 0; 1390 int negate = 0;
1392 register int i, i_byte; 1391 register int i, i_byte;
1393 int multibyte = !NILP (current_buffer->enable_multibyte_characters); 1392 /* Set to 1 if the current buffer is multibyte and the region
1393 contains non-ASCII chars. */
1394 int multibyte;
1395 /* Set to 1 if STRING is multibyte and it contains non-ASCII
1396 chars. */
1394 int string_multibyte; 1397 int string_multibyte;
1395 int size_byte; 1398 int size_byte;
1396 unsigned char *str; 1399 unsigned char *str;
1397 int len; 1400 int len;
1398 1401
1399 CHECK_STRING (string); 1402 CHECK_STRING (string);
1400 char_ranges = (int *) alloca (XSTRING (string)->size * (sizeof (int)) * 2);
1401 string_multibyte = STRING_MULTIBYTE (string);
1402 str = XSTRING (string)->data;
1403 size_byte = STRING_BYTES (XSTRING (string));
1404
1405 /* Adjust the multibyteness of the string to that of the buffer. */
1406 if (multibyte != string_multibyte)
1407 {
1408 int nbytes;
1409
1410 if (multibyte)
1411 nbytes = count_size_as_multibyte (XSTRING (string)->data,
1412 XSTRING (string)->size);
1413 else
1414 nbytes = XSTRING (string)->size;
1415 if (nbytes != size_byte)
1416 {
1417 str = (unsigned char *) alloca (nbytes);
1418 copy_text (XSTRING (string)->data, str, size_byte,
1419 string_multibyte, multibyte);
1420 size_byte = nbytes;
1421 }
1422 }
1423 1403
1424 if (NILP (lim)) 1404 if (NILP (lim))
1425 XSETINT (lim, forwardp ? ZV : BEGV); 1405 XSETINT (lim, forwardp ? ZV : BEGV);
@@ -1432,10 +1412,15 @@ skip_chars (forwardp, syntaxp, string, lim)
1432 if (XINT (lim) < BEGV) 1412 if (XINT (lim) < BEGV)
1433 XSETFASTINT (lim, BEGV); 1413 XSETFASTINT (lim, BEGV);
1434 1414
1415 multibyte = (!NILP (current_buffer->enable_multibyte_characters)
1416 && (lim - PT != CHAR_TO_BYTE (lim) - PT_BYTE));
1417 string_multibyte = STRING_BYTES (XSTRING (string)) > XSTRING (string)->size;
1418
1435 bzero (fastmap, sizeof fastmap); 1419 bzero (fastmap, sizeof fastmap);
1420 if (multibyte)
1421 char_ranges = (int *) alloca (XSTRING (string)->size * (sizeof (int)) * 2);
1436 1422
1437 i_byte = 0; 1423 i_byte = 0;
1438
1439 if (i_byte < size_byte 1424 if (i_byte < size_byte
1440 && XSTRING (string)->data[0] == '^') 1425 && XSTRING (string)->data[0] == '^')
1441 { 1426 {
@@ -1443,20 +1428,25 @@ skip_chars (forwardp, syntaxp, string, lim)
1443 } 1428 }
1444 1429
1445 /* Find the characters specified and set their elements of fastmap. 1430 /* Find the characters specified and set their elements of fastmap.
1446 If syntaxp, each character counts as itself. 1431 Handle backslashes and ranges specially.
1447 Otherwise, handle backslashes and ranges specially. */
1448 1432
1449 if (size_byte == XSTRING (string)->size) 1433 If STRING contains non-ASCII characters, setup char_ranges for
1450 while (i_byte < size_byte) 1434 them and use fastmap only for their leading codes. */
1451 {
1452 c = str[i_byte++];
1453 1435
1454 if (syntaxp) 1436 str = XSTRING (string)->data;
1455 fastmap[syntax_spec_code[c]] = 1; 1437 size_byte = STRING_BYTES (XSTRING (string));
1456 else 1438
1457 { 1439 if (! string_multibyte)
1458 if (c == '\\') 1440 {
1459 { 1441 int string_has_eight_bit = 0;
1442
1443 /* At first setup fastmap. */
1444 while (i_byte < size_byte)
1445 {
1446 c = str[i_byte++];
1447
1448 if (c == '\\')
1449 {
1460 if (i_byte == size_byte) 1450 if (i_byte == size_byte)
1461 break; 1451 break;
1462 1452
@@ -1475,67 +1465,299 @@ skip_chars (forwardp, syntaxp, string, lim)
1475 1465
1476 /* Get the end of the range. */ 1466 /* Get the end of the range. */
1477 c2 = str[i_byte++]; 1467 c2 = str[i_byte++];
1468 if (c2 == '\\'
1469 && i_byte < size_byte)
1470 c2 = str[i_byte++];
1471
1478 while (c <= c2) 1472 while (c <= c2)
1479 fastmap[c++] = 1; 1473 fastmap[c++] = 1;
1474 if (! ASCII_CHAR_P (c2))
1475 string_has_eight_bit = 1;
1480 } 1476 }
1481 else 1477 else
1482 fastmap[c] = 1; 1478 {
1479 fastmap[c] = 1;
1480 if (! ASCII_CHAR_P (c))
1481 string_has_eight_bit = 1;
1482 }
1483 }
1484
1485 /* If the current range is multibyte and STRING contains
1486 eight-bit chars, arrange fastmap and setup char_ranges for
1487 the corresponding multibyte chars. */
1488 if (multibyte && string_has_eight_bit)
1489 {
1490 unsigned char fastmap2[0400];
1491 int range_start_byte, range_start_char;
1492
1493 bcopy (fastmap2 + 0200, fastmap + 0200, 0200);
1494 bzero (fastmap + 0200, 0200);
1495 /* We are sure that this loop stops. */
1496 for (i = 0200; ! fastmap2[i]; i++);
1497 c = unibyte_char_to_multibyte (i);
1498 fastmap[CHAR_LEADING_CODE (c)] = 1;
1499 range_start_byte = i;
1500 range_start_char = c;
1501 for (i = 129; i < 0400; i++)
1502 {
1503 c = unibyte_char_to_multibyte (i);
1504 fastmap[CHAR_LEADING_CODE (c)] = 1;
1505 if (i - range_start_byte != c - range_start_char)
1506 {
1507 char_ranges[n_char_ranges++] = range_start_char;
1508 char_ranges[n_char_ranges++] = ((i - 1 - range_start_byte)
1509 + range_start_char);
1510 range_start_byte = i;
1511 range_start_char = c;
1512 }
1513 }
1514 char_ranges[n_char_ranges++] = range_start_char;
1515 char_ranges[n_char_ranges++] = ((i - 1 - range_start_byte)
1516 + range_start_char);
1483 } 1517 }
1484 } 1518 }
1485 else 1519 else
1486 while (i_byte < size_byte) 1520 {
1487 { 1521 while (i_byte < size_byte)
1488 c = STRING_CHAR_AND_LENGTH (str + i_byte, size_byte-i_byte, len); 1522 {
1489 i_byte += len; 1523 unsigned char leading_code;
1490 1524
1491 if (syntaxp) 1525 leading_code = str[i_byte];
1492 fastmap[syntax_spec_code[c & 0377]] = 1; 1526 c = STRING_CHAR_AND_LENGTH (str + i_byte, size_byte-i_byte, len);
1493 else 1527 i_byte += len;
1494 {
1495 if (c == '\\')
1496 {
1497 if (i_byte == size_byte)
1498 break;
1499 1528
1500 c = STRING_CHAR_AND_LENGTH (str+i_byte, size_byte-i_byte, len); 1529 if (c == '\\')
1501 i_byte += len; 1530 {
1502 } 1531 if (i_byte == size_byte)
1503 if (i_byte < size_byte 1532 break;
1504 && str[i_byte] == '-') 1533
1505 { 1534 leading_code = str[i_byte];
1506 unsigned int c2; 1535 c = STRING_CHAR_AND_LENGTH (str+i_byte, size_byte-i_byte, len);
1536 i_byte += len;
1537 }
1538 if (i_byte < size_byte
1539 && str[i_byte] == '-')
1540 {
1541 unsigned int c2;
1542 unsigned char leading_code2;
1507 1543
1508 /* Skip over the dash. */ 1544 /* Skip over the dash. */
1509 i_byte++; 1545 i_byte++;
1510 1546
1511 if (i_byte == size_byte) 1547 if (i_byte == size_byte)
1512 break; 1548 break;
1513 1549
1514 /* Get the end of the range. */ 1550 /* Get the end of the range. */
1515 c2 =STRING_CHAR_AND_LENGTH (str + i_byte, size_byte-i_byte, len); 1551 leading_code2 = str[i_byte];
1516 i_byte += len; 1552 c2 =STRING_CHAR_AND_LENGTH (str + i_byte, size_byte-i_byte, len);
1553 i_byte += len;
1517 1554
1518 if (ASCII_CHAR_P (c)) 1555 if (c2 == '\\'
1556 && i_byte < size_byte)
1557 {
1558 leading_code2 = str[i_byte];
1559 c2 =STRING_CHAR_AND_LENGTH (str + i_byte, size_byte-i_byte, len);
1560 i_byte += len;
1561 }
1562
1563 if (ASCII_CHAR_P (c))
1564 {
1519 while (c <= c2 && c < 0x80) 1565 while (c <= c2 && c < 0x80)
1520 fastmap[c++] = 1; 1566 fastmap[c++] = 1;
1521 if (c <= c2) 1567 leading_code = CHAR_LEADING_CODE (c);
1522 { 1568 }
1523 char_ranges[n_char_ranges++] = c; 1569 if (! ASCII_CHAR_P (c))
1524 char_ranges[n_char_ranges++] = c2; 1570 {
1525 } 1571 while (leading_code <= leading_code2)
1526 } 1572 fastmap[leading_code++] = 1;
1527 else 1573 if (c <= c2)
1528 { 1574 {
1529 if (ASCII_CHAR_P (c)) 1575 char_ranges[n_char_ranges++] = c;
1530 fastmap[c] = 1; 1576 char_ranges[n_char_ranges++] = c2;
1531 else 1577 }
1532 { 1578 }
1533 char_ranges[n_char_ranges++] = c; 1579 }
1534 char_ranges[n_char_ranges++] = c; 1580 else
1535 } 1581 {
1536 } 1582 if (ASCII_CHAR_P (c))
1583 fastmap[c] = 1;
1584 else
1585 {
1586 fastmap[leading_code] = 1;
1587 char_ranges[n_char_ranges++] = c;
1588 char_ranges[n_char_ranges++] = c;
1589 }
1590 }
1591 }
1592
1593 /* If the current range is unibyte and STRING contains non-ASCII
1594 chars, arrange fastmap for the corresponding unibyte
1595 chars. */
1596
1597 if (! multibyte && n_char_ranges > 0)
1598 {
1599 bzero (fastmap + 0200, 0200);
1600 for (i = 0; i < n_char_ranges; i += 2)
1601 {
1602 int c1 = char_ranges[i];
1603 int c2 = char_ranges[i + 1];
1604
1605 for (; c1 <= c2; c1++)
1606 fastmap[CHAR_TO_BYTE8 (c1)] = 1;
1607 }
1608 }
1609 }
1610
1611 /* If ^ was the first character, complement the fastmap. */
1612 if (negate)
1613 {
1614 if (! multibyte)
1615 for (i = 0; i < sizeof fastmap; i++)
1616 fastmap[i] ^= 1;
1617 else
1618 {
1619 for (i = 0; i < 0200; i++)
1620 fastmap[i] ^= 1;
1621 /* All non-ASCII chars possibly match. */
1622 for (; i < sizeof fastmap; i++)
1623 fastmap[i] = 1;
1624 }
1625 }
1626
1627 {
1628 int start_point = PT;
1629 int pos = PT;
1630 int pos_byte = PT_BYTE;
1631
1632 immediate_quit = 1;
1633 if (forwardp)
1634 {
1635 if (multibyte)
1636 while (pos < XINT (lim))
1637 {
1638 c = FETCH_BYTE (pos_byte);
1639 if (! fastmap[c])
1640 break;
1641 if (! ASCII_CHAR_P (c))
1642 {
1643 c = FETCH_MULTIBYTE_CHAR (pos_byte);
1644 /* As we are looking at a multibyte character, we
1645 must look up the character in the table
1646 CHAR_RANGES. If there's no data in the table,
1647 that character is not what we want to skip. */
1648
1649 /* The following code do the right thing even if
1650 n_char_ranges is zero (i.e. no data in
1651 CHAR_RANGES). */
1652 for (i = 0; i < n_char_ranges; i += 2)
1653 if (c >= char_ranges[i] && c <= char_ranges[i + 1])
1654 break;
1655 if (!(negate ^ (i < n_char_ranges)))
1656 break;
1657 }
1658 /* Since we already checked for multibyteness, avoid
1659 using INC_BOTH which checks again. */
1660 INC_POS (pos_byte);
1661 pos++;
1662 }
1663 else
1664 {
1665 while (pos < XINT (lim) && fastmap[FETCH_BYTE (pos)])
1666 pos++;
1667 pos_byte = pos;
1537 } 1668 }
1538 } 1669 }
1670 else
1671 {
1672 if (multibyte)
1673 while (pos > XINT (lim))
1674 {
1675 int prev_pos_byte = pos_byte;
1676
1677 DEC_POS (prev_pos_byte);
1678 c = FETCH_BYTE (prev_pos_byte);
1679 if (! fastmap[c])
1680 break;
1681 if (! ASCII_CHAR_P (c))
1682 {
1683 c = FETCH_MULTIBYTE_CHAR (prev_pos_byte);
1684 /* See the comment in the previous similar code. */
1685 for (i = 0; i < n_char_ranges; i += 2)
1686 if (c >= char_ranges[i] && c <= char_ranges[i + 1])
1687 break;
1688 if (!(negate ^ (i < n_char_ranges)))
1689 break;
1690 }
1691 pos--;
1692 pos_byte = prev_pos_byte;
1693 }
1694 else
1695 {
1696 while (pos > XINT (lim) && fastmap[FETCH_BYTE (pos - 1)])
1697 pos--;
1698 pos_byte = pos;
1699 }
1700 }
1701
1702 SET_PT_BOTH (pos, pos_byte);
1703 immediate_quit = 0;
1704
1705 return make_number (PT - start_point);
1706 }
1707}
1708
1709
1710static Lisp_Object
1711skip_syntaxes (forwardp, string, lim)
1712 int forwardp;
1713 Lisp_Object string, lim;
1714{
1715 register unsigned int c;
1716 unsigned char fastmap[0400];
1717 int negate = 0;
1718 register int i, i_byte;
1719 int multibyte;
1720 int size_byte;
1721 unsigned char *str;
1722
1723 CHECK_STRING (string);
1724
1725 if (NILP (lim))
1726 XSETINT (lim, forwardp ? ZV : BEGV);
1727 else
1728 CHECK_NUMBER_COERCE_MARKER (lim);
1729
1730 /* In any case, don't allow scan outside bounds of buffer. */
1731 if (XINT (lim) > ZV)
1732 XSETFASTINT (lim, ZV);
1733 if (XINT (lim) < BEGV)
1734 XSETFASTINT (lim, BEGV);
1735
1736 multibyte = (!NILP (current_buffer->enable_multibyte_characters)
1737 && (lim - PT != CHAR_TO_BYTE (lim) - PT_BYTE));
1738
1739 bzero (fastmap, sizeof fastmap);
1740
1741 i_byte = 0;
1742 if (i_byte < size_byte
1743 && XSTRING (string)->data[0] == '^')
1744 {
1745 negate = 1; i_byte++;
1746 }
1747
1748 if (STRING_BYTES (XSTRING (string)) > XSTRING (string)->size)
1749 /* As this is very rare case, don't consider efficiency. */
1750 string = string_make_unibyte (string);
1751 str = XSTRING (string)->data;
1752 size_byte = STRING_BYTES (XSTRING (string));
1753
1754 /* Find the syntaxes specified and set their elements of fastmap. */
1755
1756 while (i_byte < size_byte)
1757 {
1758 c = str[i_byte++];
1759 fastmap[syntax_spec_code[c]] = 1;
1760 }
1539 1761
1540 /* If ^ was the first character, complement the fastmap. */ 1762 /* If ^ was the first character, complement the fastmap. */
1541 if (negate) 1763 if (negate)
@@ -1548,139 +1770,75 @@ skip_chars (forwardp, syntaxp, string, lim)
1548 int pos_byte = PT_BYTE; 1770 int pos_byte = PT_BYTE;
1549 1771
1550 immediate_quit = 1; 1772 immediate_quit = 1;
1551 if (syntaxp) 1773 SETUP_SYNTAX_TABLE (pos, forwardp ? 1 : -1);
1774 if (forwardp)
1552 { 1775 {
1553 SETUP_SYNTAX_TABLE (pos, forwardp ? 1 : -1); 1776 if (multibyte)
1554 if (forwardp)
1555 { 1777 {
1556 if (multibyte) 1778 if (pos < XINT (lim))
1557 { 1779 while (fastmap[(int) SYNTAX (FETCH_CHAR (pos_byte))])
1558 if (pos < XINT (lim)) 1780 {
1559 while (fastmap[(int) SYNTAX (FETCH_CHAR (pos_byte))]) 1781 /* Since we already checked for multibyteness,
1560 { 1782 avoid using INC_BOTH which checks again. */
1561 /* Since we already checked for multibyteness, 1783 INC_POS (pos_byte);
1562 avoid using INC_BOTH which checks again. */ 1784 pos++;
1563 INC_POS (pos_byte); 1785 if (pos >= XINT (lim))
1564 pos++; 1786 break;
1565 if (pos >= XINT (lim)) 1787 UPDATE_SYNTAX_TABLE_FORWARD (pos);
1566 break; 1788 }
1567 UPDATE_SYNTAX_TABLE_FORWARD (pos);
1568 }
1569 }
1570 else
1571 {
1572 while (pos < XINT (lim)
1573 && fastmap[(int) SYNTAX (FETCH_BYTE (pos))])
1574 {
1575 pos++;
1576 UPDATE_SYNTAX_TABLE_FORWARD (pos);
1577 }
1578 }
1579 } 1789 }
1580 else 1790 else
1581 { 1791 {
1582 if (multibyte) 1792 while (pos < XINT (lim))
1583 {
1584 while (pos > XINT (lim))
1585 {
1586 int savepos = pos_byte;
1587 /* Since we already checked for multibyteness,
1588 avoid using DEC_BOTH which checks again. */
1589 pos--;
1590 DEC_POS (pos_byte);
1591 UPDATE_SYNTAX_TABLE_BACKWARD (pos);
1592 if (!fastmap[(int) SYNTAX (FETCH_CHAR (pos_byte))])
1593 {
1594 pos++;
1595 pos_byte = savepos;
1596 break;
1597 }
1598 }
1599 }
1600 else
1601 { 1793 {
1602 if (pos > XINT (lim)) 1794 c = FETCH_BYTE (pos);
1603 while (fastmap[(int) SYNTAX (FETCH_BYTE (pos - 1))]) 1795 MAKE_CHAR_MULTIBYTE (c);
1604 { 1796 if (fastmap[(int) SYNTAX (c)])
1605 pos--; 1797 break;
1606 if (pos <= XINT (lim)) 1798 pos++;
1607 break; 1799 UPDATE_SYNTAX_TABLE_FORWARD (pos);
1608 UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1);
1609 }
1610 } 1800 }
1801 pos_byte = pos;
1611 } 1802 }
1612 } 1803 }
1613 else 1804 else
1614 { 1805 {
1615 if (forwardp) 1806 if (multibyte)
1616 { 1807 {
1617 if (multibyte) 1808 while (pos > XINT (lim))
1618 while (pos < XINT (lim)) 1809 {
1619 { 1810 int savepos = pos_byte;
1620 c = FETCH_MULTIBYTE_CHAR (pos_byte); 1811 /* Since we already checked for multibyteness,
1621 if (ASCII_CHAR_P (c)) 1812 avoid using DEC_BOTH which checks again. */
1622 { 1813 pos--;
1623 if (!fastmap[c]) 1814 DEC_POS (pos_byte);
1624 break; 1815 UPDATE_SYNTAX_TABLE_BACKWARD (pos);
1625 } 1816 if (!fastmap[(int) SYNTAX (FETCH_CHAR (pos_byte))])
1626 else 1817 {
1627 { 1818 pos++;
1628 /* If we are looking at a multibyte character, 1819 pos_byte = savepos;
1629 we must look up the character in the table 1820 break;
1630 CHAR_RANGES. If there's no data in the 1821 }
1631 table, that character is not what we want to 1822 }
1632 skip. */
1633
1634 /* The following code do the right thing even if
1635 n_char_ranges is zero (i.e. no data in
1636 CHAR_RANGES). */
1637 for (i = 0; i < n_char_ranges; i += 2)
1638 if (c >= char_ranges[i] && c <= char_ranges[i + 1])
1639 break;
1640 if (!(negate ^ (i < n_char_ranges)))
1641 break;
1642 }
1643 INC_BOTH (pos, pos_byte);
1644 }
1645 else
1646 while (pos < XINT (lim) && fastmap[FETCH_BYTE (pos)])
1647 pos++;
1648 } 1823 }
1649 else 1824 else
1650 { 1825 {
1651 if (multibyte) 1826 if (pos > XINT (lim))
1652 while (pos > XINT (lim)) 1827 while (1)
1653 { 1828 {
1654 int prev_pos_byte = pos_byte; 1829 c = FETCH_BYTE (pos - 1);
1655 1830 MAKE_CHAR_MULTIBYTE (c);
1656 DEC_POS (prev_pos_byte); 1831 if (! fastmap[(int) SYNTAX (c)])
1657 c = FETCH_MULTIBYTE_CHAR (prev_pos_byte); 1832 break;
1658 if (SINGLE_BYTE_CHAR_P (c))
1659 {
1660 if (!fastmap[c])
1661 break;
1662 }
1663 else
1664 {
1665 /* See the comment in the previous similar code. */
1666 for (i = 0; i < n_char_ranges; i += 2)
1667 if (c >= char_ranges[i] && c <= char_ranges[i + 1])
1668 break;
1669 if (!(negate ^ (i < n_char_ranges)))
1670 break;
1671 }
1672 pos--; 1833 pos--;
1673 pos_byte = prev_pos_byte; 1834 if (pos <= XINT (lim))
1835 break;
1836 UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1);
1674 } 1837 }
1675 else 1838 pos_byte = pos;
1676 while (pos > XINT (lim) && fastmap[FETCH_BYTE (pos - 1)])
1677 pos--;
1678 } 1839 }
1679 } 1840 }
1680 1841
1681 if (! multibyte)
1682 pos_byte = pos;
1683
1684 SET_PT_BOTH (pos, pos_byte); 1842 SET_PT_BOTH (pos, pos_byte);
1685 immediate_quit = 0; 1843 immediate_quit = 0;
1686 1844
@@ -1851,7 +2009,7 @@ between them, return t; otherwise return nil. */)
1851 immediate_quit = 0; 2009 immediate_quit = 0;
1852 return Qnil; 2010 return Qnil;
1853 } 2011 }
1854 c = FETCH_CHAR (from_byte); 2012 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
1855 code = SYNTAX (c); 2013 code = SYNTAX (c);
1856 comstart_first = SYNTAX_COMSTART_FIRST (c); 2014 comstart_first = SYNTAX_COMSTART_FIRST (c);
1857 comnested = SYNTAX_COMMENT_NESTED (c); 2015 comnested = SYNTAX_COMMENT_NESTED (c);
@@ -1859,7 +2017,7 @@ between them, return t; otherwise return nil. */)
1859 INC_BOTH (from, from_byte); 2017 INC_BOTH (from, from_byte);
1860 UPDATE_SYNTAX_TABLE_FORWARD (from); 2018 UPDATE_SYNTAX_TABLE_FORWARD (from);
1861 if (from < stop && comstart_first 2019 if (from < stop && comstart_first
1862 && (c1 = FETCH_CHAR (from_byte), 2020 && (c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte),
1863 SYNTAX_COMSTART_SECOND (c1))) 2021 SYNTAX_COMSTART_SECOND (c1)))
1864 { 2022 {
1865 /* We have encountered a comment start sequence and we 2023 /* We have encountered a comment start sequence and we
@@ -1917,7 +2075,7 @@ between them, return t; otherwise return nil. */)
1917 DEC_BOTH (from, from_byte); 2075 DEC_BOTH (from, from_byte);
1918 /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */ 2076 /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */
1919 quoted = char_quoted (from, from_byte); 2077 quoted = char_quoted (from, from_byte);
1920 c = FETCH_CHAR (from_byte); 2078 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
1921 code = SYNTAX (c); 2079 code = SYNTAX (c);
1922 comstyle = 0; 2080 comstyle = 0;
1923 comnested = SYNTAX_COMMENT_NESTED (c); 2081 comnested = SYNTAX_COMMENT_NESTED (c);
@@ -1934,7 +2092,7 @@ between them, return t; otherwise return nil. */)
1934 code = Sendcomment; 2092 code = Sendcomment;
1935 /* Calling char_quoted, above, set up global syntax position 2093 /* Calling char_quoted, above, set up global syntax position
1936 at the new value of FROM. */ 2094 at the new value of FROM. */
1937 c1 = FETCH_CHAR (from_byte); 2095 c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte);
1938 comstyle = SYNTAX_COMMENT_STYLE (c1); 2096 comstyle = SYNTAX_COMMENT_STYLE (c1);
1939 comnested = comnested || SYNTAX_COMMENT_NESTED (c1); 2097 comnested = comnested || SYNTAX_COMMENT_NESTED (c1);
1940 } 2098 }
@@ -1950,7 +2108,7 @@ between them, return t; otherwise return nil. */)
1950 if (from == stop) 2108 if (from == stop)
1951 break; 2109 break;
1952 UPDATE_SYNTAX_TABLE_BACKWARD (from); 2110 UPDATE_SYNTAX_TABLE_BACKWARD (from);
1953 c = FETCH_CHAR (from_byte); 2111 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
1954 if (SYNTAX (c) == Scomment_fence 2112 if (SYNTAX (c) == Scomment_fence
1955 && !char_quoted (from, from_byte)) 2113 && !char_quoted (from, from_byte))
1956 { 2114 {
@@ -2011,11 +2169,11 @@ between them, return t; otherwise return nil. */)
2011 return Qt; 2169 return Qt;
2012} 2170}
2013 2171
2014/* Return syntax code of character C if C is a single byte character 2172/* Return syntax code of character C if C is an ASCII character
2015 or `multibyte_symbol_p' is zero. Otherwise, return Ssymbol. */ 2173 or `multibyte_symbol_p' is zero. Otherwise, return Ssymbol. */
2016 2174
2017#define SYNTAX_WITH_MULTIBYTE_CHECK(c) \ 2175#define SYNTAX_WITH_MULTIBYTE_CHECK(c) \
2018 ((SINGLE_BYTE_CHAR_P (c) || !multibyte_symbol_p) \ 2176 ((ASCII_CHAR_P (c) || !multibyte_symbol_p) \
2019 ? SYNTAX (c) : Ssymbol) 2177 ? SYNTAX (c) : Ssymbol)
2020 2178
2021static Lisp_Object 2179static Lisp_Object
@@ -2058,7 +2216,7 @@ scan_lists (from, count, depth, sexpflag)
2058 { 2216 {
2059 int comstart_first, prefix; 2217 int comstart_first, prefix;
2060 UPDATE_SYNTAX_TABLE_FORWARD (from); 2218 UPDATE_SYNTAX_TABLE_FORWARD (from);
2061 c = FETCH_CHAR (from_byte); 2219 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2062 code = SYNTAX_WITH_MULTIBYTE_CHECK (c); 2220 code = SYNTAX_WITH_MULTIBYTE_CHECK (c);
2063 comstart_first = SYNTAX_COMSTART_FIRST (c); 2221 comstart_first = SYNTAX_COMSTART_FIRST (c);
2064 comnested = SYNTAX_COMMENT_NESTED (c); 2222 comnested = SYNTAX_COMMENT_NESTED (c);
@@ -2069,7 +2227,7 @@ scan_lists (from, count, depth, sexpflag)
2069 INC_BOTH (from, from_byte); 2227 INC_BOTH (from, from_byte);
2070 UPDATE_SYNTAX_TABLE_FORWARD (from); 2228 UPDATE_SYNTAX_TABLE_FORWARD (from);
2071 if (from < stop && comstart_first 2229 if (from < stop && comstart_first
2072 && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from_byte)) 2230 && SYNTAX_COMSTART_SECOND (FETCH_CHAR_AS_MULTIBYTE (from_byte))
2073 && parse_sexp_ignore_comments) 2231 && parse_sexp_ignore_comments)
2074 { 2232 {
2075 /* we have encountered a comment start sequence and we 2233 /* we have encountered a comment start sequence and we
@@ -2078,7 +2236,7 @@ scan_lists (from, count, depth, sexpflag)
2078 only a comment end of the same style actually ends 2236 only a comment end of the same style actually ends
2079 the comment section */ 2237 the comment section */
2080 code = Scomment; 2238 code = Scomment;
2081 c1 = FETCH_CHAR (from_byte); 2239 c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2082 comstyle = SYNTAX_COMMENT_STYLE (c1); 2240 comstyle = SYNTAX_COMMENT_STYLE (c1);
2083 comnested = comnested || SYNTAX_COMMENT_NESTED (c1); 2241 comnested = comnested || SYNTAX_COMMENT_NESTED (c1);
2084 INC_BOTH (from, from_byte); 2242 INC_BOTH (from, from_byte);
@@ -2104,7 +2262,7 @@ scan_lists (from, count, depth, sexpflag)
2104 UPDATE_SYNTAX_TABLE_FORWARD (from); 2262 UPDATE_SYNTAX_TABLE_FORWARD (from);
2105 2263
2106 /* Some compilers can't handle this inside the switch. */ 2264 /* Some compilers can't handle this inside the switch. */
2107 c = FETCH_CHAR (from_byte); 2265 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2108 temp = SYNTAX_WITH_MULTIBYTE_CHECK (c); 2266 temp = SYNTAX_WITH_MULTIBYTE_CHECK (c);
2109 switch (temp) 2267 switch (temp)
2110 { 2268 {
@@ -2147,7 +2305,7 @@ scan_lists (from, count, depth, sexpflag)
2147 case Smath: 2305 case Smath:
2148 if (!sexpflag) 2306 if (!sexpflag)
2149 break; 2307 break;
2150 if (from != stop && c == FETCH_CHAR (from_byte)) 2308 if (from != stop && c == FETCH_CHAR_AS_MULTIBYTE (from_byte))
2151 { 2309 {
2152 INC_BOTH (from, from_byte); 2310 INC_BOTH (from, from_byte);
2153 } 2311 }
@@ -2175,12 +2333,12 @@ scan_lists (from, count, depth, sexpflag)
2175 case Sstring: 2333 case Sstring:
2176 case Sstring_fence: 2334 case Sstring_fence:
2177 temp_pos = dec_bytepos (from_byte); 2335 temp_pos = dec_bytepos (from_byte);
2178 stringterm = FETCH_CHAR (temp_pos); 2336 stringterm = FETCH_CHAR_AS_MULTIBYTE (temp_pos);
2179 while (1) 2337 while (1)
2180 { 2338 {
2181 if (from >= stop) goto lose; 2339 if (from >= stop) goto lose;
2182 UPDATE_SYNTAX_TABLE_FORWARD (from); 2340 UPDATE_SYNTAX_TABLE_FORWARD (from);
2183 c = FETCH_CHAR (from_byte); 2341 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2184 if (code == Sstring 2342 if (code == Sstring
2185 ? (c == stringterm 2343 ? (c == stringterm
2186 && SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring) 2344 && SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring)
@@ -2220,7 +2378,7 @@ scan_lists (from, count, depth, sexpflag)
2220 { 2378 {
2221 DEC_BOTH (from, from_byte); 2379 DEC_BOTH (from, from_byte);
2222 UPDATE_SYNTAX_TABLE_BACKWARD (from); 2380 UPDATE_SYNTAX_TABLE_BACKWARD (from);
2223 c = FETCH_CHAR (from_byte); 2381 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2224 code = SYNTAX_WITH_MULTIBYTE_CHECK (c); 2382 code = SYNTAX_WITH_MULTIBYTE_CHECK (c);
2225 if (depth == min_depth) 2383 if (depth == min_depth)
2226 last_good = from; 2384 last_good = from;
@@ -2238,7 +2396,7 @@ scan_lists (from, count, depth, sexpflag)
2238 DEC_BOTH (from, from_byte); 2396 DEC_BOTH (from, from_byte);
2239 UPDATE_SYNTAX_TABLE_BACKWARD (from); 2397 UPDATE_SYNTAX_TABLE_BACKWARD (from);
2240 code = Sendcomment; 2398 code = Sendcomment;
2241 c1 = FETCH_CHAR (from_byte); 2399 c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2242 comstyle = SYNTAX_COMMENT_STYLE (c1); 2400 comstyle = SYNTAX_COMMENT_STYLE (c1);
2243 comnested = comnested || SYNTAX_COMMENT_NESTED (c1); 2401 comnested = comnested || SYNTAX_COMMENT_NESTED (c1);
2244 } 2402 }
@@ -2268,7 +2426,7 @@ scan_lists (from, count, depth, sexpflag)
2268 else 2426 else
2269 temp_pos--; 2427 temp_pos--;
2270 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); 2428 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1);
2271 c1 = FETCH_CHAR (temp_pos); 2429 c1 = FETCH_CHAR_AS_MULTIBYTE (temp_pos);
2272 temp_code = SYNTAX_WITH_MULTIBYTE_CHECK (c1); 2430 temp_code = SYNTAX_WITH_MULTIBYTE_CHECK (c1);
2273 /* Don't allow comment-end to be quoted. */ 2431 /* Don't allow comment-end to be quoted. */
2274 if (temp_code == Sendcomment) 2432 if (temp_code == Sendcomment)
@@ -2280,7 +2438,7 @@ scan_lists (from, count, depth, sexpflag)
2280 temp_pos = dec_bytepos (temp_pos); 2438 temp_pos = dec_bytepos (temp_pos);
2281 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); 2439 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1);
2282 } 2440 }
2283 c1 = FETCH_CHAR (temp_pos); 2441 c1 = FETCH_CHAR_AS_MULTIBYTE (temp_pos);
2284 temp_code = SYNTAX_WITH_MULTIBYTE_CHECK (c1); 2442 temp_code = SYNTAX_WITH_MULTIBYTE_CHECK (c1);
2285 if (! (quoted || temp_code == Sword 2443 if (! (quoted || temp_code == Sword
2286 || temp_code == Ssymbol 2444 || temp_code == Ssymbol
@@ -2295,7 +2453,7 @@ scan_lists (from, count, depth, sexpflag)
2295 break; 2453 break;
2296 temp_pos = dec_bytepos (from_byte); 2454 temp_pos = dec_bytepos (from_byte);
2297 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); 2455 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1);
2298 if (from != stop && c == FETCH_CHAR (temp_pos)) 2456 if (from != stop && c == FETCH_CHAR_AS_MULTIBYTE (temp_pos))
2299 DEC_BOTH (from, from_byte); 2457 DEC_BOTH (from, from_byte);
2300 if (mathexit) 2458 if (mathexit)
2301 { 2459 {
@@ -2341,7 +2499,7 @@ scan_lists (from, count, depth, sexpflag)
2341 if (from == stop) goto lose; 2499 if (from == stop) goto lose;
2342 UPDATE_SYNTAX_TABLE_BACKWARD (from); 2500 UPDATE_SYNTAX_TABLE_BACKWARD (from);
2343 if (!char_quoted (from, from_byte) 2501 if (!char_quoted (from, from_byte)
2344 && (c = FETCH_CHAR (from_byte), 2502 && (c = FETCH_CHAR_AS_MULTIBYTE (from_byte),
2345 SYNTAX_WITH_MULTIBYTE_CHECK (c) == code)) 2503 SYNTAX_WITH_MULTIBYTE_CHECK (c) == code))
2346 break; 2504 break;
2347 } 2505 }
@@ -2349,7 +2507,7 @@ scan_lists (from, count, depth, sexpflag)
2349 break; 2507 break;
2350 2508
2351 case Sstring: 2509 case Sstring:
2352 stringterm = FETCH_CHAR (from_byte); 2510 stringterm = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2353 while (1) 2511 while (1)
2354 { 2512 {
2355 if (from == stop) goto lose; 2513 if (from == stop) goto lose;
@@ -2360,7 +2518,7 @@ scan_lists (from, count, depth, sexpflag)
2360 temp_pos--; 2518 temp_pos--;
2361 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); 2519 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1);
2362 if (!char_quoted (from - 1, temp_pos) 2520 if (!char_quoted (from - 1, temp_pos)
2363 && stringterm == (c = FETCH_CHAR (temp_pos)) 2521 && stringterm == (c = FETCH_CHAR_AS_MULTIBYTE (temp_pos))
2364 && SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring) 2522 && SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring)
2365 break; 2523 break;
2366 DEC_BOTH (from, from_byte); 2524 DEC_BOTH (from, from_byte);
@@ -2465,7 +2623,7 @@ This includes chars with "quote" or "prefix" syntax (' or p). */)
2465 2623
2466 while (!char_quoted (pos, pos_byte) 2624 while (!char_quoted (pos, pos_byte)
2467 /* Previous statement updates syntax table. */ 2625 /* Previous statement updates syntax table. */
2468 && ((c = FETCH_CHAR (pos_byte), SYNTAX (c) == Squote) 2626 && ((c = FETCH_CHAR_AS_MULTIBYTE (pos_byte), SYNTAX (c) == Squote)
2469 || SYNTAX_PREFIX (c))) 2627 || SYNTAX_PREFIX (c)))
2470 { 2628 {
2471 opoint = pos; 2629 opoint = pos;
@@ -2691,7 +2849,7 @@ do { prev_from = from; \
2691 while (from < end) 2849 while (from < end)
2692 { 2850 {
2693 /* Some compilers can't handle this inside the switch. */ 2851 /* Some compilers can't handle this inside the switch. */
2694 temp = SYNTAX (FETCH_CHAR (from_byte)); 2852 temp = SYNTAX (FETCH_CHAR_AS_MULTIBYTE (from_byte));
2695 switch (temp) 2853 switch (temp)
2696 { 2854 {
2697 case Scharquote: 2855 case Scharquote:
@@ -2763,7 +2921,7 @@ do { prev_from = from; \
2763 if (stopbefore) goto stop; /* this arg means stop at sexp start */ 2921 if (stopbefore) goto stop; /* this arg means stop at sexp start */
2764 curlevel->last = prev_from; 2922 curlevel->last = prev_from;
2765 state.instring = (code == Sstring 2923 state.instring = (code == Sstring
2766 ? (FETCH_CHAR (prev_from_byte)) 2924 ? (FETCH_CHAR_AS_MULTIBYTE (prev_from_byte))
2767 : ST_STRING_STYLE); 2925 : ST_STRING_STYLE);
2768 if (boundary_stop) goto done; 2926 if (boundary_stop) goto done;
2769 startinstring: 2927 startinstring:
@@ -2775,7 +2933,7 @@ do { prev_from = from; \
2775 int c; 2933 int c;
2776 2934
2777 if (from >= end) goto done; 2935 if (from >= end) goto done;
2778 c = FETCH_CHAR (from_byte); 2936 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2779 /* Some compilers can't handle this inside the switch. */ 2937 /* Some compilers can't handle this inside the switch. */
2780 temp = SYNTAX (c); 2938 temp = SYNTAX (c);
2781 2939