develooper Front page | perl.perl5.porters | Postings from May 2003

[PATCH] \K again -- any more comments about it?

Thread Next
From:
Jeff 'japhy' Pinyan
Date:
May 21, 2003 18:51
Subject:
[PATCH] \K again -- any more comments about it?
Message ID:
Pine.LNX.4.44.0305212140070.5607-200000@perlmonk.org
--- regcomp.c.old	Wed May 21 19:34:15 2003
+++ regcomp.c	Wed May 21 19:46:01 2003
@@ -2896,6 +2896,11 @@
 	    nextchar(pRExC_state);
             Set_Node_Length(ret, 2); /* MJD */
 	    break;
+	case 'K':
+	    ret = reg_node(pRExC_state, KEEP);
+	    nextchar(pRExC_state);
+            Set_Node_Length(ret, 2); /* MJD */
+	    break;
 	case 'Z':
 	    ret = reg_node(pRExC_state, SEOL);
 	    *flagp |= SIMPLE;
@@ -3107,6 +3112,7 @@
 		    case 'C':
 		    case 'X':
 		    case 'G':
+		    case 'K':
 		    case 'Z':
 		    case 'z':
 		    case 'w':
--- regexec.c.old	Wed May 21 19:36:20 2003
+++ regexec.c	Wed May 21 19:38:42 2003
@@ -135,7 +135,7 @@
 #define JUMPABLE(rn) ( \
     OP(rn) == OPEN || OP(rn) == CLOSE || OP(rn) == EVAL || \
     OP(rn) == SUSPEND || OP(rn) == IFMATCH || \
-    OP(rn) == PLUS || OP(rn) == MINMOD || \
+    OP(rn) == PLUS || OP(rn) == MINMOD || OP(rn) == KEEP || \
     (PL_regkind[(U8)OP(rn)] == CURLY && ARG1(rn) > 0) \
 )
 
@@ -2374,6 +2374,9 @@
 	    if (locinput == PL_reg_ganch)
 		break;
 	    sayNO;
+	case KEEP:
+	    PL_regstartp[0] = locinput - PL_bostr;
+	    break;
 	case EOL:
 	    if (PL_multiline)
 		goto meol;
--- regnodes.h.old	Wed May 21 19:38:58 2003
+++ regnodes.h	Wed May 21 19:41:09 2003
@@ -65,6 +65,7 @@
 #define	LOGICAL	59	/* 0x3b Next opcode should set the flag only. */
 #define	RENUM	60	/* 0x3c Group with independently numbered parens. */
 #define	OPTIMIZED	61	/* 0x3d Placeholder for dump. */
+#define	KEEP	62	/* 0x3e Pretend the regex started matching here. */
 
 #ifndef DOINIT
 EXTCONST U8 PL_regkind[];
@@ -132,6 +133,7 @@
 	LOGICAL,		/* LOGICAL */
 	BRANCHJ,		/* RENUM */
 	NOTHING,		/* OPTIMIZED */
+	KEEP,		/* KEEP */
 };
 #endif
 
@@ -200,6 +202,7 @@
 	0,		/* LOGICAL */
 	EXTRA_SIZE(struct regnode_1),		/* RENUM */
 	0,		/* OPTIMIZED */
+	0,		/* KEEP */
 };
 
 static const char reg_off_by_arg[] = {
@@ -265,6 +268,7 @@
 	0,		/* LOGICAL */
 	1,		/* RENUM */
 	0,		/* OPTIMIZED */
+	0,		/* KEEP */
 };
 
 #ifdef DEBUGGING
@@ -331,9 +335,10 @@
 	"LOGICAL",		/* 0x3b */
 	"RENUM",		/* 0x3c */
 	"OPTIMIZED",		/* 0x3d */
+	"KEEP",			/* 0x3e */
 };
 
-static const int reg_num = 62;
+static const int reg_num = 63;
 
 #endif /* DEBUGGING */
 #endif /* REG_COMP_C */

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About