comparison src/regex.c @ 1377:19738a2a5138

[xemacs-hg @ 2003-03-24 15:01:47 by stephent] don't use DB_AUTO_COMMIT <87ptog3j6t.fsf@tleepslib.sk.tsukuba.ac.jp> fix word boundary code in regex.c <87smtc3jfv.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Mon, 24 Mar 2003 15:01:50 +0000
parents 8d350b095c21
children 56496b493888
comparison
equal deleted inserted replaced
1376:2e0147538471 1377:19738a2a5138
6068 DEBUG_PRINT1 ("EXECUTING wordbound.\n"); 6068 DEBUG_PRINT1 ("EXECUTING wordbound.\n");
6069 should_succeed = 1; 6069 should_succeed = 1;
6070 matchwordbound: 6070 matchwordbound:
6071 { 6071 {
6072 /* XEmacs change */ 6072 /* XEmacs change */
6073 int result; 6073 /* Straightforward and (I hope) correct implementation.
6074 if (AT_STRINGS_BEG (d) || AT_STRINGS_END (d)) 6074 Probably should be optimized by arranging to compute
6075 result = 1; 6075 pos only once. */
6076 /* emch1 is the character before d, syn1 is the syntax of
6077 emch1, emch2 is the character at d, and syn2 is the
6078 syntax of emch2. */
6079 Ichar emch1, emch2;
6080 int syn1, syn2;
6081 re_char *d_before, *d_after;
6082 int result,
6083 at_beg = AT_STRINGS_BEG (d),
6084 at_end = AT_STRINGS_END (d);
6085 #ifdef emacs
6086 Charxpos pos;
6087 #endif
6088
6089 if (at_beg && at_end)
6090 {
6091 result = 0;
6092 }
6076 else 6093 else
6077 { 6094 {
6078 re_char *d_before = POS_BEFORE_GAP_UNSAFE (d); 6095 if (!at_beg)
6079 re_char *d_after = POS_AFTER_GAP_UNSAFE (d); 6096 {
6080 6097 d_before = POS_BEFORE_GAP_UNSAFE (d);
6081 /* emch1 is the character before d, syn1 is the syntax of 6098 DEC_IBYTEPTR_FMT (d_before, fmt);
6082 emch1, emch2 is the character at d, and syn2 is the 6099 emch1 = itext_ichar_fmt (d_before, fmt, lispobj);
6083 syntax of emch2. */
6084 Ichar emch1, emch2;
6085 int syn1, syn2;
6086 #ifdef emacs 6100 #ifdef emacs
6087 Charxpos pos_before; 6101 pos = offset_to_charxpos (lispobj, PTR_TO_OFFSET (d)) - 1;
6088 #endif 6102 BEGIN_REGEX_MALLOC_OK ();
6089 6103 UPDATE_SYNTAX_CACHE (scache, pos);
6090 DEC_IBYTEPTR_FMT (d_before, fmt); 6104 #endif
6091 emch1 = itext_ichar_fmt (d_before, fmt, lispobj); 6105 syn1 = SYNTAX_FROM_CACHE (scache, emch1);
6092 emch2 = itext_ichar_fmt (d_after, fmt, lispobj); 6106 END_REGEX_MALLOC_OK ();
6093 6107 }
6108 if (!at_end)
6109 {
6110 d_after = POS_AFTER_GAP_UNSAFE (d);
6111 emch2 = itext_ichar_fmt (d_after, fmt, lispobj);
6094 #ifdef emacs 6112 #ifdef emacs
6095 pos_before = 6113 pos = offset_to_charxpos (lispobj, PTR_TO_OFFSET (d));
6096 offset_to_charxpos (lispobj, PTR_TO_OFFSET (d)) - 1; 6114 BEGIN_REGEX_MALLOC_OK ();
6097 BEGIN_REGEX_MALLOC_OK (); 6115 UPDATE_SYNTAX_CACHE_FORWARD (scache, pos);
6098 UPDATE_SYNTAX_CACHE (scache, pos_before); 6116 #endif
6099 #endif 6117 syn2 = SYNTAX_FROM_CACHE (scache, emch2);
6100 syn1 = SYNTAX_FROM_CACHE (scache, emch1); 6118 END_REGEX_MALLOC_OK ();
6101 #ifdef emacs 6119 }
6102 UPDATE_SYNTAX_CACHE_FORWARD (scache, pos_before + 1);
6103 #endif
6104 syn2 = SYNTAX_FROM_CACHE (scache, emch2);
6105
6106 result = ((syn1 == Sword) != (syn2 == Sword));
6107 END_REGEX_MALLOC_OK ();
6108 RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); 6120 RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS ();
6121
6122 if (at_beg)
6123 result = (syn2 == Sword);
6124 else if (at_end)
6125 result = (syn1 == Sword);
6126 else
6127 result = ((syn1 == Sword) != (syn2 == Sword));
6109 } 6128 }
6129
6110 if (result == should_succeed) 6130 if (result == should_succeed)
6111 break; 6131 break;
6112 goto fail; 6132 goto fail;
6113 } 6133 }
6114 6134