This is the mail archive of the
gdb@sourceware.cygnus.com
mailing list for the GDB project.
Re: A patch for gnu-regex
"H . J . Lu" wrote:
>
> On Wed, Mar 08, 2000 at 06:58:18PM +0100, Mark Kettenis wrote:
> >
> > I can add --enable-gdb-regex if it helps.
> >
> > If we decide to do so, could we then try to be consistent with other
> > GNU packages that already let the user choose between the regex
> > implementation distributed with that package, and the implementation
> > in the C library, and us --with(out)-included-regex?
> >
>
> Here is a revised patch. It overrides:
>
> http://sourceware.cygnus.com/ml/gdb-patches/2000-q1/msg00562.html
> http://sourceware.cygnus.com/ml/gdb-patches/2000-q1/msg00566.html
This patch is definitly much better than the original.
Unfortunatly, I don't think that selecting a pre-installed regexp should
be the default. My rationale (As Mark? noted) is that ensuring that a
GDB release provides consistent behavour between systems (1) is more
important than having it select the latest/greatest random regexp.
Perhaphs, what is needed is a, post 5.0, update to the regexp code.
enjoy,
Andrew
PS: Should the ``defined _GLIBC_ && _GLIBC_ >= 2'' test be part of
configure.in?
PPS: I have to wonder if some of those #include's are actually needed
:-)
> H.J.
> ---
> 2000-03-08 H.J. Lu <hjl@gnu.org>
>
> * gdb_regex.h: New. Include <regex.h> for glibc 2 and include
> "gnu-regex.h" otherwise.
>
> * irix5-nat.c: Include "gdb_regex.h" instead of "gnu-regex.h".
> * monitor.c: Likewise.
> * osfsolib.c: Likewise.
> * solib.c: Likewise.
> * source.c: Likewise.
> * symtab.c: Likewise.
>
> * Makefile.in (REGEX): Changed to @REGEX@.
> (REGEX_CFLAGS): New.
> (REGEX1): Removed.
> (ADD_DEPS): Use $(REGEX) instead of $(REGEX1).
> (INTERNAL_WARN_CFLAGS): Add $(REGEX_CFLAGS).
>
> * configure.in (--with-included-regex): New switch.
> (REGEX): New. Subsstitue @REGEX@ in Makefile.in.
> (REGEX_CFLAGS): New. Subsstitue @REGEX_CFLAGS@ in Makefile.in.
> * configure: Regenerated.
>
> Index: configure.in
> ===================================================================
> RCS file: /work/cvs/gnu/gdb/gdb/configure.in,v
> retrieving revision 1.1.1.6
> diff -u -p -r1.1.1.6 configure.in
> --- configure.in 2000/03/07 18:42:10 1.1.1.6
> +++ configure.in 2000/03/08 23:33:09
> @@ -505,6 +505,34 @@ if test x$want_mmalloc = xtrue; then
> MMALLOC='../mmalloc/libmmalloc.a'
> fi
>
> +AC_ARG_WITH(included-regex,
> +[ --with-included-regex Use included regex],
> +[case "${withval}" in
> + yes) want_included_regex=true ;;
> + no) want_included_regex=false;;
> + *) AC_MSG_ERROR(bad value ${withval} for GDB with-included-regex option) ;;
> +esac],[want_included_regex=false])dnl
> +
> +REGEX="gnu-regex.o"
> +REGEX_CFLAGS="-DUSE_INCLUDED_REGEX"
> +if test $want_included_regex = false; then
> + AC_MSG_CHECKING(for GNU regex in glibc 2)
> + AC_CACHE_VAL(gdb_cv_have_glibc_2,
> +[AC_TRY_COMPILE([#include <features.h>],
> +[#if !defined __GLIBC__ || __GLIBC__ < 2
> +#error It is not glibc 2.
> +#endif
> +],
> + [gdb_cv_have_glibc_2=yes],
> + [gdb_cv_have_glibc_2=no])])
> + AC_MSG_RESULT($gdb_cv_have_glibc_2)
> + if test $gdb_cv_have_glibc_2 = yes; then
> + REGEX=
> + REGEX_CFLAGS=
> + fi
> +fi
> +AC_SUBST(REGEX)
> +AC_SUBST(REGEX_CFLAGS)
>
> # In the Cygwin environment, we need some additional flags.
> AC_CACHE_CHECK([for cygwin], gdb_cv_os_cygwin,
> Index: irix5-nat.c
> ===================================================================
> RCS file: /work/cvs/gnu/gdb/gdb/irix5-nat.c,v
> retrieving revision 1.1.1.3
> retrieving revision 1.3
> diff -u -p -r1.1.1.3 -r1.3
> --- irix5-nat.c 1999/11/19 23:38:46 1.1.1.3
> +++ irix5-nat.c 2000/03/08 00:36:03 1.3
> @@ -278,7 +278,7 @@ fetch_core_registers (core_reg_sect, cor
> #include "objfiles.h"
> #include "command.h"
> #include "frame.h"
> -#include "gnu-regex.h"
> +#include "gdb_regex.h"
> #include "inferior.h"
> #include "language.h"
> #include "gdbcmd.h"
> Index: monitor.c
> ===================================================================
> RCS file: /work/cvs/gnu/gdb/gdb/monitor.c,v
> retrieving revision 1.1.1.5
> retrieving revision 1.3
> diff -u -p -r1.1.1.5 -r1.3
> --- monitor.c 2000/03/07 18:42:14 1.1.1.5
> +++ monitor.c 2000/03/08 00:36:03 1.3
> @@ -50,7 +50,7 @@
> #include "monitor.h"
> #include "gdbcmd.h"
> #include "inferior.h"
> -#include "gnu-regex.h"
> +#include "gdb_regex.h"
> #include "dcache.h"
> #include "srec.h"
>
> Index: osfsolib.c
> ===================================================================
> RCS file: /work/cvs/gnu/gdb/gdb/osfsolib.c,v
> retrieving revision 1.1.1.3
> retrieving revision 1.3
> diff -u -p -r1.1.1.3 -r1.3
> --- osfsolib.c 1999/11/19 23:38:50 1.1.1.3
> +++ osfsolib.c 2000/03/08 00:36:03 1.3
> @@ -36,7 +36,7 @@
> #include "command.h"
> #include "target.h"
> #include "frame.h"
> -#include "gnu-regex.h"
> +#include "gdb_regex.h"
> #include "inferior.h"
> #include "language.h"
> #include "gdbcmd.h"
> Index: solib.c
> ===================================================================
> RCS file: /work/cvs/gnu/gdb/gdb/solib.c,v
> retrieving revision 1.1.1.4
> retrieving revision 1.7
> diff -u -p -r1.1.1.4 -r1.7
> --- solib.c 2000/03/07 18:42:17 1.1.1.4
> +++ solib.c 2000/03/08 18:36:11 1.7
> @@ -49,7 +49,7 @@
> #include "command.h"
> #include "target.h"
> #include "frame.h"
> -#include "gnu-regex.h"
> +#include "gdb_regex.h"
> #include "inferior.h"
> #include "environ.h"
> #include "language.h"
> Index: source.c
> ===================================================================
> RCS file: /work/cvs/gnu/gdb/gdb/source.c,v
> retrieving revision 1.1.1.3
> retrieving revision 1.3
> diff -u -p -r1.1.1.3 -r1.3
> --- source.c 2000/02/04 20:21:58 1.1.1.3
> +++ source.c 2000/03/08 00:36:03 1.3
> @@ -33,7 +33,7 @@
> #include "gdb_stat.h"
> #include <fcntl.h>
> #include "gdbcore.h"
> -#include "gnu-regex.h"
> +#include "gdb_regex.h"
> #include "symfile.h"
> #include "objfiles.h"
> #include "annotate.h"
> Index: symtab.c
> ===================================================================
> RCS file: /work/cvs/gnu/gdb/gdb/symtab.c,v
> retrieving revision 1.1.1.4
> retrieving revision 1.3
> diff -u -p -r1.1.1.4 -r1.3
> --- symtab.c 2000/03/07 18:42:17 1.1.1.4
> +++ symtab.c 2000/03/08 00:36:03 1.3
> @@ -30,7 +30,7 @@
> #include "objfiles.h"
> #include "gdbcmd.h"
> #include "call-cmds.h"
> -#include "gnu-regex.h"
> +#include "gdb_regex.h"
> #include "expression.h"
> #include "language.h"
> #include "demangle.h"
> Index: Makefile.in
> ===================================================================
> RCS file: /work/cvs/gnu/gdb/gdb/Makefile.in,v
> retrieving revision 1.1.1.9
> diff -u -p -r1.1.1.9 Makefile.in
> --- Makefile.in 2000/03/07 18:42:08 1.1.1.9
> +++ Makefile.in 2000/03/08 23:48:52
> @@ -114,6 +114,11 @@ LIBIBERTY = ../libiberty/libiberty.a
> MMALLOC = @MMALLOC@
> MMALLOC_CFLAGS = @MMALLOC_CFLAGS@
>
> +# We are using our own version of REGEX now to be consistent across
> +# machines.
> +REGEX = @REGEX@
> +REGEX_CFLAGS = @REGEX_CFLAGS@
> +
> # Where is the BFD library? Typically in ../bfd.
> BFD_DIR = ../bfd
> BFD = $(BFD_DIR)/libbfd.a
> @@ -271,7 +276,8 @@ INTERNAL_WARN_CFLAGS = \
> $(CFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \
> $(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) \
> $(BFD_CFLAGS) $(MMALLOC_CFLAGS) $(INCLUDE_CFLAGS) \
> - $(INTL_CFLAGS) $(TUI_CFLAGS) $(ENABLE_CFLAGS) $(GDB_WARN_CFLAGS)
> + $(INTL_CFLAGS) $(TUI_CFLAGS) $(ENABLE_CFLAGS) \
> + $(REGEX_CFLAGS) $(GDB_WARN_CFLAGS)
> INTERNAL_CFLAGS = $(INTERNAL_WARN_CFLAGS) $(GDB_WERROR_CFLAGS)
>
> # LDFLAGS is specifically reserved for setting from the command line
> @@ -283,11 +289,6 @@ INTERNAL_CFLAGS = $(INTERNAL_WARN_CFLAGS
> INTERNAL_LDFLAGS = $(CFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) $(LDFLAGS) $(CONFIG_LDFLAGS) @HLDFLAGS@
> HLDENV = @HLDENV@
>
> -# We are using our own version of REGEX now to be consistent across
> -# machines.
> -REGEX = gnu-regex.o
> -REGEX1 = gnu-regex.o
> -
> # If your system is missing alloca(), or, more likely, it's there but
> # it doesn't work, then refer to libiberty.
>
> @@ -308,7 +309,7 @@ CDEPS = $(XM_CDEPS) $(TM_CDEPS) $(NAT_CD
> $(OPCODES) $(MMALLOC) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS)
>
> ADD_FILES = $(REGEX) $(XM_ADD_FILES) $(TM_ADD_FILES) $(NAT_ADD_FILES)
> -ADD_DEPS = $(REGEX1) $(XM_ADD_FILES) $(TM_ADD_FILES) $(NAT_ADD_FILES)
> +ADD_DEPS = $(REGEX) $(XM_ADD_FILES) $(TM_ADD_FILES) $(NAT_ADD_FILES)
>
> VERSION = 20000204
> DIST=gdb
> --- /dev/null Tue May 5 13:32:27 1998
> +++ gdb_regex.h Wed Mar 8 15:40:01 2000
> @@ -0,0 +1,7 @@
> +#ifndef _GDB_REGEX_H
> +#if !defined USE_INCLUDED_REGEX && defined __GLIBC__ && __GLIBC__ >= 2
> +#include <regex.h>
> +#else
> +#include "gnu-regex.h"
> +#endif
> +#endif /* _GDB_REGEX_H */