#define WORST 0 /* Worst case. */
#define HASWIDTH 0x01 /* Known to match non-null strings. */
-/* Simple enough to be STAR/PLUS operand; in an EXACT node must be a single
+/* Simple enough to be STAR/PLUS operand; in an EXACTish node must be a single
* character. Note that this is not the same thing as REGNODE_SIMPLE */
#define SIMPLE 0x02
-#define SPSTART 0x04 /* Starts with * or +. */
+#define SPSTART 0x04 /* Starts with * or + */
#define TRYAGAIN 0x08 /* Weeded out a declaration. */
#define POSTPONED 0x10 /* (?1),(?&name), (??{...}) or similar */
goto finish_meta_pat;
case 'R':
ret = reg_node(pRExC_state, LNBREAK);
- *flagp |= HASWIDTH;
+ *flagp |= HASWIDTH|SIMPLE;
goto finish_meta_pat;
case 'h':
ret = reg_node(pRExC_state, HORIZWS);
ret = reg(pRExC_state, 1, ®_flags, depth+1);
- *flagp |= reg_flags&(HASWIDTH|SPSTART|POSTPONED);
+ *flagp |= reg_flags&(HASWIDTH|SIMPLE|SPSTART|POSTPONED);
RExC_parse = save_parse;
RExC_end = save_end;
/*
- regrepeat - repeatedly match something simple, report how many
*
+ * What 'simple' means is a node which can be the operand of a quantifier like
+ * '+', or {1,3}
+ *
* startposp - pointer a pointer to the start position. This is updated
* to point to the byte following the highest successful
* match.
}
break;
case LNBREAK:
- Perl_croak(aTHX_ "panic: regrepeat() should not be called with non-simple: LNBREAK");
- assert(0); /* NOTREACHED */
+ if (utf8_target) {
+ while (hardcount < max && scan < loceol &&
+ (c=is_LNBREAK_utf8_safe(scan, loceol))) {
+ scan += c;
+ hardcount++;
+ }
+ } else {
+ /* LNBREAK can match one or two latin chars, which is ok, but we
+ * have to use hardcount in this situation, and throw away the
+ * adjustment to <loceol> done before the switch statement */
+ loceol = PL_regeol;
+ while (scan < loceol && (c=is_LNBREAK_latin1_safe(scan, loceol))) {
+ scan+=c;
+ hardcount++;
+ }
+ }
+ break;
case HORIZWS:
if (utf8_target) {
while (hardcount < max && scan < loceol &&