summaryrefslogtreecommitdiff
path: root/textproc
diff options
context:
space:
mode:
authorrillig <rillig>2007-03-07 19:18:39 +0000
committerrillig <rillig>2007-03-07 19:18:39 +0000
commit55a524d1b7764ae1833823f80050f12996d93d55 (patch)
tree741e932afc5764c09d2decc80b0c4fb9707fdede /textproc
parent2dee82d6094e7f16a8884b0ff65119eb5764ed82 (diff)
downloadpkgsrc-55a524d1b7764ae1833823f80050f12996d93d55.tar.gz
Fixed a segmentation fault on IRIX. Although IRIX provides the
REG_STARTEND macro, it doesn't work as expected. A simple test case is: printf '\0\n\0\n' | nbsed /a/d This test does not yet work as expected, but at least it doesn't cause segmentation faults anymore. Handling of '\0' bytes must be improved.
Diffstat (limited to 'textproc')
-rw-r--r--textproc/nbsed/Makefile3
-rw-r--r--textproc/nbsed/files/config.h.in3
-rwxr-xr-xtextproc/nbsed/files/configure60
-rw-r--r--textproc/nbsed/files/configure.ac19
-rw-r--r--textproc/nbsed/files/process.c8
5 files changed, 87 insertions, 6 deletions
diff --git a/textproc/nbsed/Makefile b/textproc/nbsed/Makefile
index 2e6514c677f..6d8bbec5119 100644
--- a/textproc/nbsed/Makefile
+++ b/textproc/nbsed/Makefile
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.14 2006/07/14 16:24:28 jlam Exp $
+# $NetBSD: Makefile,v 1.15 2007/03/07 19:18:39 rillig Exp $
DISTNAME= nbsed-20040821
+PKGREVISION= 1
CATEGORIES= textproc pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/textproc/nbsed/files/config.h.in b/textproc/nbsed/files/config.h.in
index 98743338fc7..f1079509bec 100644
--- a/textproc/nbsed/files/config.h.in
+++ b/textproc/nbsed/files/config.h.in
@@ -37,6 +37,9 @@
/* Define to 1 if you have the <regex.h> header file. */
#undef HAVE_REGEX_H
+/* Do you have a working REG_STARTEND? */
+#undef HAVE_REG_STARTEND
+
/* Define to 1 if you have the <stdarg.h> header file. */
#undef HAVE_STDARG_H
diff --git a/textproc/nbsed/files/configure b/textproc/nbsed/files/configure
index cb1e82ecfb4..ba3bbb15601 100755
--- a/textproc/nbsed/files/configure
+++ b/textproc/nbsed/files/configure
@@ -3765,6 +3765,66 @@ fi
done
+echo "$as_me:$LINENO: checking for working REG_STARTEND" >&5
+echo $ECHO_N "checking for working REG_STARTEND... $ECHO_C" >&6
+if test "$cross_compiling" = yes; then
+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#undef NDEBUG
+#include <assert.h>
+#include <regex.h>
+int main(void) {
+ regex_t re;
+ regmatch_t rm;
+
+ assert(regcomp(&re, "lo", 0) == 0);
+ rm.rm_so = 0, rm.rm_eo = 7;
+ assert(regexec(&re, "hel\0lo\n", 1, &rm, REG_STARTEND) == 0);
+ assert(rm.rm_so == 4 && rm.rm_eo == 6);
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_REG_STARTEND 1
+_ACEOF
+
+echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
if test "${ac_cv_c_const+set}" = set; then
diff --git a/textproc/nbsed/files/configure.ac b/textproc/nbsed/files/configure.ac
index 1a5119ce8ae..638ccbed717 100644
--- a/textproc/nbsed/files/configure.ac
+++ b/textproc/nbsed/files/configure.ac
@@ -1,4 +1,4 @@
-dnl $Id: configure.ac,v 1.9 2004/09/12 16:50:50 jschauma Exp $
+dnl $Id: configure.ac,v 1.10 2007/03/07 19:18:39 rillig Exp $
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
AC_INIT([sed],[20040821],[agc@NetBSD.org])
@@ -33,6 +33,23 @@ AC_CHECK_FUNCS(regcomp)
AC_CHECK_FUNCS(regexec)
AC_CHECK_FUNCS(memcpy)
+AC_MSG_CHECKING([for working REG_STARTEND])
+AC_TRY_RUN([
+#undef NDEBUG
+#include <assert.h>
+#include <regex.h>
+int main(void) {
+ regex_t re;
+ regmatch_t rm;
+
+ assert(regcomp(&re, "lo", 0) == 0);
+ rm.rm_so = 0, rm.rm_eo = 7;
+ assert(regexec(&re, "hel\0lo\n", 1, &rm, REG_STARTEND) == 0);
+ assert(rm.rm_so == 4 && rm.rm_eo == 6);
+ return 0;
+}], [AC_DEFINE([HAVE_REG_STARTEND], [1], [Do you have a working REG_STARTEND?])
+AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])])
+
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
diff --git a/textproc/nbsed/files/process.c b/textproc/nbsed/files/process.c
index 3ade9682583..2a6edc3a201 100644
--- a/textproc/nbsed/files/process.c
+++ b/textproc/nbsed/files/process.c
@@ -1,4 +1,4 @@
-/* $NetBSD: process.c,v 1.8 2004/08/22 05:51:55 jlam Exp $ */
+/* $NetBSD: process.c,v 1.9 2007/03/07 19:18:39 rillig Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -78,7 +78,7 @@
#if 0
static char sccsid[] = "@(#)process.c 8.6 (Berkeley) 4/20/94";
#else
-__RCSID("$NetBSD: process.c,v 1.8 2004/08/22 05:51:55 jlam Exp $");
+__RCSID("$NetBSD: process.c,v 1.9 2007/03/07 19:18:39 rillig Exp $");
#endif
#endif /* not lint */
@@ -580,7 +580,7 @@ static inline int
regexec_e(regex_t *preg, const char *string, int eflags, int nomatch, size_t slen)
{
int eval;
-#ifndef REG_STARTEND
+#ifndef HAVE_REG_STARTEND
char *buf;
#endif
@@ -594,7 +594,7 @@ regexec_e(regex_t *preg, const char *string, int eflags, int nomatch, size_t sle
if (slen > 0 && string[slen - 1] == '\n')
slen--;
-#ifndef REG_STARTEND
+#ifndef HAVE_REG_STARTEND
if ((buf = malloc(slen + 1)) == NULL)
err(1, NULL);
(void)memcpy(buf, string, slen);