summaryrefslogtreecommitdiff
path: root/src/system.h
Commit message (Collapse)AuthorAgeFilesLines
* build: update gnulib submodule to latestPaul Eggert2021-08-271-2/+2
| | | | * src/system.h: Update decls to match current Gnulib.
* maint: run "make update-copyright"Paul Eggert2021-01-011-1/+1
|
* maint: update all copyright year number rangesJim Meyering2020-01-011-1/+1
| | | | | | | | Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * doc/grep.in.1: Use "-" in copyright year ranges, not \en.
* maint: update all copyright dates via "make update-copyright"Jim Meyering2019-01-011-1/+1
| | | | * gnulib: Also update submodule for its copyright updates.
* maint: update gnulib and copyright dates for 2018Jim Meyering2018-01-061-1/+1
| | | | | | * gnulib: Update to latest. * all files: Run "make update-copyright". * bootstrap: Update from gnulib.
* maint: accommodate GCC7's -Werror=duplicated-branchesJim Meyering2017-05-211-0/+14
| | | | | | * src/system.h (IGNORE_DUPLICATE_BRANCH_WARNING): Define. * src/grep.c (grepfile): Use it. * src/kwset.c (bmexec, acexec): Use it.
* maint: update to work with GCC7's -Werror=implicit-fallthrough=Jim Meyering2017-05-211-0/+8
| | | | | | | * src/system.h (FALLTHROUGH): Define. * src/grep.c (context_length_arg): Use new FALLTHROUGH macro in place of comments (fgrep_to_grep_pattern, try_fgrep_pattern, main): Likewise.
* Fix up recent -U patchesPaul Eggert2017-02-161-1/+0
| | | | | | | | | | | | | | | Inspired by a suggestion by Eric Blake (Bug#25707#17). * bootstrap.conf (gnulib_modules): Add xbinary-io, and remove binary-io and xfreopen. * doc/grep.texi (Other Options): Fix typo and reword to be a bit more general. * src/grep.c: Include xbinary-io.h instead of xfreopen.h. (grepfile): Open with O_BINARY if binary. (grepdesc): No need for set_binary_mode now. (grep_command_line_arg, main): Set stdin to binary mode if binary. (main): Avoid unnecessary test of stdin == NULL. Use xsetmode instead of xfreopen. * src/system.h: Do not include binary-io.h.
* maint: update gnulib and copyright dates for 2017Jim Meyering2017-01-011-1/+1
| | | | | * gnulib: Update to latest. * all files: Run "make update-copyright".
* maint: rewrite to avoid some macrosPaul Eggert2016-12-231-0/+1
| | | | | | | | | | | | | | | | These days, the dangerous powers of C macros are not needed if constants or functions will do just as well. * src/grep.c (SEP_CHAR_SELECTED, SEP_CHAR_REJECTED, SEP_STR_GROUP) (INITIAL_BUFSIZE): * src/kwset.c (DEPTH_SIZE): Now constants, not macros. * src/kwset.c (link): Remove macro. Instead, rename local vars from 'link' to 'cur'. (malloc) [GREP]: Remove macro. All uses of malloc changed to xmalloc. Omit double-inclusion of xalloc.h. Do not depend on 'GREP'. (U): Now a function, not a macro. * src/kwset.c, src/searchutils.c (NCHAR): Move this macro to ... * src/system.h: ... here, and make it a constant.
* maint: update copyright year, bootstrap, init.shJim Meyering2016-01-011-1/+1
| | | | | | | | Run "make update-copyright" and then... * gnulib: Update to latest. * tests/init.sh: Update from gnulib. * bootstrap: Likewise.
* tests: add support for ASAN memory poisoningJim Meyering2015-01-101-0/+40
| | | | | | | | | | | | | | | This lets us reliably detect with ASAN some UMR bugs that would otherwise be detectable only some of the time with MSAN. Use __asan_poison_memory_region to mark the unused portion of a read buffer as inaccessible. Then, with ASAN, any attempt to access those bytes results in an ASAN abort. * src/system.h: Include "ignore-value.h". (__has_feature): Define. (HAVE_ASAN): Define when address sanitizer is enabled. [HAVE_ASAN]: Declare these two __asan_* symbols. [!HAVE_ASAN] (__asan_poison_memory_region): Define stub. [!HAVE_ASAN] (__asan_unpoison_memory_region): Likewise. * src/grep.c: Use __asan_poison_memory_region.
* maint: update copyright year ranges to include 2015Jim Meyering2015-01-011-1/+1
| | | | | Run "make update-copyright". Also, ... * grep.texi: Update manually, converting each "--" to "-".
* grep: use mbclen cache more effectivelyPaul Eggert2014-09-161-1/+8
| | | | | | | | | | | | | | | | | | * src/grep.c (buffer_textbin, contains_encoding_error): Use mb_clen for speed. (buffer_textbin): Bypass mb_clen in unibyte locales. (main): Always initialize the cache, since it's sometimes used in unibyte locales now. Initialize it before contains_encoding_error might be called. * src/search.h (SEARCH_INLINE): New macro. (mbclen_cache): Now extern decl. (mb_clen): New inline function. * src/searchutils.c (SEARCH_INLINE, SYSTEM_INLINE): Define. (mbclen_cache): Now extern. (build_mbclen_cache): Put 1 into the cache when mbrlen returns 0. (mb_goback): Use mb_len for speed, and rely on it returning nonzero. * src/system.h (SYSTEM_INLINE): New macro. (to_uchar): Use it.
* grep: cleanup for HAS_DOS_FILE_CONTENTS issuePaul Eggert2014-04-111-4/+0
| | | | | | | | | | | | | | | | | | | 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.
* maint: use to_uchar function rather than explicit castsJim Meyering2014-02-011-0/+9
| | | | | | | | | * src/system.h (to_uchar): Define function. * src/kwsearch.c (Fexecute): Use to_uchar twice in place of casts. * src/dfasearch.c (EGexecute): Likewise. * src/main.c (prepend_args): Likewise. * src/kwset.c (U): Define in terms of to_uchar. * src/dfa.c (match_mb_charset): Use to_uchar, not an explicit cast.
* maint: update copyright dates for 2014Jim Meyering2014-01-011-1/+1
| | | | Do that by running "make update-copyright".
* maint: update all copyright year number rangesJim Meyering2013-01-041-1/+1
| | | | Run "make update-copyright".
* maint: factor out STREQ definitionJim Meyering2012-10-031-0/+3
| | | | | | * src/main.c (STREQ): Remove definition. * src/pcresearch.c: (STREQ): Likewise. * src/system.h (STREQ): Define it here instead.
* maint: update all copyright year number rangesJim Meyering2012-01-011-1/+1
| | | | Run "make update-copyright".
* grep: do input==output check more like dir loop checkPaul Eggert2011-12-311-39/+0
| | | | | | | | | | * src/main.c (grepfile): Just use SAME_INODE; don't bother with SAME_REGULAR_FILE. This works better on properly-working POSIX hosts, since it handles the case where the file is changing as we grep it. It works worse on hosts that don't support st_ino properly, but in practice this isn't that much of a problem here. * src/system.h (same_file_attributes, SAME_REGULAR_FILE): Remove; no longer needed.
* don't ignore errors when reading a directoryPaul Eggert2011-12-241-6/+0
| | | | | | | | | | | grep no longer silently suppresses errors when reading a directory as if it were a text file. For example, "grep x ." now reports a read error on most systems; formerly, it ignored the error. Problem reported as an aside by Bob Proulx (Bug#10355). * NEWS: Document this. * src/main.c (grep, grepfile): Implement this. Simplify the code considerably. * src/system.h (is_EISDIR): Remove; no longer needed.
* exit 2 (rather than infloop) when an input file is also on stdoutJim Meyering2011-07-241-1/+41
| | | | | | | | | | | | | | | | | This avoids a potential "infinite" disk-filling loop. Reported in http://savannah.gnu.org/patch/?5316 and http://savannah.gnu.org/bugs/?17457. * src/main.c: Include "quote.h". (out_stat): New global. (grepfile): Compare each regular file's dev/ino/etc. with those from the file on stdout (if it too is regular). (main): Set out_stat, if stdout is a regular file. * src/system.h: Include "same-inode.h". (same_file_attributes): Define. From diffutils. (SAME_REGULAR_FILE): Define. * bootstrap.conf (gnulib_modules): Use quote, not quotearg. Use same-inode. * NEWS (Bug fixes): Mention it.
* maint: update copyright year ranges to include 2011Jim Meyering2011-01-031-1/+1
| | | | Run "make update-copyright", so "make syntax-check" works in 2011.
* grep: add include guardsPaolo Bonzini2010-11-141-0/+4
| | | | | * src/system.h: Add multiple inclusion guards. * src/grep.h: Likewise.
* search: fix "grep -Fif /dev/null"Paolo Bonzini2010-08-271-0/+1
| | | | | | * bootstrap.conf: Include gnulib module minmax. * src/searchutils.c (mbtolower): Handle *N == 0 case. * src/system.h: Include minmax.h from gnulib.
* cleanup and improvement: parse command line arguments consistentlyJim Meyering2010-04-021-24/+0
| | | | | | | | | | | | * src/main.c: Include c-ctype.h, for this: (prepend_args): Use c_isspace, not ISSPACE. This is important so that we parse arguments consistently, and independently of the current locale. * bootstrap.conf (gnulib_modules): Add c-ctype. * src/system.h: Remove IS* definitions here, too. * src/dfasearch.c (WCHAR): Use isalnum, not ISALNUM. * src/kwsearch.c (WCHAR): Likewise. * src/searchutils.c (kwsinit): Use tolower, not TOLOWER.
* build: remove superfluous LOCALEDIR definitionJim Meyering2010-03-271-0/+1
| | | | | | * src/Makefile.am (INCLUDES): Remove unnecessary definition of LOCALEDIR here. Now, it's defined via gnulib's configmake.h. * src/system.h: Include "configmake.h" for its LOCALEDIR definition.
* maint: remove TYPE_* definitions from src/system.hJim Meyering2010-03-211-7/+0
| | | | | | | * src/system.h (TYPE_MAXIMUM, TYPE_MINIMUM, TYPE_SIGNED): Remove definitions. They are provided by intprops.h. * src/grep.c: Include "intprops.h" * bootstrap.conf (gnulib_modules): Add intprops.
* kwset/system: remove ptr_tPaolo Bonzini2010-03-121-12/+0
| | | | | * src/kwset.h: Declare kwset using an incomplete struct type. * src/system.h (ptr_t): Remove.
* maint: remove all uses of PARAMSJim Meyering2010-03-111-3/+0
| | | | | | | | | | | * lib/savedir.h (PARAMS): Remove definitions manually. Remove the remaining ones via this command: git grep -l define.PARAMS |xargs perl -ni -e '/define PARAMS/ or print' * src/dfa.h (PARAMS): Remove definitions. * src/system.h (PARAMS): Likewise. Remove most uses with this: git grep -lw PARAMS |xargs perl -pi -e 's/\bPARAMS *\((.*)\);/$1;/' Remove the remainder manually.
* maint: enable the prohibit_magic_number_exit syntax checkJim Meyering2010-02-071-0/+2
| | | | | | | | | | * cfg.mk (local-checks-to-skip): Remove sc_prohibit_magic_number_exit, to enable that check. * src/system.h (EXIT_TROUBLE): Define. * src/grep.c: Use symbolic names, EXIT_SUCCESS, EXIT_FAILURE, and EXIT_TROUBLE, not 0, 1, 2. * src/search.c: Likewise. * src/vms_fab.c (string): Likewise.
* maint: rely on gnulib's new isdir.hJim Meyering2010-01-061-2/+0
| | | | | * src/grep.c: Include "isdir.h". * src/system.h: Remove declaration of isdir.
* maint: avoid warnings about unused fwrite return valueJim Meyering2010-01-061-0/+2
| | | | | * bootstrap.conf (gnulib_modules): Add unlocked-io. * src/system.h: Include "unlocked-io.h".
* maint: update all FSF copyright year lists to include 2010Jim Meyering2010-01-011-1/+1
| | | | | | Use this command: git ls-files |grep -vE '^(\..*|COPYING|gnulib)$' |xargs \ env UPDATE_COPYRIGHT_USE_INTERVALS=1 build-aux/update-copyright
* replace AC_DOSFILE with gnulib modulesPaolo Bonzini2009-11-261-23/+4
| | | | | | | | * bootstrap.conf: Add binary-io, dirname. * configure.ac: Remove check for setmode, AC_DOSFILE. * m4/dosfile.m4: Remove. * src/grep.c: Adjust for dirname.h. * src/system.h: Adjust for new gnulib modules.
* replace AC_CHECK_* with gnulib modulesPaolo Bonzini2009-11-261-91/+12
| | | | | | | | | | | | | | | | * bootstrap.conf: Add gnulib modules for replacement functions and headers. * configure.ac: Remove macros subsumed by gnulib. * lib/hard-locale.c: Remove guards for headers/functions provided by gnulib. * lib/regex.c: Likewise. * lib/savedir.c: Likewise. * src/dfa.c: Likewise. * src/dfa.h: Do not look at PROTOTYPES. * src/grep.c: Likewise. * src/mbsupport.h: Likewise. * src/system.h: Likewise. * m4/mbstate_t.m4: Remove. * src/getpagesize.h: Remove.
* add gnulib modulesPaolo Bonzini2009-11-261-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bootstrap.conf: Add gnulib modules and build libgreputils.a. * configure.ac: Remove macros subsumed by gnulib. * lib/Makefile.am: Remove files subsumed by gnulib. * lib/alloca.c: Remove. * lib/atexit.c: Remove. * lib/error.c: Remove. * lib/error.h: Remove. * lib/fnmatch.c: Remove. * lib/fnmatch.h: Remove. * lib/getopt.c: Remove. * lib/getopt.h: Remove. * lib/getopt1.c: Remove. * lib/gettext.h: Remove. * lib/malloc.c: Remove. * lib/memchr.c: Remove. * lib/obstack.c: Remove. * lib/obstack.h: Remove. * lib/quotearg.c: Remove. * lib/quotearg.h: Remove. * lib/realloc.c: Remove. * lib/stpcpy.c: Remove. * lib/strtol.c: Remove. * lib/strtoul.c: Remove. * lib/strtoull.c: Remove. * lib/xalloc.h: Remove. * lib/xmalloc.c: Remove. * lib/xstrtol.c: Remove. * lib/xstrtol.h: Remove. * lib/xstrtoumax.c: Remove. * m4/error.m4: Remove. * m4/inttypes_h.m4: Remove. * m4/malloc.m4: Remove. * m4/realloc.m4: Remove. * m4/uintmax_t.m4: Remove. * m4/ulonglong.m4: Remove. * m4/xstrtoumax.m4: Remove. * src/system.h: Remove strerror, sys_nerr, sys_errlist.
* use gettext.hPaolo Bonzini2009-11-201-7/+3
| | | | | | | | | | * lib/Makefile.am: Distribute gettext.h. * lib/closeout.c: Use it. * lib/gettext.h: New. * lib/quotearg.c: Use it. * lib/xmalloc.c: Use it. * src/dfa.c: Use it. * src/system.h: Use it.
* update/add copyright noticesKarl Berry2009-01-301-1/+1
|
* GPLv2 -> GPLv3Bernhard Rosenkraenzer2007-06-281-1/+1
|
* Update FSF's civic address, zip code, and citizen relocation code.Charles Levert2005-05-021-2/+2
| | | | | * 78 files: Update FSF's civic address, zip code, and citizen relocation code.
* Port to MING32Alain Magloire2001-02-081-4/+5
| | | | | | | | | | | | | | | | | | Port to Mingw32, based on suggestions from Christian Groessler <cpg@aladdin.de>. * src/isdir.c: New file, taken from fileutils. * src/Makefile.am (base_sources): Add isdir.c. * src/grep.c (grepfile): Use isdir instead of doing it inline. (grepdir): Suppress ancestor check if the directory's inode and device are both zero, as that occurs only on Mingw32 which doesn't support inode or device. * src/system.h (isdir): New decl. (is_EISDIR): Depend on HAVE_DIR_EACCES_BUG, not D_OK. Use isdir, not access. Problen noted by Gerald Stoller <gerald_stoller@hotmail.com> * src/grep.c (main): POSIX.2 says that -q overrides -l, which in turn overrides the other output options. Fix grep to behave that way.
* CRLF handling.Alain Magloire2001-02-081-6/+1
| | | | | | | | | | | | | | | | | | | 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. * lib/getpagesize.h (getpagesize): Define to B_PAGE_SIZE if __BEOS__ is defined. Based on a fix by Bruno Haible <haible@clisp.cons.org>.
* BEOS fix.Alain Magloire2001-02-081-0/+3
| | | | | * src/system.h [BeOS]: Ignore O_BINARY. * src/getpagesize.h [BeOS]: Define getpagesize() as B_PAGE_SIZE.
* ChangeLog configure.in doc/grep.1 doc/grep.texi src/dfa.cAlain Magloire2000-02-021-1/+1
| | | | | | | | | | | | | | | | src/getpagesize.h src/grep.c src/kwset.c src/search.c src/system.h src/vms_fab.c src/vms_fab.h vms/make.com more support for VMS. * doc/grep.1: corrected typo. Noted by Ruslan Ermilob. * vms/config_vms.h: New File, contains macros specific to VMS and avoid namespace collision with operating system supplied C library. * vms/make.com: Updated. * src/getpagesize.h: New macros for VMS. * src/vms_fab.c: Cast to some assigments. * src/vms_fab.h: Added new include files. Those patches were provided by zinser@decus.de (Martin).
* ChangeLog NEWS THANKS doc/grep.1 doc/grep.texi src/grep.cAlain Magloire2000-01-171-2/+11
| | | | | | | | | | | | | | | src/system.h Support for general option --binary-file from David O'Brien. Inititial patch from David O'Brien. Add --binary-files option. * NEWS, doc/grep.1, doc/grep.texi: Document it. * src/grep.c (BINARY_FILES_OPTION): New constant. (long_options, grep, usage, main): New --binary-files option. (binary_files): New var. * src/system.h (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM, CHAR_MAX): New macros. (INT_MAX, UCHAR_MAX): Define in terms of TYPE_MAXIMUM.
* new set o patches from PaulAlain Magloire1999-10-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | new set o patches from Paul new set o patches from Paul * NEWS, doc/grep.1, doc/grep.texi: New option --mmap. * src/grep.c (mmap_option): New variable. (long_options, reset, usage): Add --mmap. Default is now read, not mmap. * doc/grep.1: Document -Z or --null. * doc/grep.texi: Fix texinfo glitches. POSIX -> POSIX.2 where appropriate. * doc/grep.texi: Fix texinfo glitches. POSIX -> POSIX.2 where appropriate. * acconfig.h (ssize_t): New #undef. * configure.in (AC_CHECK_TYPE): Add ssize_t. * src/grep.c (PREFERRED_SAVE_FACTOR): New macro. (reset): If the buffer has already been allocated, set bufsalloc to be bufalloc / PREFERRED_SAVE_FACTOR. This avoids problems when bufsalloc == bufalloc (possible after reading a large binary file). (reset): Use PREFERRED_SAVE_FACTOR instead of magic constant. Do not set bufbeg; nobody uses it. Always set buflim. Check for lseek error. Use SEEK_CUR, not a magic constant. (fillbuf): Return an error indication, not a count. All callers changed. Do not assume ssize_t fits in int. Use PREFERRED_SAVE_FACTOR instead of magic constant. Clean up mmap code. Do not attempt to mmap zero bytes. Check for lseek error. Use SEEK_SET, not a magic constant. Work correctly if read is interrupted. (grepfile): Work correctly if open or close is interrupted. * src/system.h (SEEK_SET, SEEK_CUR): New macros.
* update form Paul on his previous patch.Alain Magloire1999-09-121-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | update form Paul on his previous patch. * configure.in (AC_CHECK_FUNCS): Add memmove. * src/system.h (S_ISREG): New macro. (memmove): Define if ! defined HAVE_MEMMOVE && ! defined memmove, not if !defined STDC_HEADERS. This is needed for SunOS 4.1.4, which defines STDC_HEADERS but lacks memmove. * src/grep.c (bufoffset): Needed even if !defined HAVE_MMAP. (reset): Always fstat the file, since we always need its size if it is regular. Similarly, get the buffer offset of every regular file. Set bufmapped to 0 if the file's initial offset is not a multiple of the page size. (fillbuf): Calculate an upper bound on how much memory we should allocate only for regular files, since we don't know the sizes of other files. Don't bother to check whether the file offset is a multiple of the page size, since we now do that just once in `reset'. When an mmapped area would fall past the end of the file, trim it to just before instead of giving up immediately and doing a `read'; that avoids a worst-case behavior that could read half an mmapped file. Fix bug when computing offsets on hosts that don't have mmap.
* update to 2.3fAlain Magloire1999-08-291-1/+3
| | | | new scheme by Paul Eggert for buffer allocation.