bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

18 csets coming up


From: Jim Meyering
Subject: 18 csets coming up
Date: Fri, 01 Jan 2010 16:48:37 +0100

I expect to push the following in a day or so:

      .gitignore: ignore more
      maint: avoid warnings about unused fwrite return value
      maint: avoid compilation warnings
      fix a possible bug: remove errant semicolon
      maint: avoid more warnings
      build: remove now-useless -I../intl option
      build: add configure-time --enable-gcc-warnings option; avoid warnings
      build: avoid format-string warnings
      build: avoid warning about unused definition of N_
      build: avoid shadowing warnings
      build: avoid shadowing warning for unused "rs"
      build: avoid shadowing warning for "link"
      build: avoid warning from -Wmissing-prototypes
      build: rename local to avoid shadowing global, dfa
      maint: rely on gnulib's new isdir.h
      maint: remove decl.m4
      maint: avoid old jm_* macros
      maint: use regex from gnulib, rather than our bit-rotting one

IMHO, the only one that deserves particular scrutiny is the last one:

      maint: use regex from gnulib, rather than our bit-rotting one

There have been almost no changes to the deleted files
since 2004, and those few appear to either already be
in the gnulib version, or are in parts that have been
completely rewritten.

Of course, I've verified that all tests continue to pass.

In the patches below, I've elided the large "remove this file"
parts of the "use regex from gnulib..." cset.

Jim

>From a0993b9906f007a4498fdb901a808f99ed39c5fe Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 1 Jan 2010 16:43:07 +0100
Subject: [PATCH 01/18] .gitignore: ignore more

---
 lib/.gitignore |    3 +++
 m4/.gitignore  |    4 ++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/lib/.gitignore b/lib/.gitignore
index 59a5ee6..299f0fa 100644
--- a/lib/.gitignore
+++ b/lib/.gitignore
@@ -67,10 +67,12 @@ hard-locale.c
 hard-locale.h
 hash.c
 hash.h
+ignore-value.h
 intprops.h
 inttypes.h
 inttypes.in.h
 isdir.c
+isdir.h
 lchown.c
 localcharset.c
 localcharset.h
@@ -165,6 +167,7 @@ unitypes.h
 uniwidth.h
 unlink.c
 unlinkat.c
+unlocked-io.h
 verify.h
 wchar.h
 wchar.in.h
diff --git a/m4/.gitignore b/m4/.gitignore
index 29016c9..b4e1c37 100644
--- a/m4/.gitignore
+++ b/m4/.gitignore
@@ -23,6 +23,7 @@ exitfail.m4
 extensions.m4
 fchdir.m4
 fclose.m4
+fcntl-o.m4
 fcntl_h.m4
 fdopendir.m4
 fnmatch.m4
@@ -67,6 +68,7 @@ lock.m4
 longlong.m4
 lstat.m4
 malloc.m4
+manywarnings.m4
 mbchar.m4
 mbiter.m4
 mbrlen.m4
@@ -122,7 +124,9 @@ time_h.m4
 unistd-safer.m4
 unistd_h.m4
 unlink.m4
+unlocked-io.m4
 visibility.m4
+warnings.m4
 wchar.m4
 wchar_t.m4
 wcrtomb.m4
--
1.6.6.334.g442f


>From 1d11ce09db9184b0a12fae82f7c3b5432bacc1a1 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 24 Dec 2009 17:18:44 +0100
Subject: [PATCH 02/18] maint: avoid warnings about unused fwrite return value

* bootstrap.conf (gnulib_modules): Add unlocked-io.
* src/system.h: Include "unlocked-io.h".
---
 bootstrap.conf |    1 +
 src/system.h   |    2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index 3ddc4f0..9e4cbc5 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -63,6 +63,7 @@ strtoull
 strtoumax
 sys_stat
 unistd
+unlocked-io
 update-copyright
 useless-if-before-free
 wchar
diff --git a/src/system.h b/src/system.h
index 98a848e..62c5954 100644
--- a/src/system.h
+++ b/src/system.h
@@ -96,3 +96,5 @@ int isdir PARAMS ((char const *));
 #ifndef initialize_main
 #define initialize_main(argcp, argvp)
 #endif
+
+#include "unlocked-io.h"
--
1.6.6.334.g442f


>From 7f65deb0490da83a2a9d4e58ea45a2c75ca53b4d Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 24 Dec 2009 17:59:05 +0100
Subject: [PATCH 03/18] maint: avoid compilation warnings

* bootstrap.conf (gnulib_modules): Add ignore-value.
* src/search.c (check_multibyte_string_no_icase): A variant of
check_multibyte_string that does *not* convert case, and hence
does not modify its BUF parameter.
(check_multibyte_string): Use xcalloc in place of xmalloc+memset.
Use ignore_value to ignore the return value from wcrtomb.  This is
ok, since we know the input is a valid upper case wide character.
(Fexecute, EGexecute): Update callers of check_multibyte_string
to use both it and check_multibyte_string_no_icase.
---
 bootstrap.conf |    1 +
 src/search.c   |   50 +++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index 9e4cbc5..616f9cd 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -38,6 +38,7 @@ gitlog-to-changelog
 gnu-web-doc-update
 gnupload
 hard-locale
+ignore-value
 isdir
 locale
 malloc
diff --git a/src/search.c b/src/search.c
index 0bfb41a..fee3505 100644
--- a/src/search.c
+++ b/src/search.c
@@ -30,6 +30,7 @@
 #endif

 #include "system.h"
