grep-commit
[Top][All Lists]
Advanced

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

grep branch, master, updated. v2.18-61-g5c92a54


From: Paul Eggert
Subject: grep branch, master, updated. v2.18-61-g5c92a54
Date: Fri, 11 Apr 2014 20:23:33 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  5c92a54ec36f176854f0b0cca83b5ff224f2d8e8 (commit)
       via  45aef12b13259a36e9fd4e2085860a45202f3820 (commit)
       via  2d3832e1ff772dc1a374bfad5dcc1338350cc48b (commit)
      from  d9869ef79c2e1c549c2b2100b2115b0cdb1d3297 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=5c92a54ec36f176854f0b0cca83b5ff224f2d8e8


commit 5c92a54ec36f176854f0b0cca83b5ff224f2d8e8
Author: Paul Eggert <address@hidden>
Date:   Fri Apr 11 12:48:48 2014 -0700

    grep: cleanup for HAS_DOS_FILE_CONTENTS issue
    
    While cleaning up the empty-string fix, I noticed that one part of
    the code worried about CRLF in pattern files whereas another part
    did not.  Fix this by using the same approach in both places,
    and make the CRLF code more modular in the process.
    * src/dosbuf.c (dos_binary, dos_unix_byte_offsets): New functions.
    (undossify_input, dossified_pos): Do nothing if ! O_BINARY.
    * src/grep.c: Always include dosbuf.c so that the code is
    checked statically even on non-DOS hosts.
    (dos_binary, dos_unix_byte_offsets): New decls.
    (undossify_input): Declare unconditionally.
    * src/grep.c (fillbuf, print_line_head, main):
    * src/kwsearch.c (Fcompile):
    Simplify by not worrying about HAVE_DOS_FILE_CONTENTS.
    * src/grep.c (main): fopen with "rt" if O_TEXT; this is simpler
    than worrying about HAVE_DOS_FILE_CONTENTS elsewhere.
    * src/system.h (HAVE_DOS_FILE_CONTENTS): Remove.

diff --git a/src/dosbuf.c b/src/dosbuf.c
index 3648371..9ac2d13 100644
--- a/src/dosbuf.c
+++ b/src/dosbuf.c
@@ -49,6 +49,22 @@ static int       dos_pos_map_size  = 0;
 static int       dos_pos_map_used  = 0;
 static int       inp_map_idx = 0, out_map_idx = 1;
 
+/* Set default DOS file type to binary.  */
+static void
+dos_binary (void)
+{
+  if (O_BINARY)
+    dos_use_file_type = DOS_BINARY;
+}
+
+/* Tell DOS routines to report Unix offset.  */
+static void
+dos_unix_byte_offsets (void)
+{
+  if (O_BINARY)
+    dos_report_unix_offset = 1;
+}
+
 /* Guess DOS file type by looking at its contents.  */
 static File_type
 guess_type (char *buf, size_t buflen)
