Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
Copyright (C) 1995 Sun Microsystems, Inc.
Copyright (C) 1995 Ben Wing.
- Copyright (C) 1999,2000,2001 MORIOKA Tomohiko
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
ranges entirely within the first 256 chars. */
if ((range_start >= 0x100 || range_end >= 0x100)
-#ifdef UTF2000
- && CHAR_CHARSET_ID (range_start) != CHAR_CHARSET_ID (range_end)
-#else
- && CHAR_LEADING_BYTE (range_start) != CHAR_LEADING_BYTE (range_end)
-#endif
- )
+ && CHAR_LEADING_BYTE (range_start) !=
+ CHAR_LEADING_BYTE (range_end))
return REG_ERANGESPAN;
/* As advertised, translations only work over the 0 - 0x7F range.
#endif
matchsyntax:
#ifdef MULE
-#ifdef UTF2000
- for (j = 0; j < 0x80; j++)
- if (SYNTAX_UNSAFE
- (XCHAR_TABLE
- (regex_emacs_buffer->syntax_table), j) ==
- (enum syntaxcode) k)
- fastmap[j] = 1;
-#else
for (j = 0; j < 0x80; j++)
if (SYNTAX_UNSAFE
(XCHAR_TABLE
(regex_emacs_buffer->mirror_syntax_table), j) ==
(enum syntaxcode) k)
fastmap[j] = 1;
-#endif
for (j = 0x80; j < 0xA0; j++)
{
-#ifndef UTF2000
if (LEADING_BYTE_PREFIX_P(j))
/* too complicated to calculate this right */
fastmap[j] = 1;
else
{
-#endif
int multi_p;
Lisp_Object cset;
== Sword || multi_p)
fastmap[j] = 1;
}
-#ifndef UTF2000
}
-#endif
}
#else /* not MULE */
for (j = 0; j < (1 << BYTEWIDTH); j++)
#endif
matchnotsyntax:
#ifdef MULE
-#ifdef UTF2000
- for (j = 0; j < 0x80; j++)
- if (SYNTAX_UNSAFE
- (XCHAR_TABLE
- (regex_emacs_buffer->syntax_table), j) !=
- (enum syntaxcode) k)
- fastmap[j] = 1;
-#else
for (j = 0; j < 0x80; j++)
if (SYNTAX_UNSAFE
(XCHAR_TABLE
(regex_emacs_buffer->mirror_syntax_table), j) !=
(enum syntaxcode) k)
fastmap[j] = 1;
-#endif
for (j = 0x80; j < 0xA0; j++)
{
-#ifndef UTF2000
if (LEADING_BYTE_PREFIX_P(j))
/* too complicated to calculate this right */
fastmap[j] = 1;
else
{
-#endif
int multi_p;
Lisp_Object cset;
!= Sword || multi_p)
fastmap[j] = 1;
}
-#ifndef UTF2000
}
-#endif
}
#else /* not MULE */
for (j = 0; j < (1 << BYTEWIDTH); j++)
#define POS_AFTER_GAP_UNSAFE(d) ((d) == end1 ? string2 : (d))
/* Test if CH is a word-constituent character. (XEmacs change) */
-#ifdef UTF2000
-#define WORDCHAR_P_UNSAFE(ch) \
- (SYNTAX_UNSAFE (XCHAR_TABLE (regex_emacs_buffer->syntax_table), \
- ch) == Sword)
-#else
#define WORDCHAR_P_UNSAFE(ch) \
(SYNTAX_UNSAFE (XCHAR_TABLE (regex_emacs_buffer->mirror_syntax_table), \
ch) == Sword)
-#endif
/* Free everything we malloc. */
#ifdef MATCH_MAY_ALLOCATE
matchwordbound:
{
/* XEmacs change */
- int result;
- if (AT_STRINGS_BEG (d) || AT_STRINGS_END (d))
- result = 1;
- else
- {
- re_char *d_before = POS_BEFORE_GAP_UNSAFE (d);
- re_char *d_after = POS_AFTER_GAP_UNSAFE (d);
-
- /* emch1 is the character before d, syn1 is the syntax of emch1,
- emch2 is the character at d, and syn2 is the syntax of emch2. */
- Emchar emch1, emch2;
- int syn1, syn2;
+ /* Straightforward and (I hope) correct implementation.
+ Probably should be optimized by arranging to compute
+ pos only once. */
+ /* emch1 is the character before d, syn1 is the syntax of
+ emch1, emch2 is the character at d, and syn2 is the
+ syntax of emch2. */
+ Emchar emch1, emch2;
+ int syn1, syn2;
+ re_char *d_before, *d_after;
+ int result,
+ at_beg = AT_STRINGS_BEG (d),
+ at_end = AT_STRINGS_END (d);
#ifdef emacs
- int pos_before;
+ int xpos;
#endif
- DEC_CHARPTR (d_before);
- emch1 = charptr_emchar (d_before);
- emch2 = charptr_emchar (d_after);
-
+ if (at_beg && at_end)
+ {
+ result = 0;
+ }
+ else
+ {
+ if (!at_beg)
+ {
+ d_before = POS_BEFORE_GAP_UNSAFE (d);
+ DEC_CHARPTR (d_before);
+ emch1 = charptr_emchar (d_before);
#ifdef emacs
- pos_before = SYNTAX_CACHE_BYTE_TO_CHAR (PTR_TO_OFFSET (d)) - 1;
- UPDATE_SYNTAX_CACHE (pos_before);
+ xpos = SYNTAX_CACHE_BYTE_TO_CHAR (PTR_TO_OFFSET (d)) - 1;
+ UPDATE_SYNTAX_CACHE (xpos);
#endif
- syn1 = SYNTAX_FROM_CACHE (XCHAR_TABLE (regex_emacs_buffer->mirror_syntax_table),
- emch1);
+ syn1 = SYNTAX_FROM_CACHE
+ (XCHAR_TABLE (regex_emacs_buffer
+ ->mirror_syntax_table),
+ emch1);
+ }
+ if (!at_end)
+ {
+ d_after = POS_AFTER_GAP_UNSAFE (d);
+ emch2 = charptr_emchar (d_after);
#ifdef emacs
- UPDATE_SYNTAX_CACHE_FORWARD (pos_before + 1);
+ xpos = SYNTAX_CACHE_BYTE_TO_CHAR (PTR_TO_OFFSET (d));
+ UPDATE_SYNTAX_CACHE_FORWARD (xpos + 1);
#endif
- syn2 = SYNTAX_FROM_CACHE (XCHAR_TABLE (regex_emacs_buffer->mirror_syntax_table),
- emch2);
+ syn2 = SYNTAX_FROM_CACHE
+ (XCHAR_TABLE (regex_emacs_buffer
+ ->mirror_syntax_table),
+ emch2);
+ }
- result = ((syn1 == Sword) != (syn2 == Sword));
+ if (at_beg)
+ result = (syn2 == Sword);
+ else if (at_end)
+ result = (syn1 == Sword);
+ else
+ result = ((syn1 == Sword) != (syn2 == Sword));
}
+
if (result == should_succeed)
break;
goto fail;
#endif
emch = charptr_emchar ((const Bufbyte *) d);
-#ifdef UTF2000
- matches = (SYNTAX_FROM_CACHE (XCHAR_TABLE (regex_emacs_buffer->syntax_table),
- emch) == (enum syntaxcode) mcnt);
-#else
matches = (SYNTAX_FROM_CACHE (XCHAR_TABLE (regex_emacs_buffer->mirror_syntax_table),
emch) == (enum syntaxcode) mcnt);
-#endif
INC_CHARPTR (d);
if (matches != should_succeed)
goto fail;