+#include "ignore-value.h"
 #include "grep.h"
 #ifndef FGREP_PROGRAM
 # include <regex.h>
@@ -138,15 +139,14 @@ kwsmusts (void)
    are not single byte character nor the first byte of a multibyte
    character.  Caller must free the array.  */
 static char*
-check_multibyte_string(char const *buf, size_t size)
+check_multibyte_string(char *buf, size_t size)
 {
-  char *mb_properties = xmalloc(size);
+  char *mb_properties = xcalloc(size, 1);
   mbstate_t cur_state;
   wchar_t wc;
   int i;

   memset(&cur_state, 0, sizeof(mbstate_t));
-  memset(mb_properties, 0, sizeof(char)*size);

   for (i = 0; i < size ;)
     {
@@ -164,7 +164,7 @@ check_multibyte_string(char const *buf, size_t size)
          if (iswupper((wint_t)wc))
            {
              wc = towlower((wint_t)wc);
-             wcrtomb(buf + i, wc, &cur_state);
+             ignore_value (wcrtomb(buf + i, wc, &cur_state));
            }
        }
       mb_properties[i] = mbclen;
@@ -173,6 +173,34 @@ check_multibyte_string(char const *buf, size_t size)

   return mb_properties;
 }
+
+static char*
+check_multibyte_string_no_icase(const char *buf, size_t size)
+{
+  char *mb_properties = xcalloc(size, 1);
+  mbstate_t cur_state;
+  wchar_t wc;
+  int i;
+
+  memset(&cur_state, 0, sizeof(mbstate_t));
+
+  for (i = 0; i < size ;)
+    {
+      size_t mbclen;
+      mbclen = mbrtowc(&wc, buf + i, size - i, &cur_state);
+
+      if (mbclen == (size_t) -1 || mbclen == (size_t) -2 || mbclen == 0)
+       {
+         /* An invalid sequence, or a truncated multibyte character.
+            We treat it as a single byte character.  */
+         mbclen = 1;
+       }
+      mb_properties[i] = mbclen;
+      i += mbclen;
+    }
+
+  return mb_properties;
+}
 #endif /* MBS_SUPPORT */

 #if defined(GREP_PROGRAM) || defined(EGREP_PROGRAM)
@@ -309,10 +337,13 @@ EXECUTE_FCT(EGexecute)
           memcpy(case_buf, buf, size);
          if (start_ptr)
            start_ptr = case_buf + (start_ptr - buf);
+         if (kwset)
+           mb_properties = check_multibyte_string(case_buf, size);
           buf = case_buf;
         }
-      if (kwset)
-        mb_properties = check_multibyte_string(buf, size);
+      else
+       if (kwset)
+         mb_properties = check_multibyte_string_no_icase(buf, size);
     }
 #endif /* MBS_SUPPORT */

@@ -538,13 +569,14 @@ EXECUTE_FCT(Fexecute)
     {
       if (match_icase)
         {
-          char *case_buf = xmalloc(size);
-          memcpy(case_buf, buf, size);
+          char *case_buf = xmemdup (buf, size);
          if (start_ptr)
            start_ptr = case_buf + (start_ptr - buf);
+         mb_properties = check_multibyte_string(case_buf, size);
           buf = case_buf;
         }
-      mb_properties = check_multibyte_string(buf, size);
+      else
+       mb_properties = check_multibyte_string_no_icase(buf, size);
     }
 #endif /* MBS_SUPPORT */

--
1.6.6.334.g442f


>From 9a5eceec017818aa70a2eb2eece5457b7697405a Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 24 Dec 2009 18:50:03 +0100
Subject: [PATCH 04/18] fix a possible bug: remove errant semicolon

* src/grep.c (prline): Remove erroneous semicolon-after-if-expr.
---
 src/grep.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/grep.c b/src/grep.c
index da469e2..a20383d 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -912,7 +912,8 @@ prline (char const *beg, char const *lim, int sep)
       if (matching && (only_matching || *match_color))
        beg = print_line_middle(beg, lim, line_color, match_color);

-      if (!only_matching && *line_color);
+      /* FIXME: this test may be removable.  */
+      if (!only_matching && *line_color)
        beg = print_line_tail(beg, lim, line_color);
     }

--
1.6.6.334.g442f


>From 5531a982f583f53ef734bd9114e177b6c991bdb5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 24 Dec 2009 19:14:46 +0100
Subject: [PATCH 05/18] maint: avoid more warnings

* src/grep.c (MAX): Remove definition of unused macro.
(usage): Declare with __attribute__ ((noreturn)).
Split long strings into chunks of length < 509.
---
 src/grep.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/grep.c b/src/grep.c
index a20383d..9b2b211 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -46,9 +46,6 @@
 #include "closeout.h"
 #include "progname.h"

-#undef MAX
-#define MAX(A,B) ((A) > (B) ? (A) : (B))
-
 #define SEP_CHAR_SELECTED ':'
 #define SEP_CHAR_REJECTED '-'
 #define SEP_STR_GROUP    "--"
@@ -1392,6 +1389,7 @@ grepdir (char const *dir, struct stats const *stats)
   return status;
 }

