summaryrefslogtreecommitdiff
path: root/src/util.c
Commit message (Collapse)AuthorAgeFilesLines
* maint: update all copyright year number rangesJim Meyering2012-01-011-1/+1
| | | | Run "make update-copyright".
* build: update to latest gnulib and adaptJim Meyering2011-12-141-3/+3
| | | | | | | | | | | | | | | | | * tests/binary: Reverse arguments to compare to avoid failure of new syntax-check rule. * configure.ac: Use -Wno-format-nonliteral. Mark functions as pure of const, per recommendations enabled by new gcc -W options. Use _GL_ATTRIBUTE_PURE and _GL_ATTRIBUTE_CONST. * lib/cmpbuf.h (buffer_lcm, block_compare): Apply pure and/or const attributes. * src/cmp.c (block_compare): Likewise. * src/context.c (find_hunk): Likewise. * src/diff.h (lines_differ): Likewise. * src/diff3.c (skipwhite): Likewise. * src/dir.c (dir_loop): Likewise. * src/util.c (find_change, find_reverse_change): Likewise. (translate_line_number): Likewise.
* diff, sdiff: new option --ignore-trailing-space (-Z)Roland McGrath2011-08-141-7/+47
| | | | | | | | | | | | | | Derived from Roland McGrath's patch (dated June 2004!) in: http://lists.gnu.org/archive/html/bug-gnu-utils/2004-07/msg00000.html * NEWS: * doc/diffutils.texi (White Space, Blank Lines) (sdiff Option Summary, diff Options, sdiff Options): Document -Z. * src/diff.h (IGNORE_TRAILING_SPACE) (IGNORE_TAB_EXPANSION_AND_TRAILING_SPACE): New constants, for -Z. * src/diff.c (shortopts, longopts, main, option_help_msgid): * src/sdiff.c (longopts, option_help_msgid, main): * src/io.c (find_and_hash_each_line): * src/util.c (lines_differ, analyze_hunk): Support -Z.
* maint: remove all uses of vfork: use fork insteadJim Meyering2011-01-241-4/+4
| | | | | | | | | | | | | Our use of vfork now provokes warnings from gcc-4.6.0. Also, vfork is no longer even specified by POSIX.1-2008. * src/diff3.c (read_diff): Change each use of vfork to "fork". Remove #ifdef'd code. * src/util.c (begin_output, finish_output): Likewise. * src/sdiff.c (cleanup, main, edit): Likewise. (handler_index_of_SIGPIPE): Remove now-unused definition. * src/system.h: Don't include <vfork.h>. (vfork): Remove definition. * ms/config.site: Remove reference to vfork cache variable.
* maint: update copyright year ranges to include 2011Jim Meyering2011-01-031-1/+1
| | | | Run "make update-copyright", so "make syntax-check" works in 2011.
* diff -r: avoid printing excess slashes in concatenated file namesJim Meyering2010-08-141-12/+0
| | | | | | | | | | | | * bootstrap.conf (gnulib_modules): Add filenamecat. * src/diff.c: Include "filenamecat.h". (compare_files): Use file_name_concat, rather than dir_file_pathname. * src/util.c (dir_file_pathname): Remove now-unused function. * src/diff.h: Remove its declaration. * tests/excess-slash: New script to test for this. * tests/Makefile.am (TESTS): Add it. Forwarded by Santiago Vila from <bugs.debian.org/586301a>, reported by Jari Aalto.
* avoid compilation failure on systems lacking both fork and vforkJuan Manuel Guerrero2010-02-141-1/+1
| | | | | | | * src/sdiff.c [!HAVE_WORKING_FORK && !HAVE_WORKING_VFORK] (main): Pass the right number of arguments to shell_quote_copy. * src/util.c [!HAVE_WORKING_FORK && !HAVE_WORKING_VFORK] (begin_output): Likewise.
* 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
* admin: update all copyright notices to include the year 2009Jim Meyering2009-11-111-2/+2
|
* * NEWS: New diff option --suppress-blank-empty (no longer -u default).Paul Eggert2009-11-111-4/+18
| | | | | | | | | | | | * doc/diff.texi (Detailed Unified): Trailing spaces are no longer omitted. (Trailing Blanks): New section. (diff Options) Mention new option. * src/diff.h (suppress_blank_entry): New decl. * src/context.c (pr_unidiff_hunk): Support --suppress-blank-empty. * src/util.c (print_1_line): Likewise. * src/diff.c (longopts, main, option_help_msgid): Likewise. (SUPPRESS_BLANK_EMPTY_OPTION): New constant.
* * src/diff.c (compare_files): Use last_component rather than base_name,Paul Eggert2009-11-111-2/+3
| | | | | | adjusting to gnulib API change. This avoids a memory leak. * src/sdiff.c (expand_name): Likewise. * src/util.c (dir_file_pathname): Likewise.
* * COPYING: New file.Paul Eggert2007-07-191-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * AUTHORS: Update from GPLv2 to GPLv3. * Makefile.am: Likewise. * NEWS: Likewise. * README: Likewise. * README-hacking: Likewise. * bootstrap: Likewise. * bootstrap.conf: Likewise. * configure.ac: Likewise. * exgettext: Likewise. * doc/Makefile.am: Likewise. * lib/Makefile.am: Likewise. * lib/cmpbuf.c: Likewise. * lib/cmpbuf.h: Likewise. * lib/prepargs.c: Likewise. * m4/vararrays.m4: Likewise. * man/Makefile.am: Likewise. * ms/Makefile.am: Likewise. * ms/README: Likewise. * ms/config.bat: Likewise. * ms/config.sed: Likewise. * ms/config.site: Likewise. * po/POTFILES.in: Likewise. * src/Makefile.am: Likewise. * src/analyze.c: Likewise. * src/cmp.c: Likewise. * src/context.c: Likewise. * src/diff.c: Likewise. * src/diff.h: Likewise. * src/diff3.c: Likewise. * src/dir.c: Likewise. * src/ed.c: Likewise. * src/io.c: Likewise. * src/normal.c: Likewise. * src/sdiff.c: Likewise. * src/system.h: Likewise. * src/util.c: Likewise.
* Update FSF address.Paul Eggert2006-01-051-1/+1
|
* * src/cmp.c: Don't include <setmode.h>.Paul Eggert2006-01-051-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (specify_ignore_initial): Reword to avoid gcc -W warnings. (main): Use freopen instead of setmode, since freopen is in POSIX. * src/context.c: Revert most 2004-09-01 changes. Then: (TIMESPEC_NS): Remove. All uses replaced by get_stat_mtime_ns. Include stat-time.h, strftime.h. (nstrtime): Remove decl. * src/diff.c: Revert most 2004-09-01 changes. Then: Don't include <posixver.h>, <quotesys.h>, <setmode.h>. Include <sh-quote.h>, <stat-time.h>, <timespec.h>. All uses of quotesys replaced by sh-quote. (main, compare_files): Use freopen instead of setmode, since freopen is in POSIX. (main): Don't complain about "diff -NUM'. (main, set_mtime_to_now): Adjust to stat-time.h macros when accessing nanoseconds. * src/diff3.c: Include sh-quote.h rather than quotesys. All uses changed. * src/dir.c (dir_read): excluded_filename renamed to excluded_file_name. * src/io.c: Don't include <setmode.h>. (sip, read_files): Remove binary file stuff, leaving a FIXME behind. A DOS expert needs to look at this. * src/diff.c: Include sh-quote.h rather than quotesys.h. All uses changed. * src/system.h: Include verify.h. (verify): Remove. All uses changed to verify.h version. Include <intprops.h>. (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove. Now uses intprops.h versions. (O_BINARY): New defns, taken from coreutils. * src/util.c: Include sh-quote.h rather than quotesys.h. All uses changed.
* Do not include regex.h, as diff.h does this now.Paul Eggert2004-04-121-52/+49
| | | | | | (lines_differ): Don't convert char * to unsigned char *; just leave pointers as char *. This lessens the number of potentially-dangerous casts.
* (finish_output): Check for ENOEXEC.Paul Eggert2002-06-111-15/+37
| | | | | | (lines_differ, output_1_line): New option --tabsize=COLUMNS. (analyze_hunk): If -b or -w is also specified, -B now considers lines to be empty if they contain only white space.
* 2 -> EXIT_TROUBLE.Paul Eggert2002-02-281-11/+12
| | | | | Adopt POSIX convention for ENOEXEC and exit status 126. unsigned -> unsigned int
* (finish_output): Ensure that werrno is initialized.Paul Eggert2002-01-241-2/+5
| | | | | (lines_differ): Have an explicit do-nothing case for IGNORE_NO_WHITE_SPACE, to pacify gcc -Wall.
* (begin_output): Have child exit with status 127 rather than reportingPaul Eggert2001-12-241-7/+8
| | | | | | failure on its own. Set errno to 0 before invoking popen. (finish_output): Report errno on pclose failure. Distinguish between subsidiary program not found, and failure.
* Include dirname.h.Paul Eggert2001-12-111-8/+11
| | | | (dir_file_pathname): Use base_name rather than file_name_lastdirchar.
* (setup_output, begin_output, finish_output): HAVE_FORK ->Paul Eggert2001-12-031-7/+7
| | | | HAVE_WORKING_FORK || HAVE_WORKING_VFORK.
* Assume C89 or better.Paul Eggert2001-11-251-129/+155
| | | | | | | | | | | | | | | | | | | int -> bool for booleans. int -> lin for line numbers. int -> size_t for sizes. Use angle-brackets when including quotesys.h. Include error.h, regex.h, xalloc.h. (message5): sizeof -> offsetof (begin_output): Invoke pr without -f. (lines_differ): Renamed from line_cmp, and return bool not 3-way int. All callers changed. Add support for IGNORE_TAB_EXPANSION. (change_letter): Now an array rather than a function. All callers changed. (translate_range): Translate line numbers to long, not lin, for convenience with printf. (analyze_hunk): Return enum changes instead of a count of inserts and deletes. All callers changed. (zalloc): New function.
* (quotesys.h): Include.Paul Eggert1998-09-141-2/+2
| | | | | | | | | | (PR_PROGRAM): New macro. (pfatal_with_name): Abort if error returns. (fatal): Likewise. (print_message_queue): Free message chain after printing. (currently_recursive): Renamed from current_depth, and now a boolean. (begin_output): Report error if fflush does. Avoid stdio and gettext in child.
* (quotearg.h): Include.Paul Eggert1998-09-131-69/+80
| | | | | | | | | | (PR_PROGRAM): New macro. (pfatal_with_name): Abort if error returns. (fatal): Likewise. (print_message_queue): Free message chain after printing. (currently_recursive): Renamed from current_depth, and now a boolean. (begin_output): Report error if fflush does. Avoid stdio and gettext in child.
* (struct msg, message5, print_message_queue): Allocate just one block of memoryPaul Eggert1994-11-141-29/+47
| | | | to save a messsage.
* (pr_program): New var.Paul Eggert1994-10-311-37/+32
| | | | | | | | | (begin_output): Use system_quote_arg to compute command. (analyze_hunk): ignore_regexp_list -> ignore_regexp.fastmap Fix off-by-1 line length bug. Match with one big regexp instead of a list of regexps. Use new `trivial_length' local instead of comparing line's first byte to `\n'. Help the compiler with linbuf local vars.
* (perror_with_name, fatal): Use GNU `error'.Paul Eggert1994-10-151-70/+14
| | | | | | (error): Remove. (line_cmp): tolower -> _tolower (xmalloc, xrealloc): Remove.
* (dir_file_pathname): Use filename_lastdirchar instead of strrchr.Paul Eggert1994-10-011-1/+2
|
* isspace -> ISSPACE, etc.Paul Eggert1994-09-221-29/+26
| | | | | (PR_PROGRAM): Moved here from diff.h (old name was PR_FILE_NAME). (begin_output): Use SYSTEM_QUOTE_ARG.
* (program_name): Renamed from `program', for consistency.Paul Eggert1994-09-151-3/+3
|
* (line_cmp): Now takes just two arguments, and no longer optimizesPaul Eggert1994-09-121-37/+45
| | | | | | | for common case of exact equality; the caller does that optimization now. Optimize for the common case of mostly exact equality. Use isupper/tolower instead of islower/toupper, for consistency. (line_cmp, print_line): Use '\n' instead of line_end_char.
* (memchr, waitpid): Remove; use new substitutes instead.Paul Eggert1994-09-081-25/+0
|
* (begin_output): Use popen+pclose if !HAVE_FORK. Check fdopen status.Paul Eggert1994-09-021-4/+33
|
* (print_number_range): Don't rely on promotion to make the old-style parameterPaul Eggert1994-04-151-1/+1
| | | | | type agree with the prototype parameter type; this doesn't work on Apollos running bsd4.3.
* (xmalloc, xrealloc): "virtual memory" -> "memory"Paul Eggert1993-11-101-2/+2
|
* (memchr): Make first arg char const *Paul Eggert1993-09-271-4/+4
| | | | | | to match standard. (xmalloc, xrealloc): Cast malloc, realloc to (VOID *) to suppress bogus warnings on some nonstandard hosts.
* (output_1_line): Use isprint, since some hosts lack isgraph.Paul Eggert1993-09-181-4/+4
| | | | | Ensure that its argument isn't negative. (xmalloc, xrealloc): Remove needless casts.
* (line_cmp): bcmp -> memcmpPaul Eggert1993-09-131-4/+4
|
* Add prototypes to function declarations. Use `const' to pacify `gcc'.Paul Eggert1993-08-271-97/+138
| | | | | | | | | | | | | | | | | Use size_t, not int, when needed. Use STD{IN,OUT,ERR}_FILENO instead of [012]. (struct msg, msg_chain, msg_chain_end): Moved here from diff.h. (message5): New function. (pr_pid): New var. (begin_output): Allocate `name' more precisely. Put child pid into pr_pid, so that we can wait for it later. Don't check execl's return value, since any return must be an error. (finish_output): Detect and report output errors. Use waitpid if available. Check pr exit status. (line_cmp): Use locale's definition of white space instead of using one hardwired defn for -b and another for -w. (analyze_cmp): Avoid double negation with `! nontrivial'. Pacify `gcc -Wall' be rewriting for-loop into do-while-loop. (dir_file_pathname): New function.
* Change NULL to 0.Paul Eggert1993-05-261-5/+5
|
* entered into RCSPaul Eggert1992-11-121-6/+2
|
* *** empty log message ***Paul Eggert1992-09-281-49/+57
|
* *** empty log message ***Paul Eggert1992-09-271-1/+1
|
* *** empty log message ***David MacKenzie1992-09-151-1/+1
|
* *** empty log message ***David MacKenzie1992-09-121-4/+4
|
* *** empty log message ***Paul Eggert1992-09-061-74/+58
|
* Initial revisionDavid MacKenzie1992-07-071-0/+715