comparison src/syntax.c @ 5118:e0db3c197671 ben-lisp-object

merge up to latest default branch, doesn't compile yet
author Ben Wing <ben@xemacs.org>
date Sat, 26 Dec 2009 21:18:49 -0600
parents aa5ed11f473b
children d1247f3cc363
comparison
equal deleted inserted replaced
5117:3742ea8250b5 5118:e0db3c197671
28 #include "lisp.h" 28 #include "lisp.h"
29 29
30 #include "buffer.h" 30 #include "buffer.h"
31 #include "syntax.h" 31 #include "syntax.h"
32 #include "extents.h" 32 #include "extents.h"
33
34 #ifdef NEW_GC
35 # define UNUSED_IF_NEW_GC(decl) UNUSED (decl)
36 #else
37 # define UNUSED_IF_NEW_GC(decl) decl
38 #endif
33 39
34 #define ST_COMMENT_STYLE 0x101 40 #define ST_COMMENT_STYLE 0x101
35 #define ST_STRING_STYLE 0x102 41 #define ST_STRING_STYLE 0x102
36 42
37 Lisp_Object Qsyntax_table; 43 Lisp_Object Qsyntax_table;
144 return find_start_value; 150 return find_start_value;
145 } 151 }
146 152
147 DEFUN ("syntax-table-p", Fsyntax_table_p, 1, 1, 0, /* 153 DEFUN ("syntax-table-p", Fsyntax_table_p, 1, 1, 0, /*
148 Return t if OBJECT is a syntax table. 154 Return t if OBJECT is a syntax table.
149 Any vector of 256 elements will do.
150 */ 155 */
151 (object)) 156 (object))
152 { 157 {
153 return (CHAR_TABLEP (object) 158 return (CHAR_TABLEP (object)
154 && XCHAR_TABLE_TYPE (object) == CHAR_TABLE_TYPE_SYNTAX) 159 && XCHAR_TABLE_TYPE (object) == CHAR_TABLE_TYPE_SYNTAX)
236 syntax_cache_table_was_changed (buf); 241 syntax_cache_table_was_changed (buf);
237 /* Indicate that this buffer now has a specified syntax table. */ 242 /* Indicate that this buffer now has a specified syntax table. */
238 buf->local_var_flags |= XINT (buffer_local_flags.syntax_table); 243 buf->local_var_flags |= XINT (buffer_local_flags.syntax_table);
239 return syntax_table; 244 return syntax_table;
240 } 245 }
246
247
241 248
249 /*
250 * Syntax caching
251 */
252
253 /* syntax_cache object implementation */
254
255 static const struct memory_description syntax_cache_description_1 [] = {
256 { XD_LISP_OBJECT, offsetof (struct syntax_cache, object) },
257 { XD_LISP_OBJECT, offsetof (struct syntax_cache, buffer) },
258 { XD_LISP_OBJECT, offsetof (struct syntax_cache, syntax_table) },
259 { XD_LISP_OBJECT, offsetof (struct syntax_cache, mirror_table) },
260 { XD_LISP_OBJECT, offsetof (struct syntax_cache, start) },
261 { XD_LISP_OBJECT, offsetof (struct syntax_cache, end) },
262 { XD_END }
263 };
264
265 #ifdef NEW_GC
266 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("syntax-cache", syntax_cache,
267 0, syntax_cache_description_1,
268 Lisp_Syntax_Cache);
269 #else /* not NEW_GC */
270
271 const struct sized_memory_description syntax_cache_description = {
272 sizeof (struct syntax_cache),
273 syntax_cache_description_1
274 };
275 #endif /* not NEW_GC */
276
277 /* static syntax cache utilities */
278
279 static void
280 syntax_cache_table_was_changed (struct buffer *buf)
281 {
282 struct syntax_cache *cache = buf->syntax_cache;
283 if (cache->no_syntax_table_prop)
284 {
285 cache->syntax_table =
286 BUFFER_SYNTAX_TABLE (buf);
287 cache->mirror_table =
288 BUFFER_MIRROR_SYNTAX_TABLE (buf);
289 }
290 }
291
292 static void
293 reset_buffer_syntax_cache_range (struct syntax_cache *cache,
294 Lisp_Object buffer, int infinite)
295 {
296 Fset_marker (cache->start, make_int (1), buffer);
297 Fset_marker (cache->end, make_int (1), buffer);
298 Fset_marker_insertion_type (cache->start, Qt);
299 Fset_marker_insertion_type (cache->end, Qnil);
300 /* #### Should we "cache->no_syntax_table_prop = 1;" here? */
301 /* #### Cf comment on INFINITE in init_syntax_cache. -- sjt */
302 if (infinite)
303 {
304 cache->prev_change = EMACS_INT_MIN;
305 cache->next_change = EMACS_INT_MAX;
306 }
307 else
308 {
309 cache->prev_change = -1;
310 cache->next_change = -1;
311 }
312 }
242 313
243 static void 314 static void
244 init_syntax_cache (struct syntax_cache *cache, Lisp_Object object, 315 init_syntax_cache (struct syntax_cache *cache, Lisp_Object object,
245 struct buffer *buffer, int infinite) 316 struct buffer *buffer, int infinite)
246 { 317 {
252 BUFFER_SYNTAX_TABLE (cache->buffer); 323 BUFFER_SYNTAX_TABLE (cache->buffer);
253 cache->mirror_table = 324 cache->mirror_table =
254 BUFFER_MIRROR_SYNTAX_TABLE (cache->buffer); 325 BUFFER_MIRROR_SYNTAX_TABLE (cache->buffer);
255 cache->start = Qnil; 326 cache->start = Qnil;
256 cache->end = Qnil; 327 cache->end = Qnil;
328 /* #### I'm not sure what INFINITE is for, but it's apparently needed by
329 setup_syntax_cache(). It looks like it's supposed to guarantee that
330 the test for POS outside of cache-valid range will never succeed, so
331 that update_syntax_cache won't get called, but it's hard to be sure.
332 Cf reset_buffer_syntax_cache_range. -- sjt */
257 if (infinite) 333 if (infinite)
258 { 334 {
259 cache->prev_change = EMACS_INT_MIN; 335 cache->prev_change = EMACS_INT_MIN;
260 cache->next_change = EMACS_INT_MAX; 336 cache->next_change = EMACS_INT_MAX;
261 } 337 }
264 cache->prev_change = -1; 340 cache->prev_change = -1;
265 cache->next_change = -1; 341 cache->next_change = -1;
266 } 342 }
267 } 343 }
268 344
269 struct syntax_cache * 345 /* external syntax cache API */
270 setup_syntax_cache (struct syntax_cache *cache, Lisp_Object object, 346
271 struct buffer *buffer, Charxpos from, int count) 347 /* #### This function and associated logic still needs work, and especially
272 { 348 documentation. */
349 struct syntax_cache * /* return CACHE or the cache of OBJECT */
350 setup_syntax_cache (struct syntax_cache *cache, /* syntax cache, may be NULL
351 if OBJECT is a buffer */
352 Lisp_Object object, /* the object (if any) cache
353 is associated with */
354 struct buffer *buffer, /* the buffer to use as source
355 of the syntax table */
356 Charxpos from, /* initial position of cache */
357 int count) /* direction? see code */
358 {
359 /* If OBJECT is a buffer, use its cache. Initialize cache. Make it valid
360 for the whole buffer if the syntax-table property is not being respected.
361 Else if OBJECT is not a buffer, initialize the cache passed in CACHE.
362 If the syntax-table property is being respected, update the cache. */
273 if (BUFFERP (object)) 363 if (BUFFERP (object))
274 cache = XBUFFER (object)->syntax_cache; 364 {
275 if (!lookup_syntax_properties) 365 cache = XBUFFER (object)->syntax_cache;
276 init_syntax_cache (cache, object, buffer, 1); 366 if (!lookup_syntax_properties)
277 else if (!BUFFERP (object)) 367 reset_buffer_syntax_cache_range (cache, object, 1);
368 }
369 else
278 init_syntax_cache (cache, object, buffer, 0); 370 init_syntax_cache (cache, object, buffer, 0);
279 if (lookup_syntax_properties) 371 if (lookup_syntax_properties)
280 { 372 {
281 if (count <= 0) 373 if (count <= 0)
282 { 374 {
297 setup_buffer_syntax_cache (struct buffer *buffer, Charxpos from, int count) 389 setup_buffer_syntax_cache (struct buffer *buffer, Charxpos from, int count)
298 { 390 {
299 return setup_syntax_cache (NULL, wrap_buffer (buffer), buffer, from, count); 391 return setup_syntax_cache (NULL, wrap_buffer (buffer), buffer, from, count);
300 } 392 }
301 393
302 static const struct memory_description syntax_cache_description_1 [] = {
303 { XD_LISP_OBJECT, offsetof (struct syntax_cache, object) },
304 { XD_LISP_OBJECT, offsetof (struct syntax_cache, buffer) },
305 { XD_LISP_OBJECT, offsetof (struct syntax_cache, syntax_table) },
306 { XD_LISP_OBJECT, offsetof (struct syntax_cache, mirror_table) },
307 { XD_LISP_OBJECT, offsetof (struct syntax_cache, start) },
308 { XD_LISP_OBJECT, offsetof (struct syntax_cache, end) },
309 { XD_END }
310 };
311
312 const struct sized_memory_description syntax_cache_description = {
313 sizeof (struct syntax_cache),
314 syntax_cache_description_1
315 };
316
317 void
318 mark_buffer_syntax_cache (struct buffer *buf)
319 {
320 struct syntax_cache *cache = buf->syntax_cache;
321 if (!cache) /* Vbuffer_defaults and such don't have caches */
322 return;
323 mark_object (cache->object);
324 if (cache->buffer)
325 mark_object (wrap_buffer (cache->buffer));
326 mark_object (cache->syntax_table);
327 mark_object (cache->mirror_table);
328 mark_object (cache->start);
329 mark_object (cache->end);
330 }
331
332 static void
333 reset_buffer_cache_range (struct syntax_cache *cache, Lisp_Object buffer)
334 {
335 Fset_marker (cache->start, make_int (1), buffer);
336 Fset_marker (cache->end, make_int (1), buffer);
337 Fset_marker_insertion_type (cache->start, Qt);
338 Fset_marker_insertion_type (cache->end, Qnil);
339 cache->prev_change = -1;
340 cache->next_change = -1;
341 }
342
343 void
344 init_buffer_syntax_cache (struct buffer *buf)
345 {
346 struct syntax_cache *cache;
347 buf->syntax_cache = xnew_and_zero (struct syntax_cache);
348 cache = buf->syntax_cache;
349 cache->object = wrap_buffer (buf);
350 cache->buffer = buf;
351 cache->no_syntax_table_prop = 1;
352 cache->syntax_table = BUFFER_SYNTAX_TABLE (cache->buffer);
353 cache->mirror_table = BUFFER_MIRROR_SYNTAX_TABLE (cache->buffer);
354 cache->start = Fmake_marker ();
355 cache->end = Fmake_marker ();
356 reset_buffer_cache_range (cache, cache->object);
357 }
358
359 void
360 uninit_buffer_syntax_cache (struct buffer *buf)
361 {
362 xfree (buf->syntax_cache, struct syntax_cache *);
363 buf->syntax_cache = 0;
364 }
365
366
367 static void
368 syntax_cache_table_was_changed (struct buffer *buf)
369 {
370 struct syntax_cache *cache = buf->syntax_cache;
371 if (cache->no_syntax_table_prop)
372 {
373 cache->syntax_table =
374 BUFFER_SYNTAX_TABLE (buf);
375 cache->mirror_table =
376 BUFFER_MIRROR_SYNTAX_TABLE (buf);
377 }
378 }
379
380 /* The syntax-table property on the range covered by EXTENT may be changing,
381 either because EXTENT has a syntax-table property and is being attached
382 or detached (this includes having its endpoints changed), or because
383 the value of EXTENT's syntax-table property is changing. */
384
385 void
386 signal_syntax_table_extent_changed (EXTENT extent)
387 {
388 Lisp_Object buffer = Fextent_object (wrap_extent (extent));
389 if (BUFFERP (buffer))
390 {
391 struct syntax_cache *cache = XBUFFER (buffer)->syntax_cache;
392 Bytexpos start = extent_endpoint_byte (extent, 0);
393 Bytexpos end = extent_endpoint_byte (extent, 1);
394 Bytexpos start2 = byte_marker_position (cache->start);
395 Bytexpos end2 = byte_marker_position (cache->end);
396 /* If the extent is entirely before or entirely after the cache range,
397 it doesn't overlap. Otherwise, invalidate the range. */
398 if (!(end < start2 || start > end2))
399 reset_buffer_cache_range (cache, buffer);
400 }
401 }
402
403 /* Extents have been adjusted for insertion or deletion, so we need to
404 refetch the start and end position of the extent */
405 void
406 signal_syntax_table_extent_adjust (struct buffer *buf)
407 {
408 struct syntax_cache *cache = buf->syntax_cache;
409 /* If the cache was invalid before, leave it that way. We only want
410 to update the limits of validity when they were actually valid. */
411 if (cache->prev_change < 0)
412 return;
413 cache->prev_change = marker_position (cache->start);
414 cache->next_change = marker_position (cache->end);
415 }
416
417 /* 394 /*
418 Update syntax_cache to an appropriate setting for position POS 395 Update syntax_cache to an appropriate setting for position POS
419 396
420 The sign of COUNT gives the relative position of POS wrt the 397 The sign of COUNT gives the relative position of POS wrt the
421 previously valid interval. (not currently used) 398 previously valid interval. (not currently used)
479 { 456 {
480 /* If we are at the beginning or end of buffer, check to see if there's 457 /* If we are at the beginning or end of buffer, check to see if there's
481 a zero-length `syntax-table' extent there (highly unlikely); if not, 458 a zero-length `syntax-table' extent there (highly unlikely); if not,
482 then we can safely make the end closed, so it will take in newly 459 then we can safely make the end closed, so it will take in newly
483 inserted text. (If such an extent is inserted, we will be informed 460 inserted text. (If such an extent is inserted, we will be informed
484 through signal_syntax_table_extent_changed().) */ 461 through signal_syntax_cache_extent_changed().) */
485 Fset_marker (cache->start, make_int (cache->prev_change), cache->object); 462 Fset_marker (cache->start, make_int (cache->prev_change), cache->object);
486 Fset_marker_insertion_type 463 Fset_marker_insertion_type
487 (cache->start, 464 (cache->start,
488 at_begin && NILP (extent_at (prev, cache->object, Qsyntax_table, 465 at_begin && NILP (extent_at (prev, cache->object, Qsyntax_table,
489 NULL, EXTENT_AT_AT, 0)) 466 NULL, EXTENT_AT_AT, 0))
521 #ifdef NOT_WORTH_THE_EFFORT 498 #ifdef NOT_WORTH_THE_EFFORT
522 update_mirror_syntax_if_dirty (cache->mirror_table); 499 update_mirror_syntax_if_dirty (cache->mirror_table);
523 #endif /* NOT_WORTH_THE_EFFORT */ 500 #endif /* NOT_WORTH_THE_EFFORT */
524 } 501 }
525 } 502 }
503
504 /* buffer-specific APIs used in buffer.c
505 #### This is really unclean;
506 the syntax cache should just be a LISP object */
507
508 void
509 mark_buffer_syntax_cache (struct buffer *buf)
510 {
511 struct syntax_cache *cache = buf->syntax_cache;
512 if (!cache) /* Vbuffer_defaults and such don't have caches */
513 return;
514 mark_object (cache->object);
515 if (cache->buffer)
516 mark_object (wrap_buffer (cache->buffer));
517 mark_object (cache->syntax_table);
518 mark_object (cache->mirror_table);
519 mark_object (cache->start);
520 mark_object (cache->end);
521 }
522
523 void
524 init_buffer_syntax_cache (struct buffer *buf)
525 {
526 struct syntax_cache *cache;
527 #ifdef NEW_GC
528 buf->syntax_cache = alloc_lrecord_type (struct syntax_cache,
529 &lrecord_syntax_cache);
530 #else /* not NEW_GC */
531 buf->syntax_cache = xnew_and_zero (struct syntax_cache);
532 #endif /* not NEW_GC */
533 cache = buf->syntax_cache;
534 cache->object = wrap_buffer (buf);
535 cache->buffer = buf;
536 cache->no_syntax_table_prop = 1;
537 cache->syntax_table = BUFFER_SYNTAX_TABLE (cache->buffer);
538 cache->mirror_table = BUFFER_MIRROR_SYNTAX_TABLE (cache->buffer);
539 cache->start = Fmake_marker ();
540 cache->end = Fmake_marker ();
541 reset_buffer_syntax_cache_range (cache, cache->object, 0);
542 }
543
544 /* finalize the syntax cache for BUF */
545
546 void
547 uninit_buffer_syntax_cache (struct buffer *UNUSED_IF_NEW_GC (buf))
548 {
549 #ifndef NEW_GC
550 xfree (buf->syntax_cache, struct syntax_cache *);
551 buf->syntax_cache = 0;
552 #endif /* not NEW_GC */
553 }
554
555 /* extent-specific APIs used in extents.c and insdel.c */
556
557 /* The syntax-table property on the range covered by EXTENT may be changing,
558 either because EXTENT has a syntax-table property and is being attached
559 or detached (this includes having its endpoints changed), or because
560 the value of EXTENT's syntax-table property is changing. */
561
562 void
563 signal_syntax_cache_extent_changed (EXTENT extent)
564 {
565 Lisp_Object buffer = Fextent_object (wrap_extent (extent));
566 if (BUFFERP (buffer))
567 {
568 /* This was getting called with the buffer's start and end null, eg in
569 cperl mode, which triggers an assert in byte_marker_position. Cf
570 thread rooted at <yxz7j7xzk97.fsf@gimli.holgi.priv> on xemacs-beta.
571 <yxzfymklb6p.fsf@gimli.holgi.priv> has a recipe, but you also need
572 to delete or type SPC to get the crash.
573 #### Delete this comment when setup_syntax_cache is made sane. */
574 struct syntax_cache *cache = XBUFFER (buffer)->syntax_cache;
575 /* #### would this be slower or less accurate in character terms? */
576 Bytexpos start = extent_endpoint_byte (extent, 0);
577 Bytexpos end = extent_endpoint_byte (extent, 1);
578 Bytexpos start2 = byte_marker_position (cache->start);
579 Bytexpos end2 = byte_marker_position (cache->end);
580 /* If the extent is entirely before or entirely after the cache
581 range, it doesn't overlap. Otherwise, invalidate the range. */
582 if (!(end < start2 || start > end2))
583 reset_buffer_syntax_cache_range (cache, buffer, 0);
584 }
585 }
586
587 /* Extents have been adjusted for insertion or deletion, so we need to
588 refetch the start and end position of the extent */
589 void
590 signal_syntax_cache_extent_adjust (struct buffer *buf)
591 {
592 struct syntax_cache *cache = buf->syntax_cache;
593 /* If the cache was invalid before, leave it that way. We only want
594 to update the limits of validity when they were actually valid. */
595 if (cache->prev_change < 0)
596 return;
597 cache->prev_change = marker_position (cache->start);
598 cache->next_change = marker_position (cache->end);
599 }
600
601
526 602
527 /* Convert a letter which signifies a syntax code 603 /* Convert a letter which signifies a syntax code
528 into the code it signifies. 604 into the code it signifies.
529 This is used by modify-syntax-entry, and other things. */ 605 This is used by modify-syntax-entry, and other things. */
530 606
593 charset_syntax (struct buffer *UNUSED (buf), Lisp_Object UNUSED (charset), 669 charset_syntax (struct buffer *UNUSED (buf), Lisp_Object UNUSED (charset),
594 int *multi_p_out) 670 int *multi_p_out)
595 { 671 {
596 *multi_p_out = 1; 672 *multi_p_out = 1;
597 /* !!#### get this right */ 673 /* !!#### get this right */
598 return Spunct; 674 return Sword;
599 } 675 }
600 676
601 #endif 677 #endif
602 678
603 Lisp_Object 679 Lisp_Object
1989 break; 2065 break;
1990 2066
1991 case Sopen: 2067 case Sopen:
1992 if (stopbefore) goto stop; /* this arg means stop at sexp start */ 2068 if (stopbefore) goto stop; /* this arg means stop at sexp start */
1993 depth++; 2069 depth++;
1994 /* curlevel++->last ran into compiler bug on Apollo */
1995 curlevel->last = from - 1; 2070 curlevel->last = from - 1;
1996 if (++curlevel == endlevel) 2071 if (++curlevel == endlevel)
1997 stack_overflow ("Nesting too deep for parser", 2072 stack_overflow ("Nesting too deep for parser",
1998 make_int (curlevel - levelstart)); 2073 make_int (curlevel - levelstart));
1999 curlevel->prev = -1; 2074 curlevel->prev = -1;
2276 /* second clause catches bootstrapping problems when initializing the 2351 /* second clause catches bootstrapping problems when initializing the
2277 standard syntax table */ 2352 standard syntax table */
2278 if (!EQ (table, Vstandard_syntax_table) && !NILP (Vstandard_syntax_table)) 2353 if (!EQ (table, Vstandard_syntax_table) && !NILP (Vstandard_syntax_table))
2279 map_char_table (Vstandard_syntax_table, &range, 2354 map_char_table (Vstandard_syntax_table, &range,
2280 copy_if_not_already_present, LISP_TO_VOID (mirrortab)); 2355 copy_if_not_already_present, LISP_TO_VOID (mirrortab));
2281 /* The resetting made the default be Qnil. Put it back to Spunct. */ 2356 /* The resetting made the default be Qnil. Put it back to Sword. */
2282 set_char_table_default (mirrortab, make_int (Spunct)); 2357 set_char_table_default (mirrortab, make_int (Sword));
2283 XCHAR_TABLE (mirrortab)->dirty = 0; 2358 XCHAR_TABLE (mirrortab)->dirty = 0;
2284 } 2359 }
2285 2360
2286 /* Called from chartab.c when a change is made to a syntax table. 2361 /* Called from chartab.c when a change is made to a syntax table.
2287 If this is the standard syntax table, we need to recompute 2362 If this is the standard syntax table, we need to recompute
2311 /************************************************************************/ 2386 /************************************************************************/
2312 2387
2313 void 2388 void
2314 syms_of_syntax (void) 2389 syms_of_syntax (void)
2315 { 2390 {
2391 #ifdef NEW_GC
2392 INIT_LISP_OBJECT (syntax_cache);
2393 #endif /* NEW_GC */
2316 DEFSYMBOL (Qsyntax_table_p); 2394 DEFSYMBOL (Qsyntax_table_p);
2317 DEFSYMBOL (Qsyntax_table); 2395 DEFSYMBOL (Qsyntax_table);
2318 2396
2319 DEFSUBR (Fsyntax_table_p); 2397 DEFSUBR (Fsyntax_table_p);
2320 DEFSUBR (Fsyntax_table); 2398 DEFSUBR (Fsyntax_table);
2371 Vbogus_syntax_table_value = make_float (0.0); 2449 Vbogus_syntax_table_value = make_float (0.0);
2372 staticpro (&Vbogus_syntax_table_value); 2450 staticpro (&Vbogus_syntax_table_value);
2373 } 2451 }
2374 2452
2375 static void 2453 static void
2376 define_standard_syntax (const char *p, enum syntaxcode syn) 2454 define_standard_syntax (const UExtbyte *p, enum syntaxcode syn)
2377 { 2455 {
2378 for (; *p; p++) 2456 for (; *p; p++)
2379 Fput_char_table (make_char (*p), make_int (syn), Vstandard_syntax_table); 2457 Fput_char_table (make_char (*p), make_int (syn), Vstandard_syntax_table);
2380 } 2458 }
2381 2459
2382 void 2460 void
2383 complex_vars_of_syntax (void) 2461 complex_vars_of_syntax (void)
2384 { 2462 {
2385 Ichar i; 2463 Ichar i;
2386 const char *p; 2464 const UExtbyte *p; /* Latin-1, not internal format. */
2387 /* Set this now, so first buffer creation can refer to it. */ 2465
2388 /* Make it nil before calling copy-syntax-table 2466 #define SET_RANGE_SYNTAX(start, end, syntax) \
2389 so that copy-syntax-table will know not to try to copy from garbage */ 2467 do { \
2468 for (i = start; i <= end; i++) \
2469 Fput_char_table(make_char(i), make_int(syntax), \
2470 Vstandard_syntax_table); \
2471 } while (0)
2472
2473 /* Set this now, so first buffer creation can refer to it.
2474
2475 Make it nil before calling copy-syntax-table so that copy-syntax-table
2476 will know not to try to copy from garbage */
2390 Vstandard_syntax_table = Qnil; 2477 Vstandard_syntax_table = Qnil;
2391 Vstandard_syntax_table = Fcopy_syntax_table (Qnil); 2478 Vstandard_syntax_table = Fcopy_syntax_table (Qnil);
2392 staticpro (&Vstandard_syntax_table); 2479 staticpro (&Vstandard_syntax_table);
2393 2480
2394 Vtemp_table_for_use_updating_syntax_tables = Fmake_char_table (Qgeneric); 2481 Vtemp_table_for_use_updating_syntax_tables = Fmake_char_table (Qgeneric);
2396 2483
2397 Vsyntax_designator_chars_string = make_string_nocopy (syntax_code_spec, 2484 Vsyntax_designator_chars_string = make_string_nocopy (syntax_code_spec,
2398 Smax); 2485 Smax);
2399 staticpro (&Vsyntax_designator_chars_string); 2486 staticpro (&Vsyntax_designator_chars_string);
2400 2487
2401 set_char_table_default (Vstandard_syntax_table, make_int (Spunct)); 2488 /* Default character syntax is word. */
2402 2489 set_char_table_default (Vstandard_syntax_table, make_int (Sword));
2403 for (i = 0; i <= 32; i++) /* Control 0 plus SPACE */ 2490
2404 Fput_char_table (make_char (i), make_int (Swhitespace), 2491 /* Control 0; treat as punctuation */
2405 Vstandard_syntax_table); 2492 SET_RANGE_SYNTAX(0, 32, Spunct);
2406 for (i = 127; i <= 159; i++) /* DEL plus Control 1 */ 2493
2407 Fput_char_table (make_char (i), make_int (Swhitespace), 2494 /* The whitespace--overwriting some of the above changes.
2408 Vstandard_syntax_table); 2495
2409 2496 String literals are const char *s, not const unsigned char *s. */
2410 define_standard_syntax ("abcdefghijklmnopqrstuvwxyz" 2497 define_standard_syntax((const UExtbyte *)" \t\015\014\012", Swhitespace);
2411 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 2498
2412 "0123456789" 2499 /* DEL plus Control 1 */
2413 "$%", Sword); 2500 SET_RANGE_SYNTAX(127, 159, Spunct);
2414 define_standard_syntax ("\"", Sstring); 2501
2415 define_standard_syntax ("\\", Sescape); 2502 define_standard_syntax ((const UExtbyte *)"\"", Sstring);
2416 define_standard_syntax ("_-+*/&|<>=", Ssymbol); 2503 define_standard_syntax ((const UExtbyte *)"\\", Sescape);
2417 define_standard_syntax (".,;:?!#@~^'`", Spunct); 2504 define_standard_syntax ((const UExtbyte *)"_-+*/&|<>=", Ssymbol);
2418 2505 define_standard_syntax ((const UExtbyte *)".,;:?!#@~^'`", Spunct);
2419 for (p = "()[]{}"; *p; p+=2) 2506
2507 for (p = (const UExtbyte *)"()[]{}"; *p; p+=2)
2420 { 2508 {
2421 Fput_char_table (make_char (p[0]), 2509 Fput_char_table (make_char (p[0]),
2422 Fcons (make_int (Sopen), make_char (p[1])), 2510 Fcons (make_int (Sopen), make_char (p[1])),
2423 Vstandard_syntax_table); 2511 Vstandard_syntax_table);
2424 Fput_char_table (make_char (p[1]), 2512 Fput_char_table (make_char (p[1]),
2425 Fcons (make_int (Sclose), make_char (p[0])), 2513 Fcons (make_int (Sclose), make_char (p[0])),
2426 Vstandard_syntax_table); 2514 Vstandard_syntax_table);
2427 } 2515 }
2428 } 2516
2517 /* Latin 1 "symbols." This contrasts with the FSF, where they're word
2518 constituents. */
2519 SET_RANGE_SYNTAX(0240, 0277, Ssymbol);
2520
2521 /* The guillemets. These are not parentheses, in contrast to what the old
2522 code did. */
2523 define_standard_syntax((const UExtbyte *)"\253\273", Spunct);
2524
2525 /* The inverted exclamation mark, and the multiplication and division
2526 signs. */
2527 define_standard_syntax((const UExtbyte *)"\241\327\367", Spunct);
2528
2529 #undef SET_RANGE_SYNTAX
2530 }