+static void usage (int status) __attribute__ ((noreturn));
 static void
 usage (int status)
 {
@@ -1454,21 +1452,29 @@ Output control:\n\
   -H, --with-filename       print the filename for each match\n\
   -h, --no-filename         suppress the prefixing filename on output\n\
       --label=LABEL         print LABEL as filename for standard input\n\
+"));
+      printf (_("\
   -o, --only-matching       show only the part of a line matching PATTERN\n\
   -q, --quiet, --silent     suppress all normal output\n\
       --binary-files=TYPE   assume that binary files are TYPE;\n\
                             TYPE is `binary', `text', or `without-match'\n\
   -a, --text                equivalent to --binary-files=text\n\
+"));
+      printf (_("\
   -I                        equivalent to --binary-files=without-match\n\
   -d, --directories=ACTION  how to handle directories;\n\
                             ACTION is `read', `recurse', or `skip'\n\
   -D, --devices=ACTION      how to handle devices, FIFOs and sockets;\n\
                             ACTION is `read' or `skip'\n\
   -R, -r, --recursive       equivalent to --directories=recurse\n\
+"));
+      printf (_("\
       --include=FILE_PATTERN  search only files that match FILE_PATTERN\n\
       --exclude=FILE_PATTERN  skip files and directories matching 
FILE_PATTERN\n\
       --exclude-from=FILE   skip files matching any file pattern from FILE\n\
       --exclude-dir=PATTERN  directories that match PATTERN will be skipped.\n\
+"));
+      printf (_("\
   -L, --files-without-match  print only names of FILEs containing no match\n\
   -l, --files-with-matches  print only names of FILEs containing matches\n\
   -c, --count               print only a count of matching lines per FILE\n\
@@ -1480,6 +1486,8 @@ Context control:\n\
   -B, --before-context=NUM  print NUM lines of leading context\n\
   -A, --after-context=NUM   print NUM lines of trailing context\n\
   -C, --context=NUM         print NUM lines of output context\n\
+"));
+      printf (_("\
   -NUM                      same as --context=NUM\n\
       --color[=WHEN],\n\
       --colour[=WHEN]       use markers to highlight the matching strings;\n\
--
1.6.6.334.g442f


>From 091e06060e20635cfae71a035fd3b17688997e90 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 24 Dec 2009 19:16:29 +0100
Subject: [PATCH 06/18] build: remove now-useless -I../intl option

* src/Makefile.am (INCLUDES): Remove -I../intl, now that intl is gone.
---
 src/Makefile.am |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 8fdb964..20c6855 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,7 +25,7 @@ noinst_HEADERS = grep.h dfa.h kwset.h getpagesize.h system.h 
mbsupport.h
 LDADD = $(LIBINTL) ../lib/libgreputils.a
 grep_LDADD = $(PCRE_LIBS) $(LDADD)
 localedir = $(datadir)/locale
-INCLUDES = -I../intl -I$(top_srcdir)/lib -DLOCALEDIR=\"$(localedir)\"
+INCLUDES = -I$(top_srcdir)/lib -DLOCALEDIR=\"$(localedir)\"

 EXTRA_DIST = \
              dosbuf.c \
--
1.6.6.334.g442f


>From c8cea5fafdb181ce1de5015525b4ee2d14fb74eb Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 25 Dec 2009 20:19:37 +0100
Subject: [PATCH 07/18] build: add configure-time --enable-gcc-warnings option; 
avoid warnings

* bootstrap.conf (gnulib_modules): Add "manywarnings" module.
* configure.ac: Add --enable-gcc-warnings, derived from code in bison.
* src/Makefile.am (AM_CFLAGS): Set to $(WARN_CFLAGS) $(WERROR_CFLAGS)
* lib/Makefile.am (AM_CFLAGS): Likewise, but append.
---
 bootstrap.conf  |    1 +
 configure.ac    |   81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/Makefile.am |    2 +
 src/Makefile.am |    2 +
 4 files changed, 86 insertions(+), 0 deletions(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index 616f9cd..48751b6 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -43,6 +43,7 @@ isdir
 locale
 malloc
 maintainer-makefile
+manywarnings
 mbrlen
 mbrtowc
 memchr
diff --git a/configure.ac b/configure.ac
index e553601..f5204dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,6 +56,87 @@ AC_TYPE_SIZE_T
 AC_C_CONST
 gl_INIT

+AC_ARG_ENABLE([gcc-warnings],
+  [AS_HELP_STRING([--enable-gcc-warnings],
+                  [turn on lots of GCC warnings (for developers)])],
+  [case $enableval in
+     yes|no) ;;
+     *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
+   esac
+   gl_gcc_warnings=$enableval],
+  [gl_gcc_warnings=no]
+)
+
+if test "$gl_gcc_warnings" = yes; then
+  gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
+  AC_SUBST([WERROR_CFLAGS])
+
+  nw=
+  # This, $nw, is the list of warnings we disable.
+  nw="$nw -Wdeclaration-after-statement" # too useful to forbid
+  nw="$nw -Waggregate-return"       # anachronistic
+  nw="$nw -Wlong-long"              # C90 is anachronistic (lib/gethrxtime.h)
+  nw="$nw -Wc++-compat"             # We don't care about C++ compilers
+  nw="$nw -Wundef"                  # Warns on '#if GNULIB_FOO' etc in gnulib
+  nw="$nw -Wtraditional"            # Warns on #elif which we use often
+  nw="$nw -Wcast-qual"              # Too many warnings for now
+  nw="$nw -Wconversion"             # Too many warnings for now
+  nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
+  nw="$nw -Wsign-conversion"        # Too many warnings for now
+  nw="$nw -Wtraditional-conversion" # Too many warnings for now
+  nw="$nw -Wunreachable-code"       # Too many warnings for now
+  nw="$nw -Wpadded"                 # Our structs are not padded
+  nw="$nw -Wredundant-decls"        # openat.h declares e.g., mkdirat
+  nw="$nw -Wlogical-op"             # any use of fwrite provokes this
+  nw="$nw -Wformat-nonliteral"      # who.c and pinky.c strftime uses
+  nw="$nw -Wvla"                    # warnings in gettext.h
+  nw="$nw -Wnested-externs"         # use of XARGMATCH/verify_function__
+  nw="$nw -Wswitch-enum"            # Too many warnings for now
+  nw="$nw -Wswitch-default"         # Too many warnings for now
+  nw="$nw -Wstack-protector"        # not worth working around
+  # things I might fix soon:
+  nw="$nw -Wfloat-equal"            # sort.c, seq.c
+  nw="$nw -Wmissing-format-attribute" # copy.c
+  nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
+  nw="$nw -Winline"                 # system.h's 
readdir_ignoring_dot_and_dotdot
+  nw="$nw -Wstrict-overflow"        # expr.c, pr.c, tr.c, factor.c
+  # ?? -Wstrict-overflow
+
+  gl_MANYWARN_ALL_GCC([ws])
+  gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
+  for w in $ws; do
+    gl_WARN_ADD([$w])
+  done
+  gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
+  gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
+  gl_WARN_ADD([-Wno-pointer-sign])     # Too many warnings for now
+  gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
+
+  # In spite of excluding -Wlogical-op above, it is enabled, as of
+  # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
+  gl_WARN_ADD([-Wno-logical-op])
+
+  gl_WARN_ADD([-fdiagnostics-show-option])
+  gl_WARN_ADD([-funit-at-a-time])
+
+  AC_SUBST([WARN_CFLAGS])
+
+  AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
+  AC_DEFINE([_FORTIFY_SOURCE], [2],
+    [enable compile-time and run-time bounds-checking, and some warnings])
+  AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
+
+  # We use a slightly smaller set of warning options for lib/.
+  # Remove the following and save the result in GNULIB_WARN_CFLAGS.
+  nw=
+  nw="$nw -Wuninitialized"
+  nw="$nw -Wunused-macros"
+  nw="$nw -Wmissing-prototypes"
+  nw="$nw -Wold-style-definition"
+  gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
+  AC_SUBST([GNULIB_WARN_CFLAGS])
+fi
+
 dnl Checks for header files.
 AC_HEADER_STDC
 AC_HEADER_DIRENT
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 492ef32..7b34222 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -18,6 +18,8 @@ include gnulib.mk

 INCLUDES = -I.. -I$(srcdir)

+AM_CFLAGS += $(WARN_CFLAGS) $(WERROR_CFLAGS)
+
 libgreputils_a_SOURCES += \
   savedir.c savedir.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 20c6855..5104793 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,6 +16,8 @@

 LN = ln

+AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
+
 bin_PROGRAMS = grep egrep fgrep
 grep_SOURCES  =  grep.c  search.c kwset.c dfa.c
 egrep_SOURCES = egrep.c esearch.c kwset.c dfa.c
--
1.6.6.334.g442f


>From 12ee9331567e42d4a6aa16dbad7598d85c787e1e Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 25 Dec 2009 20:21:24 +0100
Subject: [PATCH 08/18] build: avoid format-string warnings

* src/search.c (dfaerror): Use literal "%s" as format string.
(kwsmusts, GEAcompile): Likewise.
(Pcompile): Likewise.
---
 src/search.c |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/search.c b/src/search.c
index fee3505..edcb376 100644
--- a/src/search.c
+++ b/src/search.c
@@ -86,7 +86,7 @@ size_t pcount;
 void
 dfaerror (char const *mesg)
 {
-  error (2, 0, mesg);
+  error (2, 0, "%s", mesg);
 }

 /* Number of compiled fixed strings known to exactly match the regexp.
@@ -115,8 +115,8 @@ kwsmusts (void)
          if (!dm->exact)
            continue;
          ++kwset_exact_matches;
-         if ((err = kwsincr (kwset, dm->must, strlen (dm->must))) != 0)
-           error (2, 0, err);
+         if ((err = kwsincr (kwset, dm->must, strlen (dm->must))) != NULL)
+           error (2, 0, "%s", err);
        }
       /* Now, we compile the substrings that will require
         the use of the regexp matcher.  */
@@ -124,11 +124,11 @@ kwsmusts (void)
        {
          if (dm->exact)
            continue;
-         if ((err = kwsincr (kwset, dm->must, strlen (dm->must))) != 0)
-           error (2, 0, err);
+         if ((err = kwsincr (kwset, dm->must, strlen (dm->must))) != NULL)
+           error (2, 0, "%s", err);
        }
-      if ((err = kwsprep (kwset)) != 0)
-       error (2, 0, err);
+      if ((err = kwsprep (kwset)) != NULL)
+       error (2, 0, "%s", err);
     }
 }
 #endif /* !FGREP_PROGRAM */
@@ -252,8 +252,8 @@ GEAcompile (char const *pattern, size_t size, reg_syntax_t 
syntax_bits)
       patterns[pcount] = patterns0;

       if ((err = re_compile_pattern (motif, len,
-                                   &(patterns[pcount].regexbuf))) != 0)
-       error (2, 0, err);
+                                   &(patterns[pcount].regexbuf))) != NULL)
+       error (2, 0, "%s", err);
       pcount++;

       motif = sep;
