Mercurial > emacs
comparison src/syntax.c @ 13144:fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
(Fmodify_syntax_entry, init_syntax_once): Use SET_RAW_SYNTAX_ENTRY.
Handle new syntax-table data format.
(check_syntax_table): Use CHECK_CHAR_TABLE. Now static.
Don't return anything; callers changed.
(Fcopy_syntax_table): Use Fcopy_sequence.
(Fchar_syntax, Fmatching_paren, Fforward_comment): Copy complex args
to SYNTAX into variables before using them.
(Fsyntax_table_p): Accept any char-table.
(syntax_parent_lookup): New function.
(syntax_temp): New variable.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Sat, 07 Oct 1995 21:59:28 +0000 |
| parents | b2a75405de3c |
| children | d2fc560c7740 |
comparison
equal
deleted
inserted
replaced
| 13143:ba670977cceb | 13144:fd14ccddb85a |
|---|---|
| 29 | 29 |
| 30 static void scan_sexps_forward (); | 30 static void scan_sexps_forward (); |
| 31 static int char_quoted (); | 31 static int char_quoted (); |
| 32 | 32 |
| 33 int words_include_escapes; | 33 int words_include_escapes; |
| 34 | |
| 35 /* Used as a temporary in SYNTAX_ENTRY and other macros in syntax.h, | |
| 36 if not compiled with GCC. No need to mark it, since it is used | |
| 37 only very temporarily. */ | |
| 38 Lisp_Object syntax_temp; | |
| 34 | 39 |
| 35 /* This is the internal form of the parse state used in parse-partial-sexp. */ | 40 /* This is the internal form of the parse state used in parse-partial-sexp. */ |
| 36 | 41 |
| 37 struct lisp_parse_state | 42 struct lisp_parse_state |
| 38 { | 43 { |
| 105 return find_start_value; | 110 return find_start_value; |
| 106 } | 111 } |
| 107 | 112 |
| 108 DEFUN ("syntax-table-p", Fsyntax_table_p, Ssyntax_table_p, 1, 1, 0, | 113 DEFUN ("syntax-table-p", Fsyntax_table_p, Ssyntax_table_p, 1, 1, 0, |
| 109 "Return t if ARG is a syntax table.\n\ | 114 "Return t if ARG is a syntax table.\n\ |
| 110 Any vector of 256 elements will do.") | 115 Currently, any char-table counts as a syntax table.") |
| 111 (obj) | 116 (obj) |
| 112 Lisp_Object obj; | 117 Lisp_Object obj; |
| 113 { | 118 { |
| 114 if (VECTORP (obj) && XVECTOR (obj)->size == 0400) | 119 if (CHAR_TABLE_P (obj)) |
| 115 return Qt; | 120 return Qt; |
| 116 return Qnil; | 121 return Qnil; |
| 117 } | 122 } |
| 118 | 123 |
| 119 Lisp_Object | 124 static void |
| 120 check_syntax_table (obj) | 125 check_syntax_table (obj) |
| 121 Lisp_Object obj; | 126 Lisp_Object obj; |
| 122 { | 127 { |
| 123 register Lisp_Object tem; | 128 CHECK_CHAR_TABLE (obj, 0); |
| 124 while (tem = Fsyntax_table_p (obj), | |
| 125 NILP (tem)) | |
| 126 obj = wrong_type_argument (Qsyntax_table_p, obj); | |
| 127 return obj; | |
| 128 } | 129 } |
| 129 | 130 |
| 130 | 131 |
| 131 DEFUN ("syntax-table", Fsyntax_table, Ssyntax_table, 0, 0, 0, | 132 DEFUN ("syntax-table", Fsyntax_table, Ssyntax_table, 0, 0, 0, |
| 132 "Return the current syntax table.\n\ | 133 "Return the current syntax table.\n\ |
| 149 "Construct a new syntax table and return it.\n\ | 150 "Construct a new syntax table and return it.\n\ |
| 150 It is a copy of the TABLE, which defaults to the standard syntax table.") | 151 It is a copy of the TABLE, which defaults to the standard syntax table.") |
| 151 (table) | 152 (table) |
| 152 Lisp_Object table; | 153 Lisp_Object table; |
| 153 { | 154 { |
| 154 Lisp_Object size, val; | 155 Lisp_Object copy; |
| 155 XSETFASTINT (size, 0400); | 156 |
| 156 XSETFASTINT (val, 0); | |
| 157 val = Fmake_vector (size, val); | |
| 158 if (!NILP (table)) | 157 if (!NILP (table)) |
| 159 table = check_syntax_table (table); | 158 check_syntax_table (table); |
| 160 else if (NILP (Vstandard_syntax_table)) | 159 else |
| 161 /* Can only be null during initialization */ | 160 table = Vstandard_syntax_table; |
| 162 return val; | 161 |
| 163 else table = Vstandard_syntax_table; | 162 copy = Fcopy_sequence (table); |
| 164 | 163 Fset_char_table_parent (copy, Vstandard_syntax_table); |
| 165 bcopy (XVECTOR (table)->contents, | 164 return copy; |
| 166 XVECTOR (val)->contents, 0400 * sizeof (Lisp_Object)); | |
| 167 return val; | |
| 168 } | 165 } |
| 169 | 166 |
| 170 DEFUN ("set-syntax-table", Fset_syntax_table, Sset_syntax_table, 1, 1, 0, | 167 DEFUN ("set-syntax-table", Fset_syntax_table, Sset_syntax_table, 1, 1, 0, |
| 171 "Select a new syntax table for the current buffer.\n\ | 168 "Select a new syntax table for the current buffer.\n\ |
| 172 One argument, a syntax table.") | 169 One argument, a syntax table.") |
| 173 (table) | 170 (table) |
| 174 Lisp_Object table; | 171 Lisp_Object table; |
| 175 { | 172 { |
| 176 table = check_syntax_table (table); | 173 check_syntax_table (table); |
| 177 current_buffer->syntax_table = table; | 174 current_buffer->syntax_table = table; |
| 178 /* Indicate that this buffer now has a specified syntax table. */ | 175 /* Indicate that this buffer now has a specified syntax table. */ |
| 179 current_buffer->local_var_flags | 176 current_buffer->local_var_flags |
| 180 |= XFASTINT (buffer_local_flags.syntax_table); | 177 |= XFASTINT (buffer_local_flags.syntax_table); |
| 181 return table; | 178 return table; |
| 212 char syntax_code_spec[14] = | 209 char syntax_code_spec[14] = |
| 213 { | 210 { |
| 214 ' ', '.', 'w', '_', '(', ')', '\'', '\"', '$', '\\', '/', '<', '>', '@' | 211 ' ', '.', 'w', '_', '(', ')', '\'', '\"', '$', '\\', '/', '<', '>', '@' |
| 215 }; | 212 }; |
| 216 | 213 |
| 214 /* Look up the value for CHARACTER in syntax table TABLE's parent | |
| 215 and its parents. SYNTAX_ENTRY calls this, when TABLE itself has nil | |
| 216 for CHARACTER. It's actually used only when not compiled with GCC. */ | |
| 217 | |
| 218 Lisp_Object | |
| 219 syntax_parent_lookup (table, character) | |
| 220 Lisp_Object table; | |
| 221 int character; | |
| 222 { | |
| 223 Lisp_Object value; | |
| 224 | |
| 225 while (1) | |
| 226 { | |
| 227 table = XCHAR_TABLE (table)->parent; | |
| 228 if (NILP (table)) | |
| 229 return Qnil; | |
| 230 | |
| 231 value = XCHAR_TABLE (table)->contents[character]; | |
| 232 if (!NILP (value)) | |
| 233 return value; | |
| 234 } | |
| 235 } | |
| 236 | |
| 217 DEFUN ("char-syntax", Fchar_syntax, Schar_syntax, 1, 1, 0, | 237 DEFUN ("char-syntax", Fchar_syntax, Schar_syntax, 1, 1, 0, |
| 218 "Return the syntax code of CHAR, described by a character.\n\ | 238 "Return the syntax code of CHAR, described by a character.\n\ |
| 219 For example, if CHAR is a word constituent, the character `?w' is returned.\n\ | 239 For example, if CHAR is a word constituent, the character `?w' is returned.\n\ |
| 220 The characters that correspond to various syntax codes\n\ | 240 The characters that correspond to various syntax codes\n\ |
| 221 are listed in the documentation of `modify-syntax-entry'.") | 241 are listed in the documentation of `modify-syntax-entry'.") |
| 222 (ch) | 242 (ch) |
| 223 Lisp_Object ch; | 243 Lisp_Object ch; |
| 224 { | 244 { |
| 245 int char_int; | |
| 225 CHECK_NUMBER (ch, 0); | 246 CHECK_NUMBER (ch, 0); |
| 226 return make_number (syntax_code_spec[(int) SYNTAX (XINT (ch))]); | 247 char_int = XINT (ch); |
| 248 return make_number (syntax_code_spec[(int) SYNTAX (char_int)]); | |
| 227 } | 249 } |
| 228 | 250 |
| 229 DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0, | 251 DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0, |
| 230 "Return the matching parenthesis of CHAR, or nil if none.") | 252 "Return the matching parenthesis of CHAR, or nil if none.") |
| 231 (ch) | 253 (ch) |
| 232 Lisp_Object ch; | 254 Lisp_Object ch; |
| 233 { | 255 { |
| 234 int code; | 256 int char_int, code; |
| 235 CHECK_NUMBER (ch, 0); | 257 CHECK_NUMBER (ch, 0); |
| 236 code = SYNTAX (XINT (ch)); | 258 char_int = XINT (ch); |
| 259 code = SYNTAX (char_int); | |
| 237 if (code == Sopen || code == Sclose) | 260 if (code == Sopen || code == Sclose) |
| 238 return make_number (SYNTAX_MATCH (XINT (ch))); | 261 return make_number (SYNTAX_MATCH (char_int)); |
| 239 return Qnil; | 262 return Qnil; |
| 240 } | 263 } |
| 241 | 264 |
| 242 /* This comment supplies the doc string for modify-syntax-entry, | 265 /* This comment supplies the doc string for modify-syntax-entry, |
| 243 for make-docfile to see. We cannot put this in the real DEFUN | 266 for make-docfile to see. We cannot put this in the real DEFUN |
| 287 "cSet syntax for character: \nsSet syntax for %s to: ", | 310 "cSet syntax for character: \nsSet syntax for %s to: ", |
| 288 0 /* See immediately above */) | 311 0 /* See immediately above */) |
| 289 (c, newentry, syntax_table) | 312 (c, newentry, syntax_table) |
| 290 Lisp_Object c, newentry, syntax_table; | 313 Lisp_Object c, newentry, syntax_table; |
| 291 { | 314 { |
| 292 register unsigned char *p, match; | 315 register unsigned char *p; |
| 293 register enum syntaxcode code; | 316 register enum syntaxcode code; |
| 294 int val; | 317 int val; |
| 318 Lisp_Object match; | |
| 295 | 319 |
| 296 CHECK_NUMBER (c, 0); | 320 CHECK_NUMBER (c, 0); |
| 297 CHECK_STRING (newentry, 1); | 321 CHECK_STRING (newentry, 1); |
| 322 | |
| 298 if (NILP (syntax_table)) | 323 if (NILP (syntax_table)) |
| 299 syntax_table = current_buffer->syntax_table; | 324 syntax_table = current_buffer->syntax_table; |
| 300 else | 325 else |
| 301 syntax_table = check_syntax_table (syntax_table); | 326 check_syntax_table (syntax_table); |
| 302 | 327 |
| 303 p = XSTRING (newentry)->data; | 328 p = XSTRING (newentry)->data; |
| 304 code = (enum syntaxcode) syntax_spec_code[*p++]; | 329 code = (enum syntaxcode) syntax_spec_code[*p++]; |
| 305 if (((int) code & 0377) == 0377) | 330 if (((int) code & 0377) == 0377) |
| 306 error ("invalid syntax description letter: %c", c); | 331 error ("invalid syntax description letter: %c", c); |
| 307 | 332 |
| 308 match = *p; | 333 if (code == Sinherit) |
| 309 if (match) p++; | 334 { |
| 310 if (match == ' ') match = 0; | 335 SET_RAW_SYNTAX_ENTRY (syntax_table, c, Qnil); |
| 311 | 336 return Qnil; |
| 312 val = (match << 8) + (int) code; | 337 } |
| 338 | |
| 339 if (*p) | |
| 340 XSETINT (match, *p++); | |
| 341 if (XFASTINT (match) == ' ') | |
| 342 match = Qnil; | |
| 343 | |
| 344 val = (int) code; | |
| 313 while (*p) | 345 while (*p) |
| 314 switch (*p++) | 346 switch (*p++) |
| 315 { | 347 { |
| 316 case '1': | 348 case '1': |
| 317 val |= 1 << 16; | 349 val |= 1 << 16; |
| 336 case 'b': | 368 case 'b': |
| 337 val |= 1 << 21; | 369 val |= 1 << 21; |
| 338 break; | 370 break; |
| 339 } | 371 } |
| 340 | 372 |
| 341 XSETFASTINT (XVECTOR (syntax_table)->contents[0xFF & XINT (c)], val); | 373 SET_RAW_SYNTAX_ENTRY (syntax_table, c, |
| 374 Fcons (make_number (val), match)); | |
| 342 | 375 |
| 343 return Qnil; | 376 return Qnil; |
| 344 } | 377 } |
| 345 | 378 |
| 346 /* Dump syntax table to buffer in human-readable format */ | 379 /* Dump syntax table to buffer in human-readable format */ |
| 350 Lisp_Object value; | 383 Lisp_Object value; |
| 351 { | 384 { |
| 352 register enum syntaxcode code; | 385 register enum syntaxcode code; |
| 353 char desc, match, start1, start2, end1, end2, prefix, comstyle; | 386 char desc, match, start1, start2, end1, end2, prefix, comstyle; |
| 354 char str[2]; | 387 char str[2]; |
| 388 Lisp_Object first, match_lisp; | |
| 355 | 389 |
| 356 Findent_to (make_number (16), make_number (1)); | 390 Findent_to (make_number (16), make_number (1)); |
| 357 | 391 |
| 358 if (!INTEGERP (value)) | 392 if (NILP (value)) |
| 393 { | |
| 394 insert_string ("inherit"); | |
| 395 return; | |
| 396 } | |
| 397 | |
| 398 if (!CONSP (value)) | |
| 359 { | 399 { |
| 360 insert_string ("invalid"); | 400 insert_string ("invalid"); |
| 361 return; | 401 return; |
| 362 } | 402 } |
| 363 | 403 |
| 364 code = (enum syntaxcode) (XINT (value) & 0377); | 404 first = XCONS (value)->car; |
| 365 match = (XINT (value) >> 8) & 0377; | 405 match_lisp = XCONS (value)->cdr; |
| 366 start1 = (XINT (value) >> 16) & 1; | 406 |
| 367 start2 = (XINT (value) >> 17) & 1; | 407 if (!INTEGERP (first) || !(NILP (match_lisp) || INTEGERP (match_lisp))) |
| 368 end1 = (XINT (value) >> 18) & 1; | |
| 369 end2 = (XINT (value) >> 19) & 1; | |
| 370 prefix = (XINT (value) >> 20) & 1; | |
| 371 comstyle = (XINT (value) >> 21) & 1; | |
| 372 | |
| 373 if ((int) code < 0 || (int) code >= (int) Smax) | |
| 374 { | 408 { |
| 375 insert_string ("invalid"); | 409 insert_string ("invalid"); |
| 376 return; | 410 return; |
| 377 } | 411 } |
| 412 | |
| 413 code = (enum syntaxcode) (first & 0377); | |
| 414 start1 = (XINT (first) >> 16) & 1; | |
| 415 start2 = (XINT (first) >> 17) & 1; | |
| 416 end1 = (XINT (first) >> 18) & 1; | |
| 417 end2 = (XINT (first) >> 19) & 1; | |
| 418 prefix = (XINT (first) >> 20) & 1; | |
| 419 comstyle = (XINT (first) >> 21) & 1; | |
| 420 | |
| 421 if ((int) code < 0 || (int) code >= (int) Smax) | |
| 422 { | |
| 423 insert_string ("invalid"); | |
| 424 return; | |
| 425 } | |
| 378 desc = syntax_code_spec[(int) code]; | 426 desc = syntax_code_spec[(int) code]; |
| 379 | 427 |
| 380 str[0] = desc, str[1] = 0; | 428 str[0] = desc, str[1] = 0; |
| 381 insert (str, 1); | 429 insert (str, 1); |
| 382 | 430 |
| 383 str[0] = match ? match : ' '; | 431 str[0] = !NILP (match_lisp) ? XINT (match_lisp) : ' '; |
| 384 insert (str, 1); | 432 insert (str, 1); |
| 385 | |
| 386 | 433 |
| 387 if (start1) | 434 if (start1) |
| 388 insert ("1", 1); | 435 insert ("1", 1); |
| 389 if (start2) | 436 if (start2) |
| 390 insert ("2", 1); | 437 insert ("2", 1); |
| 427 insert_string ("charquote"); break; | 474 insert_string ("charquote"); break; |
| 428 case Scomment: | 475 case Scomment: |
| 429 insert_string ("comment"); break; | 476 insert_string ("comment"); break; |
| 430 case Sendcomment: | 477 case Sendcomment: |
| 431 insert_string ("endcomment"); break; | 478 insert_string ("endcomment"); break; |
| 432 case Sinherit: | |
| 433 insert_string ("inherit"); break; | |
| 434 default: | 479 default: |
| 435 insert_string ("invalid"); | 480 insert_string ("invalid"); |
| 436 return; | 481 return; |
| 437 } | 482 } |
| 438 | 483 |
| 439 if (match) | 484 if (!NILP (match_lisp)) |
| 440 { | 485 { |
| 441 insert_string (", matches "); | 486 insert_string (", matches "); |
| 442 insert_char (match); | 487 insert_char (XINT (match_lisp)); |
| 443 } | 488 } |
| 444 | 489 |
| 445 if (start1) | 490 if (start1) |
| 446 insert_string (",\n\t is the first character of a comment-start sequence"); | 491 insert_string (",\n\t is the first character of a comment-start sequence"); |
| 447 if (start2) | 492 if (start2) |
| 491 register int from, count; | 536 register int from, count; |
| 492 { | 537 { |
| 493 register int beg = BEGV; | 538 register int beg = BEGV; |
| 494 register int end = ZV; | 539 register int end = ZV; |
| 495 register int code; | 540 register int code; |
| 541 int charcode; | |
| 496 | 542 |
| 497 immediate_quit = 1; | 543 immediate_quit = 1; |
| 498 QUIT; | 544 QUIT; |
| 499 | 545 |
| 500 while (count > 0) | 546 while (count > 0) |
| 504 if (from == end) | 550 if (from == end) |
| 505 { | 551 { |
| 506 immediate_quit = 0; | 552 immediate_quit = 0; |
| 507 return 0; | 553 return 0; |
| 508 } | 554 } |
| 509 code = SYNTAX (FETCH_CHAR (from)); | 555 charcode = FETCH_CHAR (from); |
| 556 code = SYNTAX (charcode); | |
| 510 if (words_include_escapes | 557 if (words_include_escapes |
| 511 && (code == Sescape || code == Scharquote)) | 558 && (code == Sescape || code == Scharquote)) |
| 512 break; | 559 break; |
| 513 if (code == Sword) | 560 if (code == Sword) |
| 514 break; | 561 break; |
| 515 from++; | 562 from++; |
| 516 } | 563 } |
| 517 while (1) | 564 while (1) |
| 518 { | 565 { |
| 519 if (from == end) break; | 566 if (from == end) break; |
| 520 code = SYNTAX (FETCH_CHAR (from)); | 567 charcode = FETCH_CHAR (from); |
| 568 code = SYNTAX (charcode); | |
| 521 if (!(words_include_escapes | 569 if (!(words_include_escapes |
| 522 && (code == Sescape || code == Scharquote))) | 570 && (code == Sescape || code == Scharquote))) |
| 523 if (code != Sword) | 571 if (code != Sword) |
| 524 break; | 572 break; |
| 525 from++; | 573 from++; |
| 533 if (from == beg) | 581 if (from == beg) |
| 534 { | 582 { |
| 535 immediate_quit = 0; | 583 immediate_quit = 0; |
| 536 return 0; | 584 return 0; |
| 537 } | 585 } |
| 538 code = SYNTAX (FETCH_CHAR (from - 1)); | 586 charcode = FETCH_CHAR (from - 1); |
| 587 code = SYNTAX (charcode); | |
| 539 if (words_include_escapes | 588 if (words_include_escapes |
| 540 && (code == Sescape || code == Scharquote)) | 589 && (code == Sescape || code == Scharquote)) |
| 541 break; | 590 break; |
| 542 if (code == Sword) | 591 if (code == Sword) |
| 543 break; | 592 break; |
| 544 from--; | 593 from--; |
| 545 } | 594 } |
| 546 while (1) | 595 while (1) |
| 547 { | 596 { |
| 548 if (from == beg) break; | 597 if (from == beg) break; |
| 549 code = SYNTAX (FETCH_CHAR (from - 1)); | 598 charcode = FETCH_CHAR (from - 1); |
| 599 code = SYNTAX (charcode); | |
| 550 if (!(words_include_escapes | 600 if (!(words_include_escapes |
| 551 && (code == Sescape || code == Scharquote))) | 601 && (code == Sescape || code == Scharquote))) |
| 552 if (code != Sword) | 602 if (code != Sword) |
| 553 break; | 603 break; |
| 554 from--; | 604 from--; |
| 590 (count) | 640 (count) |
| 591 Lisp_Object count; | 641 Lisp_Object count; |
| 592 { | 642 { |
| 593 register int from; | 643 register int from; |
| 594 register int stop; | 644 register int stop; |
| 595 register int c; | 645 register int c, c1; |
| 596 register enum syntaxcode code; | 646 register enum syntaxcode code; |
| 597 int comstyle = 0; /* style of comment encountered */ | 647 int comstyle = 0; /* style of comment encountered */ |
| 598 int found; | 648 int found; |
| 599 int count1; | 649 int count1; |
| 600 | 650 |
| 620 c = FETCH_CHAR (from); | 670 c = FETCH_CHAR (from); |
| 621 code = SYNTAX (c); | 671 code = SYNTAX (c); |
| 622 from++; | 672 from++; |
| 623 comstyle = 0; | 673 comstyle = 0; |
| 624 if (from < stop && SYNTAX_COMSTART_FIRST (c) | 674 if (from < stop && SYNTAX_COMSTART_FIRST (c) |
| 625 && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from))) | 675 && (c1 = FETCH_CHAR (from), |
| 676 SYNTAX_COMSTART_SECOND (c1))) | |
| 626 { | 677 { |
| 627 /* We have encountered a comment start sequence and we | 678 /* We have encountered a comment start sequence and we |
| 628 are ignoring all text inside comments. We must record | 679 are ignoring all text inside comments. We must record |
| 629 the comment style this sequence begins so that later, | 680 the comment style this sequence begins so that later, |
| 630 only a comment end of the same style actually ends | 681 only a comment end of the same style actually ends |
| 631 the comment section. */ | 682 the comment section. */ |
| 632 code = Scomment; | 683 code = Scomment; |
| 633 comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from)); | 684 comstyle = SYNTAX_COMMENT_STYLE (c1); |
| 634 from++; | 685 from++; |
| 635 } | 686 } |
| 636 } | 687 } |
| 637 while (code == Swhitespace || code == Sendcomment); | 688 while (code == Swhitespace || code == Sendcomment); |
| 638 if (code != Scomment) | 689 if (code != Scomment) |
| 657 /* we have encountered a comment end of the same style | 708 /* we have encountered a comment end of the same style |
| 658 as the comment sequence which began this comment | 709 as the comment sequence which began this comment |
| 659 section */ | 710 section */ |
| 660 break; | 711 break; |
| 661 if (from < stop && SYNTAX_COMEND_FIRST (c) | 712 if (from < stop && SYNTAX_COMEND_FIRST (c) |
| 662 && SYNTAX_COMEND_SECOND (FETCH_CHAR (from)) | 713 && (c1 = FETCH_CHAR (from), |
| 714 SYNTAX_COMEND_SECOND (c1)) | |
| 663 && SYNTAX_COMMENT_STYLE (c) == comstyle) | 715 && SYNTAX_COMMENT_STYLE (c) == comstyle) |
| 664 /* we have encountered a comment end of the same style | 716 /* we have encountered a comment end of the same style |
| 665 as the comment sequence which began this comment | 717 as the comment sequence which began this comment |
| 666 section */ | 718 section */ |
| 667 { from++; break; } | 719 { from++; break; } |
| 685 code = SYNTAX (c); | 737 code = SYNTAX (c); |
| 686 comstyle = 0; | 738 comstyle = 0; |
| 687 if (code == Sendcomment) | 739 if (code == Sendcomment) |
| 688 comstyle = SYNTAX_COMMENT_STYLE (c); | 740 comstyle = SYNTAX_COMMENT_STYLE (c); |
| 689 if (from > stop && SYNTAX_COMEND_SECOND (c) | 741 if (from > stop && SYNTAX_COMEND_SECOND (c) |
| 690 && SYNTAX_COMEND_FIRST (FETCH_CHAR (from - 1)) | 742 && (c1 = FETCH_CHAR (from - 1), |
| 743 SYNTAX_COMEND_FIRST (c1)) | |
| 691 && !char_quoted (from - 1)) | 744 && !char_quoted (from - 1)) |
| 692 { | 745 { |
| 693 /* We must record the comment style encountered so that | 746 /* We must record the comment style encountered so that |
| 694 later, we can match only the proper comment begin | 747 later, we can match only the proper comment begin |
| 695 sequence of the same style. */ | 748 sequence of the same style. */ |
| 696 code = Sendcomment; | 749 code = Sendcomment; |
| 697 comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from - 1)); | 750 comstyle = SYNTAX_COMMENT_STYLE (c1); |
| 698 from--; | 751 from--; |
| 699 } | 752 } |
| 700 | 753 |
| 701 if (code == Sendcomment && !quoted) | 754 if (code == Sendcomment && !quoted) |
| 702 { | 755 { |
| 706 it does end a comment. So scan back in a simple way. */ | 759 it does end a comment. So scan back in a simple way. */ |
| 707 { | 760 { |
| 708 if (from != stop) from--; | 761 if (from != stop) from--; |
| 709 while (1) | 762 while (1) |
| 710 { | 763 { |
| 711 if (SYNTAX (c = FETCH_CHAR (from)) == Scomment | 764 if ((c = FETCH_CHAR (from), |
| 765 SYNTAX (c) == Scomment) | |
| 712 && SYNTAX_COMMENT_STYLE (c) == comstyle) | 766 && SYNTAX_COMMENT_STYLE (c) == comstyle) |
| 713 break; | 767 break; |
| 714 if (from == stop) | 768 if (from == stop) |
| 715 { | 769 { |
| 716 immediate_quit = 0; | 770 immediate_quit = 0; |
| 717 SET_PT (from); | 771 SET_PT (from); |
| 718 return Qnil; | 772 return Qnil; |
| 719 } | 773 } |
| 720 from--; | 774 from--; |
| 721 if (SYNTAX_COMSTART_SECOND (c) | 775 if (SYNTAX_COMSTART_SECOND (c) |
| 722 && SYNTAX_COMSTART_FIRST (FETCH_CHAR (from)) | 776 && (c1 = FETCH_CHAR (from), |
| 777 SYNTAX_COMSTART_FIRST (c1)) | |
| 723 && SYNTAX_COMMENT_STYLE (c) == comstyle | 778 && SYNTAX_COMMENT_STYLE (c) == comstyle |
| 724 && !char_quoted (from)) | 779 && !char_quoted (from)) |
| 725 break; | 780 break; |
| 726 } | 781 } |
| 727 break; | 782 break; |
| 1661 } | 1716 } |
| 1662 | 1717 |
| 1663 init_syntax_once () | 1718 init_syntax_once () |
| 1664 { | 1719 { |
| 1665 register int i; | 1720 register int i; |
| 1666 register struct Lisp_Vector *v; | 1721 Lisp_Object temp; |
| 1667 | 1722 |
| 1668 /* Set this now, so first buffer creation can refer to it. */ | 1723 temp = Fcons (make_number ((int) Swhitespace), Qnil); |
| 1669 /* Make it nil before calling copy-syntax-table | 1724 |
| 1670 so that copy-syntax-table will know not to try to copy from garbage */ | 1725 Vstandard_syntax_table = Fmake_char_table (make_number (0), temp); |
| 1671 Vstandard_syntax_table = Qnil; | 1726 |
| 1672 Vstandard_syntax_table = Fcopy_syntax_table (Qnil); | 1727 temp = Fcons (make_number ((int) Sword), Qnil); |
| 1673 | |
| 1674 v = XVECTOR (Vstandard_syntax_table); | |
| 1675 | |
| 1676 for (i = 'a'; i <= 'z'; i++) | 1728 for (i = 'a'; i <= 'z'; i++) |
| 1677 XSETFASTINT (v->contents[i], (int) Sword); | 1729 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); |
| 1678 for (i = 'A'; i <= 'Z'; i++) | 1730 for (i = 'A'; i <= 'Z'; i++) |
| 1679 XSETFASTINT (v->contents[i], (int) Sword); | 1731 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); |
| 1680 for (i = '0'; i <= '9'; i++) | 1732 for (i = '0'; i <= '9'; i++) |
| 1681 XSETFASTINT (v->contents[i], (int) Sword); | 1733 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); |
| 1682 XSETFASTINT (v->contents['$'], (int) Sword); | 1734 |
| 1683 XSETFASTINT (v->contents['%'], (int) Sword); | 1735 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '$', temp); |
| 1684 | 1736 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '%', temp); |
| 1685 XSETFASTINT (v->contents['('], (int) Sopen + (')' << 8)); | 1737 |
| 1686 XSETFASTINT (v->contents[')'], (int) Sclose + ('(' << 8)); | 1738 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '(', |
| 1687 XSETFASTINT (v->contents['['], (int) Sopen + (']' << 8)); | 1739 Fcons (make_number (Sopen), make_number (')'))); |
| 1688 XSETFASTINT (v->contents[']'], (int) Sclose + ('[' << 8)); | 1740 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, ')', |
| 1689 XSETFASTINT (v->contents['{'], (int) Sopen + ('}' << 8)); | 1741 Fcons (make_number (Sclose), make_number ('('))); |
| 1690 XSETFASTINT (v->contents['}'], (int) Sclose + ('{' << 8)); | 1742 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '[', |
| 1691 XSETFASTINT (v->contents['"'], (int) Sstring); | 1743 Fcons (make_number (Sopen), make_number (']'))); |
| 1692 XSETFASTINT (v->contents['\\'], (int) Sescape); | 1744 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, ']', |
| 1693 | 1745 Fcons (make_number (Sclose), make_number ('['))); |
| 1746 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '{', | |
| 1747 Fcons (make_number (Sopen), make_number ('}'))); | |
| 1748 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '}', | |
| 1749 Fcons (make_number (Sclose), make_number ('{'))); | |
| 1750 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '"', | |
| 1751 Fcons (make_number ((int) Sstring), Qnil)); | |
| 1752 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '\\', | |
| 1753 Fcons (make_number ((int) Sescape), Qnil)); | |
| 1754 | |
| 1755 temp = Fcons (make_number ((int) Ssymbol), Qnil); | |
| 1694 for (i = 0; i < 10; i++) | 1756 for (i = 0; i < 10; i++) |
| 1695 XSETFASTINT (v->contents["_-+*/&|<>="[i]], (int) Ssymbol); | 1757 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, "_-+*/&|<>="[i], temp); |
| 1696 | 1758 |
| 1759 temp = Fcons (make_number ((int) Spunct), Qnil); | |
| 1697 for (i = 0; i < 12; i++) | 1760 for (i = 0; i < 12; i++) |
| 1698 XSETFASTINT (v->contents[".,;:?!#@~^'`"[i]], (int) Spunct); | 1761 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, ".,;:?!#@~^'`"[i], temp); |
| 1699 } | 1762 } |
| 1700 | 1763 |
| 1701 syms_of_syntax () | 1764 syms_of_syntax () |
| 1702 { | 1765 { |
| 1703 Qsyntax_table_p = intern ("syntax-table-p"); | 1766 Qsyntax_table_p = intern ("syntax-table-p"); |
