aboutsummaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/regexec.c b/regexec.c
index 2f8a234..e8131e2 100644
--- a/regexec.c
+++ b/regexec.c
@@ -155,11 +155,13 @@ static struct sset *pickss(struct vars *, struct dfa *, chr *, chr *);
/* automatically gathered by fwd; do not hand-edit */
/* =====^!^===== end forwards =====^!^===== */
-#ifdef REGEX_UTF8
-
static inline chr *
-nextchr(chr *s)
+nextchr(struct vars *v, chr *s)
{
+ if (v->eflags & REG_RAW) {
+ return s+1;
+ }
+
unsigned char c = (unsigned char)*s;
if (c < 0x80) /* 0xxxxxxx */
@@ -176,8 +178,12 @@ nextchr(chr *s)
}
static inline chr *
-prevchr(chr *s)
+prevchr(struct vars *v, chr *s)
{
+ if (v->eflags & REG_RAW) {
+ return s-1;
+ }
+
do {
--s;
} while (((unsigned char)*s & 0xC0) == 0x80);
@@ -186,21 +192,17 @@ prevchr(chr *s)
}
static inline pchr
-getchr(const chr *s, const chr *end)
+getchr(struct vars *v, const chr *s, const chr *end)
{
+ if (v->eflags & REG_RAW) {
+ return *s;
+ }
+
wchar_t c = 0;
mbtowc(&c, (const char *)s, end - s);
return c;
}
-#else /* !REGEX_UTF8 */
-
-static inline chr *nextchr(chr *s) { return s+1; }
-static inline chr *prevchr(chr *s) { return s-1; }
-static inline pchr getchr(const chr *s, const chr *end) { return *s; }
-
-#endif
-
/*
- exec - match regular expression
^ int exec(regex_t *, const chr *, size_t, rm_detail_t *,
@@ -399,7 +401,7 @@ find(
d = newdfa(v, cnfa, cm, &v->dfa1);
assert(!(ISERR() && d != NULL));
NOERR();
- for (begin = open; begin <= close; begin = nextchr(begin)) {
+ for (begin = open; begin <= close; begin = nextchr(v, begin)) {
MDEBUG(("\nfind trying at %ld\n", LOFF(begin)));
if (shorter) {
end = shortest(v, d, begin, begin, v->stop, NULL, &hitend);
@@ -524,7 +526,7 @@ cfindloop(
open = cold;
cold = NULL;
MDEBUG(("cbetween %ld and %ld\n", LOFF(open), LOFF(close)));
- for (begin = open; begin <= close; begin = nextchr(begin)) {
+ for (begin = open; begin <= close; begin = nextchr(v, begin)) {
MDEBUG(("\ncfind trying at %ld\n", LOFF(begin)));
estart = begin;
estop = v->stop;
@@ -571,9 +573,9 @@ cfindloop(
*/
if (shorter) {
- estart = nextchr(end);
+ estart = nextchr(v, end);
} else {
- estop = prevchr(end);
+ estop = prevchr(v, end);
}
}
}