@@ -546,14 +546,14 @@ COMPILE_FCT(Fcompile)
           }
 #endif
        }
-      if ((err = kwsincr (kwset, beg, end - beg)) != 0)
-       error (2, 0, err);
+      if ((err = kwsincr (kwset, beg, end - beg)) != NULL)
+       error (2, 0, "%s", err);
       beg = lim;
     }
   while (beg < pattern + size);

-  if ((err = kwsprep (kwset)) != 0)
-    error (2, 0, err);
+  if ((err = kwsprep (kwset)) != NULL)
+    error (2, 0, "%s", err);
 }

 EXECUTE_FCT(Fexecute)
@@ -716,11 +716,11 @@ COMPILE_FCT(Pcompile)

   cre = pcre_compile (re, flags, &ep, &e, pcre_maketables ());
   if (!cre)
-    error (2, 0, ep);
+    error (2, 0, "%s", ep);

   extra = pcre_study (cre, 0, &ep);
   if (ep)
-    error (2, 0, ep);
+    error (2, 0, "%s", ep);

   free (re);
 #endif
--
1.6.6.334.g442f


>From 7873a55c89ac30793cd70f9b489e183d375cdb63 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 25 Dec 2009 20:31:42 +0100
Subject: [PATCH 09/18] build: avoid warning about unused definition of N_