@@ -79,6 +95,9 @@ guess_type (char *buf, size_t buflen)
 static int
 undossify_input (char *buf, size_t buflen)
 {
+  if (! O_BINARY)
+    return buflen;
+
   int chars_left = 0;
 
   if (totalcc == 0)
@@ -167,6 +186,9 @@ undossify_input (char *buf, size_t buflen)
 static off_t
 dossified_pos (off_t byteno)
 {
+  if (! O_BINARY)
+    return byteno;
+
   off_t pos_lo;
   off_t pos_hi;
 
diff --git a/src/grep.c b/src/grep.c
index 8bd6c49..d58ef03 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -395,9 +395,10 @@ static enum
 
 static int grepfile (int, char const *, int, int);
 static int grepdesc (int, int);
-#if defined HAVE_DOS_FILE_CONTENTS
+
+static void dos_binary (void);
+static void dos_unix_byte_offsets (void);
 static int undossify_input (char *, size_t);
-#endif
 
 static int
 is_device_mode (mode_t m)
@@ -648,10 +649,7 @@ fillbuf (size_t save, struct stat const *st)
   if (fillsize < 0)
     fillsize = cc = 0;
   bufoffset += fillsize;
-#if defined HAVE_DOS_FILE_CONTENTS
-  if (fillsize)
-    fillsize = undossify_input (readbuf, fillsize);
-#endif
+  fillsize = undossify_input (readbuf, fillsize);
   buflim = readbuf + fillsize;
   return cc;
 }
@@ -695,9 +693,7 @@ static intmax_t pending;    /* Pending lines of output.
 static int done_on_match;      /* Stop scanning file on first match.  */
 static int exit_on_match;      /* Exit on first match.  */
 
-#if defined HAVE_DOS_FILE_CONTENTS
-# include "dosbuf.c"
-#endif
+#include "dosbuf.c"
 
 /* Add two numbers that count input bytes or lines, and report an
    error if the addition overflows.  */
@@ -803,9 +799,7 @@ print_line_head (char const *beg, char const *lim, int sep)
   if (out_byte)
     {
       uintmax_t pos = add_count (totalcc, beg - bufbeg);
-#if defined HAVE_DOS_FILE_CONTENTS
       pos = dossified_pos (pos);
-#endif
       if (pending_sep)
         print_sep (sep);
       print_offset (pos, 6, byte_num_color);
@@ -2043,15 +2037,11 @@ main (int argc, char **argv)
         break;
 
       case 'U':
-#if defined HAVE_DOS_FILE_CONTENTS
-        dos_use_file_type = DOS_BINARY;
-#endif
+        dos_binary ();
         break;
 
       case 'u':
-#if defined HAVE_DOS_FILE_CONTENTS
-        dos_report_unix_offset = 1;
-#endif
+        dos_unix_byte_offsets ();
         break;
 
       case 'V':
@@ -2086,7 +2076,7 @@ main (int argc, char **argv)
         break;
 
       case 'f':
-        fp = STREQ (optarg, "-") ? stdin : fopen (optarg, "r");
+        fp = STREQ (optarg, "-") ? stdin : fopen (optarg, O_TEXT ? "rt" : "r");
         if (!fp)
           error (EXIT_TROUBLE, errno, "%s", optarg);
         for (keyalloc = 1; keyalloc <= keycc + 1; keyalloc *= 2)
diff --git a/src/kwsearch.c b/src/kwsearch.c
index cf8df3c..5f3f233 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -50,10 +50,6 @@ Fcompile (char const *pattern, size_t size)
           len = sep - p;
           sep++;
           total -= (len + 1);
-#if HAVE_DOS_FILE_CONTENTS
-         if (sep[-1] == '\r')
-           --len;
-#endif
         }
       else
         {
diff --git a/src/system.h b/src/system.h
index 4c85409..7da1d8d 100644
--- a/src/system.h
+++ b/src/system.h
@@ -29,10 +29,6 @@
 #include "minmax.h"
 #include "same-inode.h"
 
-#if O_BINARY
-# define HAVE_DOS_FILE_CONTENTS 1
-#endif
-
 #include <stdlib.h>
 #include <stddef.h>
 #include <limits.h>

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=45aef12b13259a36e9fd4e2085860a45202f3820


commit 5c92a54ec36f176854f0b0cca83b5ff224f2d8e8
Author: Paul Eggert <address@hidden>
Date:   Fri Apr 11 12:48:48 2014 -0700

    grep: cleanup for HAS_DOS_FILE_CONTENTS issue
    
    While cleaning up the empty-string fix, I noticed that one part of
    the code worried about CRLF in pattern files whereas another part
    did not.  Fix this by using the same approach in both places,
    and make the CRLF code more modular in the process.
    * src/dosbuf.c (dos_binary, dos_unix_byte_offsets): New functions.
    (undossify_input, dossified_pos): Do nothing if ! O_BINARY.
    * src/grep.c: Always include dosbuf.c so that the code is
    checked statically even on non-DOS hosts.
    (dos_binary, dos_unix_byte_offsets): New decls.
    (undossify_input): Declare unconditionally.
    * src/grep.c (fillbuf, print_line_head, main):
    * src/kwsearch.c (Fcompile):
    Simplify by not worrying about HAVE_DOS_FILE_CONTENTS.
    * src/grep.c (main): fopen with "rt" if O_TEXT; this is simpler
    than worrying about HAVE_DOS_FILE_CONTENTS elsewhere.
    * src/system.h (HAVE_DOS_FILE_CONTENTS): Remove.

diff --git a/src/dosbuf.c b/src/dosbuf.c
index 3648371..9ac2d13 100644
--- a/src/dosbuf.c
+++ b/src/dosbuf.c
@@ -49,6 +49,22 @@ static int       dos_pos_map_size  = 0;
 static int       dos_pos_map_used  = 0;
 static int       inp_map_idx = 0, out_map_idx = 1;
 
+/* Set default DOS file type to binary.  */
+static void
+dos_binary (void)
+{
+  if (O_BINARY)
+    dos_use_file_type = DOS_BINARY;
+}
+
+/* Tell DOS routines to report Unix offset.  */
+static void
+dos_unix_byte_offsets (void)
+{
+  if (O_BINARY)
+    dos_report_unix_offset = 1;
+}
+
 /* Guess DOS file type by looking at its contents.  */
 static File_type
 guess_type (char *buf, size_t buflen)
@@ -79,6 +95,9 @@ guess_type (char *buf, size_t buflen)
 static int
 undossify_input (char *buf, size_t buflen)
 {
+  if (! O_BINARY)
+    return buflen;
+
   int chars_left = 0;
 
   if (totalcc == 0)
@@ -167,6 +186,9 @@ undossify_input (char *buf, size_t buflen)
 static off_t
 dossified_pos (off_t byteno)
 {
+  if (! O_BINARY)
+    return byteno;
+
   off_t pos_lo;
   off_t pos_hi;
 
diff --git a/src/grep.c b/src/grep.c
index 8bd6c49..d58ef03 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -395,9 +395,10 @@ static enum
 
 static int grepfile (int, char const *, int, int);
 static int grepdesc (int, int);
-#if defined HAVE_DOS_FILE_CONTENTS
+
+static void dos_binary (void);
+static void dos_unix_byte_offsets (void);
 static int undossify_input (char *, size_t);
-#endif
 
 static int
 is_device_mode (mode_t m)
@@ -648,10 +649,7 @@ fillbuf (size_t save, struct stat const *st)
   if (fillsize < 0)
     fillsize = cc = 0;
   bufoffset += fillsize;
-#if defined HAVE_DOS_FILE_CONTENTS
-  if (fillsize)
-    fillsize = undossify_input (readbuf, fillsize);
-#endif
+  fillsize = undossify_input (readbuf, fillsize);
   buflim = readbuf + fillsize;
   return cc;
 }
@@ -695,9 +693,7 @@ static intmax_t pending;    /* Pending lines of output.
 static int done_on_match;      /* Stop scanning file on first match.  */
 static int exit_on_match;      /* Exit on first match.  */
 
-#if defined HAVE_DOS_FILE_CONTENTS
-# include "dosbuf.c"
-#endif
+#include "dosbuf.c"
 
 /* Add two numbers that count input bytes or lines, and report an
    error if the addition overflows.  */
@@ -803,9 +799,7 @@ print_line_head (char const *beg, char const *lim, int sep)
   if (out_byte)
     {
       uintmax_t pos = add_count (totalcc, beg - bufbeg);
-#if defined HAVE_DOS_FILE_CONTENTS
       pos = dossified_pos (pos);
-#endif
       if (pending_sep)
         print_sep (sep);
       print_offset (pos, 6, byte_num_color);
@@ -2043,15 +2037,11 @@ main (int argc, char **argv)
         break;
 
       case 'U':
-#if defined HAVE_DOS_FILE_CONTENTS
-        dos_use_file_type = DOS_BINARY;
-#endif
+        dos_binary ();
         break;
 
       case 'u':
-#if defined HAVE_DOS_FILE_CONTENTS
-        dos_report_unix_offset = 1;
-#endif
+        dos_unix_byte_offsets ();
         break;
 
       case 'V':
@@ -2086,7 +2076,7 @@ main (int argc, char **argv)
         break;
 
       case 'f':
-        fp = STREQ (optarg, "-") ? stdin : fopen (optarg, "r");
+        fp = STREQ (optarg, "-") ? stdin : fopen (optarg, O_TEXT ? "rt" : "r");
         if (!fp)
           error (EXIT_TROUBLE, errno, "%s", optarg);
         for (keyalloc = 1; keyalloc <= keycc + 1; keyalloc *= 2)
diff --git a/src/kwsearch.c b/src/kwsearch.c
index cf8df3c..5f3f233 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -50,10 +50,6 @@ Fcompile (char const *pattern, size_t size)
           len = sep - p;
           sep++;
           total -= (len + 1);
-#if HAVE_DOS_FILE_CONTENTS
-         if (sep[-1] == '\r')
-           --len;
-#endif
         }
       else
         {
diff --git a/src/system.h b/src/system.h
index 4c85409..7da1d8d 100644
--- a/src/system.h
+++ b/src/system.h
@@ -29,10 +29,6 @@
 #include "minmax.h"
 #include "same-inode.h"
 
-#if O_BINARY
-# define HAVE_DOS_FILE_CONTENTS 1
-#endif
-
 #include <stdlib.h>
 #include <stddef.h>
 #include <limits.h>

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=2d3832e1ff772dc1a374bfad5dcc1338350cc48b


commit 5c92a54ec36f176854f0b0cca83b5ff224f2d8e8
Author: Paul Eggert <address@hidden>
Date:   Fri Apr 11 12:48:48 2014 -0700

    grep: cleanup for HAS_DOS_FILE_CONTENTS issue
    
    While cleaning up the empty-string fix, I noticed that one part of
    the code worried about CRLF in pattern files whereas another part
    did not.  Fix this by using the same approach in both places,
    and make the CRLF code more modular in the process.
    * src/dosbuf.c (dos_binary, dos_unix_byte_offsets): New functions.
    (undossify_input, dossified_pos): Do nothing if ! O_BINARY.
    * src/grep.c: Always include dosbuf.c so that the code is
    checked statically even on non-DOS hosts.
    (dos_binary, dos_unix_byte_offsets): New decls.
    (undossify_input): Declare unconditionally.
    * src/grep.c (fillbuf, print_line_head, main):
    * src/kwsearch.c (Fcompile):
    Simplify by not worrying about HAVE_DOS_FILE_CONTENTS.
    * src/grep.c (main): fopen with "rt" if O_TEXT; this is simpler
    than worrying about HAVE_DOS_FILE_CONTENTS elsewhere.
    * src/system.h (HAVE_DOS_FILE_CONTENTS): Remove.

diff --git a/src/dosbuf.c b/src/dosbuf.c
index 3648371..9ac2d13 100644
--- a/src/dosbuf.c
+++ b/src/dosbuf.c
@@ -49,6 +49,22 @@ static int       dos_pos_map_size  = 0;
 static int       dos_pos_map_used  = 0;
 static int       inp_map_idx = 0, out_map_idx = 1;
 
+/* Set default DOS file type to binary.  */
+static void
+dos_binary (void)
+{
+  if (O_BINARY)
+    dos_use_file_type = DOS_BINARY;
+}
+
+/* Tell DOS routines to report Unix offset.  */
+static void
+dos_unix_byte_offsets (void)
+{
+  if (O_BINARY)
+    dos_report_unix_offset = 1;
+}
+
 /* Guess DOS file type by looking at its contents.  */
 static File_type
 guess_type (char *buf, size_t buflen)
@@ -79,6 +95,9 @@ guess_type (char *buf, size_t buflen)
 static int
 undossify_input (char *buf, size_t buflen)
 {
+  if (! O_BINARY)
+    return buflen;
+
   int chars_left = 0;
 
   if (totalcc == 0)
@@ -167,6 +186,9 @@ undossify_input (char *buf, size_t buflen)
 static off_t
 dossified_pos (off_t byteno)
 {
+  if (! O_BINARY)
+    return byteno;
+
   off_t pos_lo;
   off_t pos_hi;
 
diff --git a/src/grep.c b/src/grep.c
index 8bd6c49..d58ef03 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -395,9 +395,10 @@ static enum
 
 static int grepfile (int, char const *, int, int);
 static int grepdesc (int, int);
-#if defined HAVE_DOS_FILE_CONTENTS
+
+static void dos_binary (void);
+static void dos_unix_byte_offsets (void);
 static int undossify_input (char *, size_t);
-#endif
 
 static int
 is_device_mode (mode_t m)
@@ -648,10 +649,7 @@ fillbuf (size_t save, struct stat const *st)
   if (fillsize < 0)
     fillsize = cc = 0;
   bufoffset += fillsize;
-#if defined HAVE_DOS_FILE_CONTENTS
-  if (fillsize)
-    fillsize = undossify_input (readbuf, fillsize);
-#endif
+  fillsize = undossify_input (readbuf, fillsize);
   buflim = readbuf + fillsize;
   return cc;
 }
@@ -695,9 +693,7 @@ static intmax_t pending;    /* Pending lines of output.
 static int done_on_match;      /* Stop scanning file on first match.  */
 static int exit_on_match;      /* Exit on first match.  */
 
-#if defined HAVE_DOS_FILE_CONTENTS
-# include "dosbuf.c"
-#endif
+#include "dosbuf.c"
 
 /* Add two numbers that count input bytes or lines, and report an
    error if the addition overflows.  */
@@ -803,9 +799,7 @@ print_line_head (char const *beg, char const *lim, int sep)
   if (out_byte)
     {
       uintmax_t pos = add_count (totalcc, beg - bufbeg);
-#if defined HAVE_DOS_FILE_CONTENTS
       pos = dossified_pos (pos);
-#endif
       if (pending_sep)
         print_sep (sep);
       print_offset (pos, 6, byte_num_color);
@@ -2043,15 +2037,11 @@ main (int argc, char **argv)
         break;
 
       case 'U':
-#if defined HAVE_DOS_FILE_CONTENTS
-        dos_use_file_type = DOS_BINARY;
-#endif
+        dos_binary ();
         break;
 
       case 'u':
-#if defined HAVE_DOS_FILE_CONTENTS
-        dos_report_unix_offset = 1;
-#endif
+        dos_unix_byte_offsets ();
         break;
 
       case 'V':
@@ -2086,7 +2076,7 @@ main (int argc, char **argv)
         break;
 
       case 'f':
-        fp = STREQ (optarg, "-") ? stdin : fopen (optarg, "r");
+        fp = STREQ (optarg, "-") ? stdin : fopen (optarg, O_TEXT ? "rt" : "r");
         if (!fp)
           error (EXIT_TROUBLE, errno, "%s", optarg);
         for (keyalloc = 1; keyalloc <= keycc + 1; keyalloc *= 2)
diff --git a/src/kwsearch.c b/src/kwsearch.c
index cf8df3c..5f3f233 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -50,10 +50,6 @@ Fcompile (char const *pattern, size_t size)
           len = sep - p;
           sep++;
           total -= (len + 1);
-#if HAVE_DOS_FILE_CONTENTS
-         if (sep[-1] == '\r')
-           --len;
-#endif
         }
       else
         {
diff --git a/src/system.h b/src/system.h
index 4c85409..7da1d8d 100644
--- a/src/system.h
+++ b/src/system.h
@@ -29,10 +29,6 @@
 #include "minmax.h"
 #include "same-inode.h"
 
-#if O_BINARY
-# define HAVE_DOS_FILE_CONTENTS 1
-#endif
-
 #include <stdlib.h>
 #include <stddef.h>
 #include <limits.h>

-----------------------------------------------------------------------

Summary of changes:
 NEWS              |    3 +++
 src/dfasearch.c   |   23 +++++++++++------------
 src/dosbuf.c      |   22 ++++++++++++++++++++++
 src/grep.c        |   26 ++++++++------------------
 src/kwsearch.c    |   41 +++++++++++++++++------------------------
 src/system.h      |    4 ----
 tests/Makefile.am |    1 +
 tests/empty-line  |   41 +++++++++++++++++++++++++++++++++++++++++
 8 files changed, 103 insertions(+), 58 deletions(-)
 create mode 100755 tests/empty-line


hooks/post-receive
-- 
grep



reply via email to

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