From df1819094ef7fa210df7e076cd1c18da62ac454f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 31 Jan 2013 12:51:47 -0800 Subject: [PATCH] Use gnulib's regex code, now merged with Gawk's. * awk.h, dfa.c: Include on all platforms, for ptrdiff_t. is required by C89 and is safe to assume nowadays. * configure.ac (gl_EARLY, gl_INIT): Invoke, for gnulib. (with_included_regex): Set to yes, for gnulib. * replace.c: Include missing_d/btowc.c if ! HAVE_BTOWC. * merge-gnulib: New file. Invoke this script after installing this patch, to sync the rest of the files from gnulib. * missing_d/btowc.c: New file. * pc/config.sed: Configure HAVE_DECL_ISBLANK, HAVE_ISBLANK, HAVE_MBSTATE_T, _REGEX_INCLUDE_LIMITS_H, _REGEX_LARGE_OFFSETS. --- ChangeLog | 11 ++++++ awk.h | 2 +- configure.ac | 3 ++ dfa.c | 3 +- merge-gnulib | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++ missing_d/ChangeLog | 5 +++ missing_d/btowc.c | 19 +++++++++ pc/ChangeLog | 6 +++ pc/config.sed | 14 +++++++ replace.c | 4 ++ 10 files changed, 175 insertions(+), 3 deletions(-) create mode 100755 merge-gnulib create mode 100644 missing_d/btowc.c diff --git a/ChangeLog b/ChangeLog index d00b1fb..2fc1f0e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2013-01-31 Paul Eggert + + Use gnulib's regex code, now merged with Gawk's. + * awk.h, dfa.c: Include on all platforms, for ptrdiff_t. + is required by C89 and is safe to assume nowadays. + * configure.ac (gl_EARLY, gl_INIT): Invoke, for gnulib. + (with_included_regex): Set to yes, for gnulib. + * replace.c: Include missing_d/btowc.c if ! HAVE_BTOWC. + * merge-gnulib: New file. Invoke this script after installing + this patch, to sync the rest of the files from gnulib. + 2013-01-31 Arnold D. Robbins * dfa.c: Include "dfa.h" which includes regex.h after limits.h diff --git a/awk.h b/awk.h index f26ec20..f5469d6 100644 --- a/awk.h +++ b/awk.h @@ -133,6 +133,7 @@ typedef long int32_t; /* This section is the messiest one in the file, not a lot that can be done */ +#include #ifndef VMS #ifdef HAVE_FCNTL_H #include @@ -140,7 +141,6 @@ typedef long int32_t; #include #include #else /* VMS */ -#include #include #include /* avoid in io.c */ /* debug.c needs this; when _DECC_V4_SOURCE is defined (as it is diff --git a/configure.ac b/configure.ac index 4ba5f6a..6d910ec 100644 --- a/configure.ac +++ b/configure.ac @@ -106,6 +106,9 @@ AC_SUBST(acl_shlibext) AC_SUBST([pkgextensiondir], ['${pkglibdir}']) dnl checks for systems +gl_EARLY +with_included_regex=yes +gl_INIT AC_ZOS_USS AC_ISC_POSIX AC_SYS_LARGEFILE diff --git a/dfa.c b/dfa.c index 88d34d5..b2bbbd3 100644 --- a/dfa.c +++ b/dfa.c @@ -26,10 +26,9 @@ #include #include +#include #ifndef VMS #include -#else -#include #endif #include #include diff --git a/merge-gnulib b/merge-gnulib new file mode 100755 index 0000000..c76dd3a --- /dev/null +++ b/merge-gnulib @@ -0,0 +1,111 @@ +#! /bin/sh +# Merge gnulib sources into GAWK sources. +# Typical usage: +# +# ./merge-gnulib + +# Copyright 2012-2013 Free Software Foundation, Inc. + +# This file is part of GAWK, the GNU implementation of the +# AWK Programming Language. + +# GAWK is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with GAWK. If not, see . + +# written by Paul Eggert + +GNULIB_URL=git://git.savannah.gnu.org/gnulib.git + +GNULIB_MODULES=' + regex +' + +GNULIB_TOOL_FLAGS=' + --avoid=alloca-opt + --avoid=gettext-h + --avoid=btowc + --avoid=localcharset + --avoid=malloc-gnu + --avoid=mbrtowc + --avoid=mbsinit + --avoid=mbtowc + --avoid=memcmp + --avoid=memmove + --avoid=nl_langinfo + --avoid=stdbool + --avoid=stdint + --avoid=wchar + --avoid=wcrtomb + --avoid=wctype + --avoid=wctype-h + --conditional-dependencies --import + --no-changelog --no-vc-files + --makefile-name=gnulib.mk + --source-base=. +' + +# The source directory, with a trailing '/'. +# If empty, the source directory is the working directory. +src=$2 +case $src in + */ | '') ;; + *) src=$src/ ;; +esac + +# Gnulib's source directory. +gnulib_srcdir=${1-$src../gnulib} + +case $gnulib_srcdir in + -*) src=- ;; +esac +case $src in + -*) + echo >&2 "$0: usage: $0 [GNULIB_SRCDIR [SRCDIR]] + + SRCDIR is the GAWK source directory (default: working directory). + GNULIB_SRCDIR is the Gnulib source directory (default: SRCDIR/../gnulib)." + exit 1 ;; +esac + +test -r "$src"awk.h || { + echo >&2 "$0: '${src:-.}' is not a Gawk source directory." + exit 1 +} + +test -d "$gnulib_srcdir" || +git clone -- "$GNULIB_URL" "$gnulib_srcdir" || +exit + +test -x "$gnulib_srcdir"/gnulib-tool || { + echo >&2 "$0: '$gnulib_srcdir' is not a Gnulib source directory." + exit 1 +} + +"$gnulib_srcdir"/gnulib-tool --dir="$src" $GNULIB_TOOL_FLAGS $GNULIB_MODULES && +rm -- "$src"dummy.c "$src"gnulib.mk "$src"m4/gnulib-cache.m4 && +cp -- "$gnulib_srcdir"/build-aux/texinfo.tex "$src"doc && +cp -- "$gnulib_srcdir"/build-aux/ar-lib \ + "$gnulib_srcdir"/build-aux/config.guess \ + "$gnulib_srcdir"/build-aux/config.rpath \ + "$gnulib_srcdir"/build-aux/config.sub \ + "$gnulib_srcdir"/build-aux/depcomp \ + "$gnulib_srcdir"/build-aux/install-sh \ + "$src"extension/build-aux && +cp -- "$gnulib_srcdir"/build-aux/config.guess \ + "$gnulib_srcdir"/build-aux/config.rpath \ + "$gnulib_srcdir"/build-aux/config.sub \ + "$gnulib_srcdir"/build-aux/depcomp \ + "$gnulib_srcdir"/build-aux/install-sh \ + "$gnulib_srcdir"/build-aux/mkinstalldirs \ + "$src". && +autoreconf -I m4 -- ${src:+"$src"} diff --git a/missing_d/ChangeLog b/missing_d/ChangeLog index 54825c8..87f9b5b 100644 --- a/missing_d/ChangeLog +++ b/missing_d/ChangeLog @@ -1,3 +1,8 @@ +2013-01-31 Paul Eggert + + Use gnulib's regex code, now merged with Gawk's. + * btowc.c: New file. + 2012-12-24 Arnold D. Robbins * 4.0.2: Release tar ball made. diff --git a/missing_d/btowc.c b/missing_d/btowc.c new file mode 100644 index 0000000..4ebf6ce --- /dev/null +++ b/missing_d/btowc.c @@ -0,0 +1,19 @@ +#ifdef ZOS_USS + +/* For ZOS USS we must define btowc */ + +wchar_t +btowc (int c) +{ + wchar_t wtmp[2]; + char tmp[2]; + mbstate_t mbs; + + memset(& mbs, 0, sizeof(mbs)); + tmp[0] = c; + tmp[1] = 0; + + mbrtowc (wtmp, tmp, 1, & mbs); + return wtmp[0]; +} +#endif diff --git a/pc/ChangeLog b/pc/ChangeLog index 1dc181d..fc7edd5 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -1,3 +1,9 @@ +2013-01-31 Paul Eggert + + Use gnulib's regex code, now merged with Gawk's. + * config.sed: Configure HAVE_DECL_ISBLANK, HAVE_ISBLANK, + HAVE_MBSTATE_T, _REGEX_INCLUDE_LIMITS_H, _REGEX_LARGE_OFFSETS. + 2013-01-25 Arnold D. Robbins * config.h: Version bumped. diff --git a/pc/config.sed b/pc/config.sed index 5e57e82..803a833 100644 --- a/pc/config.sed +++ b/pc/config.sed @@ -38,6 +38,10 @@ s/^#undef HAVE_ATEXIT *$/#define HAVE_ATEXIT 1/ #ifdef _WIN32\ #define HAVE_BTOWC 1\ #endif +/^#undef HAVE_DECL_ISBLANK *$/c\ +#ifdef __MINGW32__\ +#define HAVE_DECL_ISBLANK 1\ +#endif /^#undef HAVE_DECL_TZNAME *$/c\ #ifdef __MINGW32__\ #define HAVE_DECL_TZNAME 1\ @@ -60,6 +64,10 @@ s/^#undef HAVE_FMOD *$/#define HAVE_FMOD 1/ #ifdef __MINGW32__\ #define HAVE_ISASCII 1\ #endif +/^#undef HAVE_ISBLANK *$/c\ +#ifdef __MINGW32__\ +#define HAVE_ISBLANK 1\ +#endif /^#undef HAVE_ISWCTYPE *$/c\ #ifdef __MINGW32__\ #define HAVE_ISWCTYPE 1\ @@ -92,6 +100,10 @@ s/^#undef HAVE_LIMITS_H *$/#define HAVE_LIMITS_H 1/ #ifdef __MINGW32__\ #define HAVE_MBRTOWC 1\ #endif +/^#undef HAVE_MBSTATE_T *$/c\ +#ifdef __MINGW32__\ +#define HAVE_MBSTATE_T 1\ +#endif s/^#undef HAVE_MEMCMP *$/#define HAVE_MEMCMP 1/ s/^#undef HAVE_MEMCPY *$/#define HAVE_MEMCPY 1/ /^#undef HAVE_MEMMOVE *$/c\ @@ -220,6 +232,8 @@ s/^#undef HAVE_VPRINTF *$/#define HAVE_VPRINTF 1/ #define HAVE_WINT_T 1\ #endif s/^#undef PROTOTYPES *$/#define PROTOTYPES 1/ +s/^#undef _REGEX_INCLUDE_LIMITS_H *$/#define _REGEX_INCLUDE_LIMITS_H 1/ +s/^#undef _REGEX_LARGE_OFFSETS *$/#define _REGEX_LARGE_OFFSETS 1/ s/^#undef RETSIGTYPE *$/#define RETSIGTYPE void/ /^#.*RETSIGTYPE /a\ \ diff --git a/replace.c b/replace.c index 4259aaf..1568cf3 100644 --- a/replace.c +++ b/replace.c @@ -34,6 +34,10 @@ #include "missing_d/system.c" #endif /* HAVE_SYSTEM */ +#ifndef HAVE_BTOWC +#include "missing_d/btowc.c" +#endif /* HAVE_MEMCPY */ + #ifndef HAVE_MEMCMP #include "missing_d/memcmp.c" #endif /* HAVE_MEMCMP */ -- 1.7.11.7