Module Name: src
Committed By: christos
Date: Mon Jun 9 12:48:58 UTC 2014
Modified Files:
src/usr.bin/sed: process.c
Log Message:
PR/48883: Justin Cormack: Cope with systems that don't provide REG_STARTEND
To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.bin/sed/process.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/sed/process.c
diff -u src/usr.bin/sed/process.c:1.43 src/usr.bin/sed/process.c:1.44
--- src/usr.bin/sed/process.c:1.43 Sat Jun 7 12:36:54 2014
+++ src/usr.bin/sed/process.c Mon Jun 9 08:48:58 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: process.c,v 1.43 2014/06/07 16:36:54 christos Exp $ */
+/* $NetBSD: process.c,v 1.44 2014/06/09 12:48:58 christos Exp $ */
/*-
* Copyright (c) 1992 Diomidis Spinellis.
@@ -38,7 +38,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: process.c,v 1.43 2014/06/07 16:36:54 christos Exp $");
+__RCSID("$NetBSD: process.c,v 1.44 2014/06/09 12:48:58 christos Exp $");
#ifdef __FBSDID
__FBSDID("$FreeBSD: head/usr.bin/sed/process.c 192732 2009-05-25 06:45:33Z brian $");
#endif
@@ -650,6 +650,9 @@ regexec_e(regex_t *preg, const char *str
size_t slen)
{
int eval;
+#ifndef REG_STARTEND
+ char *buf;
+#endif
if (preg == NULL) {
if (defpreg == NULL)
@@ -658,11 +661,19 @@ regexec_e(regex_t *preg, const char *str
defpreg = preg;
/* Set anchors */
+#ifndef REG_STARTEND
+ buf = xmalloc(slen + 1);
+ (void)memcpy(buf, string, slen);
+ buf[slen] = '\0';
+ eval = regexec(defpreg, buf,
+ nomatch ? 0 : maxnsub + 1, match, eflags);
+ free(buf);
+#else
match[0].rm_so = 0;
match[0].rm_eo = (regoff_t)slen;
-
eval = regexec(defpreg, string,
nomatch ? 0 : maxnsub + 1, match, eflags | REG_STARTEND);
+#endif
switch(eval) {
case 0:
return (1);