#define RF_warned 2 /* warned about big count? */
#define RF_evaled 4 /* Did an EVAL with setting? */
#define RF_utf8 8 /* String contains multibyte chars? */
+#define RF_false 16 /* odd number of nested negatives */
#define UTF ((PL_reg_flags & RF_utf8) != 0)
I32 doevery = (prog->reganch & ROPT_SKIP) == 0;
char *m;
STRLEN ln;
+ STRLEN lnc;
unsigned int c1;
unsigned int c2;
char *e;
}
break;
case EXACTF:
- m = STRING(c);
- ln = STR_LEN(c);
+ m = STRING(c);
+ ln = STR_LEN(c); /* length to match in octets/bytes */
+ lnc = (I32) ln; /* length to match in characters */
if (UTF) {
STRLEN ulen1, ulen2;
+ U8 *sm = (U8 *) m;
U8 tmpbuf1[UTF8_MAXLEN_UCLC+1];
U8 tmpbuf2[UTF8_MAXLEN_UCLC+1];
0, ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY);
c2 = utf8n_to_uvchr(tmpbuf2, UTF8_MAXLEN_UCLC,
0, ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY);
+ lnc = 0;
+ while (sm < ((U8 *) m + ln)) {
+ lnc++;
+ sm += UTF8SKIP(sm);
+ }
}
else {
c1 = *(U8*)m;
}
goto do_exactf;
case EXACTFL:
- m = STRING(c);
- ln = STR_LEN(c);
+ m = STRING(c);
+ ln = STR_LEN(c);
+ lnc = (I32) ln;
c1 = *(U8*)m;
c2 = PL_fold_locale[c1];
do_exactf:
- e = HOP3c(strend, -(I32)ln, s);
+ e = HOP3c(strend, -((I32)lnc), s);
if (norun && e < s)
e = s; /* Due to minlen logic of intuit() */
STRLEN len, foldlen;
if (c1 == c2) {
+ /* Upper and lower of 1st char are equal -
+ * probably not a "letter". */
while (s <= e) {
c = utf8n_to_uvchr((U8*)s, UTF8_MAXLEN, &len,
ckWARN(WARN_UTF8) ?
"%*s already tried at this position...\n",
REPORT_CODE_OFF+PL_regindent*2, "")
);
- sayNO_SILENT;
+ if (PL_reg_flags & RF_false)
+ sayYES;
+ else
+ sayNO_SILENT;
}
PL_reg_poscache[o] |= (1<<b);
}
if (! HAS_TEXT(text_node)) c1 = c2 = -1000;
else {
if (PL_regkind[(U8)OP(text_node)] == REF) {
- I32 n, ln;
- n = ARG(text_node); /* which paren pair */
- ln = PL_regstartp[n];
- /* assume yes if we haven't seen CLOSEn */
- if (
- (I32)*PL_reglastparen < n ||
- ln == -1 ||
- ln == PL_regendp[n]
- ) {
- c1 = c2 = -1000;
- goto assume_ok_MM;
- }
- c1 = *(PL_bostr + ln);
+ c1 = c2 = -1000;
+ goto assume_ok_MM;
}
else { c1 = (U8)*STRING(text_node); }
if (OP(text_node) == EXACTF || OP(text_node) == REFF)
if (! HAS_TEXT(text_node)) c1 = c2 = -1000;
else {
if (PL_regkind[(U8)OP(text_node)] == REF) {
- I32 n, ln;
- n = ARG(text_node); /* which paren pair */
- ln = PL_regstartp[n];
- /* assume yes if we haven't seen CLOSEn */
- if (
- (I32)*PL_reglastparen < n ||
- ln == -1 ||
- ln == PL_regendp[n]
- ) {
- c1 = c2 = -1000;
- goto assume_ok_REG;
- }
- c1 = *(PL_bostr + ln);
+ c1 = c2 = -1000;
+ goto assume_ok_REG;
}
else { c1 = (U8)*STRING(text_node); }
if (! HAS_TEXT(text_node)) c1 = c2 = -1000;
else {
if (PL_regkind[(U8)OP(text_node)] == REF) {
- I32 n, ln;
- n = ARG(text_node); /* which paren pair */
- ln = PL_regstartp[n];
- /* assume yes if we haven't seen CLOSEn */
- if (
- (I32)*PL_reglastparen < n ||
- ln == -1 ||
- ln == PL_regendp[n]
- ) {
- c1 = c2 = -1000;
- goto assume_ok_easy;
- }
- s = (U8*)PL_bostr + ln;
+ c1 = c2 = -1000;
+ goto assume_ok_easy;
}
else { s = (U8*)STRING(text_node); }
}
else
PL_reginput = locinput;
+ PL_reg_flags ^= RF_false;
goto do_ifmatch;
case IFMATCH:
n = 1;
do_ifmatch:
inner = NEXTOPER(NEXTOPER(scan));
if (regmatch(inner) != n) {
+ if (n == 0)
+ PL_reg_flags ^= RF_false;
say_no:
if (logical) {
logical = 0;
else
sayNO;
}
+ if (n == 0)
+ PL_reg_flags ^= RF_false;
say_yes:
if (logical) {
logical = 0;