diff options
-rw-r--r-- | ChangeLog | 25 | ||||
-rw-r--r-- | THANKS | 3 | ||||
-rw-r--r-- | bootstrap/Makefile.try | 1 | ||||
-rw-r--r-- | m4/dosfile.m4 | 3 | ||||
-rw-r--r-- | src/getpagesize.h | 2 | ||||
-rw-r--r-- | src/grep.c | 16 | ||||
-rw-r--r-- | src/system.h | 7 |
7 files changed, 42 insertions, 15 deletions
@@ -1,3 +1,28 @@ +2000-04-17 Paul Eggert <eggert@twinsun.com> + + Do CRLF munging only if HAVE_DOS_FILE_CONTENTS, instead of + having it depend on O_BINARY (which leads to incorrect results + on BeOS, VMS, and MacOS). + + * bootstrap/Makefile.try (DEFS): Add -DHAVE_DOS_FILE_CONTENTS. + * src/system.h (SET_BINARY): Define only if HAVE_DOS_FILE_CONTENTS. + (O_BINARY): Do not define. + + * m4/dosfile.m4: Define HAVE_DOS_FILE_CONTENTS if it appears we're + using DOS. + + * src/grep.c (undossify_input, fillbuf, dosbuf.c, prline, main): + Depend on HAVE_DOS_FILE_CONTENTS, not O_BINARY, when handling CRLF + matters. + (grepfile, main): Depend on SET_BINARY, not O_BINARY, when + handling binary files on hosts that care about text versus binary. + +2000-04-17 Paul Eggert + + * lib/getpagesize.h (getpagesize): Define to B_PAGE_SIZE if + __BEOS__ is defined. Based on a fix by Bruno Haible + <haible@clisp.cons.org>. + 2000-04-17 Bruno Haible * src/system.h [BeOS]: Ignore O_BINARY. @@ -5,6 +5,7 @@ Andreas Schwab <schwab@suse.de> Andreas Ley <andy@rz.uni-karlsruhe.de> Ben Elliston <bje@cygnus.com> Bastiaan "Darquan" Stougie <darquan@zonnet.nl> +Bruno Haible <haible@ilog.fr> David J MacKenzie <djm@catapult.va.pubnix.com> David O'Brien <obrien@freebsd.org> Eli Zaretskii <eliz@is.elta.co.il> @@ -12,6 +13,7 @@ Florian La Roche <florian@knorke.saar.de> Franc,ois Pinard <pinard@IRO.UMontreal.CA> Grant McDorman <grant@isgtec.com> Harald Hanche-Olsen <hanche@math.ntnu.no> +H. Merijn Brand <h.m.brand@hccnet.nl> Jeff Bailey <jbailey@nisa.net> Jim Hand <jhand@austx.tandem.com> Jim Meyering <meyering@asic.sc.ti.com> @@ -36,6 +38,7 @@ Paul Kimoto <kimoto@spacenet.tn.cornell.edu> Phillip C. Brisco <phillip.craig.brisco@ccmail.census.gov> Philippe Defert <Philippe.Defert@cern.ch> Philippe De Muyter <phdm@info.ucl.ac.be> +Philip Hazel <ph10@cus.cam.ac.uk> Roland Roberts <rroberts@muller.com> Ruslan Ermilov <ru@freebsd.org> Shannon Hill <hill@synnet.com> diff --git a/bootstrap/Makefile.try b/bootstrap/Makefile.try index 24d3f0b4..bd9aef16 100644 --- a/bootstrap/Makefile.try +++ b/bootstrap/Makefile.try @@ -48,6 +48,7 @@ DEFS = -I. \ # DOS/WIN (change also OBJEXT/EXEEXT, see above) # DOS/DJGPP DEFS = -DSTDC_HEADERS -DHAVE_MEMCHR -DHAVE_STRERROR -DHAVE_DIRENT_H \ + -DHAVE_DOS_FILE_CONTENTS \ -DHAVE_DOS_FILE_NAMES -DHAVE_UNISTD_H -DHAVE_SETMODE #### diff --git a/m4/dosfile.m4 b/m4/dosfile.m4 index 1e85900c..609d042d 100644 --- a/m4/dosfile.m4 +++ b/m4/dosfile.m4 @@ -1,10 +1,13 @@ # Check to see if we use dir\file name conventtion # If so, set macro HAVE_DOS_FILE_NAMES +# Also set the macro HAVE_DOS_FILE_CONTENTS for now, +# since don't know of a good way to independently check this. dnl AC_DOSFILE() AC_DEFUN(AC_DOSFILE, [AC_CACHE_CHECK([for dos file convention], ac_cv_dosfile, [if test -d ".\."; then ac_cv_dosfile=yes + AC_DEFINE(HAVE_DOS_FILE_CONTENTS, , [Define if text file lines end in CRLF.]) AC_DEFINE(HAVE_DOS_FILE_NAMES) else ac_cv_dosfile=no diff --git a/src/getpagesize.h b/src/getpagesize.h index b9f4a3d9..198967b9 100644 --- a/src/getpagesize.h +++ b/src/getpagesize.h @@ -2,7 +2,7 @@ #ifndef HAVE_GETPAGESIZE -#ifdef __BEOS__ +#if !defined getpagesize && defined __BEOS__ # include <OS.h> # define getpagesize() B_PAGE_SIZE #endif @@ -131,7 +131,7 @@ static enum } directories; static int grepdir PARAMS ((char const *, struct stats const *)); -#if O_BINARY +#if HAVE_DOS_FILE_CONTENTS static inline int undossify_input PARAMS ((register char *, size_t)); #endif @@ -447,7 +447,7 @@ fillbuf (size_t save, struct stats const *stats) } bufoffset += fillsize; -#if O_BINARY +#if HAVE_DOS_FILE_CONTENTS if (fillsize) fillsize = undossify_input (buffer + bufsalloc, fillsize); #endif @@ -489,7 +489,7 @@ static int pending; /* Pending lines of output. Always kept 0 if out_quiet is true. */ static int done_on_match; /* Stop scanning file on first match */ -#if O_BINARY +#if HAVE_DOS_FILE_CONTENTS # include "dosbuf.c" #endif @@ -535,7 +535,7 @@ prline (char const *beg, char const *lim, int sep) if (out_byte) { off_t pos = totalcc + (beg - bufbeg); -#if O_BINARY +#if HAVE_DOS_FILE_CONTENTS pos = dossified_pos (pos); #endif print_offset_sep (pos, sep); @@ -865,7 +865,7 @@ grepfile (char const *file, struct stats *stats) filename = file; } -#if O_BINARY +#ifdef SET_BINARY /* Set input to binary mode. Pipes are simulated with files on DOS, so this includes the case of "foo | grep bar". */ if (!isatty (desc)) @@ -1288,12 +1288,12 @@ main (int argc, char **argv) binary_files = WITHOUT_MATCH_BINARY_FILES; break; case 'U': -#if O_BINARY +#if HAVE_DOS_FILE_CONTENTS dos_use_file_type = DOS_BINARY; #endif break; case 'u': -#if O_BINARY +#if HAVE_DOS_FILE_CONTENTS dos_report_unix_offset = 1; #endif break; @@ -1485,7 +1485,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n")) if ((argc - optind > 1 && !no_filenames) || with_filenames) out_file = 1; -#if O_BINARY +#ifdef SET_BINARY /* Output is set to binary mode because we shouldn't convert NL to CR-LF pairs, especially when grepping binary files. */ if (!isatty (1)) diff --git a/src/system.h b/src/system.h index ce46c29d..9d7cea54 100644 --- a/src/system.h +++ b/src/system.h @@ -56,18 +56,13 @@ extern char *sys_errlist[]; #ifdef __BEOS__ # undef O_BINARY /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect. */ #endif -#if O_BINARY +#ifdef HAVE_DOS_FILE_CONTENTS # include <io.h> # ifdef HAVE_SETMODE # define SET_BINARY(fd) setmode (fd, O_BINARY) # else # define SET_BINARY(fd) _setmode (fd, O_BINARY) # endif -#else -# ifndef O_BINARY -# define O_BINARY 0 -# define SET_BINARY(fd) (void)0 -# endif #endif #ifdef HAVE_DOS_FILE_NAMES |