aboutsummaryrefslogtreecommitdiffstats
path: root/src/syntax.c
diff options
context:
space:
mode:
authorMiles Bader2004-06-28 07:56:49 +0000
committerMiles Bader2004-06-28 07:56:49 +0000
commit327719ee8a3fcdb36ed6acaf6d8cb5fbdf0bd801 (patch)
tree21de188e13b5e41a79bb50040933072ae0235217 /src/syntax.c
parent852f73b7fa7b71910282eacb6263b3ecfd4ee783 (diff)
parent376de73927383d6062483db10b8a82448505f52b (diff)
downloademacs-327719ee8a3fcdb36ed6acaf6d8cb5fbdf0bd801.tar.gz
emacs-327719ee8a3fcdb36ed6acaf6d8cb5fbdf0bd801.zip
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-15
Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-218 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-220 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-221 Restore deleted tagline in etc/TUTORIAL.ru * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-222 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-228 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-229 Remove TeX output files from the archive * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-230 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-247 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-248 src/lisp.h (CYCLE_CHECK): Macro moved from xfaces.c * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-249 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-256 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-258 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-263 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-264 Update from CVS: lispref/display.texi: emacs -> Emacs. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-265 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-274 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-275 Update from CVS: man/makefile.w32-in: Revert last change * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-276 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-295 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-296 Allow restarting an existing debugger session that's exited * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-297 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-299 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-300 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-327 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-328 Update from CVS: src/.gdbinit (xsymbol): Fix last change. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-329 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-344 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-345 Tweak source regexps so that building in place won't cause problems * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-346 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-351 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-352 Update from CVS: lisp/flymake.el: New file. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-353 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-361 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-362 Support " [...]" style defaults in minibuffer-electric-default-mode * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-363 (read-number): Use canonical format for default in prompt. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-364 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-367 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-368 Improve display-supports-face-attributes-p on non-ttys * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-369 Rewrite face-differs-from-default-p * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-370 Move `display-supports-face-attributes-p' entirely into C code * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-371 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-372 Simplify face-differs-from-default-p; don't consider :stipple. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-373 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-374 (tty_supports_face_attributes_p): Ensure attributes differ from default * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-375 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-376 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-377 (Fdisplay_supports_face_attributes_p): Work around bootstrapping problem * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-378 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-380 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-381 Face merging cleanups * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-382 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-384 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-385 src/xfaces.c (push_named_merge_point): Return 0 if a cycle is detected * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-386 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-395 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-396 Tweak arch tagging to make build/install-in-place less annoying * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397 Work around vc-arch problems when building eshell * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-398 Tweak permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-399 Tweak directory permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-400 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-401 More build-in-place tweaking of arch tagging * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-402 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-403 Yet more build-in-place tweaking of arch tagging * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-404 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-409 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-410 Make sure image types are initialized for lookup too * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-411 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-416 Update from CVS
Diffstat (limited to 'src/syntax.c')
-rw-r--r--src/syntax.c196
1 files changed, 173 insertions, 23 deletions
diff --git a/src/syntax.c b/src/syntax.c
index 22a34c40fb3..57606f314d6 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -26,6 +26,7 @@ Boston, MA 02111-1307, USA. */
26#include "buffer.h" 26#include "buffer.h"
27#include "character.h" 27#include "character.h"
28#include "keymap.h" 28#include "keymap.h"
29#include "regex.h"
29 30
30/* Make syntax table lookup grant data in gl_state. */ 31/* Make syntax table lookup grant data in gl_state. */
31#define SYNTAX_ENTRY_VIA_PROPERTY 32#define SYNTAX_ENTRY_VIA_PROPERTY
@@ -97,12 +98,13 @@ static int find_start_modiff;
97static int find_defun_start P_ ((int, int)); 98static int find_defun_start P_ ((int, int));
98static int back_comment P_ ((int, int, int, int, int, int *, int *)); 99static int back_comment P_ ((int, int, int, int, int, int *, int *));
99static int char_quoted P_ ((int, int)); 100static int char_quoted P_ ((int, int));
100static Lisp_Object skip_chars P_ ((int, Lisp_Object, Lisp_Object)); 101static Lisp_Object skip_chars P_ ((int, Lisp_Object, Lisp_Object, int));
101static Lisp_Object skip_syntaxes P_ ((int, Lisp_Object, Lisp_Object)); 102static Lisp_Object skip_syntaxes P_ ((int, Lisp_Object, Lisp_Object));
102static Lisp_Object scan_lists P_ ((int, int, int, int)); 103static Lisp_Object scan_lists P_ ((int, int, int, int));
103static void scan_sexps_forward P_ ((struct lisp_parse_state *, 104static void scan_sexps_forward P_ ((struct lisp_parse_state *,
104 int, int, int, int, 105 int, int, int, int,
105 int, Lisp_Object, int)); 106 int, Lisp_Object, int));
107static int in_classes P_ ((int, Lisp_Object));
106 108
107 109
108struct gl_state_s gl_state; /* Global state of syntax parser. */ 110struct gl_state_s gl_state; /* Global state of syntax parser. */
@@ -293,8 +295,11 @@ char_quoted (charpos, bytepos)
293 295
294 while (bytepos >= beg) 296 while (bytepos >= beg)
295 { 297 {
298 int c;
299
296 UPDATE_SYNTAX_TABLE_BACKWARD (charpos); 300 UPDATE_SYNTAX_TABLE_BACKWARD (charpos);
297 code = SYNTAX (FETCH_CHAR_AS_MULTIBYTE (bytepos)); 301 c = FETCH_CHAR_AS_MULTIBYTE (bytepos);
302 code = SYNTAX (c);
298 if (! (code == Scharquote || code == Sescape)) 303 if (! (code == Scharquote || code == Sescape))
299 break; 304 break;
300 305
@@ -381,12 +386,16 @@ find_defun_start (pos, pos_byte)
381 gl_state.use_global = 0; 386 gl_state.use_global = 0;
382 while (PT > BEGV) 387 while (PT > BEGV)
383 { 388 {
389 int c;
390
384 /* Open-paren at start of line means we may have found our 391 /* Open-paren at start of line means we may have found our
385 defun-start. */ 392 defun-start. */
386 if (SYNTAX (FETCH_CHAR_AS_MULTIBYTE (PT_BYTE)) == Sopen) 393 c = FETCH_CHAR_AS_MULTIBYTE (PT_BYTE);
394 if (SYNTAX (c) == Sopen)
387 { 395 {
388 SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ 396 SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */
389 if (SYNTAX (FETCH_CHAR_AS_MULTIBYTE (PT_BYTE)) == Sopen) 397 c = FETCH_CHAR_AS_MULTIBYTE (PT_BYTE);
398 if (SYNTAX (c) == Sopen)
390 break; 399 break;
391 /* Now fallback to the default value. */ 400 /* Now fallback to the default value. */
392 gl_state.current_syntax_table = current_buffer->syntax_table; 401 gl_state.current_syntax_table = current_buffer->syntax_table;
@@ -955,7 +964,7 @@ text property. */)
955DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3, 964DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3,
956 "cSet syntax for character: \nsSet syntax for %s to: ", 965 "cSet syntax for character: \nsSet syntax for %s to: ",
957 doc: /* Set syntax for character CHAR according to string NEWENTRY. 966 doc: /* Set syntax for character CHAR according to string NEWENTRY.
958The syntax is changed only for table SYNTAX_TABLE, which defaults to 967The syntax is changed only for table SYNTAX-TABLE, which defaults to
959 the current buffer's syntax table. 968 the current buffer's syntax table.
960CHAR may be a cons (MIN . MAX), in which case, syntaxes of all characters 969CHAR may be a cons (MIN . MAX), in which case, syntaxes of all characters
961in the range MIN and MAX are changed. 970in the range MIN and MAX are changed.
@@ -1339,13 +1348,13 @@ except that `]' is never special and `\\' quotes `^', `-' or `\\'
1339 (but not as the end of a range; quoting is never needed there). 1348 (but not as the end of a range; quoting is never needed there).
1340Thus, with arg "a-zA-Z", this skips letters stopping before first nonletter. 1349Thus, with arg "a-zA-Z", this skips letters stopping before first nonletter.
1341With arg "^a-zA-Z", skips nonletters stopping before first letter. 1350With arg "^a-zA-Z", skips nonletters stopping before first letter.
1342Returns the distance traveled, either zero or positive. 1351Char classes, e.g. `[:alpha:]', are supported.
1343Note that char classes, e.g. `[:alpha:]', are not currently supported; 1352
1344they will be treated as literals. */) 1353Returns the distance traveled, either zero or positive. */)
1345 (string, lim) 1354 (string, lim)
1346 Lisp_Object string, lim; 1355 Lisp_Object string, lim;
1347{ 1356{
1348 return skip_chars (1, string, lim); 1357 return skip_chars (1, string, lim, 1);
1349} 1358}
1350 1359
1351DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0, 1360DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0,
@@ -1355,7 +1364,7 @@ Returns the distance traveled, either zero or negative. */)
1355 (string, lim) 1364 (string, lim)
1356 Lisp_Object string, lim; 1365 Lisp_Object string, lim;
1357{ 1366{
1358 return skip_chars (0, string, lim); 1367 return skip_chars (0, string, lim, 1);
1359} 1368}
1360 1369
1361DEFUN ("skip-syntax-forward", Fskip_syntax_forward, Sskip_syntax_forward, 1, 2, 0, 1370DEFUN ("skip-syntax-forward", Fskip_syntax_forward, Sskip_syntax_forward, 1, 2, 0,
@@ -1383,9 +1392,10 @@ This function returns the distance traveled, either zero or negative. */)
1383} 1392}
1384 1393
1385static Lisp_Object 1394static Lisp_Object
1386skip_chars (forwardp, string, lim) 1395skip_chars (forwardp, string, lim, handle_iso_classes)
1387 int forwardp; 1396 int forwardp;
1388 Lisp_Object string, lim; 1397 Lisp_Object string, lim;
1398 int handle_iso_classes;
1389{ 1399{
1390 register unsigned int c; 1400 register unsigned int c;
1391 unsigned char fastmap[0400]; 1401 unsigned char fastmap[0400];
@@ -1403,8 +1413,10 @@ skip_chars (forwardp, string, lim)
1403 int size_byte; 1413 int size_byte;
1404 const unsigned char *str; 1414 const unsigned char *str;
1405 int len; 1415 int len;
1416 Lisp_Object iso_classes;
1406 1417
1407 CHECK_STRING (string); 1418 CHECK_STRING (string);
1419 iso_classes = Qnil;
1408 1420
1409 if (NILP (lim)) 1421 if (NILP (lim))
1410 XSETINT (lim, forwardp ? ZV : BEGV); 1422 XSETINT (lim, forwardp ? ZV : BEGV);
@@ -1448,6 +1460,42 @@ skip_chars (forwardp, string, lim)
1448 { 1460 {
1449 c = str[i_byte++]; 1461 c = str[i_byte++];
1450 1462
1463 if (handle_iso_classes && c == '['
1464 && i_byte < size_byte
1465 && str[i_byte] == ':')
1466 {
1467 const unsigned char *class_beg = str + i_byte + 1;
1468 const unsigned char *class_end = class_beg;
1469 const unsigned char *class_limit = str + size_byte - 2;
1470 /* Leave room for the null. */
1471 unsigned char class_name[CHAR_CLASS_MAX_LENGTH + 1];
1472 re_wctype_t cc;
1473
1474 if (class_limit - class_beg > CHAR_CLASS_MAX_LENGTH)
1475 class_limit = class_beg + CHAR_CLASS_MAX_LENGTH;
1476
1477 while (class_end < class_limit
1478 && *class_end >= 'a' && *class_end <= 'z')
1479 class_end++;
1480
1481 if (class_end == class_beg
1482 || *class_end != ':' || class_end[1] != ']')
1483 goto not_a_class_name;
1484
1485 bcopy (class_beg, class_name, class_end - class_beg);
1486 class_name[class_end - class_beg] = 0;
1487
1488 cc = re_wctype (class_name);
1489 if (cc == 0)
1490 error ("Invalid ISO C character class");
1491
1492 iso_classes = Fcons (make_number (cc), iso_classes);
1493
1494 i_byte = class_end + 2 - str;
1495 continue;
1496 }
1497
1498 not_a_class_name:
1451 if (c == '\\') 1499 if (c == '\\')
1452 { 1500 {
1453 if (i_byte == size_byte) 1501 if (i_byte == size_byte)
@@ -1534,6 +1582,42 @@ skip_chars (forwardp, string, lim)
1534 c = STRING_CHAR_AND_LENGTH (str + i_byte, size_byte-i_byte, len); 1582 c = STRING_CHAR_AND_LENGTH (str + i_byte, size_byte-i_byte, len);
1535 i_byte += len; 1583 i_byte += len;
1536 1584
1585 if (handle_iso_classes && c == '['
1586 && i_byte < size_byte
1587 && STRING_CHAR (str + i_byte, size_byte - i_byte) == ':')
1588 {
1589 const unsigned char *class_beg = str + i_byte + 1;
1590 const unsigned char *class_end = class_beg;
1591 const unsigned char *class_limit = str + size_byte - 2;
1592 /* Leave room for the null. */
1593 unsigned char class_name[CHAR_CLASS_MAX_LENGTH + 1];
1594 re_wctype_t cc;
1595
1596 if (class_limit - class_beg > CHAR_CLASS_MAX_LENGTH)
1597 class_limit = class_beg + CHAR_CLASS_MAX_LENGTH;
1598
1599 while (class_end < class_limit
1600 && *class_end >= 'a' && *class_end <= 'z')
1601 class_end++;
1602
1603 if (class_end == class_beg
1604 || *class_end != ':' || class_end[1] != ']')
1605 goto not_a_class_name_multibyte;
1606
1607 bcopy (class_beg, class_name, class_end - class_beg);
1608 class_name[class_end - class_beg] = 0;
1609
1610 cc = re_wctype (class_name);
1611 if (cc == 0)
1612 error ("Invalid ISO C character class");
1613
1614 iso_classes = Fcons (make_number (cc), iso_classes);
1615
1616 i_byte = class_end + 2 - str;
1617 continue;
1618 }
1619
1620 not_a_class_name_multibyte:
1537 if (c == '\\') 1621 if (c == '\\')
1538 { 1622 {
1539 if (i_byte == size_byte) 1623 if (i_byte == size_byte)
@@ -1643,13 +1727,13 @@ skip_chars (forwardp, string, lim)
1643 1727
1644 if (forwardp) 1728 if (forwardp)
1645 { 1729 {
1646 endp = (XINT (lim) == GPT) ? GPT_ADDR : CHAR_POS_ADDR (XINT (lim)); 1730 endp = (XINT (lim) == GPT) ? GPT_ADDR : CHAR_POS_ADDR (XINT (lim));
1647 stop = (pos < GPT && GPT < XINT (lim)) ? GPT_ADDR : endp; 1731 stop = (pos < GPT && GPT < XINT (lim)) ? GPT_ADDR : endp;
1648 } 1732 }
1649 else 1733 else
1650 { 1734 {
1651 endp = CHAR_POS_ADDR (XINT (lim)); 1735 endp = CHAR_POS_ADDR (XINT (lim));
1652 stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp; 1736 stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp;
1653 } 1737 }
1654 1738
1655 immediate_quit = 1; 1739 immediate_quit = 1;
@@ -1667,9 +1751,17 @@ skip_chars (forwardp, string, lim)
1667 p = GAP_END_ADDR; 1751 p = GAP_END_ADDR;
1668 stop = endp; 1752 stop = endp;
1669 } 1753 }
1754 c = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, nbytes);
1755 if (! NILP (iso_classes) && in_classes (c, iso_classes))
1756 {
1757 if (negate)
1758 break;
1759 else
1760 goto fwd_ok;
1761 }
1762
1670 if (! fastmap[*p]) 1763 if (! fastmap[*p])
1671 break; 1764 break;
1672 c = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, nbytes);
1673 if (! ASCII_CHAR_P (c)) 1765 if (! ASCII_CHAR_P (c))
1674 { 1766 {
1675 /* As we are looking at a multibyte character, we 1767 /* As we are looking at a multibyte character, we
@@ -1686,6 +1778,7 @@ skip_chars (forwardp, string, lim)
1686 if (!(negate ^ (i < n_char_ranges))) 1778 if (!(negate ^ (i < n_char_ranges)))
1687 break; 1779 break;
1688 } 1780 }
1781 fwd_ok:
1689 p += nbytes, pos++, pos_byte += nbytes; 1782 p += nbytes, pos++, pos_byte += nbytes;
1690 } 1783 }
1691 else 1784 else
@@ -1698,8 +1791,18 @@ skip_chars (forwardp, string, lim)
1698 p = GAP_END_ADDR; 1791 p = GAP_END_ADDR;
1699 stop = endp; 1792 stop = endp;
1700 } 1793 }
1794
1795 if (!NILP (iso_classes) && in_classes (*p, iso_classes))
1796 {
1797 if (negate)
1798 break;
1799 else
1800 goto fwd_unibyte_ok;
1801 }
1802
1701 if (!fastmap[*p]) 1803 if (!fastmap[*p])
1702 break; 1804 break;
1805 fwd_unibyte_ok:
1703 p++, pos++, pos_byte++; 1806 p++, pos++, pos_byte++;
1704 } 1807 }
1705 } 1808 }
@@ -1719,9 +1822,18 @@ skip_chars (forwardp, string, lim)
1719 } 1822 }
1720 prev_p = p; 1823 prev_p = p;
1721 while (--p >= stop && ! CHAR_HEAD_P (*p)); 1824 while (--p >= stop && ! CHAR_HEAD_P (*p));
1825 c = STRING_CHAR (p, MAX_MULTIBYTE_LENGTH);
1826
1827 if (! NILP (iso_classes) && in_classes (c, iso_classes))
1828 {
1829 if (negate)
1830 break;
1831 else
1832 goto back_ok;
1833 }
1834
1722 if (! fastmap[*p]) 1835 if (! fastmap[*p])
1723 break; 1836 break;
1724 c = STRING_CHAR (p, MAX_MULTIBYTE_LENGTH);
1725 if (! ASCII_CHAR_P (c)) 1837 if (! ASCII_CHAR_P (c))
1726 { 1838 {
1727 /* See the comment in the previous similar code. */ 1839 /* See the comment in the previous similar code. */
@@ -1731,6 +1843,7 @@ skip_chars (forwardp, string, lim)
1731 if (!(negate ^ (i < n_char_ranges))) 1843 if (!(negate ^ (i < n_char_ranges)))
1732 break; 1844 break;
1733 } 1845 }
1846 back_ok:
1734 pos--, pos_byte -= prev_p - p; 1847 pos--, pos_byte -= prev_p - p;
1735 } 1848 }
1736 else 1849 else
@@ -1743,8 +1856,18 @@ skip_chars (forwardp, string, lim)
1743 p = GPT_ADDR; 1856 p = GPT_ADDR;
1744 stop = endp; 1857 stop = endp;
1745 } 1858 }
1859
1860 if (! NILP (iso_classes) && in_classes (p[-1], iso_classes))
1861 {
1862 if (negate)
1863 break;
1864 else
1865 goto back_unibyte_ok;
1866 }
1867
1746 if (!fastmap[p[-1]]) 1868 if (!fastmap[p[-1]])
1747 break; 1869 break;
1870 back_unibyte_ok:
1748 p--, pos--, pos_byte--; 1871 p--, pos--, pos_byte--;
1749 } 1872 }
1750 } 1873 }
@@ -1927,6 +2050,30 @@ skip_syntaxes (forwardp, string, lim)
1927 return make_number (PT - start_point); 2050 return make_number (PT - start_point);
1928 } 2051 }
1929} 2052}
2053
2054/* Return 1 if character C belongs to one of the ISO classes
2055 in the list ISO_CLASSES. Each class is represented by an
2056 integer which is its type according to re_wctype. */
2057
2058static int
2059in_classes (c, iso_classes)
2060 int c;
2061 Lisp_Object iso_classes;
2062{
2063 int fits_class = 0;
2064
2065 while (! NILP (iso_classes))
2066 {
2067 Lisp_Object elt;
2068 elt = XCAR (iso_classes);
2069 iso_classes = XCDR (iso_classes);
2070
2071 if (re_iswctype (c, XFASTINT (elt)))
2072 fits_class = 1;
2073 }
2074
2075 return fits_class;
2076}
1930 2077
1931/* Jump over a comment, assuming we are at the beginning of one. 2078/* Jump over a comment, assuming we are at the beginning of one.
1932 FROM is the current position. 2079 FROM is the current position.
@@ -2310,7 +2457,8 @@ scan_lists (from, count, depth, sexpflag)
2310 INC_BOTH (from, from_byte); 2457 INC_BOTH (from, from_byte);
2311 UPDATE_SYNTAX_TABLE_FORWARD (from); 2458 UPDATE_SYNTAX_TABLE_FORWARD (from);
2312 if (from < stop && comstart_first 2459 if (from < stop && comstart_first
2313 && SYNTAX_COMSTART_SECOND (FETCH_CHAR_AS_MULTIBYTE (from_byte)) 2460 && (c = FETCH_CHAR_AS_MULTIBYTE (from_byte),
2461 SYNTAX_COMSTART_SECOND (c))
2314 && parse_sexp_ignore_comments) 2462 && parse_sexp_ignore_comments)
2315 { 2463 {
2316 /* we have encountered a comment start sequence and we 2464 /* we have encountered a comment start sequence and we
@@ -2636,7 +2784,7 @@ scan_lists (from, count, depth, sexpflag)
2636 Fcons (build_string ("Unbalanced parentheses"), 2784 Fcons (build_string ("Unbalanced parentheses"),
2637 Fcons (make_number (last_good), 2785 Fcons (make_number (last_good),
2638 Fcons (make_number (from), Qnil)))); 2786 Fcons (make_number (from), Qnil))));
2639 2787 abort ();
2640 /* NOTREACHED */ 2788 /* NOTREACHED */
2641} 2789}
2642 2790
@@ -2776,8 +2924,8 @@ scan_sexps_forward (stateptr, from, from_byte, end, targetdepth,
2776#define INC_FROM \ 2924#define INC_FROM \
2777do { prev_from = from; \ 2925do { prev_from = from; \
2778 prev_from_byte = from_byte; \ 2926 prev_from_byte = from_byte; \
2779 prev_from_syntax \ 2927 temp = FETCH_CHAR_AS_MULTIBYTE (prev_from_byte); \
2780 = SYNTAX_WITH_FLAGS (FETCH_CHAR_AS_MULTIBYTE (prev_from_byte)); \ 2928 prev_from_syntax = SYNTAX_WITH_FLAGS (temp); \
2781 INC_BOTH (from, from_byte); \ 2929 INC_BOTH (from, from_byte); \
2782 if (from < end) \ 2930 if (from < end) \
2783 UPDATE_SYNTAX_TABLE_FORWARD (from); \ 2931 UPDATE_SYNTAX_TABLE_FORWARD (from); \
@@ -2852,7 +3000,8 @@ do { prev_from = from; \
2852 curlevel->last = -1; 3000 curlevel->last = -1;
2853 3001
2854 SETUP_SYNTAX_TABLE (prev_from, 1); 3002 SETUP_SYNTAX_TABLE (prev_from, 1);
2855 prev_from_syntax = SYNTAX_WITH_FLAGS (FETCH_CHAR (prev_from_byte)); 3003 temp = FETCH_CHAR (prev_from_byte);
3004 prev_from_syntax = SYNTAX_WITH_FLAGS (temp);
2856 UPDATE_SYNTAX_TABLE_FORWARD (from); 3005 UPDATE_SYNTAX_TABLE_FORWARD (from);
2857 3006
2858 /* Enter the loop at a place appropriate for initial state. */ 3007 /* Enter the loop at a place appropriate for initial state. */
@@ -2931,7 +3080,8 @@ do { prev_from = from; \
2931 while (from < end) 3080 while (from < end)
2932 { 3081 {
2933 /* Some compilers can't handle this inside the switch. */ 3082 /* Some compilers can't handle this inside the switch. */
2934 temp = SYNTAX (FETCH_CHAR_AS_MULTIBYTE (from_byte)); 3083 temp = FETCH_CHAR_AS_MULTIBYTE (from_byte);
3084 temp = SYNTAX (temp);
2935 switch (temp) 3085 switch (temp)
2936 { 3086 {
2937 case Scharquote: 3087 case Scharquote: