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.
This commit is contained in:
parent
bdb47b8960
commit
1fd58b933b
5 changed files with 87 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
60
textproc/nbsed/files/configure
vendored
60
textproc/nbsed/files/configure
vendored
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue