Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/sed PR/48883: Justin Cormack: Cope with systems that...
details: https://anonhg.NetBSD.org/src/rev/b78a723deeeb
branches: trunk
changeset: 329786:b78a723deeeb
user: christos <christos%NetBSD.org@localhost>
date: Mon Jun 09 12:48:58 2014 +0000
description:
PR/48883: Justin Cormack: Cope with systems that don't provide REG_STARTEND
diffstat:
usr.bin/sed/process.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diffs (49 lines):
diff -r 94b4a2aacee2 -r b78a723deeeb usr.bin/sed/process.c
--- a/usr.bin/sed/process.c Mon Jun 09 12:44:06 2014 +0000
+++ b/usr.bin/sed/process.c Mon Jun 09 12:48:58 2014 +0000
@@ -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 @@
size_t slen)
{
int eval;
+#ifndef REG_STARTEND
+ char *buf;
+#endif
if (preg == NULL) {
if (defpreg == NULL)
@@ -658,11 +661,19 @@
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);
Home |
Main Index |
Thread Index |
Old Index