* src/dfa.c (N_): Remove unused definition.
---
 src/dfa.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index 35f1ad9..ef7a829 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -76,7 +76,6 @@
 #define ISASCIIDIGIT(c) ((unsigned) (c) - '0' <= 9)

 #include <gettext.h>
-#define N_(String) gettext_noop(String)
 #define _(String) gettext(String)

 #include "mbsupport.h"  /* defines MBS_SUPPORT if appropriate */
--
1.6.6.334.g442f


>From ec531d354f5ea0fa1bd86f95fc1cc989893dd80e Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 25 Dec 2009 20:34:42 +0100
Subject: [PATCH 10/18] build: avoid shadowing warnings

* src/dfa.c (match_mb_charset): Rename parameter: s/index/idx/.
(check_matching_with_multibyte_ops, match_anychar): Likewise.
---
 src/dfa.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index ef7a829..7f69878 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -469,7 +469,7 @@ fetch_wc (char const *eoferr)
    This function  parse a bracket expression and build a struct
    mb_char_classes.  */
 static void
-parse_bracket_exp_mb ()
+parse_bracket_exp_mb (void)
 {
   wint_t wc, wc1, wc2;

@@ -2433,18 +2433,18 @@ transit_state_singlebyte (struct dfa *d, int s, 
unsigned char const *p,
 /* Check whether period can match or not in the current context.  If it can,
    return the amount of the bytes with which period can match, otherwise
    return 0.
-   `pos' is the position of the period.  `index' is the index from the
+   `pos' is the position of the period.  `idx' is the index from the
    buf_begin, and it is the current position in the buffer.  */
 static int
-match_anychar (struct dfa *d, int s, position pos, int index)
+match_anychar (struct dfa *d, int s, position pos, int idx)
 {
   int newline = 0;
   int letter = 0;
   wchar_t wc;
   int mbclen;

-  wc = inputwcs[index];
-  mbclen = (mblen_buf[index] == 0)? 1 : mblen_buf[index];
+  wc = inputwcs[idx];
+  mbclen = (mblen_buf[idx] == 0)? 1 : mblen_buf[idx];

   /* Check context.  */
   if (wc == (wchar_t)eolbyte)
@@ -2473,10 +2473,10 @@ match_anychar (struct dfa *d, int s, position pos, int 
index)
 /* Check whether bracket expression can match or not in the current context.
    If it can, return the amount of the bytes with which expression can match,
    otherwise return 0.
-   `pos' is the position of the bracket expression.  `index' is the index
+   `pos' is the position of the bracket expression.  `idx' is the index
    from the buf_begin, and it is the current position in the buffer.  */
 int
-match_mb_charset (struct dfa *d, int s, position pos, int index)
+match_mb_charset (struct dfa *d, int s, position pos, int idx)
 {
   int i;
   int match;           /* Flag which represent that matching succeed.  */
@@ -2493,7 +2493,7 @@ match_mb_charset (struct dfa *d, int s, position pos, int 
index)
   int letter = 0;
   wchar_t wc;          /* Current refering character.  */

-  wc = inputwcs[index];
+  wc = inputwcs[idx];

   /* Check context.  */
   if (wc == (wchar_t)eolbyte)
@@ -2517,7 +2517,7 @@ match_mb_charset (struct dfa *d, int s, position pos, int 
index)
   /* Assign the current refering operator to work_mbc.  */
   work_mbc = &(d->mbcsets[(d->multibyte_prop[pos.index]) >> 2]);
   match = !work_mbc->invert;
-  match_len = (mblen_buf[index] == 0)? 1 : mblen_buf[index];
+  match_len = (mblen_buf[idx] == 0)? 1 : mblen_buf[idx];

   /* match with a character class?  */
   for (i = 0; i<work_mbc->nch_classes; i++)
@@ -2526,14 +2526,14 @@ match_mb_charset (struct dfa *d, int s, position pos, 
int index)
        goto charset_matched;
     }

-  strncpy(buffer, (char const *) buf_begin + index, match_len);
+  strncpy(buffer, (char const *) buf_begin + idx, match_len);
   buffer[match_len] = '\0';

   /* match with an equivalent class?  */
   for (i = 0; i<work_mbc->nequivs; i++)
     {
       op_len = strlen(work_mbc->equivs[i]);
-      strncpy(buffer, (char const *) buf_begin + index, op_len);
+      strncpy(buffer, (char const *) buf_begin + idx, op_len);
       buffer[op_len] = '\0';
       if (strcoll(work_mbc->equivs[i], buffer) == 0)
        {
@@ -2546,7 +2546,7 @@ match_mb_charset (struct dfa *d, int s, position pos, int 
index)
   for (i = 0; i<work_mbc->ncoll_elems; i++)
     {
       op_len = strlen(work_mbc->coll_elems[i]);
-      strncpy(buffer, (char const *) buf_begin + index, op_len);
+      strncpy(buffer, (char const *) buf_begin + idx, op_len);
       buffer[op_len] = '\0';

       if (strcoll(work_mbc->coll_elems[i], buffer) == 0)
@@ -2587,11 +2587,11 @@ match_mb_charset (struct dfa *d, int s, position pos, 
int index)
    array which corresponds to `d->states[s].mbps.elem' and each element of
    the array contains the amount of the bytes with which the element can
    match.
-   `index' is the index from the buf_begin, and it is the current position
+   `idx' is the index from the buf_begin, and it is the current position
    in the buffer.
    Caller MUST free the array which this function return.  */
 static int*
-check_matching_with_multibyte_ops (struct dfa *d, int s, int index)
+check_matching_with_multibyte_ops (struct dfa *d, int s, int idx)
 {
   int i;
   int* rarray;
@@ -2603,10 +2603,10 @@ check_matching_with_multibyte_ops (struct dfa *d, int 
s, int index)
       switch(d->tokens[pos.index])
        {
        case ANYCHAR:
-         rarray[i] = match_anychar(d, s, pos, index);
+         rarray[i] = match_anychar(d, s, pos, idx);
          break;
        case MBCSET:
-         rarray[i] = match_mb_charset(d, s, pos, index);
+         rarray[i] = match_mb_charset(d, s, pos, idx);
          break;
        default:
          break; /* can not happen.  */
--
1.6.6.334.g442f


>From ed42840ed6eb3ed280e4041dd8567938d5967b67 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 25 Dec 2009 20:48:32 +0100
Subject: [PATCH 11/18] build: avoid shadowing warning for unused "rs"

* src/dfa.c (transit_state): Remove dead stores;
move a declaration "down".
Ignore transit_state_consume_1char return value.
---
 src/dfa.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index 7f69878..3fbc0eb 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2682,7 +2682,6 @@ transit_state (struct dfa *d, int s, unsigned char const 
**pp)
   int nelem = d->states[s].mbps.nelem; /* Just a alias.  */
   position_set follows;
   unsigned char const *p1 = *pp;
-  status_transit_state rs;
   wchar_t wc;

   if (nelem > 0)
@@ -2725,7 +2724,7 @@ transit_state (struct dfa *d, int s, unsigned char const 
**pp)
      not be a character but a (multi character) collating element.
      We enumerate all of the positions which `s' can reach by consuming
      `maxlen' bytes.  */
-  rs = transit_state_consume_1char(d, s, pp, match_lens, &mbclen, &follows);
+  transit_state_consume_1char(d, s, pp, match_lens, &mbclen, &follows);

   wc = inputwcs[*pp - mbclen - buf_begin];
   s1 = state_index(d, &follows, wc == L'\n', iswalnum(wc));
@@ -2734,7 +2733,7 @@ transit_state (struct dfa *d, int s, unsigned char const 
**pp)
   while (*pp - p1 < maxlen)
     {
       follows.nelem = 0;
-      rs = transit_state_consume_1char(d, s1, pp, NULL, &mbclen, &follows);
+      transit_state_consume_1char(d, s1, pp, NULL, &mbclen, &follows);

       for (i = 0; i < nelem ; i++)
        {
--
1.6.6.334.g442f


>From d3beaa933ff931e58183ece2a01ef45bd758da80 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 25 Dec 2009 22:25:00 +0100
Subject: [PATCH 12/18] build: avoid shadowing warning for "link"

* src/kwset.c (link): Define to kwset_link, to avoid shadowing
the function.

(transit_state): Ignore transit_state_consume_1char return value.
---
 src/kwset.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/kwset.c b/src/kwset.c
index 459f0a0..1cdaabb 100644
--- a/src/kwset.c
+++ b/src/kwset.c
@@ -35,6 +35,8 @@
 #include "kwset.h"
 #include "obstack.h"

+#define link kwset_link
+
 #ifdef GREP
 # include "xalloc.h"
 # undef malloc
--
1.6.6.334.g442f


>From c5cc3f858f1be85a651f91f07b77c9c589c50d4f Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 25 Dec 2009 22:26:40 +0100
Subject: [PATCH 13/18] build: avoid warning from -Wmissing-prototypes

* src/dfa.c (match_mb_charset): Declare to be static.
---
 src/dfa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index 3fbc0eb..2d19bfc 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2475,7 +2475,7 @@ match_anychar (struct dfa *d, int s, position pos, int 
idx)
    otherwise return 0.
    `pos' is the position of the bracket expression.  `idx' is the index
    from the buf_begin, and it is the current position in the buffer.  */
-int
+static int
 match_mb_charset (struct dfa *d, int s, position pos, int idx)
 {
   int i;
--
1.6.6.334.g442f


>From 6b5936465137a899e8621b152ea8dde7b59440ea Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 25 Dec 2009 22:33:05 +0100
Subject: [PATCH 14/18] build: rename local to avoid shadowing global, dfa

* src/dfa.c (dfamust): Rename parameter: s/dfa/d/.
---
 src/dfa.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index 2d19bfc..60ec372 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3354,7 +3354,7 @@ resetmust (must *mp)
 }

 static void
-dfamust (struct dfa *dfa)
+dfamust (struct dfa *d)
 {
   must *musts;
   must *mp;
@@ -3369,13 +3369,13 @@ dfamust (struct dfa *dfa)

   result = empty_string;
   exact = 0;
-  musts = (must *) malloc((dfa->tindex + 1) * sizeof *musts);
+  musts = (must *) malloc((d->tindex + 1) * sizeof *musts);
   if (musts == NULL)
     return;
   mp = musts;
-  for (i = 0; i <= dfa->tindex; ++i)
+  for (i = 0; i <= d->tindex; ++i)
     mp[i] = must0;
-  for (i = 0; i <= dfa->tindex; ++i)
+  for (i = 0; i <= d->tindex; ++i)
     {
       mp[i].in = (char **) malloc(sizeof *mp[i].in);
       mp[i].left = malloc(2);
@@ -3389,16 +3389,16 @@ dfamust (struct dfa *dfa)
     }
 #ifdef DEBUG
   fprintf(stderr, "dfamust:\n");
-  for (i = 0; i < dfa->tindex; ++i)
+  for (i = 0; i < d->tindex; ++i)
     {
       fprintf(stderr, " %d:", i);
-      prtok(dfa->tokens[i]);
+      prtok(d->tokens[i]);
     }
   putc('\n', stderr);
 #endif
-  for (ri = 0; ri < dfa->tindex; ++ri)
+  for (ri = 0; ri < d->tindex; ++ri)
     {
-      switch (t = dfa->tokens[ri])
+      switch (t = d->tokens[ri])
        {
        case LPAREN:
        case RPAREN:
@@ -3567,7 +3567,7 @@ dfamust (struct dfa *dfa)
        }
 #ifdef DEBUG
       fprintf(stderr, " node: %d:", ri);
-      prtok(dfa->tokens[ri]);
+      prtok(d->tokens[ri]);
       fprintf(stderr, "\n  in:");
       for (i = 0; mp->in[i]; ++i)
        fprintf(stderr, " \"%s\"", mp->in[i]);
@@ -3584,11 +3584,11 @@ dfamust (struct dfa *dfa)
       dm->exact = exact;
       MALLOC(dm->must, char, strlen(result) + 1);
       strcpy(dm->must, result);
-      dm->next = dfa->musts;
-      dfa->musts = dm;
+      dm->next = d->musts;
+      d->musts = dm;
     }
   mp = musts;
-  for (i = 0; i <= dfa->tindex; ++i)
+  for (i = 0; i <= d->tindex; ++i)
     {
       freelist(mp[i].in);
       ifree((char *) mp[i].in);
--
1.6.6.334.g442f


>From 34e516d0fcb1ff5a455c16b218c782ce46d7ea39 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 26 Dec 2009 10:02:22 +0100
Subject: [PATCH 15/18] maint: rely on gnulib's new isdir.h

* src/grep.c: Include "isdir.h".
* src/system.h: Remove declaration of isdir.
---
 src/grep.c   |    1 +
 src/system.h |    2 --
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/src/grep.c b/src/grep.c
index 9b2b211..bef60b8 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -45,6 +45,7 @@
 #include "exitfail.h"
 #include "closeout.h"
 #include "progname.h"
+#include "isdir.h"

 #define SEP_CHAR_SELECTED ':'
 #define SEP_CHAR_REJECTED '-'
diff --git a/src/system.h b/src/system.h
index 62c5954..dddb026 100644
--- a/src/system.h
+++ b/src/system.h
@@ -42,8 +42,6 @@
 # define HAVE_DOS_FILE_CONTENTS 1
 #endif

-int isdir PARAMS ((char const *));
-
 #ifdef EISDIR
 # define is_EISDIR(e, f) ((e) == EISDIR)
 #else
--
1.6.6.334.g442f


>From 0524f7b0af73f7a43a753951f56547d737c2140b Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 26 Dec 2009 11:34:49 +0100
Subject: [PATCH 16/18] maint: remove decl.m4

* m4/decl.m4: Remove unused file.
---
 m4/decl.m4 |   37 -------------------------------------
 1 files changed, 0 insertions(+), 37 deletions(-)
 delete mode 100644 m4/decl.m4

diff --git a/m4/decl.m4 b/m4/decl.m4
deleted file mode 100644
index c503a5d..0000000
--- a/m4/decl.m4
+++ /dev/null
@@ -1,37 +0,0 @@
-#serial 5
-
-AC_DEFUN([jm_CHECK_DECLARATION],
-[
-  AC_MSG_CHECKING([whether $1 is declared])
-  AC_CACHE_VAL(jm_cv_func_decl_$1,
-    [AC_TRY_COMPILE([$2],
-      [
-#ifndef $1
-char *(*pfn) = (char *(*)) $1
-#endif
-      ],
-      eval "jm_cv_func_decl_$1=yes",
-      eval "jm_cv_func_decl_$1=no")])
-
-  if eval "test \"`echo '$jm_cv_func_decl_'$1`\" = yes"; then
-    AC_MSG_RESULT(yes)
-    ifelse([$3], , :, [$3])
-  else
-    AC_MSG_RESULT(no)
-    ifelse([$4], , , [$4
-])dnl
-  fi
-])dnl
-
-dnl jm_CHECK_DECLARATIONS(INCLUDES, FUNCTION... [, ACTION-IF-DECLARED
-dnl                       [, ACTION-IF-NOT-DECLARED]])
-AC_DEFUN([jm_CHECK_DECLARATIONS],
-[
-  for jm_func in $2
-  do
-    jm_CHECK_DECLARATION($jm_func, [$1],
-    [
-      jm_tr_func=HAVE_DECL_`echo $jm_func | tr abcdefghijklmnopqrstuvwxyz 
ABCDEFGHIJKLMNOPQRSTUVWXYZ`
-      AC_DEFINE_UNQUOTED($jm_tr_func, 1, [Define if your system declares $1]) 
$3], [$4])dnl
-  done
-])
--
1.6.6.334.g442f


>From f7e7b7bbb6e1ef1907f7c3785a677d08efd65c58 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 30 Dec 2009 17:58:59 +0100
Subject: [PATCH 17/18] maint: avoid old jm_* macros

There were jm_* macros here, until very recently.
* cfg.mk (sc_prohibit_jm_in_m4): New rule, from coreutils.
---
 cfg.mk |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index 0d9ffaf..80cf2ec 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -38,3 +38,11 @@ bootstrap-tools = autoconf,automake,gnulib
 export VERBOSE = yes

 old_NEWS_hash = f81932a59c299cb94579f099231305a6
+
+# Many m4 macros names once began with `jm_'.
+# Make sure that none are inadvertently reintroduced.
+sc_prohibit_jm_in_m4:
+       @grep -nE 'jm_[A-Z]'                                            \
+               $$($(VC_LIST) m4 |grep '\.m4$$'; echo /dev/null) &&     \
+           { echo '$(ME): do not use jm_ in m4 macro names'            \
+             1>&2; exit 1; } || :
--
1.6.6.334.g442f


>From f2f22ee3e4081f6006bf4471712bcf1241833832 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 26 Dec 2009 11:45:36 +0100
Subject: [PATCH 18/18] maint: use regex from gnulib, rather than our 
bit-rotting one

* bootstrap.conf (gnulib_modules): Add regex.
* configure.ac: Don't use jm_INCLUDED_REGEX.
Update use of cache variable.
* lib/regex.c: Remove file.
* lib/regex.h: Likewise.
* m4/regex.m4: Likewise.
* POTFILES.in: Update to match.
---
 bootstrap.conf |    1 +
 configure.ac   |   12 +-
 lib/regex.c    | 7897 --------------------------------------------------------
 lib/regex.h    |  579 -----
 m4/regex.m4    |   74 -
 po/POTFILES.in |    2 +-
 6 files changed, 4 insertions(+), 8561 deletions(-)
 delete mode 100644 lib/regex.c
 delete mode 100644 lib/regex.h
 delete mode 100644 m4/regex.m4

diff --git a/bootstrap.conf b/bootstrap.conf
index 48751b6..d8ef2f1 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -53,6 +53,7 @@ obstack
 progname
 quotearg
 realloc
+regex
 ssize_t
 stddef
 stdlib
diff --git a/configure.ac b/configure.ac
index f5204dc..de5725c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -151,20 +151,12 @@ dnl I18N feature
 AM_GNU_GETTEXT_VERSION([0.17])
 AM_GNU_GETTEXT([external])

-dnl some folks ask for this, that's fine by me
-dnl hope they know what they're doing ...
-dnl if glibc2 regex is not included
-
-dnl Many GNU/Linux people have different
-dnl glibc versions with buggy regex.
-jm_INCLUDED_REGEX(lib/regex.c)
-
 dnl Some installers want to be informed if we do not use our regex.
 dnl For example, if the host platform uses dynamic linking and the installer
 dnl knows that the grep may be invoked on other hosts with buggy libraries,
 dnl then the installer should configure --with-included-regex.
-if test "$jm_with_regex" = no; then
-       AC_MSG_WARN(Included lib/regex.c not used)
+if test "$ac_use_included_regex" = no; then
+  AC_MSG_WARN([Included lib/regex.c not used])
 fi

 # support for pcre
diff --git a/lib/regex.c b/lib/regex.c
deleted file mode 100644
index c0e911e..0000000
--- a/lib/regex.c
+++ /dev/null
@@ -1,7897 +0,0 @@
-/* Extended regular expression matching and search library,
-   version 0.12.
...
diff --git a/lib/regex.h b/lib/regex.h
deleted file mode 100644
index 2965672..0000000
--- a/lib/regex.h
+++ /dev/null
@@ -1,579 +0,0 @@
-/* Definitions for data structures and routines for the regular
-   expression library, version 0.12.
-   Copyright (C) 1985, 1989-1993, 1995-1998, 2000, 2006-2007, 2009-2010 Free
...
diff --git a/m4/regex.m4 b/m4/regex.m4
deleted file mode 100644
index b313b5e..0000000
--- a/m4/regex.m4
+++ /dev/null
@@ -1,74 +0,0 @@
-#serial 5001
-
-dnl Initially derived from code in GNU grep.
...
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8e98466..920413e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -20,7 +20,7 @@ lib/error.c
 lib/getopt.c
 lib/obstack.c
 lib/quotearg.c
-lib/regex.c
+lib/regcomp.c
 lib/xalloc-die.c
 lib/xstrtol-error.c
 src/dfa.c
--
1.6.6.334.g442f




reply via email to

[Prev in Thread] Current Thread [Next in Thread]