Module Name:    src
Committed By:   agc
Date:           Thu Apr 22 17:33:54 UTC 2010

Modified Files:
        src/external/bsd/tre/dist/lib: regexec.c

Log Message:
implement the REG_STARTEND extension using tre_regnexec - REG_STARTEND is
used by mail(1), and file(1), to name but two.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/tre/dist/lib/regexec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/tre/dist/lib/regexec.c
diff -u src/external/bsd/tre/dist/lib/regexec.c:1.1.1.1 src/external/bsd/tre/dist/lib/regexec.c:1.2
--- src/external/bsd/tre/dist/lib/regexec.c:1.1.1.1	Thu Feb 25 07:33:19 2010
+++ src/external/bsd/tre/dist/lib/regexec.c	Thu Apr 22 17:33:54 2010
@@ -213,7 +213,20 @@
 tre_regexec(const regex_t *preg, const char *str,
 	size_t nmatch, regmatch_t pmatch[], int eflags)
 {
-  return tre_regnexec(preg, str, (unsigned)-1, nmatch, pmatch, eflags);
+	const char	*newstr;
+	unsigned	 newflags;
+	size_t		 newlen;
+
+	if (eflags & REG_STARTEND) {
+		newstr = &str[pmatch[0].rm_so];
+		newlen = pmatch[0].rm_eo;
+		newflags = (unsigned)(eflags & ~REG_STARTEND);
+	} else {
+		newstr = str;
+		newlen = (size_t)-1;
+		newflags = (unsigned)eflags;
+	}
+	return tre_regnexec(preg, newstr, newlen, nmatch, pmatch, (int)newflags);
 }
 
 

Reply via email to