Mercurial > hg > xemacs-beta
comparison src/syntax.c @ 420:41dbb7a9d5f2 r21-2-18
Import from CVS: tag r21-2-18
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:24:09 +0200 |
parents | 697ef44129c6 |
children | 11054d720c21 |
comparison
equal
deleted
inserted
replaced
419:66615b78f1a5 | 420:41dbb7a9d5f2 |
---|---|
51 So, we introduced Sextword for Japanese letters. A character of | 51 So, we introduced Sextword for Japanese letters. A character of |
52 Sextword is a word-constituent but a word boundary may exist between | 52 Sextword is a word-constituent but a word boundary may exist between |
53 two such characters. */ | 53 two such characters. */ |
54 | 54 |
55 /* Mule 2.4 doesn't seem to have Sextword - I'm removing it -- mrb */ | 55 /* Mule 2.4 doesn't seem to have Sextword - I'm removing it -- mrb */ |
56 /* Recovered by tomo */ | |
56 | 57 |
57 Lisp_Object Qsyntax_table_p; | 58 Lisp_Object Qsyntax_table_p; |
58 | 59 |
59 int words_include_escapes; | 60 int words_include_escapes; |
60 | 61 |
324 return syntax_match (table, XCHAR (ch)); | 325 return syntax_match (table, XCHAR (ch)); |
325 return Qnil; | 326 return Qnil; |
326 } | 327 } |
327 | 328 |
328 | 329 |
329 | 330 #ifdef MULE |
331 /* Return 1 if there is a word boundary between two word-constituent | |
332 characters C1 and C2 if they appear in this order, else return 0. | |
333 There is no word boundary between two word-constituent ASCII | |
334 characters. */ | |
335 #define WORD_BOUNDARY_P(c1, c2) \ | |
336 (!(CHAR_ASCII_P (c1) && CHAR_ASCII_P (c2)) \ | |
337 && word_boundary_p (c1, c2)) | |
338 | |
339 extern int word_boundary_p (Emchar c1, Emchar c2); | |
340 #else | |
330 static int | 341 static int |
331 word_constituent_p (struct buffer *buf, Bufpos pos, | 342 word_constituent_p (struct buffer *buf, Bufpos pos, |
332 struct Lisp_Char_Table *tab) | 343 struct Lisp_Char_Table *tab) |
333 { | 344 { |
334 enum syntaxcode code = SYNTAX_UNSAFE (tab, BUF_FETCH_CHAR (buf, pos)); | 345 enum syntaxcode code = SYNTAX_UNSAFE (tab, BUF_FETCH_CHAR (buf, pos)); |
335 return ((words_include_escapes && | 346 return ((words_include_escapes && |
336 (code == Sescape || code == Scharquote)) | 347 (code == Sescape || code == Scharquote)) |
337 || (code == Sword)); | 348 || (code == Sword)); |
338 } | 349 } |
350 #endif | |
339 | 351 |
340 /* Return the position across COUNT words from FROM. | 352 /* Return the position across COUNT words from FROM. |
341 If that many words cannot be found before the end of the buffer, return 0. | 353 If that many words cannot be found before the end of the buffer, return 0. |
342 COUNT negative means scan backward and stop at word beginning. */ | 354 COUNT negative means scan backward and stop at word beginning. */ |
343 | 355 |
344 Bufpos | 356 Bufpos |
345 scan_words (struct buffer *buf, Bufpos from, int count) | 357 scan_words (struct buffer *buf, Bufpos from, int count) |
346 { | 358 { |
347 Bufpos limit = count > 0 ? BUF_ZV (buf) : BUF_BEGV (buf); | 359 Bufpos limit = count > 0 ? BUF_ZV (buf) : BUF_BEGV (buf); |
348 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); | 360 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); |
361 #ifdef MULE | |
362 Emchar ch0, ch1; | |
363 enum syntaxcode code; | |
364 #endif | |
365 | |
349 while (count > 0) | 366 while (count > 0) |
350 { | 367 { |
351 QUIT; | 368 QUIT; |
352 | 369 |
353 while (1) | 370 while (1) |
354 { | 371 { |
355 if (from == limit) | 372 if (from == limit) |
356 return 0; | 373 return 0; |
374 #ifdef MULE | |
375 ch0 = BUF_FETCH_CHAR (buf, from); | |
376 code = SYNTAX_UNSAFE (mirrortab, ch0); | |
377 #else | |
357 if (word_constituent_p (buf, from, mirrortab)) | 378 if (word_constituent_p (buf, from, mirrortab)) |
358 break; | 379 break; |
380 #endif | |
359 from++; | 381 from++; |
382 #ifdef MULE | |
383 if (words_include_escapes | |
384 && (code == Sescape || code == Scharquote)) | |
385 break; | |
386 if (code == Sword) | |
387 break; | |
388 #endif | |
360 } | 389 } |
361 | 390 |
362 QUIT; | 391 QUIT; |
363 | 392 |
364 while ((from != limit) && word_constituent_p (buf, from, mirrortab)) | 393 while ((from != limit) |
394 #ifndef MULE | |
395 && word_constituent_p (buf, from, mirrortab) | |
396 #endif | |
397 ) | |
365 { | 398 { |
399 #ifdef MULE | |
400 ch1 = BUF_FETCH_CHAR (buf, from); | |
401 code = SYNTAX_UNSAFE (mirrortab, ch1); | |
402 if (!(words_include_escapes | |
403 && (code == Sescape || code == Scharquote))) | |
404 if (code != Sword || WORD_BOUNDARY_P (ch0, ch1)) | |
405 break; | |
406 ch0 = ch1; | |
407 #endif | |
366 from++; | 408 from++; |
367 } | 409 } |
368 count--; | 410 count--; |
369 } | 411 } |
370 | 412 |
374 | 416 |
375 while (1) | 417 while (1) |
376 { | 418 { |
377 if (from == limit) | 419 if (from == limit) |
378 return 0; | 420 return 0; |
421 #ifndef MULE | |
379 if (word_constituent_p (buf, from - 1, mirrortab)) | 422 if (word_constituent_p (buf, from - 1, mirrortab)) |
380 break; | 423 break; |
424 #endif | |
381 from--; | 425 from--; |
426 #ifdef MULE | |
427 ch1 = BUF_FETCH_CHAR (buf, from - 1); | |
428 code = SYNTAX_UNSAFE (mirrortab, ch1); | |
429 if (words_include_escapes | |
430 && (code == Sescape || code == Scharquote)) | |
431 break; | |
432 if (code == Sword) | |
433 break; | |
434 #endif | |
382 } | 435 } |
383 | 436 |
384 QUIT; | 437 QUIT; |
385 | 438 |
386 while ((from != limit) && word_constituent_p (buf, from - 1, mirrortab)) | 439 while ((from != limit) |
440 #ifndef MULE | |
441 && word_constituent_p (buf, from - 1, mirrortab) | |
442 #endif | |
443 ) | |
387 { | 444 { |
445 #ifdef MULE | |
446 ch0 = BUF_FETCH_CHAR (buf, from - 1); | |
447 code = SYNTAX_UNSAFE (mirrortab, ch0); | |
448 if (!(words_include_escapes | |
449 && (code == Sescape || code == Scharquote))) | |
450 if (code != Sword || WORD_BOUNDARY_P (ch0, ch1)) | |
451 break; | |
452 ch1 = ch0; | |
453 #endif | |
388 from--; | 454 from--; |
389 } | 455 } |
390 count++; | 456 count++; |
391 } | 457 } |
392 | 458 |