Mercurial > hg > xemacs-beta
comparison src/syntax.c @ 424:11054d720c21 r21-2-20
Import from CVS: tag r21-2-20
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:26:11 +0200 |
parents | 41dbb7a9d5f2 |
children |
comparison
equal
deleted
inserted
replaced
423:28d9c139be4c | 424:11054d720c21 |
---|---|
325 return syntax_match (table, XCHAR (ch)); | 325 return syntax_match (table, XCHAR (ch)); |
326 return Qnil; | 326 return Qnil; |
327 } | 327 } |
328 | 328 |
329 | 329 |
330 | |
330 #ifdef MULE | 331 #ifdef MULE |
331 /* Return 1 if there is a word boundary between two word-constituent | 332 /* 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 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 There is no word boundary between two word-constituent ASCII |
334 characters. */ | 335 characters. */ |
335 #define WORD_BOUNDARY_P(c1, c2) \ | 336 #define WORD_BOUNDARY_P(c1, c2) \ |
336 (!(CHAR_ASCII_P (c1) && CHAR_ASCII_P (c2)) \ | 337 (!(CHAR_ASCII_P (c1) && CHAR_ASCII_P (c2)) \ |
337 && word_boundary_p (c1, c2)) | 338 && word_boundary_p (c1, c2)) |
338 | 339 |
339 extern int word_boundary_p (Emchar c1, Emchar c2); | 340 extern int word_boundary_p (Emchar c1, Emchar c2); |
340 #else | |
341 static int | |
342 word_constituent_p (struct buffer *buf, Bufpos pos, | |
343 struct Lisp_Char_Table *tab) | |
344 { | |
345 enum syntaxcode code = SYNTAX_UNSAFE (tab, BUF_FETCH_CHAR (buf, pos)); | |
346 return ((words_include_escapes && | |
347 (code == Sescape || code == Scharquote)) | |
348 || (code == Sword)); | |
349 } | |
350 #endif | 341 #endif |
351 | 342 |
352 /* Return the position across COUNT words from FROM. | 343 /* Return the position across COUNT words from FROM. |
353 If that many words cannot be found before the end of the buffer, return 0. | 344 If that many words cannot be found before the end of the buffer, return 0. |
354 COUNT negative means scan backward and stop at word beginning. */ | 345 COUNT negative means scan backward and stop at word beginning. */ |
356 Bufpos | 347 Bufpos |
357 scan_words (struct buffer *buf, Bufpos from, int count) | 348 scan_words (struct buffer *buf, Bufpos from, int count) |
358 { | 349 { |
359 Bufpos limit = count > 0 ? BUF_ZV (buf) : BUF_BEGV (buf); | 350 Bufpos limit = count > 0 ? BUF_ZV (buf) : BUF_BEGV (buf); |
360 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); | 351 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); |
361 #ifdef MULE | |
362 Emchar ch0, ch1; | 352 Emchar ch0, ch1; |
363 enum syntaxcode code; | 353 enum syntaxcode code; |
364 #endif | 354 |
365 | 355 /* #### is it really worth it to hand expand both cases? JV */ |
366 while (count > 0) | 356 while (count > 0) |
367 { | 357 { |
368 QUIT; | 358 QUIT; |
369 | 359 |
370 while (1) | 360 while (1) |
371 { | 361 { |
372 if (from == limit) | 362 if (from == limit) |
373 return 0; | 363 return 0; |
374 #ifdef MULE | 364 |
375 ch0 = BUF_FETCH_CHAR (buf, from); | 365 ch0 = BUF_FETCH_CHAR (buf, from); |
376 code = SYNTAX_UNSAFE (mirrortab, ch0); | 366 code = SYNTAX_UNSAFE (mirrortab, ch0); |
377 #else | 367 |
378 if (word_constituent_p (buf, from, mirrortab)) | |
379 break; | |
380 #endif | |
381 from++; | |
382 #ifdef MULE | |
383 if (words_include_escapes | 368 if (words_include_escapes |
384 && (code == Sescape || code == Scharquote)) | 369 && (code == Sescape || code == Scharquote)) |
385 break; | 370 break; |
386 if (code == Sword) | 371 if (code == Sword) |
387 break; | 372 break; |
388 #endif | 373 |
374 from++; | |
389 } | 375 } |
390 | 376 |
391 QUIT; | 377 QUIT; |
392 | 378 |
393 while ((from != limit) | 379 while (from != limit) |
394 #ifndef MULE | |
395 && word_constituent_p (buf, from, mirrortab) | |
396 #endif | |
397 ) | |
398 { | 380 { |
399 #ifdef MULE | |
400 ch1 = BUF_FETCH_CHAR (buf, from); | 381 ch1 = BUF_FETCH_CHAR (buf, from); |
401 code = SYNTAX_UNSAFE (mirrortab, ch1); | 382 code = SYNTAX_UNSAFE (mirrortab, ch1); |
402 if (!(words_include_escapes | 383 if (!(words_include_escapes |
403 && (code == Sescape || code == Scharquote))) | 384 && (code == Sescape || code == Scharquote))) |
404 if (code != Sword || WORD_BOUNDARY_P (ch0, ch1)) | 385 if (code != Sword |
386 #ifdef MULE | |
387 || WORD_BOUNDARY_P (ch0, ch1) | |
388 #endif | |
389 ) | |
405 break; | 390 break; |
391 #ifdef MULE | |
406 ch0 = ch1; | 392 ch0 = ch1; |
407 #endif | 393 #endif |
408 from++; | 394 from++; |
409 } | 395 } |
410 count--; | 396 count--; |
411 } | 397 } |
412 | 398 |
416 | 402 |
417 while (1) | 403 while (1) |
418 { | 404 { |
419 if (from == limit) | 405 if (from == limit) |
420 return 0; | 406 return 0; |
421 #ifndef MULE | 407 |
422 if (word_constituent_p (buf, from - 1, mirrortab)) | |
423 break; | |
424 #endif | |
425 from--; | |
426 #ifdef MULE | |
427 ch1 = BUF_FETCH_CHAR (buf, from - 1); | 408 ch1 = BUF_FETCH_CHAR (buf, from - 1); |
428 code = SYNTAX_UNSAFE (mirrortab, ch1); | 409 code = SYNTAX_UNSAFE (mirrortab, ch1); |
429 if (words_include_escapes | 410 if (words_include_escapes |
430 && (code == Sescape || code == Scharquote)) | 411 && (code == Sescape || code == Scharquote)) |
431 break; | 412 break; |
432 if (code == Sword) | 413 if (code == Sword) |
433 break; | 414 break; |
434 #endif | 415 |
416 from--; | |
435 } | 417 } |
436 | 418 |
437 QUIT; | 419 QUIT; |
438 | 420 |
439 while ((from != limit) | 421 while (from != limit) |
440 #ifndef MULE | |
441 && word_constituent_p (buf, from - 1, mirrortab) | |
442 #endif | |
443 ) | |
444 { | 422 { |
445 #ifdef MULE | |
446 ch0 = BUF_FETCH_CHAR (buf, from - 1); | 423 ch0 = BUF_FETCH_CHAR (buf, from - 1); |
447 code = SYNTAX_UNSAFE (mirrortab, ch0); | 424 code = SYNTAX_UNSAFE (mirrortab, ch0); |
448 if (!(words_include_escapes | 425 if (!(words_include_escapes |
449 && (code == Sescape || code == Scharquote))) | 426 && (code == Sescape || code == Scharquote))) |
450 if (code != Sword || WORD_BOUNDARY_P (ch0, ch1)) | 427 if (code != Sword |
428 #ifdef MULE | |
429 || WORD_BOUNDARY_P (ch0, ch1) | |
430 #endif | |
431 ) | |
451 break; | 432 break; |
433 #ifdef MULE | |
452 ch1 = ch0; | 434 ch1 = ch0; |
453 #endif | 435 #endif |
454 from--; | 436 from--; |
455 } | 437 } |
456 count++; | 438 count++; |