From 008e37b6a440e5d2ea40a3aafefe3f7ae29f8d74 Mon Sep 17 00:00:00 2001 From: John Marino Date: Sat, 29 Oct 2011 17:39:48 +0200 Subject: [PATCH] Upgrade diffutils from 3.0 to 3.2 on the vendor branch --- contrib/diffutils/README | 31 +- .../doc/{diff.info => diffutils.info} | 823 +++++++++--------- .../diffutils/lib/{inttostr.c => anytostr.c} | 17 +- contrib/diffutils/lib/basename-lgpl.c | 2 +- contrib/diffutils/lib/basename.c | 2 +- contrib/diffutils/lib/bitrotate.h | 2 +- contrib/diffutils/lib/c-ctype.c | 2 +- contrib/diffutils/lib/c-ctype.h | 2 +- contrib/diffutils/lib/c-stack.c | 58 +- contrib/diffutils/lib/c-stack.h | 2 +- contrib/diffutils/lib/c-strcase.h | 2 +- contrib/diffutils/lib/c-strcasecmp.c | 2 +- contrib/diffutils/lib/c-strncasecmp.c | 2 +- contrib/diffutils/lib/cmpbuf.c | 18 +- contrib/diffutils/lib/cmpbuf.h | 2 +- contrib/diffutils/lib/diffseq.h | 2 +- contrib/diffutils/lib/dirname-lgpl.c | 2 +- contrib/diffutils/lib/dirname.c | 2 +- contrib/diffutils/lib/dirname.h | 32 +- contrib/diffutils/lib/dosname.h | 53 ++ contrib/diffutils/lib/dup2.c | 6 +- contrib/diffutils/lib/error.c | 40 +- contrib/diffutils/lib/error.h | 18 +- contrib/diffutils/lib/exclude.c | 26 +- contrib/diffutils/lib/exclude.h | 4 +- contrib/diffutils/lib/exitfail.c | 3 +- contrib/diffutils/lib/exitfail.h | 2 +- contrib/diffutils/lib/fcntl.c | 16 +- contrib/diffutils/lib/file-type.c | 2 +- contrib/diffutils/lib/file-type.h | 2 +- contrib/diffutils/lib/filenamecat-lgpl.c | 88 ++ .../lib/{dirname.c => filenamecat.c} | 21 +- .../lib/{file-type.h => filenamecat.h} | 20 +- contrib/diffutils/lib/fnmatch.c | 3 +- contrib/diffutils/lib/fnmatch_loop.c | 14 +- contrib/diffutils/lib/freopen-safer.c | 2 +- contrib/diffutils/lib/getopt.c | 95 +- contrib/diffutils/lib/getopt1.c | 4 +- contrib/diffutils/lib/getopt_int.h | 4 +- contrib/diffutils/lib/gettext.h | 10 +- contrib/diffutils/lib/gettime.c | 2 +- contrib/diffutils/lib/hard-locale.c | 6 +- contrib/diffutils/lib/hard-locale.h | 2 +- contrib/diffutils/lib/hash.c | 114 ++- contrib/diffutils/lib/hash.h | 25 +- contrib/diffutils/lib/ignore-value.h | 37 +- contrib/diffutils/lib/imaxtostr.c | 5 +- contrib/diffutils/lib/intprops.h | 318 ++++++- contrib/diffutils/lib/inttostr.c | 57 +- contrib/diffutils/lib/inttostr.h | 7 +- contrib/diffutils/lib/localcharset.c | 12 +- contrib/diffutils/lib/localcharset.h | 2 +- contrib/diffutils/lib/lstat.c | 7 +- contrib/diffutils/lib/malloca.c | 8 +- contrib/diffutils/lib/malloca.h | 2 +- contrib/diffutils/lib/mbchar.c | 2 +- contrib/diffutils/lib/mbchar.h | 2 +- contrib/diffutils/lib/mbiter.h | 2 +- contrib/diffutils/lib/mbscasecmp.c | 2 +- contrib/diffutils/lib/mbslen.c | 2 +- contrib/diffutils/lib/mbsstr.c | 11 +- contrib/diffutils/lib/mbuiter.h | 2 +- contrib/diffutils/lib/mktime.c | 200 +++-- contrib/diffutils/lib/offtostr.c | 5 +- contrib/diffutils/lib/prepargs.c | 2 +- contrib/diffutils/lib/progname.c | 2 +- contrib/diffutils/lib/progname.h | 2 +- contrib/diffutils/lib/propername.c | 5 +- contrib/diffutils/lib/propername.h | 2 +- contrib/diffutils/lib/quote.c | 4 +- contrib/diffutils/lib/quote.h | 3 +- contrib/diffutils/lib/quotearg.c | 9 +- contrib/diffutils/lib/quotearg.h | 4 +- contrib/diffutils/lib/regcomp.c | 3 +- contrib/diffutils/lib/regex.c | 4 +- contrib/diffutils/lib/regex.h | 25 +- contrib/diffutils/lib/regex_internal.c | 7 +- contrib/diffutils/lib/regex_internal.h | 17 +- contrib/diffutils/lib/regexec.c | 5 +- contrib/diffutils/lib/sh-quote.c | 2 +- contrib/diffutils/lib/sh-quote.h | 2 +- contrib/diffutils/lib/sig-handler.h | 2 +- contrib/diffutils/lib/stat-time.h | 16 +- contrib/diffutils/lib/stdio--.h | 2 +- contrib/diffutils/lib/stdio-safer.h | 2 +- contrib/diffutils/lib/str-kmp.h | 34 +- contrib/diffutils/lib/streq.h | 4 +- contrib/diffutils/lib/strerror-override.c | 279 ++++++ contrib/diffutils/lib/strerror-override.h | 52 ++ contrib/diffutils/lib/strftime.c | 20 +- contrib/diffutils/lib/strftime.h | 2 +- contrib/diffutils/lib/striconv.c | 29 +- contrib/diffutils/lib/striconv.h | 2 +- contrib/diffutils/lib/stripslash.c | 2 +- contrib/diffutils/lib/strnlen1.c | 2 +- contrib/diffutils/lib/strnlen1.h | 2 +- contrib/diffutils/lib/tempname.c | 2 +- contrib/diffutils/lib/tempname.h | 2 +- contrib/diffutils/lib/timegm.c | 41 - contrib/diffutils/lib/timespec.h | 53 +- contrib/diffutils/lib/trim.c | 38 +- contrib/diffutils/lib/trim.h | 2 +- contrib/diffutils/lib/uinttostr.c | 5 +- contrib/diffutils/lib/umaxtostr.c | 5 +- contrib/diffutils/lib/unistr/u8-mbtoucr.c | 287 ++++++ contrib/diffutils/lib/unistr/u8-uctomb-aux.c | 71 ++ contrib/diffutils/lib/unistr/u8-uctomb.c | 90 ++ contrib/diffutils/lib/unitypes.h | 28 - contrib/diffutils/lib/uniwidth.h | 67 -- contrib/diffutils/lib/uniwidth/cjk.h | 4 +- contrib/diffutils/lib/uniwidth/width.c | 71 +- contrib/diffutils/lib/unlocked-io.h | 2 +- contrib/diffutils/lib/verify.h | 177 +++- contrib/diffutils/lib/version-etc-fsf.c | 2 +- contrib/diffutils/lib/version-etc.c | 4 +- contrib/diffutils/lib/version-etc.h | 10 +- contrib/diffutils/lib/wcwidth.c | 2 +- contrib/diffutils/lib/xalloc-die.c | 6 +- contrib/diffutils/lib/xalloc-oversized.h | 38 + contrib/diffutils/lib/xalloc.h | 88 +- contrib/diffutils/lib/xfreopen.c | 2 +- contrib/diffutils/lib/xmalloc.c | 18 +- contrib/diffutils/lib/xstriconv.c | 2 +- contrib/diffutils/lib/xstriconv.h | 2 +- contrib/diffutils/lib/xstrndup.c | 2 +- contrib/diffutils/lib/xstrndup.h | 2 +- contrib/diffutils/lib/xstrtol-error.c | 2 +- contrib/diffutils/lib/xstrtol.c | 2 +- contrib/diffutils/lib/xstrtol.h | 18 +- contrib/diffutils/man/diff.1 | 233 ++--- contrib/diffutils/man/diff3.1 | 83 +- contrib/diffutils/man/sdiff.1 | 86 +- contrib/diffutils/src/analyze.c | 2 +- contrib/diffutils/src/context.c | 3 +- contrib/diffutils/src/diff.c | 151 ++-- contrib/diffutils/src/diff.h | 91 +- contrib/diffutils/src/diff3.c | 62 +- contrib/diffutils/src/dir.c | 93 +- contrib/diffutils/src/ed.c | 2 +- contrib/diffutils/src/ifdef.c | 2 +- contrib/diffutils/src/io.c | 165 ++-- contrib/diffutils/src/normal.c | 2 +- contrib/diffutils/src/sdiff.c | 123 +-- contrib/diffutils/src/side.c | 2 +- contrib/diffutils/src/system.h | 25 +- contrib/diffutils/src/util.c | 76 +- 146 files changed, 3312 insertions(+), 1852 deletions(-) rename contrib/diffutils/doc/{diff.info => diffutils.info} (88%) copy contrib/diffutils/lib/{inttostr.c => anytostr.c} (76%) create mode 100644 contrib/diffutils/lib/dosname.h create mode 100644 contrib/diffutils/lib/filenamecat-lgpl.c copy contrib/diffutils/lib/{dirname.c => filenamecat.c} (66%) copy contrib/diffutils/lib/{file-type.h => filenamecat.h} (63%) create mode 100644 contrib/diffutils/lib/strerror-override.c create mode 100644 contrib/diffutils/lib/strerror-override.h delete mode 100644 contrib/diffutils/lib/timegm.c create mode 100644 contrib/diffutils/lib/unistr/u8-mbtoucr.c create mode 100644 contrib/diffutils/lib/unistr/u8-uctomb-aux.c create mode 100644 contrib/diffutils/lib/unistr/u8-uctomb.c delete mode 100644 contrib/diffutils/lib/unitypes.h delete mode 100644 contrib/diffutils/lib/uniwidth.h create mode 100644 contrib/diffutils/lib/xalloc-oversized.h diff --git a/contrib/diffutils/README b/contrib/diffutils/README index 061ec8aae8..f51587a155 100644 --- a/contrib/diffutils/README +++ b/contrib/diffutils/README @@ -8,10 +8,10 @@ Please see the file COPYING for copying conditions. Please see the file doc/version.texi for version information. -Please see the file doc/diff.texi (or doc/diff.info) for documentation -that can be printed with TeX, or read with the `info' program or with -Emacs's `M-x info'. Brief man pages are in man/*, but they are no -substitute for the documentation. +Please see the file doc/diffutils.texi (or doc/diffutils.info) for +documentation that can be printed with TeX, or read with the `info' +program or with Emacs's `M-x info'. Brief man pages are in man/*, +but they are no substitute for the documentation. Please see the file ABOUT-NLS for notes about translations. @@ -44,24 +44,21 @@ this distribution: * help2man 1.33 * Texinfo 4.7 +For any copyright year range specified as YYYY-ZZZZ in this package +note that the range specifies every single year in that closed interval. + Please report bugs to . ----- -Copyright (C) 1992, 1998, 2001-2002, 2004, 2009-2010 Free Software Foundation, +Copyright (C) 1992, 1998, 2001-2002, 2004, 2009-2011 Free Software Foundation, Inc. This file is part of GNU Diffutils. -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with no +Invariant Sections, with no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license is included in the ``GNU Free +Documentation License'' file as part of this distribution. diff --git a/contrib/diffutils/doc/diff.info b/contrib/diffutils/doc/diffutils.info similarity index 88% rename from contrib/diffutils/doc/diff.info rename to contrib/diffutils/doc/diffutils.info index 540d4a15b8..b44d1cfc76 100644 --- a/contrib/diffutils/doc/diff.info +++ b/contrib/diffutils/doc/diffutils.info @@ -1,64 +1,55 @@ -This is diff.info, produced by makeinfo version 4.13 from diff.texi. +This is diffutils.info, produced by makeinfo version 4.13 from +diffutils.texi. -This manual is for GNU Diffutils (version 3.0, 15 April 2010), and +This manual is for GNU Diffutils (version 3.2, 15 August 2011), and documents the GNU `diff', `diff3', `sdiff', and `cmp' commands for showing the differences between files and the GNU `patch' command for using their output to update files. - Copyright (C) 1992-1994, 1998, 2001-2002, 2004, 2006, 2009-2010 Free + Copyright (C) 1992-1994, 1998, 2001-2002, 2004, 2006, 2009-2011 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software - Foundation; with no Invariant Sections, with the Front-Cover texts - being "A GNU Manual," and with the Back-Cover Texts as in (a) - below. A copy of the license is included in the section entitled - "GNU Free Documentation License." - - (a) The FSF's Back-Cover Text is: "You have the freedom to copy - and modify this GNU manual. Buying copies from the FSF supports - it in developing GNU and promoting software freedom." + Foundation; with no Invariant Sections, no Front-Cover Texts, and + no Back-Cover Texts. A copy of the license is included in the + section entitled "GNU Free Documentation License." INFO-DIR-SECTION Individual utilities START-INFO-DIR-ENTRY -* cmp: (diff)Invoking cmp. Compare 2 files byte by byte. -* diff: (diff)Invoking diff. Compare 2 files line by line. -* diff3: (diff)Invoking diff3. Compare 3 files line by line. -* patch: (diff)Invoking patch. Apply a patch to a file. -* sdiff: (diff)Invoking sdiff. Merge 2 files side-by-side. +* cmp: (diffutils)Invoking cmp. Compare 2 files byte by byte. +* diff: (diffutils)Invoking diff. Compare 2 files line by line. +* diff3: (diffutils)Invoking diff3. Compare 3 files line by line. +* patch: (diffutils)Invoking patch. Apply a patch to a file. +* sdiff: (diffutils)Invoking sdiff. Merge 2 files side-by-side. END-INFO-DIR-ENTRY INFO-DIR-SECTION Text creation and manipulation START-INFO-DIR-ENTRY -* Diff: (diff). Comparing and merging files. +* Diffutils: (diffutils). Comparing and merging files. END-INFO-DIR-ENTRY  -File: diff.info, Node: Top, Next: Overview, Up: (dir) +File: diffutils.info, Node: Top, Next: Overview, Up: (dir) Comparing and Merging Files *************************** -This manual is for GNU Diffutils (version 3.0, 15 April 2010), and +This manual is for GNU Diffutils (version 3.2, 15 August 2011), and documents the GNU `diff', `diff3', `sdiff', and `cmp' commands for showing the differences between files and the GNU `patch' command for using their output to update files. - Copyright (C) 1992-1994, 1998, 2001-2002, 2004, 2006, 2009-2010 Free + Copyright (C) 1992-1994, 1998, 2001-2002, 2004, 2006, 2009-2011 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software - Foundation; with no Invariant Sections, with the Front-Cover texts - being "A GNU Manual," and with the Back-Cover Texts as in (a) - below. A copy of the license is included in the section entitled - "GNU Free Documentation License." - - (a) The FSF's Back-Cover Text is: "You have the freedom to copy - and modify this GNU manual. Buying copies from the FSF supports - it in developing GNU and promoting software freedom." + Foundation; with no Invariant Sections, no Front-Cover Texts, and + no Back-Cover Texts. A copy of the license is included in the + section entitled "GNU Free Documentation License." * Menu: @@ -93,7 +84,7 @@ Software Foundation, Inc. * Index:: Index.  -File: diff.info, Node: Overview, Next: Comparison, Prev: Top, Up: Top +File: diffutils.info, Node: Overview, Next: Comparison, Prev: Top, Up: Top Overview ******** @@ -164,7 +155,7 @@ MacKenzie. Parts of this manual are adapted from a manual page written by Larry Wall, with his permission.  -File: diff.info, Node: Comparison, Next: Output Formats, Prev: Overview, Up: Top +File: diffutils.info, Node: Comparison, Next: Output Formats, Prev: Overview, Up: Top 1 What Comparison Means *********************** @@ -217,7 +208,7 @@ changes to the same file. * Binary:: Comparing binary files or forcing text comparisons.  -File: diff.info, Node: Hunks, Next: White Space, Up: Comparison +File: diffutils.info, Node: Hunks, Next: White Space, Up: Comparison 1.1 Hunks ========= @@ -259,29 +250,32 @@ output: It is also possible to find `a' as the common line. `diff' does not always find an optimal matching between the files; it takes shortcuts to run faster. But its output is usually close to the shortest -possible. You can adjust this tradeoff with the `-d' or `--minimal' +possible. You can adjust this tradeoff with the `--minimal' (`-d') option (*note diff Performance::).  -File: diff.info, Node: White Space, Next: Blank Lines, Prev: Hunks, Up: Comparison +File: diffutils.info, Node: White Space, Next: Blank Lines, Prev: Hunks, Up: Comparison 1.2 Suppressing Differences in Blank and Tab Spacing ==================================================== -The `-E' or `--ignore-tab-expansion' option ignores the distinction +The `--ignore-tab-expansion' (`-E') option ignores the distinction between tabs and spaces on input. A tab is considered to be equivalent to the number of spaces to the next tab stop (*note Tabs::). - The `-b' or `--ignore-space-change' option is stronger. It ignores -white space at line end, and considers all other sequences of one or -more white space characters within a line to be equivalent. With this -option, `diff' considers the following two lines to be equivalent, -where `$' denotes the line end: + The `--ignore-trailing-space' (`-Z') option ignores white space at +line end. + + The `--ignore-space-change' (`-b') option is stronger than `-E' and +`-Z' combined. It ignores white space at line end, and considers all +other sequences of one or more white space characters within a line to +be equivalent. With this option, `diff' considers the following two +lines to be equivalent, where `$' denotes the line end: Here lyeth muche rychnesse in lytell space. -- John Heywood$ Here lyeth muche rychnesse in lytell space. -- John Heywood $ - The `-w' or `--ignore-all-space' option is stronger still. It + The `--ignore-all-space' (`-w') option is stronger still. It ignores differences even if one line has white space where the other line has none. "White space" characters include tab, vertical tab, form feed, carriage return, and space; some locales may define @@ -298,12 +292,12 @@ line. Hence the `-w' or `--ignore-all-space' option does not ignore newline-related changes; it ignores only other white space changes.  -File: diff.info, Node: Blank Lines, Next: Specified Lines, Prev: White Space, Up: Comparison +File: diffutils.info, Node: Blank Lines, Next: Specified Lines, Prev: White Space, Up: Comparison 1.3 Suppressing Differences Whose Lines Are All Blank ===================================================== -The `-B' or `--ignore-blank-lines' option ignores changes that consist +The `--ignore-blank-lines' (`-B') option ignores changes that consist entirely of blank lines. With this option, for example, a file containing 1. A point is that which has no part. @@ -318,24 +312,23 @@ containing -- Euclid, The Elements, I Normally this option affects only lines that are completely empty, -but if you also specify the `-b' or `--ignore-space-change' option, or -the `-w' or `--ignore-all-space' option, lines are also affected if -they look empty but contain white space. In other words, `-B' is -equivalent to `-I '^$'' by default, but it is equivalent to `-I -'^[[:space:]]*$'' if `-b' or `-w' is also specified. +but if you also specify an option that ignores trailing spaces, lines +are also affected if they look empty but contain white space. In other +words, `-B' is equivalent to `-I '^$'' by default, but it is equivalent +to `-I '^[[:space:]]*$'' if `-b', `-w' or `-Z' is also specified.  -File: diff.info, Node: Specified Lines, Next: Case Folding, Prev: Blank Lines, Up: Comparison +File: diffutils.info, Node: Specified Lines, Next: Case Folding, Prev: Blank Lines, Up: Comparison 1.4 Suppressing Differences Whose Lines All Match a Regular Expression ====================================================================== To ignore insertions and deletions of lines that match a `grep'-style -regular expression, use the `-I REGEXP' or -`--ignore-matching-lines=REGEXP' option. You should escape regular -expressions that contain shell metacharacters to prevent the shell from -expanding them. For example, `diff -I '^[[:digit:]]'' ignores all -changes to lines beginning with a digit. +regular expression, use the `--ignore-matching-lines=REGEXP' (`-I +REGEXP') option. You should escape regular expressions that contain +shell metacharacters to prevent the shell from expanding them. For +example, `diff -I '^[[:digit:]]'' ignores all changes to lines +beginning with a digit. However, `-I' only ignores the insertion or deletion of lines that contain the regular expression if every changed line in the hunk--every @@ -348,7 +341,7 @@ by using more than one `-I' option. `diff' tries to match each line against each regular expression.  -File: diff.info, Node: Case Folding, Next: Brief, Prev: Specified Lines, Up: Comparison +File: diffutils.info, Node: Case Folding, Next: Brief, Prev: Specified Lines, Up: Comparison 1.5 Suppressing Case Differences ================================ @@ -359,7 +352,7 @@ case counterparts, so that, for example, it considers `Funky Stuff', use the `-i' or `--ignore-case' option.  -File: diff.info, Node: Brief, Next: Binary, Prev: Case Folding, Up: Comparison +File: diffutils.info, Node: Brief, Next: Binary, Prev: Case Folding, Up: Comparison 1.6 Summarizing Which Files Differ ================================== @@ -367,8 +360,8 @@ File: diff.info, Node: Brief, Next: Binary, Prev: Case Folding, Up: Comparis When you only want to find out whether files are different, and you don't care what the differences are, you can use the summary output format. In this format, instead of showing the differences between the -files, `diff' simply reports whether files differ. The `-q' or -`--brief' option selects this output format. +files, `diff' simply reports whether files differ. The `--brief' +(`-q') option selects this output format. This format is especially useful when comparing the contents of two directories. It is also much faster than doing the normal line by line @@ -388,7 +381,7 @@ Invoking cmp::). two files.  -File: diff.info, Node: Binary, Prev: Brief, Up: Comparison +File: diffutils.info, Node: Binary, Prev: Brief, Up: Comparison 1.7 Binary Files and Forcing Text Comparisons ============================================= @@ -411,21 +404,21 @@ characters; `diff' would erroneously decide that those are non-text files. Or you might be comparing documents that are in a format used by a word processing system that uses null characters to indicate special formatting. You can force `diff' to consider all files to be -text files, and compare them line by line, by using the `-a' or -`--text' option. If the files you compare using this option do not in -fact contain text, they will probably contain few newline characters, -and the `diff' output will consist of hunks showing differences between +text files, and compare them line by line, by using the `--text' (`-a') +option. If the files you compare using this option do not in fact +contain text, they will probably contain few newline characters, and +the `diff' output will consist of hunks showing differences between long lines of whatever characters the files contain. You can also force `diff' to report only whether files differ (but -not how). Use the `-q' or `--brief' option for this. +not how). Use the `--brief' (`-q') option for this. Normally, differing binary files count as trouble because the resulting `diff' output does not capture all the differences. This trouble causes `diff' to exit with status 2. However, this trouble -cannot occur with the `-a' or `--text' option, or with the `-q' or -`--brief' option, as these options both cause `diff' to generate a form -of output that represents differences as requested. +cannot occur with the `--text' (`-a') option, or with the `--brief' +(`-q') option, as these options both cause `diff' to generate a form of +output that represents differences as requested. In operating systems that distinguish between text and binary files, `diff' normally reads and writes all data as text. Use the `--binary' @@ -448,7 +441,7 @@ affects how lines are read, which in turn affects how they are compared and output. If you want to compare two files byte by byte, you can use the `cmp' -program with the `-l' or `--verbose' option to show the values of each +program with the `--verbose' (`-l') option to show the values of each differing byte in the two files. With GNU `cmp', you can also use the `-b' or `--print-bytes' option to show the ASCII representation of those bytes. *Note Invoking cmp::, for more information. @@ -462,7 +455,7 @@ few non-text bytes but otherwise are like text files, you can force line by using the `-a' or `--text' option.  -File: diff.info, Node: Output Formats, Next: Incomplete Lines, Prev: Comparison, Up: Top +File: diffutils.info, Node: Output Formats, Next: Incomplete Lines, Prev: Comparison, Up: Top 2 `diff' Output Formats *********************** @@ -481,7 +474,7 @@ reports the differences between two sample input files. * If-then-else:: Merging files with if-then-else.  -File: diff.info, Node: Sample diff Input, Next: Context, Up: Output Formats +File: diffutils.info, Node: Sample diff Input, Next: Context, Up: Output Formats 2.1 Two Sample Input Files ========================== @@ -525,7 +518,7 @@ second and third lines of `tzu', and the last hunk contains just the last three lines of `tzu'.  -File: diff.info, Node: Context, Next: Side by Side, Prev: Sample diff Input, Up: Output Formats +File: diffutils.info, Node: Context, Next: Side by Side, Prev: Sample diff Input, Up: Output Formats 2.2 Showing Differences in Their Context ======================================== @@ -558,7 +551,7 @@ more information on using `patch' to apply imperfect diffs. * Alternate Names:: Showing alternate file names in context headers.  -File: diff.info, Node: Context Format, Next: Unified Format, Up: Context +File: diffutils.info, Node: Context Format, Next: Unified Format, Up: Context 2.2.1 Context Format -------------------- @@ -567,11 +560,11 @@ The context output format shows several lines of context around the lines that differ. It is the standard format for distributing updates to source code. - To select this output format, use the `-C LINES', -`--context[=LINES]', or `-c' option. The argument LINES that some of -these options take is the number of lines of context to show. If you -do not specify LINES, it defaults to three. For proper operation, -`patch' typically needs at least two lines of context. + To select this output format, use the `--context[=LINES]' (`-C +LINES') or `-c' option. The argument LINES that some of these options +take is the number of lines of context to show. If you do not specify +LINES, it defaults to three. For proper operation, `patch' typically +needs at least two lines of context. * Menu: @@ -580,7 +573,7 @@ do not specify LINES, it defaults to three. For proper operation, * Detailed Context:: A detailed description of the context output format.  -File: diff.info, Node: Example Context, Next: Less Context, Up: Context Format +File: diffutils.info, Node: Example Context, Next: Less Context, Up: Context Format 2.2.1.1 An Example of Context Format .................................... @@ -620,7 +613,7 @@ run together, because their contents overlap. + The door of all subtleties!  -File: diff.info, Node: Less Context, Next: Detailed Context, Prev: Example Context, Up: Context Format +File: diffutils.info, Node: Less Context, Next: Detailed Context, Prev: Example Context, Up: Context Format 2.2.1.2 An Example of Context Format with Less Context ...................................................... @@ -652,7 +645,7 @@ context line is reported here. + The door of all subtleties!  -File: diff.info, Node: Detailed Context, Prev: Less Context, Up: Context Format +File: diffutils.info, Node: Detailed Context, Prev: Less Context, Up: Context Format 2.2.1.3 Detailed Description of Context Format .............................................. @@ -712,14 +705,14 @@ FROM-FILE are omitted. If all of the changes are deletions, the lines of TO-FILE are omitted.  -File: diff.info, Node: Unified Format, Next: Sections, Prev: Context Format, Up: Context +File: diffutils.info, Node: Unified Format, Next: Sections, Prev: Context Format, Up: Context 2.2.2 Unified Format -------------------- The unified output format is a variation on the context format that is more compact because it omits redundant context lines. To select this -output format, use the `-U LINES', `--unified[=LINES]', or `-u' option. +output format, use the `--unified[=LINES]' (`-U LINES'), or `-u' option. The argument LINES is the number of lines of context to show. When it is not given, it defaults to three. @@ -733,7 +726,7 @@ operation, `patch' typically needs at least three lines of context. * Detailed Unified:: A detailed description of unified format.  -File: diff.info, Node: Example Unified, Next: Detailed Unified, Up: Unified Format +File: diffutils.info, Node: Example Unified, Next: Detailed Unified, Up: Unified Format 2.2.2.1 An Example of Unified Format .................................... @@ -762,7 +755,7 @@ Input::, for the complete contents of the two files): +The door of all subtleties!  -File: diff.info, Node: Detailed Unified, Prev: Example Unified, Up: Unified Format +File: diffutils.info, Node: Detailed Unified, Prev: Example Unified, Up: Unified Format 2.2.2.2 Detailed Description of Unified Format .............................................. @@ -808,7 +801,7 @@ following indicator characters in the left print column: A line was removed here from the first file.  -File: diff.info, Node: Sections, Next: Alternate Names, Prev: Unified Format, Up: Context +File: diffutils.info, Node: Sections, Next: Alternate Names, Prev: Unified Format, Up: Context 2.2.3 Showing Which Sections Differences Are in ----------------------------------------------- @@ -826,17 +819,17 @@ lines are "section headings" is determined by a regular expression. * C Function Headings:: Showing headings of C functions.  -File: diff.info, Node: Specified Headings, Next: C Function Headings, Up: Sections +File: diffutils.info, Node: Specified Headings, Next: C Function Headings, Up: Sections 2.2.3.1 Showing Lines That Match Regular Expressions .................................................... To show in which sections differences occur for files that are not -source code for C or similar languages, use the `-F REGEXP' or -`--show-function-line=REGEXP' option. `diff' considers lines that -match the `grep'-style regular expression REGEXP to be the beginning of -a section of the file. Here are suggested regular expressions for some -common languages: +source code for C or similar languages, use the +`--show-function-line=REGEXP' (`-F REGEXP') option. `diff' considers +lines that match the `grep'-style regular expression REGEXP to be the +beginning of a section of the file. Here are suggested regular +expressions for some common languages: `^[[:alpha:]$_]' C, C++, Prolog @@ -852,38 +845,38 @@ to use it, you must select the context format (*note Context Format::) or unified format (*note Unified Format::). In other output formats it has no effect. - The `-F' or `--show-function-line' option finds the nearest -unchanged line that precedes each hunk of differences and matches the -given regular expression. Then it adds that line to the end of the -line of asterisks in the context format, or to the `@@' line in unified -format. If no matching line exists, this option leaves the output for -that hunk unchanged. If that line is more than 40 characters long, it -outputs only the first 40 characters. You can specify more than one -regular expression for such lines; `diff' tries to match each line -against each regular expression, starting with the last one given. This -means that you can use `-p' and `-F' together, if you wish. + The `--show-function-line' (`-F') option finds the nearest unchanged +line that precedes each hunk of differences and matches the given +regular expression. Then it adds that line to the end of the line of +asterisks in the context format, or to the `@@' line in unified format. +If no matching line exists, this option leaves the output for that hunk +unchanged. If that line is more than 40 characters long, it outputs +only the first 40 characters. You can specify more than one regular +expression for such lines; `diff' tries to match each line against each +regular expression, starting with the last one given. This means that +you can use `-p' and `-F' together, if you wish.  -File: diff.info, Node: C Function Headings, Prev: Specified Headings, Up: Sections +File: diffutils.info, Node: C Function Headings, Prev: Specified Headings, Up: Sections 2.2.3.2 Showing C Function Headings ................................... To show in which functions differences occur for C and similar -languages, you can use the `-p' or `--show-c-function' option. This +languages, you can use the `--show-c-function' (`-p') option. This option automatically defaults to the context output format (*note Context Format::), with the default number of lines of context. You can override that number with `-C LINES' elsewhere in the command line. You can override both the format and the number with `-U LINES' elsewhere in the command line. - The `-p' or `--show-c-function' option is equivalent to `-F + The `--show-c-function' (`-p') option is equivalent to `-F '^[[:alpha:]$_]'' if the unified format is specified, otherwise `-c -F '^[[:alpha:]$_]'' (*note Specified Headings::). GNU `diff' provides this option for the sake of convenience.  -File: diff.info, Node: Alternate Names, Prev: Sections, Up: Context +File: diffutils.info, Node: Alternate Names, Prev: Sections, Up: Context 2.2.4 Showing Alternate File Names ---------------------------------- @@ -906,7 +899,7 @@ Pagination::). --- modified  -File: diff.info, Node: Side by Side, Next: Normal, Prev: Context, Up: Output Formats +File: diffutils.info, Node: Side by Side, Next: Normal, Prev: Context, Up: Output Formats 2.3 Showing Differences Side by Side ==================================== @@ -970,16 +963,16 @@ merging files. * Example Side by Side:: Sample side by side output.  -File: diff.info, Node: Side by Side Format, Next: Example Side by Side, Up: Side by Side +File: diffutils.info, Node: Side by Side Format, Next: Example Side by Side, Up: Side by Side 2.3.1 Controlling Side by Side Format ------------------------------------- -The `-y' or `--side-by-side' option selects side by side format. +The `--side-by-side' (`-y') option selects side by side format. Because side by side output lines contain two input lines, the output is wider than usual: normally 130 print columns, which can fit onto a traditional printer line. You can set the width of the output with the -`-W COLUMNS' or `--width=COLUMNS' option. The output is split into two +`--width=COLUMNS' (`-W COLUMNS') option. The output is split into two halves of equal width, separated by a small gutter to mark differences; the right half is aligned to a tab stop so that tabs line up. Input lines that are too long to fit in half of an output line are truncated @@ -990,7 +983,7 @@ lines. The `--suppress-common-lines' option suppresses common lines entirely.  -File: diff.info, Node: Example Side by Side, Prev: Side by Side Format, Up: Side by Side +File: diffutils.info, Node: Example Side by Side, Prev: Side by Side Format, Up: Side by Side 2.3.2 An Example of Side by Side Format --------------------------------------- @@ -1015,7 +1008,7 @@ diff Input::, for the complete contents of the two files). > The door of all subtleties!  -File: diff.info, Node: Normal, Next: Scripts, Prev: Side by Side, Up: Output Formats +File: diffutils.info, Node: Normal, Next: Scripts, Prev: Side by Side, Up: Output Formats 2.4 Showing Differences Without Context ======================================= @@ -1037,7 +1030,7 @@ Use the `--normal' option to select this output format explicitly. * Detailed Normal:: A detailed description of normal output format.  -File: diff.info, Node: Example Normal, Next: Detailed Normal, Up: Normal +File: diffutils.info, Node: Example Normal, Next: Detailed Normal, Up: Normal 2.4.1 An Example of Normal Format --------------------------------- @@ -1060,7 +1053,7 @@ shows only the lines that are different between the two files. > The door of all subtleties!  -File: diff.info, Node: Detailed Normal, Prev: Example Normal, Up: Normal +File: diffutils.info, Node: Detailed Normal, Prev: Example Normal, Up: Normal 2.4.2 Detailed Description of Normal Format ------------------------------------------- @@ -1104,7 +1097,7 @@ are: after line 3 of file 2.  -File: diff.info, Node: Scripts, Next: If-then-else, Prev: Normal, Up: Output Formats +File: diffutils.info, Node: Scripts, Next: If-then-else, Prev: Normal, Up: Output Formats 2.5 Making Edit Scripts ======================= @@ -1119,7 +1112,7 @@ produce TO-FILE. * RCS:: A special `diff' output format used by RCS.  -File: diff.info, Node: ed Scripts, Next: Forward ed, Up: Scripts +File: diffutils.info, Node: ed Scripts, Next: Forward ed, Up: Scripts 2.5.1 `ed' Scripts ------------------ @@ -1128,7 +1121,7 @@ File: diff.info, Node: ed Scripts, Next: Forward ed, Up: Scripts the first file into the second file. Long ago, this was the only output mode that was suitable for editing one file into another automatically; today, with `patch', it is almost obsolete. Use the -`-e' or `--ed' option to select this output format. +`--ed' (`-e') option to select this output format. Like the normal format (*note Normal::), this output format does not show any context; unlike the normal format, it does not include the @@ -1148,7 +1141,7 @@ old' edits `old' to make it a copy of `newN'. * Detailed ed:: A detailed description of `ed' format.  -File: diff.info, Node: Example ed, Next: Detailed ed, Up: ed Scripts +File: diffutils.info, Node: Example ed, Next: Detailed ed, Up: ed Scripts 2.5.1.1 Example `ed' Script ........................... @@ -1168,7 +1161,7 @@ the complete contents of the two files): 1,2d  -File: diff.info, Node: Detailed ed, Prev: Example ed, Up: ed Scripts +File: diffutils.info, Node: Detailed ed, Prev: Example ed, Up: ed Scripts 2.5.1.2 Detailed Description of `ed' Format ........................................... @@ -1214,7 +1207,7 @@ are: `5,7d' means delete lines 5-7 of file 1.  -File: diff.info, Node: Forward ed, Next: RCS, Prev: ed Scripts, Up: Scripts +File: diffutils.info, Node: Forward ed, Next: RCS, Prev: ed Scripts, Up: Scripts 2.5.2 Forward `ed' Scripts -------------------------- @@ -1232,20 +1225,20 @@ compatibility with older versions of `diff'. Use the `-f' or `--forward-ed' option to select it.  -File: diff.info, Node: RCS, Prev: Forward ed, Up: Scripts +File: diffutils.info, Node: RCS, Prev: Forward ed, Up: Scripts 2.5.3 RCS Scripts ----------------- The RCS output format is designed specifically for use by the Revision Control System, which is a set of free programs used for organizing -different versions and systems of files. Use the `-n' or `--rcs' -option to select this output format. It is like the forward `ed' -format (*note Forward ed::), but it can represent arbitrary changes to -the contents of a file because it avoids the forward `ed' format's -problems with lines consisting of a single period and with incomplete -lines. Instead of ending text sections with a line consisting of a -single period, each command specifies the number of lines it affects; a +different versions and systems of files. Use the `--rcs' (`-n') option +to select this output format. It is like the forward `ed' format +(*note Forward ed::), but it can represent arbitrary changes to the +contents of a file because it avoids the forward `ed' format's problems +with lines consisting of a single period and with incomplete lines. +Instead of ending text sections with a line consisting of a single +period, each command specifies the number of lines it affects; a combination of the `a' and `d' commands are used instead of `c'. Also, if the second file ends in a changed incomplete line, then the output also ends in an incomplete line. @@ -1264,7 +1257,7 @@ for the complete contents of the two files): The door of all subtleties!  -File: diff.info, Node: If-then-else, Prev: Scripts, Up: Output Formats +File: diffutils.info, Node: If-then-else, Prev: Scripts, Up: Output Formats 2.6 Merging Files with If-then-else =================================== @@ -1306,7 +1299,7 @@ group formats and line formats, as described in the next sections. * Detailed If-then-else:: A detailed description of if-then-else format.  -File: diff.info, Node: Line Group Formats, Next: Line Formats, Up: If-then-else +File: diffutils.info, Node: Line Group Formats, Next: Line Formats, Up: If-then-else 2.6.1 Line Group Formats ------------------------ @@ -1472,7 +1465,7 @@ forms. 0, to `1 line' if N is 1, and to `%dN lines' otherwise.  -File: diff.info, Node: Line Formats, Next: Example If-then-else, Prev: Line Group Formats, Up: If-then-else +File: diffutils.info, Node: Line Formats, Next: Example If-then-else, Prev: Line Group Formats, Up: If-then-else 2.6.2 Line Formats ------------------ @@ -1573,7 +1566,7 @@ fine control over `diff' output. old new  -File: diff.info, Node: Example If-then-else, Next: Detailed If-then-else, Prev: Line Formats, Up: If-then-else +File: diffutils.info, Node: Example If-then-else, Next: Detailed If-then-else, Prev: Line Formats, Up: If-then-else 2.6.3 An Example of If-then-else Format --------------------------------------- @@ -1606,7 +1599,7 @@ for the complete contents of the two files): #endif /* TWO */  -File: diff.info, Node: Detailed If-then-else, Prev: Example If-then-else, Up: If-then-else +File: diffutils.info, Node: Detailed If-then-else, Prev: Example If-then-else, Up: If-then-else 2.6.4 Detailed Description of If-then-else Format ------------------------------------------------- @@ -1652,7 +1645,7 @@ option, except it operates on a file and a diff to produce a merged file; *Note patch Options::.  -File: diff.info, Node: Incomplete Lines, Next: Comparing Directories, Prev: Output Formats, Up: Top +File: diffutils.info, Node: Incomplete Lines, Next: Comparing Directories, Prev: Output Formats, Up: Top 3 Incomplete Lines ****************** @@ -1698,7 +1691,7 @@ outputs the following without a trailing newline: .  -File: diff.info, Node: Comparing Directories, Next: Adjusting Output, Prev: Incomplete Lines, Up: Top +File: diffutils.info, Node: Comparing Directories, Next: Adjusting Output, Prev: Incomplete Lines, Up: Top 4 Comparing Directories *********************** @@ -1708,12 +1701,12 @@ trees. When both file name arguments to `diff' are directories, it compares each file that is contained in both directories, examining file names in alphabetical order as specified by the `LC_COLLATE' locale category. Normally `diff' is silent about pairs of files that -contain no differences, but if you use the `-s' or -`--report-identical-files' option, it reports pairs of identical files. -Normally `diff' reports subdirectories common to both directories -without comparing subdirectories' files, but if you use the `-r' or -`--recursive' option, it compares every corresponding pair of files in -the directory trees, as many levels deep as they go. +contain no differences, but if you use the `--report-identical-files' +(`-s') option, it reports pairs of identical files. Normally `diff' +reports subdirectories common to both directories without comparing +subdirectories' files, but if you use the `-r' or `--recursive' option, +it compares every corresponding pair of files in the directory trees, +as many levels deep as they go. For file names that are in only one of the directories, `diff' normally does not show the contents of the file that exists; it reports @@ -1722,7 +1715,7 @@ can make `diff' act as though the file existed but was empty in the other directory, so that it outputs the entire contents of the file that actually exists. (It is output as either an insertion or a deletion, depending on whether it is in the first or the second directory given.) -To do this, use the `-N' or `--new-file' option. +To do this, use the `--new-file' (`-N') option. If the older directory contains one or more large files that are not in the newer directory, you can make the patch smaller by using the @@ -1734,27 +1727,27 @@ applying the patch to remove the files that were deleted before applying the patch. *Note Making Patches::, for more discussion of making patches for distribution. - To ignore some files while comparing directories, use the `-x -PATTERN' or `--exclude=PATTERN' option. This option ignores any files -or subdirectories whose base names match the shell pattern PATTERN. -Unlike in the shell, a period at the start of the base of a file name -matches a wildcard at the start of a pattern. You should enclose -PATTERN in quotes so that the shell does not expand it. For example, -the option `-x '*.[ao]'' ignores any file whose name ends with `.a' or -`.o'. + To ignore some files while comparing directories, use the +`--exclude=PATTERN' (`-x PATTERN') option. This option ignores any +files or subdirectories whose base names match the shell pattern +PATTERN. Unlike in the shell, a period at the start of the base of a +file name matches a wildcard at the start of a pattern. You should +enclose PATTERN in quotes so that the shell does not expand it. For +example, the option `-x '*.[ao]'' ignores any file whose name ends with +`.a' or `.o'. This option accumulates if you specify it more than once. For example, using the options `-x 'RCS' -x '*,v'' ignores any file or subdirectory whose base name is `RCS' or ends with `,v'. If you need to give this option many times, you can instead put the -patterns in a file, one pattern per line, and use the `-X FILE' or -`--exclude-from=FILE' option. Trailing white space and empty lines are -ignored in the pattern file. +patterns in a file, one pattern per line, and use the +`--exclude-from=FILE' (`-X FILE') option. Trailing white space and +empty lines are ignored in the pattern file. If you have been comparing two directories and stopped partway through, later you might want to continue where you left off. You can -do this by using the `-S FILE' or `--starting-file=FILE' option. This +do this by using the `--starting-file=FILE' (`-S FILE') option. This compares only the file FILE and all alphabetically later files in the topmost directory level. @@ -1768,13 +1761,13 @@ in the other. The `--no-ignore-file-name-case' option cancels the effect of the `--ignore-file-name-case' option, reverting to the default behavior. - If an `-x PATTERN' or `--exclude=PATTERN' option, or an `-X FILE' or -`--exclude-from=FILE' option, is specified while the + If an `--exclude=PATTERN' (`-x PATTERN') option, or an +`--exclude-from=FILE' (`-X FILE') option, is specified while the `--ignore-file-name-case' option is in effect, case is ignored when excluding file names matching the specified patterns.  -File: diff.info, Node: Adjusting Output, Next: diff Performance, Prev: Comparing Directories, Up: Top +File: diffutils.info, Node: Adjusting Output, Next: diff Performance, Prev: Comparing Directories, Up: Top 5 Making `diff' Output Prettier ******************************* @@ -1789,7 +1782,7 @@ These adjustments can be applied to any output format. * Pagination:: Page numbering and time-stamping `diff' output.  -File: diff.info, Node: Tabs, Next: Trailing Blanks, Up: Adjusting Output +File: diffutils.info, Node: Tabs, Next: Trailing Blanks, Up: Adjusting Output 5.1 Preserving Tab Stop Alignment ================================= @@ -1803,7 +1796,7 @@ line up correctly. The first way is to have `diff' convert all tabs into the correct number of spaces before outputting them; select this method with the -`-t' or `--expand-tabs' option. To use this form of output with +`--expand-tabs' (`-t') option. To use this form of output with `patch', you must give `patch' the `-l' or `--ignore-white-space' option (*note Changed White Space::, for more information). `diff' normally assumes that tab stops are set every 8 print columns, but this @@ -1821,7 +1814,7 @@ type indicator character. Select this method with the `-T' or `--initial-tab' option.  -File: diff.info, Node: Trailing Blanks, Next: Pagination, Prev: Tabs, Up: Adjusting Output +File: diffutils.info, Node: Trailing Blanks, Next: Pagination, Prev: Tabs, Up: Adjusting Output 5.2 Omitting trailing blanks ============================ @@ -1845,20 +1838,20 @@ to be munged by text editors or by transmission via email. It is accepted by GNU `patch' as well.  -File: diff.info, Node: Pagination, Prev: Trailing Blanks, Up: Adjusting Output +File: diffutils.info, Node: Pagination, Prev: Trailing Blanks, Up: Adjusting Output 5.3 Paginating `diff' Output ============================ It can be convenient to have long output page-numbered and time-stamped. -The `-l' or `--paginate' option does this by sending the `diff' output +The `--paginate' (`-l') option does this by sending the `diff' output through the `pr' program. Here is what the page header might look like for `diff -lc lao tzu': 2002-02-22 14:20 diff -lc lao tzu Page 1  -File: diff.info, Node: diff Performance, Next: Comparing Three Files, Prev: Adjusting Output, Up: Top +File: diffutils.info, Node: diff Performance, Next: Comparing Three Files, Prev: Adjusting Output, Up: Top 6 `diff' Performance Tradeoffs ****************************** @@ -1888,7 +1881,7 @@ hurting it in others. comes up with a near-minimal set of differences. Usually it is good enough for practical purposes. If the `diff' output is large, you might want `diff' to use a modified algorithm that sometimes produces a -smaller set of differences. The `-d' or `--minimal' option does this; +smaller set of differences. The `--minimal' (`-d') option does this; however, it can also cause `diff' to run more slowly than usual, so it is not the default behavior. @@ -1917,7 +1910,7 @@ towards the end of the file. Merging hunks can make the output look nicer in some cases.  -File: diff.info, Node: Comparing Three Files, Next: diff3 Merging, Prev: diff Performance, Up: Top +File: diffutils.info, Node: Comparing Three Files, Next: diff3 Merging, Prev: diff Performance, Up: Top 7 Comparing Three Files *********************** @@ -1940,7 +1933,7 @@ location in the input files. * Detailed diff3 Normal:: A detailed description of normal output format.  -File: diff.info, Node: Sample diff3 Input, Next: Example diff3 Normal, Up: Comparing Three Files +File: diffutils.info, Node: Sample diff3 Input, Next: Example diff3 Normal, Up: Comparing Three Files 7.1 A Third Sample Input File ============================= @@ -1966,7 +1959,7 @@ Input::). This is the third sample file, called `tao': -- The Way of Lao-Tzu, tr. Wing-tsit Chan  -File: diff.info, Node: Example diff3 Normal, Next: diff3 Hunks, Prev: Sample diff3 Input, Up: Comparing Three Files +File: diffutils.info, Node: Example diff3 Normal, Next: diff3 Hunks, Prev: Sample diff3 Input, Up: Comparing Three Files 7.2 An Example of `diff3' Normal Format ======================================= @@ -2005,7 +1998,7 @@ shows only the lines that are different among the three files. -- The Way of Lao-Tzu, tr. Wing-tsit Chan  -File: diff.info, Node: Detailed diff3 Normal, Prev: diff3 Hunks, Up: Comparing Three Files +File: diffutils.info, Node: Detailed diff3 Normal, Prev: diff3 Hunks, Up: Comparing Three Files 7.3 Detailed Description of `diff3' Normal Format ================================================= @@ -2017,7 +2010,7 @@ contain copies of two or three sets of input lines each preceded by one or two commands identifying where the lines came from. Normally, two spaces precede each copy of an input line to -distinguish it from the commands. But with the `-T' or `--initial-tab' +distinguish it from the commands. But with the `--initial-tab' (`-T') option, `diff3' uses a tab instead of two spaces; this lines up tabs correctly. *Note Tabs::, for more information. @@ -2043,7 +2036,7 @@ Incomplete Lines::), it is distinguished on output from a full line by a following line that starts with `\'.  -File: diff.info, Node: diff3 Hunks, Next: Detailed diff3 Normal, Prev: Example diff3 Normal, Up: Comparing Three Files +File: diffutils.info, Node: diff3 Hunks, Next: Detailed diff3 Normal, Prev: Example diff3 Normal, Up: Comparing Three Files 7.4 `diff3' Hunks ================= @@ -2084,7 +2077,7 @@ all three files, then a three-way hunk containing the last line of each file.  -File: diff.info, Node: diff3 Merging, Next: Interactive Merging, Prev: Comparing Three Files, Up: Top +File: diffutils.info, Node: diff3 Merging, Next: Interactive Merging, Prev: Comparing Three Files, Up: Top 8 Merging From a Common Ancestor ******************************** @@ -2135,21 +2128,21 @@ this bypasses some problems with `ed'. * Saving the Changed File:: Emulating System V behavior.  -File: diff.info, Node: Which Changes, Next: Marking Conflicts, Up: diff3 Merging +File: diffutils.info, Node: Which Changes, Next: Marking Conflicts, Up: diff3 Merging 8.1 Selecting Which Changes to Incorporate ========================================== You can select all unmerged changes from OLDER to YOURS for merging -into MINE with the `-e' or `--ed' option. You can select only the -nonoverlapping unmerged changes with `-3' or `--easy-only', and you can -select only the overlapping changes with `-x' or `--overlap-only'. +into MINE with the `--ed' (`-e') option. You can select only the +nonoverlapping unmerged changes with `--easy-only' (`-3'), and you can +select only the overlapping changes with `--overlap-only' (`-x'). The `-e', `-3' and `-x' options select only "unmerged changes", i.e. changes where MINE and YOURS differ; they ignore changes from OLDER to YOURS where MINE and YOURS are identical, because they assume that such changes have already been merged. If this assumption is not a safe -one, you can use the `-A' or `--show-all' option (*note Marking +one, you can use the `--show-all' (`-A') option (*note Marking Conflicts::). Here is the output of the command `diff3' with each of these three @@ -2178,7 +2171,7 @@ changes output by `-3' and `-x'. .  -File: diff.info, Node: Marking Conflicts, Next: Bypassing ed, Prev: Which Changes, Up: diff3 Merging +File: diffutils.info, Node: Marking Conflicts, Next: Bypassing ed, Prev: Which Changes, Up: diff3 Merging 8.2 Marking Conflicts ===================== @@ -2204,7 +2197,7 @@ follows: lines from C >>>>>>> C - The `-A' or `--show-all' option acts like the `-e' option, except + The `--show-all' (`-A') option acts like the `-e' option, except that it brackets conflicts, and it outputs all changes from OLDER to YOURS, not just the unmerged changes. Thus, given the sample input files (*note Sample diff3 Input::), `diff3 -A lao tzu tao' puts @@ -2228,14 +2221,14 @@ brackets around the conflict where only `tzu' differs: -- The Way of Lao-Tzu, tr. Wing-tsit Chan >>>>>>> tao - The `-E' or `--show-overlap' option outputs less information than -the `-A' or `--show-all' option, because it outputs only unmerged -changes, and it never outputs the contents of the second file. Thus -the `-E' option acts like the `-e' option, except that it brackets the -first and third files from three-way overlapping changes. Similarly, -`-X' acts like `-x', except it brackets all its (necessarily -overlapping) changes. For example, for the three-way overlapping -change above, the `-E' and `-X' options output the following: + The `--show-overlap' (`-E') option outputs less information than the +`--show-all' (`-A') option, because it outputs only unmerged changes, +and it never outputs the contents of the second file. Thus the `-E' +option acts like the `-e' option, except that it brackets the first and +third files from three-way overlapping changes. Similarly, `-X' acts +like `-x', except it brackets all its (necessarily overlapping) +changes. For example, for the three-way overlapping change above, the +`-E' and `-X' options output the following: <<<<<<< lao ======= @@ -2252,12 +2245,12 @@ that the output looks like it came from files named `X', `Y' and `Z' rather than from files named `A', `B' and `C'.  -File: diff.info, Node: Bypassing ed, Next: Merging Incomplete Lines, Prev: Marking Conflicts, Up: diff3 Merging +File: diffutils.info, Node: Bypassing ed, Next: Merging Incomplete Lines, Prev: Marking Conflicts, Up: diff3 Merging 8.3 Generating the Merged Output Directly ========================================= -With the `-m' or `--merge' option, `diff3' outputs the merged file +With the `--merge' (`-m') option, `diff3' outputs the merged file directly. This is more efficient than using `ed' to generate it, and works even with non-text files that `ed' would reject. If you specify `-m' without an `ed' script option, `-A' is assumed. @@ -2290,7 +2283,7 @@ Input:: for a copy of the input files) would output the following: >>>>>>> tao  -File: diff.info, Node: Merging Incomplete Lines, Next: Saving the Changed File, Prev: Bypassing ed, Up: diff3 Merging +File: diffutils.info, Node: Merging Incomplete Lines, Next: Saving the Changed File, Prev: Bypassing ed, Up: diff3 Merging 8.4 How `diff3' Merges Incomplete Lines ======================================= @@ -2307,7 +2300,7 @@ incomplete line is found, `diff3' generates a warning and acts as if a newline had been present.  -File: diff.info, Node: Saving the Changed File, Prev: Merging Incomplete Lines, Up: diff3 Merging +File: diffutils.info, Node: Saving the Changed File, Prev: Merging Incomplete Lines, Up: diff3 Merging 8.5 Saving the Changed File =========================== @@ -2322,14 +2315,14 @@ and appends the `w' and `q' commands. and is incompatible with the merged output option `-m'.  -File: diff.info, Node: Interactive Merging, Next: Merging with patch, Prev: diff3 Merging, Up: Top +File: diffutils.info, Node: Interactive Merging, Next: Merging with patch, Prev: diff3 Merging, Up: Top 9 Interactive Merging with `sdiff' ********************************** With `sdiff', you can merge two files interactively based on a -side-by-side `-y' format comparison (*note Side by Side::). Use `-o -FILE' or `--output=FILE' to specify where to put the merged text. +side-by-side `-y' format comparison (*note Side by Side::). Use +`--output=FILE' (`-o FILE') to specify where to put the merged text. *Note Invoking sdiff::, for more details on the options to `sdiff'. Another way to merge files interactively is to use the Emacs Lisp @@ -2341,7 +2334,7 @@ package `emerge'. *Note emerge: (emacs)emerge, for more information. * Merge Commands:: Merging two files interactively.  -File: diff.info, Node: sdiff Option Summary, Next: Merge Commands, Up: Interactive Merging +File: diffutils.info, Node: sdiff Option Summary, Next: Merge Commands, Up: Interactive Merging 9.1 Specifying `diff' Options to `sdiff' ======================================== @@ -2350,12 +2343,12 @@ The following `sdiff' options have the same meaning as for `diff'. *Note diff Options::, for the use of these options. -a -b -d -i -t -v - -B -E -I REGEXP + -B -E -I REGEXP -Z --expand-tabs --ignore-blank-lines --ignore-case --ignore-matching-lines=REGEXP --ignore-space-change - --ignore-tab-expansion + --ignore-tab-expansion --ignore-trailing-space --left-column --minimal --speed-large-files --strip-trailing-cr --suppress-common-lines --tabsize=COLUMNS --text --version --width=COLUMNS @@ -2366,11 +2359,11 @@ and similarly `-s' is equivalent to `--suppress-common-lines'. The meaning of the `sdiff' `-w' and `-W' options is interchanged from that of `diff': with `sdiff', `-w COLUMNS' is equivalent to `--width=COLUMNS', and `-W' is equivalent to `--ignore-all-space'. -`sdiff' without the `-o' option is equivalent to `diff' with the `-y' -or `--side-by-side' option (*note Side by Side::). +`sdiff' without the `-o' option is equivalent to `diff' with the +`--side-by-side' (`-y') option (*note Side by Side::).  -File: diff.info, Node: Merge Commands, Prev: sdiff Option Summary, Up: Interactive Merging +File: diffutils.info, Node: Merge Commands, Prev: sdiff Option Summary, Up: Interactive Merging 9.2 Merge Commands ================== @@ -2423,7 +2416,7 @@ Follow each command with . variable if it is set. The default is system-dependent.  -File: diff.info, Node: Merging with patch, Next: Making Patches, Prev: Interactive Merging, Up: Top +File: diffutils.info, Node: Merging with patch, Next: Making Patches, Prev: Interactive Merging, Up: Top 10 Merging with `patch' *********************** @@ -2472,7 +2465,7 @@ each file F with its new version, putting reject hunks (if any) into * patch and Tradition:: GNU versus traditional `patch'.  -File: diff.info, Node: patch Input, Next: Revision Control, Up: Merging with patch +File: diffutils.info, Node: patch Input, Next: Revision Control, Up: Merging with patch 10.1 Selecting the `patch' Input Format ======================================= @@ -2501,7 +2494,7 @@ format of diff. The output formats listed here are the only ones that unified diff.  -File: diff.info, Node: Revision Control, Next: Imperfect, Prev: patch Input, Up: Merging with patch +File: diffutils.info, Node: Revision Control, Next: Imperfect, Prev: patch Input, Up: Merging with patch 10.2 Revision Control ===================== @@ -2513,7 +2506,7 @@ supports RCS, ClearCase and SCCS. Under RCS and SCCS, `patch' also asks when the input file is read-only and matches the default version in the revision control system. - The `-g NUM' or `--get=NUM' option affects access to files under + The `--get=NUM' (`-g NUM') option affects access to files under supported revision control systems. If NUM is positive, `patch' gets the file without asking the user; if zero, `patch' neither asks the user nor gets the file; and if negative, `patch' asks the user before @@ -2526,7 +2519,7 @@ value is zero if `patch' is conforming to POSIX, negative otherwise. `VERSION_CONTROL' environment variable (*note Backup Names::).  -File: diff.info, Node: Imperfect, Next: Creating and Removing, Prev: Revision Control, Up: Merging with patch +File: diffutils.info, Node: Imperfect, Next: Creating and Removing, Prev: Revision Control, Up: Merging with patch 10.3 Applying Imperfect Patches =============================== @@ -2553,7 +2546,7 @@ intervention or testing. * Dry Runs:: Predicting what `patch' will do.  -File: diff.info, Node: Changed White Space, Next: Reversed Patches, Up: Imperfect +File: diffutils.info, Node: Changed White Space, Next: Reversed Patches, Up: Imperfect 10.3.1 Applying Patches with Changed White Space ------------------------------------------------ @@ -2569,14 +2562,14 @@ the input files. Non-blank characters must still match exactly. Each line of the context must still match a line in the input file.  -File: diff.info, Node: Reversed Patches, Next: Inexact, Prev: Changed White Space, Up: Imperfect +File: diffutils.info, Node: Reversed Patches, Next: Inexact, Prev: Changed White Space, Up: Imperfect 10.3.2 Applying Reversed Patches -------------------------------- Sometimes people run `diff' with the new file first instead of second. This creates a diff that is "reversed". To apply such patches, give -`patch' the `-R' or `--reverse' option. `patch' then attempts to swap +`patch' the `--reverse' (`-R') option. `patch' then attempts to swap each hunk around before applying it. Rejects come out in the swapped format. @@ -2599,7 +2592,7 @@ subsequent "apply anyway" question--or type `C-c' to kill the `patch' process.  -File: diff.info, Node: Inexact, Next: Dry Runs, Prev: Reversed Patches, Up: Imperfect +File: diffutils.info, Node: Inexact, Next: Dry Runs, Prev: Reversed Patches, Up: Imperfect 10.3.3 Helping `patch' Find Inexact Matches ------------------------------------------- @@ -2621,7 +2614,7 @@ more, it makes another scan, ignoring the first two and last two lines of context are ignored. It continues similarly if the maximum fuzz factor is larger. - The `-F LINES' or `--fuzz=LINES' option sets the maximum fuzz factor + The `--fuzz=LINES' (`-F LINES') option sets the maximum fuzz factor to LINES. This option only applies to context and unified diffs; it ignores up to LINES lines while looking for the place to install a hunk. Note that a larger fuzz factor increases the odds of making a @@ -2666,7 +2659,7 @@ is applied to an exact copy of the file that the patch was generated from.  -File: diff.info, Node: Dry Runs, Prev: Inexact, Up: Imperfect +File: diffutils.info, Node: Dry Runs, Prev: Inexact, Up: Imperfect 10.3.4 Predicting what `patch' will do -------------------------------------- @@ -2684,20 +2677,20 @@ patch you can apply it by invoking `patch' as before, but this time without the `--dry-run' option.  -File: diff.info, Node: Creating and Removing, Next: Patching Time Stamps, Prev: Imperfect, Up: Merging with patch +File: diffutils.info, Node: Creating and Removing, Next: Patching Time Stamps, Prev: Imperfect, Up: Merging with patch 10.4 Creating and Removing Files ================================ Sometimes when comparing two directories, a file may exist in one -directory but not the other. If you give `diff' the `-N' or -`--new-file' option, or if you supply an old or new file that is named +directory but not the other. If you give `diff' the `--new-file' +(`-N') option, or if you supply an old or new file that is named `/dev/null' or is empty and is dated the Epoch (1970-01-01 00:00:00 UTC), `diff' outputs a patch that adds or deletes the contents of this file. When given such a patch, `patch' normally creates a new file or removes the old file. However, when conforming to POSIX (*note patch and POSIX::), `patch' does not remove the old file, but leaves it empty. -The `-E' or `--remove-empty-files' option causes `patch' to remove +The `--remove-empty-files' (`-E') option causes `patch' to remove output files that are empty after applying a patch, even if the patch does not appear to be one that removed the file. @@ -2705,7 +2698,7 @@ does not appear to be one that removed the file. asks for confirmation before applying the patch.  -File: diff.info, Node: Patching Time Stamps, Next: Multiple Patches, Prev: Creating and Removing, Up: Merging with patch +File: diffutils.info, Node: Patching Time Stamps, Next: Multiple Patches, Prev: Creating and Removing, Up: Merging with patch 10.5 Updating Time Stamps on Patched Files ========================================== @@ -2719,25 +2712,24 @@ then `syntax.y', then `syntax.c' will normally appear to be out of date with respect to `syntax.y' even though its contents are actually up to date. - The `-Z' or `--set-utc' option causes `patch' to set a patched -file's modification and access times to the time stamps given in -context diff headers. If the context diff headers do not specify a -time zone, they are assumed to use Coordinated Universal Time (UTC, -often known as GMT). - - The `-T' or `--set-time' option acts like `-Z' or `--set-utc', -except that it assumes that the context diff headers' time stamps use -local time instead of UTC. This option is not recommended, because -patches using local time cannot easily be used by people in other time -zones, and because local time stamps are ambiguous when local clocks -move backwards during daylight-saving time adjustments. If the context -diff headers specify a time zone, this option is equivalent to `-Z' or -`--set-utc'. + The `--set-utc' (`-Z') option causes `patch' to set a patched file's +modification and access times to the time stamps given in context diff +headers. If the context diff headers do not specify a time zone, they +are assumed to use Coordinated Universal Time (UTC, often known as GMT). + + The `--set-time' (`-T') option acts like `-Z' or `--set-utc', except +that it assumes that the context diff headers' time stamps use local +time instead of UTC. This option is not recommended, because patches +using local time cannot easily be used by people in other time zones, +and because local time stamps are ambiguous when local clocks move +backwards during daylight-saving time adjustments. If the context diff +headers specify a time zone, this option is equivalent to `--set-utc' +(`-Z'). `patch' normally refrains from setting a file's time stamps if the file's original last-modified time stamp does not match the time given in the diff header, of if the file's contents do not exactly match the -patch. However, if the `-f' or `--force' option is given, the file's +patch. However, if the `--force' (`-f') option is given, the file's time stamps are set regardless. Due to the limitations of the current `diff' format, `patch' cannot @@ -2748,7 +2740,7 @@ on the patched files, so that later invocations of `make' do not get confused by the patched files' times.  -File: diff.info, Node: Multiple Patches, Next: patch Directories, Prev: Patching Time Stamps, Up: Merging with patch +File: diffutils.info, Node: Multiple Patches, Next: patch Directories, Prev: Patching Time Stamps, Up: Merging with patch 10.6 Multiple Patches in a File =============================== @@ -2806,12 +2798,12 @@ first remaining name. POSIX.  -File: diff.info, Node: patch Directories, Next: Backups, Prev: Multiple Patches, Up: Merging with patch +File: diffutils.info, Node: patch Directories, Next: Backups, Prev: Multiple Patches, Up: Merging with patch 10.7 Applying Patches in Other Directories ========================================== -The `-d DIRECTORY' or `--directory=DIRECTORY' option to `patch' makes +The `--directory=DIRECTORY' (`-d DIRECTORY') option to `patch' makes directory DIRECTORY the current directory for interpreting both file names in the patch file, and file names given as arguments to other options (such as `-B' and `-o'). For example, while in a mail reading @@ -2822,13 +2814,13 @@ directly from a message containing the patch like this: Sometimes the file names given in a patch contain leading directories, but you keep your files in a directory different from the -one given in the patch. In those cases, you can use the `-pNUMBER' or -`--strip=NUMBER' option to set the file name strip count to NUMBER. -The strip count tells `patch' how many slashes, along with the directory -names between them, to strip from the front of file names. A sequence -of one or more adjacent slashes is counted as a single slash. By -default, `patch' strips off all leading directories, leaving just the -base file names. +one given in the patch. In those cases, you can use the +`--strip=NUMBER' (`-pNUMBER') option to set the file name strip count +to NUMBER. The strip count tells `patch' how many slashes, along with +the directory names between them, to strip from the front of file +names. A sequence of one or more adjacent slashes is counted as a +single slash. By default, `patch' strips off all leading directories, +leaving just the base file names. For example, suppose the file name in the patch file is `/gnu/src/emacs/etc/NEWS'. Using `-p0' gives the entire file name @@ -2840,7 +2832,7 @@ in the current directory, or if you used the `-d DIRECTORY' option, in that directory.  -File: diff.info, Node: Backups, Next: Backup Names, Prev: patch Directories, Up: Merging with patch +File: diffutils.info, Node: Backups, Next: Backup Names, Prev: patch Directories, Up: Merging with patch 10.8 Backup Files ================= @@ -2851,7 +2843,7 @@ might not be recovered if you undo the patch with `patch -R' (*note Reversed Patches::). However, when conforming to POSIX, `patch' does not create backup files by default. *Note patch and POSIX::. - The `-b' or `--backup' option causes `patch' to make a backup file + The `--backup' (`-b') option causes `patch' to make a backup file regardless of whether the patch matches the original input. The `--backup-if-mismatch' option causes `patch' to create backup files for mismatches files; this is the default when not conforming to POSIX. The @@ -2864,7 +2856,7 @@ backup file is created as a placeholder to represent the nonexistent file.  -File: diff.info, Node: Backup Names, Next: Reject Names, Prev: Backups, Up: Merging with patch +File: diffutils.info, Node: Backup Names, Next: Reject Names, Prev: Backups, Up: Merging with patch 10.9 Backup File Names ====================== @@ -2914,12 +2906,12 @@ are acceptable. Always make simple backups. You can also tell `patch' to prepend a prefix, such as a directory -name, to produce backup file names. The `-B PREFIX' or -`--prefix=PREFIX' option makes backup files by prepending PREFIX to -them. The `-Y PREFIX' or `--basename-prefix=PREFIX' prepends PREFIX to -the last file name component of backup file names instead; for example, -`-Y ~' causes the backup name for `dir/file.c' to be `dir/~file.c'. If -you use either of these prefix options, the suffix-based options are +name, to produce backup file names. The `--prefix=PREFIX' (`-B +PREFIX') option makes backup files by prepending PREFIX to them. The +`--basename-prefix=PREFIX' (`-Y PREFIX') prepends PREFIX to the last +file name component of backup file names instead; for example, `-Y ~' +causes the backup name for `dir/file.c' to be `dir/~file.c'. If you +use either of these prefix options, the suffix-based options are ignored. If you specify the output file with the `-o' option, that file is @@ -2936,7 +2928,7 @@ section have any affect, because no backups are made. use `~', but this should be fixed in the next release.  -File: diff.info, Node: Reject Names, Next: patch Messages, Prev: Backup Names, Up: Merging with patch +File: diffutils.info, Node: Reject Names, Next: patch Messages, Prev: Backup Names, Up: Merging with patch 10.10 Reject File Names ======================= @@ -2952,7 +2944,7 @@ patches in a single file. The `-r REJECT-FILE' or name.  -File: diff.info, Node: patch Messages, Next: patch and POSIX, Prev: Reject Names, Up: Merging with patch +File: diffutils.info, Node: patch Messages, Next: patch and POSIX, Prev: Reject Names, Up: Merging with patch 10.11 Messages and Questions from `patch' ========================================= @@ -2976,7 +2968,7 @@ When applying a set of patches in a loop, you should check the exit status, so you don't apply a later patch to a partially patched file.  -File: diff.info, Node: More or Fewer Messages, Next: patch and Keyboard Input, Up: patch Messages +File: diffutils.info, Node: More or Fewer Messages, Next: patch and Keyboard Input, Up: patch Messages 10.11.1 Controlling the Verbosity of `patch' -------------------------------------------- @@ -2991,13 +2983,13 @@ of patch it is. occurs, by using the `-s', `--quiet', or `--silent' option.  -File: diff.info, Node: patch and Keyboard Input, Next: patch Quoting Style, Prev: More or Fewer Messages, Up: patch Messages +File: diffutils.info, Node: patch and Keyboard Input, Next: patch Quoting Style, Prev: More or Fewer Messages, Up: patch Messages 10.11.2 Inhibiting Keyboard Input --------------------------------- There are two ways you can prevent `patch' from asking you any -questions. The `-f' or `--force' option assumes that you know what you +questions. The `--force' (`-f') option assumes that you know what you are doing. It causes `patch' to do the following: * Skip patches that do not contain file names in their headers. @@ -3008,7 +3000,7 @@ are doing. It causes `patch' to do the following: * Assume that patches are not reversed even if they look like they are. -The `-t' or `--batch' option is similar to `-f', in that it suppresses +The `--batch' (`-t') option is similar to `-f', in that it suppresses questions, but it makes somewhat different assumptions: * Skip patches that do not contain file names in their headers (the @@ -3020,7 +3012,7 @@ questions, but it makes somewhat different assumptions: * Assume that patches are reversed if they look like they are.  -File: diff.info, Node: patch Quoting Style, Prev: patch and Keyboard Input, Up: patch Messages +File: diffutils.info, Node: patch Quoting Style, Prev: patch and Keyboard Input, Up: patch Messages 10.11.3 `patch' Quoting Style ----------------------------- @@ -3055,7 +3047,7 @@ variable is not set, the default value is `shell', but this default may change in a future version of `patch'.  -File: diff.info, Node: patch and POSIX, Next: patch and Tradition, Prev: patch Messages, Up: Merging with patch +File: diffutils.info, Node: patch and POSIX, Next: patch and Tradition, Prev: patch Messages, Up: Merging with patch 10.12 `patch' and the POSIX Standard ==================================== @@ -3080,7 +3072,7 @@ standard, as follows:  -File: diff.info, Node: patch and Tradition, Prev: patch and POSIX, Up: Merging with patch +File: diffutils.info, Node: patch and Tradition, Prev: patch and POSIX, Up: Merging with patch 10.13 GNU `patch' and Traditional `patch' ========================================= @@ -3105,7 +3097,7 @@ version 2.1 and earlier. `//' in file names. * In traditional `patch', backups were enabled by default. This - behavior is now enabled with the `-b' or `--backup' option. + behavior is now enabled with the `--backup' (`-b') option. Conversely, in POSIX `patch', backups are never made, even when there is a mismatch. In GNU `patch', this behavior is enabled @@ -3159,7 +3151,7 @@ version 2.1 and earlier.  -File: diff.info, Node: Making Patches, Next: Invoking cmp, Prev: Merging with patch, Up: Top +File: diffutils.info, Node: Making Patches, Next: Invoking cmp, Prev: Merging with patch, Up: Top 11 Tips for Making and Using Patches ************************************ @@ -3180,7 +3172,7 @@ to distribute patches for updating a software package. * Generating Smaller Patches:: How to generate smaller patches.  -File: diff.info, Node: Tips for Patch Producers, Next: Tips for Patch Consumers, Up: Making Patches +File: diffutils.info, Node: Tips for Patch Producers, Next: Tips for Patch Consumers, Up: Making Patches 11.1 Tips for Patch Producers ============================= @@ -3209,7 +3201,7 @@ recipient and applying your patches to a copy of the original files. when generating a patch.  -File: diff.info, Node: Tips for Patch Consumers, Next: Avoiding Common Mistakes, Prev: Tips for Patch Producers, Up: Making Patches +File: diffutils.info, Node: Tips for Patch Consumers, Next: Avoiding Common Mistakes, Prev: Tips for Patch Producers, Up: Making Patches 11.2 Tips for Patch Consumers ============================= @@ -3224,7 +3216,7 @@ cannot patch such files. If you are having trouble applying such patches, try upgrading to a recent version of GNU `patch'.  -File: diff.info, Node: Avoiding Common Mistakes, Next: Generating Smaller Patches, Prev: Tips for Patch Consumers, Up: Making Patches +File: diffutils.info, Node: Avoiding Common Mistakes, Next: Generating Smaller Patches, Prev: Tips for Patch Consumers, Up: Making Patches 11.3 Avoiding Common Mistakes ============================= @@ -3276,7 +3268,7 @@ proceeding. This makes it difficult to accidentally apply patches in the wrong order.  -File: diff.info, Node: Generating Smaller Patches, Prev: Avoiding Common Mistakes, Up: Making Patches +File: diffutils.info, Node: Generating Smaller Patches, Prev: Avoiding Common Mistakes, Up: Making Patches 11.4 Generating Smaller Patches =============================== @@ -3311,7 +3303,7 @@ but bear in mind that `patch' typically needs at least two lines for proper operation when patches do not exactly match the input files.  -File: diff.info, Node: Invoking cmp, Next: Invoking diff, Prev: Making Patches, Up: Top +File: diffutils.info, Node: Invoking cmp, Next: Invoking diff, Prev: Making Patches, Up: Top 12 Invoking `cmp' ***************** @@ -3351,7 +3343,7 @@ differences were found, and 2 means trouble. * cmp Options:: Summary of options to `cmp'.  -File: diff.info, Node: cmp Options, Up: Invoking cmp +File: diffutils.info, Node: cmp Options, Up: Invoking cmp 12.1 Options to `cmp' ===================== @@ -3479,7 +3471,7 @@ rejected by your computer due to limitations of its arithmetic. extension to IEC 60027-2.)  -File: diff.info, Node: Invoking diff, Next: Invoking diff3, Prev: Invoking cmp, Up: Top +File: diffutils.info, Node: Invoking diff, Next: Invoking diff3, Prev: Invoking cmp, Up: Top 13 Invoking `diff' ****************** @@ -3499,11 +3491,11 @@ non-directory file must not be `-'. If two file names are given and both are directories, `diff' compares corresponding files in both directories, in alphabetical -order; this comparison is not recursive unless the `-r' or -`--recursive' option is given. `diff' never compares the actual -contents of a directory as if it were a file. The file that is fully -specified may not be standard input, because standard input is nameless -and the notion of "file with the same name" does not apply. +order; this comparison is not recursive unless the `--recursive' (`-r') +option is given. `diff' never compares the actual contents of a +directory as if it were a file. The file that is fully specified may +not be standard input, because standard input is nameless and the +notion of "file with the same name" does not apply. If the `--from-file=FILE' option is given, the number of file names is arbitrary, and FILE is compared to each named file. Similarly, if @@ -3517,14 +3509,14 @@ arguments as file names even if they begin with `-'. An exit status of 0 means no differences were found, 1 means some differences were found, and 2 means trouble. Normally, differing binary files count as trouble, but this can be altered by using the -`-a' or `--text' option, or the `-q' or `--brief' option. +`--text' (`-a') option, or the `-q' or `--brief' option. * Menu: * diff Options:: Summary of options to `diff'.  -File: diff.info, Node: diff Options, Up: Invoking diff +File: diffutils.info, Node: diff Options, Up: Invoking diff 13.1 Options to `diff' ====================== @@ -3568,7 +3560,7 @@ optional argument. For compatibility `diff' also supports an obsolete option syntax `-LINES' that has effect when combined with `-c', `-p', or `-u'. - New scripts should use `-C LINES' or `-U LINES' instead. + New scripts should use `-U LINES' (`-C LINES') instead. `--changed-group-format=FORMAT' Use FORMAT to output a line group containing differing lines from @@ -3625,13 +3617,16 @@ optional argument. *Note Specified Lines::. `--ignore-file-name-case' - Ignore case when comparing file names during recursive comparison. - *Note Comparing Directories::. + Ignore case when comparing file names. For example, recursive + comparison of `d' to `e' might compare the contents of `d/Init' + and `e/inIt'. At the top level, `diff d inIt' might compare the + contents of `d/Init' and `inIt'. *Note Comparing Directories::. `-l' `--paginate' Pass the output through `pr' to paginate it. *Note Pagination::. +`-L LABEL' `--label=LABEL' Use LABEL instead of the file name in the context format (*note Context Format::) and unified format (*note Unified Format::) @@ -3789,8 +3784,12 @@ optional argument. `--side-by-side' Use the side by side output format. *Note Side by Side Format::. +`-Z' +`--ignore-trailing-space' + Ignore white space at line end. *Note White Space::. +  -File: diff.info, Node: Invoking diff3, Next: Invoking patch, Prev: Invoking diff, Up: Top +File: diffutils.info, Node: Invoking diff3, Next: Invoking patch, Prev: Invoking diff, Up: Top 14 Invoking `diff3' ******************* @@ -3812,7 +3811,7 @@ conflicts were found, and 2 means trouble. * diff3 Options:: Summary of options to `diff3'.  -File: diff.info, Node: diff3 Options, Up: Invoking diff3 +File: diffutils.info, Node: diff3 Options, Up: Invoking diff3 14.1 Options to `diff3' ======================= @@ -3909,7 +3908,7 @@ combined into a single command line argument. Which Changes::.  -File: diff.info, Node: Invoking patch, Next: Invoking sdiff, Prev: Invoking diff3, Up: Top +File: diffutils.info, Node: Invoking patch, Next: Invoking sdiff, Prev: Invoking diff3, Up: Top 15 Invoking `patch' ******************* @@ -3944,7 +3943,7 @@ if FILE is one of the input files. * patch Options:: Summary table of options to `patch'.  -File: diff.info, Node: patch Options, Up: Invoking patch +File: diffutils.info, Node: patch Options, Up: Invoking patch 15.1 Options to `patch' ======================= @@ -4127,7 +4126,7 @@ combined into a single command line argument with only one dash.  -File: diff.info, Node: Invoking sdiff, Next: Standards conformance, Prev: Invoking patch, Up: Top +File: diffutils.info, Node: Invoking sdiff, Next: Standards conformance, Prev: Invoking patch, Up: Top 16 Invoking `sdiff' ******************* @@ -4147,8 +4146,8 @@ may not begin with `-'. However, `--' as an argument by itself treats the remaining arguments as file names even if they begin with `-'. You may not use `-' as an input file. - `sdiff' without `-o' (or `--output') produces a side-by-side -difference. This usage is obsolete; use the `-y' or `--side-by-side' + `sdiff' without `--output' (`-o') produces a side-by-side +difference. This usage is obsolete; use the `--side-by-side' (`-y') option of `diff' instead. An exit status of 0 means no differences were found, 1 means some @@ -4159,7 +4158,7 @@ differences were found, and 2 means trouble. * sdiff Options:: Summary of options to `diff'.  -File: diff.info, Node: sdiff Options, Up: Invoking sdiff +File: diffutils.info, Node: sdiff Options, Up: Invoking sdiff 16.1 Options to `sdiff' ======================= @@ -4258,8 +4257,12 @@ options can be abbreviated to any unique prefix of their name. Note that for historical reasons, this option is `-w' in `diff', `-W' in `sdiff'. +`-Z' +`--ignore-trailing-space' + Ignore white space at line end. *Note White Space::. +  -File: diff.info, Node: Standards conformance, Next: Projects, Prev: Invoking sdiff, Up: Top +File: diffutils.info, Node: Standards conformance, Next: Projects, Prev: Invoking sdiff, Up: Top 17 Standards conformance ************************ @@ -4294,7 +4297,7 @@ around the compatibility problems by setting `_POSIX2_VERSION=199209' in your environment.  -File: diff.info, Node: Projects, Next: Copying This Manual, Prev: Standards conformance, Up: Top +File: diffutils.info, Node: Projects, Next: Copying This Manual, Prev: Standards conformance, Up: Top 18 Future Projects ****************** @@ -4315,7 +4318,7 @@ to coordinate with other volunteers. * Bugs:: Reporting bugs.  -File: diff.info, Node: Shortcomings, Next: Bugs, Up: Projects +File: diffutils.info, Node: Shortcomings, Next: Bugs, Up: Projects 18.1 Suggested Projects for Improving GNU `diff' and `patch' ============================================================ @@ -4338,7 +4341,7 @@ These shortcomings motivate the following suggested projects. * Speedups:: Improving performance.  -File: diff.info, Node: Internationalization, Next: Changing Structure, Up: Shortcomings +File: diffutils.info, Node: Internationalization, Next: Changing Structure, Up: Shortcomings 18.1.1 Handling Multibyte and Varying-Width Characters ------------------------------------------------------ @@ -4363,7 +4366,7 @@ Unfortunately, these patches are incomplete and are to an older version of `diff', so more work needs to be done in this area.  -File: diff.info, Node: Changing Structure, Next: Special Files, Prev: Internationalization, Up: Shortcomings +File: diffutils.info, Node: Changing Structure, Next: Special Files, Prev: Internationalization, Up: Shortcomings 18.1.2 Handling Changes to the Directory Structure -------------------------------------------------- @@ -4386,7 +4389,7 @@ represent changes in directory structure, and extending `patch' to understand these extensions.  -File: diff.info, Node: Special Files, Next: Unusual File Names, Prev: Changing Structure, Up: Shortcomings +File: diffutils.info, Node: Special Files, Next: Unusual File Names, Prev: Changing Structure, Up: Shortcomings 18.1.3 Files that are Neither Directories Nor Regular Files ----------------------------------------------------------- @@ -4407,7 +4410,7 @@ files, instead of the change to the symbolic link. and `patch' should be extended to understand these extensions.  -File: diff.info, Node: Unusual File Names, Next: Time Stamp Order, Prev: Special Files, Up: Shortcomings +File: diffutils.info, Node: Unusual File Names, Next: Time Stamp Order, Prev: Special Files, Up: Shortcomings 18.1.4 File Names that Contain Unusual Characters ------------------------------------------------- @@ -4420,7 +4423,7 @@ that is syntactically correct but patches the wrong files. The format of `diff' output should be extended to handle all possible file names.  -File: diff.info, Node: Time Stamp Order, Next: Ignoring Changes, Prev: Unusual File Names, Up: Shortcomings +File: diffutils.info, Node: Time Stamp Order, Next: Ignoring Changes, Prev: Unusual File Names, Up: Shortcomings 18.1.5 Outputting Diffs in Time Stamp Order ------------------------------------------- @@ -4434,7 +4437,7 @@ way to do this would be to implement a `diff' option to output diffs in time stamp order.  -File: diff.info, Node: Ignoring Changes, Next: Speedups, Prev: Time Stamp Order, Up: Shortcomings +File: diffutils.info, Node: Ignoring Changes, Next: Speedups, Prev: Time Stamp Order, Up: Shortcomings 18.1.6 Ignoring Certain Changes ------------------------------- @@ -4456,7 +4459,7 @@ e.g.: However, this outputs the filtered text, not the original.  -File: diff.info, Node: Speedups, Prev: Ignoring Changes, Up: Shortcomings +File: diffutils.info, Node: Speedups, Prev: Ignoring Changes, Up: Shortcomings 18.1.7 Improving Performance ---------------------------- @@ -4468,7 +4471,7 @@ originally copied from the other with time stamps preserved (e.g., with the same content. *Note diff Performance::.  -File: diff.info, Node: Bugs, Prev: Shortcomings, Up: Projects +File: diffutils.info, Node: Bugs, Prev: Shortcomings, Up: Projects 18.2 Reporting Bugs =================== @@ -4487,7 +4490,7 @@ patch is relative to a recent test release, which you can find in the directory `ftp://alpha.gnu.org/gnu/diffutils/'.  -File: diff.info, Node: Copying This Manual, Next: Translations, Prev: Projects, Up: Top +File: diffutils.info, Node: Copying This Manual, Next: Translations, Prev: Projects, Up: Top Appendix A Copying This Manual ****************************** @@ -4973,7 +4976,7 @@ free software license, such as the GNU General Public License, to permit their use in free software.  -File: diff.info, Node: Translations, Next: Index, Prev: Copying This Manual, Up: Top +File: diffutils.info, Node: Translations, Next: Index, Prev: Copying This Manual, Up: Top Appendix B Translations of This Manual ************************************** @@ -4983,7 +4986,7 @@ translation of this manual. Its most recent version can be found at `http://openlab.ring.gr.jp/gnujdoc/cvsweb/cvsweb.cgi/gnujdoc/'.  -File: diff.info, Node: Index, Prev: Translations, Up: Top +File: diffutils.info, Node: Index, Prev: Translations, Up: Top Appendix C Index **************** @@ -5188,118 +5191,118 @@ Appendix C Index  Tag Table: -Node: Top1675 -Node: Overview4135 -Node: Comparison7759 -Node: Hunks10457 -Node: White Space11895 -Node: Blank Lines13623 -Node: Specified Lines14653 -Node: Case Folding15775 -Node: Brief16187 -Node: Binary17506 -Node: Output Formats21591 -Node: Sample diff Input22311 -Node: Context23805 -Node: Context Format25377 -Node: Example Context26164 -Node: Less Context27666 -Node: Detailed Context28850 -Node: Unified Format31043 -Node: Example Unified31834 -Node: Detailed Unified32867 -Node: Sections34509 -Node: Specified Headings35263 -Node: C Function Headings36812 -Node: Alternate Names37654 -Node: Side by Side38563 -Node: Side by Side Format40707 -Node: Example Side by Side41605 -Node: Normal42940 -Node: Example Normal43935 -Node: Detailed Normal44666 -Node: Scripts46400 -Node: ed Scripts46800 -Node: Example ed48002 -Node: Detailed ed48447 -Node: Forward ed50201 -Node: RCS50972 -Node: If-then-else52184 -Node: Line Group Formats53857 -Node: Line Formats59728 -Node: Example If-then-else62993 -Node: Detailed If-then-else64067 -Node: Incomplete Lines65945 -Node: Comparing Directories67577 -Node: Adjusting Output71621 -Node: Tabs72123 -Node: Trailing Blanks73733 -Node: Pagination74954 -Node: diff Performance75418 -Node: Comparing Three Files78501 -Node: Sample diff3 Input79374 -Node: Example diff3 Normal80317 -Node: Detailed diff3 Normal81362 -Node: diff3 Hunks83117 -Node: diff3 Merging84408 -Node: Which Changes86647 -Node: Marking Conflicts88046 -Node: Bypassing ed90500 -Node: Merging Incomplete Lines91839 -Node: Saving the Changed File92560 -Node: Interactive Merging93171 -Node: sdiff Option Summary93876 -Node: Merge Commands95047 -Node: Merging with patch96331 -Node: patch Input98698 -Node: Revision Control99375 -Node: Imperfect100541 -Node: Changed White Space101684 -Node: Reversed Patches102476 -Node: Inexact103936 -Node: Dry Runs107490 -Node: Creating and Removing108349 -Node: Patching Time Stamps109395 -Node: Multiple Patches111593 -Node: patch Directories114251 -Node: Backups115872 -Node: Backup Names116933 -Ref: Backup Names-Footnote-1119897 -Node: Reject Names120024 -Node: patch Messages120608 -Node: More or Fewer Messages121663 -Node: patch and Keyboard Input122289 -Node: patch Quoting Style123315 -Node: patch and POSIX124460 -Node: patch and Tradition125295 -Node: Making Patches128747 -Node: Tips for Patch Producers129568 -Node: Tips for Patch Consumers130819 -Node: Avoiding Common Mistakes131451 -Node: Generating Smaller Patches133971 -Node: Invoking cmp135727 -Node: cmp Options137145 -Node: Invoking diff140632 -Node: diff Options142485 -Node: Invoking diff3150912 -Node: diff3 Options151545 -Node: Invoking patch154573 -Node: patch Options155776 -Node: Invoking sdiff160998 -Node: sdiff Options162140 -Node: Standards conformance165015 -Node: Projects166756 -Node: Shortcomings167462 -Node: Internationalization168559 -Node: Changing Structure169720 -Node: Special Files170819 -Node: Unusual File Names171926 -Node: Time Stamp Order172560 -Node: Ignoring Changes173198 -Node: Speedups173963 -Node: Bugs174422 -Node: Copying This Manual175270 -Node: Translations200404 -Node: Index200771 +Node: Top1433 +Node: Overview3646 +Node: Comparison7275 +Node: Hunks9978 +Node: White Space11420 +Node: Blank Lines13259 +Node: Specified Lines14251 +Node: Case Folding15377 +Node: Brief15794 +Node: Binary17117 +Node: Output Formats21202 +Node: Sample diff Input21927 +Node: Context23426 +Node: Context Format25003 +Node: Example Context25795 +Node: Less Context27302 +Node: Detailed Context28491 +Node: Unified Format30689 +Node: Example Unified31486 +Node: Detailed Unified32524 +Node: Sections34171 +Node: Specified Headings34930 +Node: C Function Headings36481 +Node: Alternate Names37326 +Node: Side by Side38240 +Node: Side by Side Format40389 +Node: Example Side by Side41290 +Node: Normal42630 +Node: Example Normal43630 +Node: Detailed Normal44366 +Node: Scripts46105 +Node: ed Scripts46510 +Node: Example ed47716 +Node: Detailed ed48166 +Node: Forward ed49925 +Node: RCS50701 +Node: If-then-else51916 +Node: Line Group Formats53594 +Node: Line Formats59470 +Node: Example If-then-else62740 +Node: Detailed If-then-else63819 +Node: Incomplete Lines65702 +Node: Comparing Directories67339 +Node: Adjusting Output71383 +Node: Tabs71890 +Node: Trailing Blanks73504 +Node: Pagination74730 +Node: diff Performance75198 +Node: Comparing Three Files78285 +Node: Sample diff3 Input79163 +Node: Example diff3 Normal80111 +Node: Detailed diff3 Normal81161 +Node: diff3 Hunks82920 +Node: diff3 Merging84216 +Node: Which Changes86460 +Node: Marking Conflicts87860 +Node: Bypassing ed90316 +Node: Merging Incomplete Lines91659 +Node: Saving the Changed File92385 +Node: Interactive Merging93001 +Node: sdiff Option Summary93710 +Node: Merge Commands94913 +Node: Merging with patch96202 +Node: patch Input98574 +Node: Revision Control99256 +Node: Imperfect100426 +Node: Changed White Space101574 +Node: Reversed Patches102371 +Node: Inexact103835 +Node: Dry Runs107393 +Node: Creating and Removing108257 +Node: Patching Time Stamps109306 +Node: Multiple Patches111505 +Node: patch Directories114168 +Node: Backups115793 +Node: Backup Names116858 +Ref: Backup Names-Footnote-1119825 +Node: Reject Names119952 +Node: patch Messages120541 +Node: More or Fewer Messages121601 +Node: patch and Keyboard Input122232 +Node: patch Quoting Style123261 +Node: patch and POSIX124411 +Node: patch and Tradition125251 +Node: Making Patches128707 +Node: Tips for Patch Producers129533 +Node: Tips for Patch Consumers130789 +Node: Avoiding Common Mistakes131426 +Node: Generating Smaller Patches133951 +Node: Invoking cmp135712 +Node: cmp Options137135 +Node: Invoking diff140627 +Node: diff Options142483 +Node: Invoking diff3151185 +Node: diff3 Options151823 +Node: Invoking patch154856 +Node: patch Options156064 +Node: Invoking sdiff161291 +Node: sdiff Options162434 +Node: Standards conformance165405 +Node: Projects167151 +Node: Shortcomings167862 +Node: Internationalization168964 +Node: Changing Structure170130 +Node: Special Files171234 +Node: Unusual File Names172346 +Node: Time Stamp Order172985 +Node: Ignoring Changes173628 +Node: Speedups174398 +Node: Bugs174862 +Node: Copying This Manual175715 +Node: Translations200854 +Node: Index201226  End Tag Table diff --git a/contrib/diffutils/lib/inttostr.c b/contrib/diffutils/lib/anytostr.c similarity index 76% copy from contrib/diffutils/lib/inttostr.c copy to contrib/diffutils/lib/anytostr.c index 7a4a47f5f6..e23746acb1 100644 --- a/contrib/diffutils/lib/inttostr.c +++ b/contrib/diffutils/lib/anytostr.c @@ -1,6 +1,6 @@ -/* inttostr.c -- convert integers to printable strings +/* anytostr.c -- convert integers to printable strings - Copyright (C) 2001, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2001, 2006, 2008-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,23 +17,25 @@ /* Written by Paul Eggert */ +/* Tell gcc not to warn about the (i < 0) test, below. */ +#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif + #include #include "inttostr.h" -#include "verify.h" /* Convert I to a printable string in BUF, which must be at least INT_BUFSIZE_BOUND (INTTYPE) bytes long. Return the address of the printable string, which need not start at BUF. */ -char * -inttostr (inttype i, char *buf) +char * __attribute_warn_unused_result__ +anytostr (inttype i, char *buf) { - verify (TYPE_SIGNED (inttype) == inttype_is_signed); char *p = buf + INT_STRLEN_BOUND (inttype); *p = 0; -#if inttype_is_signed if (i < 0) { do @@ -43,7 +45,6 @@ inttostr (inttype i, char *buf) *--p = '-'; } else -#endif { do *--p = '0' + i % 10; diff --git a/contrib/diffutils/lib/basename-lgpl.c b/contrib/diffutils/lib/basename-lgpl.c index a35ff01c2c..529bc35d72 100644 --- a/contrib/diffutils/lib/basename-lgpl.c +++ b/contrib/diffutils/lib/basename-lgpl.c @@ -1,6 +1,6 @@ /* basename.c -- return the last element in a file name - Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2010 Free Software + Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/basename.c b/contrib/diffutils/lib/basename.c index 24da93ac47..90ac5012a4 100644 --- a/contrib/diffutils/lib/basename.c +++ b/contrib/diffutils/lib/basename.c @@ -1,6 +1,6 @@ /* basename.c -- return the last element in a file name - Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2010 Free Software + Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/bitrotate.h b/contrib/diffutils/lib/bitrotate.h index 80e6ef5000..c3a5e1a5d2 100644 --- a/contrib/diffutils/lib/bitrotate.h +++ b/contrib/diffutils/lib/bitrotate.h @@ -1,5 +1,5 @@ /* bitrotate.h - Rotate bits in integers - Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2008-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/c-ctype.c b/contrib/diffutils/lib/c-ctype.c index 48baa72e19..835f4e1adc 100644 --- a/contrib/diffutils/lib/c-ctype.c +++ b/contrib/diffutils/lib/c-ctype.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Character handling in C locale. - Copyright 2000-2003, 2006, 2009-2010 Free Software Foundation, Inc. + Copyright 2000-2003, 2006, 2009-2011 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/c-ctype.h b/contrib/diffutils/lib/c-ctype.h index 26c89b8153..a58913eabc 100644 --- a/contrib/diffutils/lib/c-ctype.h +++ b/contrib/diffutils/lib/c-ctype.h @@ -7,7 +7,7 @@ functions' behaviour depends on the current locale set via setlocale. - Copyright (C) 2000-2003, 2006, 2008-2010 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2006, 2008-2011 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/c-stack.c b/contrib/diffutils/lib/c-stack.c index 46575489de..2f902af3a4 100644 --- a/contrib/diffutils/lib/c-stack.c +++ b/contrib/diffutils/lib/c-stack.c @@ -1,7 +1,6 @@ /* Stack overflow handling. - Copyright (C) 2002, 2004, 2006, 2008, 2009, 2010 Free Software Foundation, - Inc. + Copyright (C) 2002, 2004, 2006, 2008-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -53,6 +52,12 @@ typedef struct sigaltstack stack_t; #endif #ifndef SIGSTKSZ # define SIGSTKSZ 16384 +#elif HAVE_LIBSIGSEGV && SIGSTKSZ < 16384 +/* libsigsegv 2.6 through 2.8 have a bug where some architectures use + more than the Linux default of an 8k alternate stack when deciding + if a fault was caused by stack overflow. */ +# undef SIGSTKSZ +# define SIGSTKSZ 16384 #endif #include @@ -75,9 +80,9 @@ typedef struct sigaltstack stack_t; #include "ignore-value.h" #if defined SA_ONSTACK && defined SA_SIGINFO -# define SIGACTION_WORKS 1 +# define SIGINFO_WORKS 1 #else -# define SIGACTION_WORKS 0 +# define SIGINFO_WORKS 0 # ifndef SA_ONSTACK # define SA_ONSTACK 0 # endif @@ -99,11 +104,16 @@ static char const * volatile stack_overflow_message; appears to have been a stack overflow, or with a core dump otherwise. This function is async-signal-safe. */ -static void die (int) __attribute__ ((noreturn)); -static void +static _Noreturn void die (int signo) { char const *message; +#if !SIGINFO_WORKS && !HAVE_LIBSIGSEGV + /* We can't easily determine whether it is a stack overflow; so + assume that the rest of our program is perfect (!) and that + this segmentation violation is a stack overflow. */ + signo = 0; +#endif /* !SIGINFO_WORKS && !HAVE_LIBSIGSEGV */ segv_action (signo); message = signo ? program_error_message : stack_overflow_message; ignore_value (write (STDERR_FILENO, program_name, strlen (program_name))); @@ -171,9 +181,7 @@ static int segv_handler (void *address __attribute__ ((unused)), /* Handle a segmentation violation that is likely to be a stack overflow and exit. This function is async-signal-safe. */ -static void overflow_handler (int, stackoverflow_context_t) - __attribute__ ((noreturn)); -static void +static _Noreturn void overflow_handler (int emergency, stackoverflow_context_t context __attribute__ ((unused))) { @@ -212,29 +220,12 @@ c_stack_action (void (*action) (int)) #elif HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK && HAVE_STACK_OVERFLOW_HANDLING -/* Direction of the C runtime stack. This function is - async-signal-safe. */ - -# if STACK_DIRECTION -# define find_stack_direction(ptr) STACK_DIRECTION -# else -# if ! SIGACTION_WORKS || HAVE_XSI_STACK_OVERFLOW_HEURISTIC -static int -find_stack_direction (char const *addr) -{ - char dummy; - return ! addr ? find_stack_direction (&dummy) : addr < &dummy ? 1 : -1; -} -# endif -# endif - -# if SIGACTION_WORKS +# if SIGINFO_WORKS /* Handle a segmentation violation and exit. This function is async-signal-safe. */ -static void segv_handler (int, siginfo_t *, void *) __attribute__((noreturn)); -static void +static _Noreturn void segv_handler (int signo, siginfo_t *info, void *context __attribute__ ((unused))) { @@ -255,17 +246,14 @@ segv_handler (int signo, siginfo_t *info, if (0 < info->si_code) { /* If the faulting address is within the stack, or within one - page of the stack end, assume that it is a stack - overflow. */ + page of the stack, assume that it is a stack overflow. */ ucontext_t const *user_context = context; char const *stack_base = user_context->uc_stack.ss_sp; size_t stack_size = user_context->uc_stack.ss_size; char const *faulting_address = info->si_addr; - size_t s = faulting_address - stack_base; size_t page_size = sysconf (_SC_PAGESIZE); - if (find_stack_direction (NULL) < 0) - s += page_size; - if (s < stack_size + page_size) + size_t s = faulting_address - stack_base + page_size; + if (s < stack_size + 2 * page_size) signo = 0; # if DEBUG @@ -311,7 +299,7 @@ c_stack_action (void (*action) (int)) sigemptyset (&act.sa_mask); -# if SIGACTION_WORKS +# if SIGINFO_WORKS /* POSIX 1003.1-2001 says SA_RESETHAND implies SA_NODEFER, but this is not true on Solaris 8 at least. It doesn't hurt to use SA_NODEFER here, so leave it in. */ diff --git a/contrib/diffutils/lib/c-stack.h b/contrib/diffutils/lib/c-stack.h index 910bb68f2c..5aadfb5757 100644 --- a/contrib/diffutils/lib/c-stack.h +++ b/contrib/diffutils/lib/c-stack.h @@ -1,6 +1,6 @@ /* Stack overflow handling. - Copyright (C) 2002, 2004, 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2008-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/c-strcase.h b/contrib/diffutils/lib/c-strcase.h index 2f129e6e48..09e9e9cb1a 100644 --- a/contrib/diffutils/lib/c-strcase.h +++ b/contrib/diffutils/lib/c-strcase.h @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Case-insensitive string comparison functions in C locale. - Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2010 Free Software + Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2011 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/c-strcasecmp.c b/contrib/diffutils/lib/c-strcasecmp.c index b4113a91c4..928c5e6b80 100644 --- a/contrib/diffutils/lib/c-strcasecmp.c +++ b/contrib/diffutils/lib/c-strcasecmp.c @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* c-strcasecmp.c -- case insensitive string comparator in C locale - Copyright (C) 1998-1999, 2005-2006, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2006, 2009-2011 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/c-strncasecmp.c b/contrib/diffutils/lib/c-strncasecmp.c index 7c2e5191b1..810bf56a94 100644 --- a/contrib/diffutils/lib/c-strncasecmp.c +++ b/contrib/diffutils/lib/c-strncasecmp.c @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* c-strncasecmp.c -- case insensitive string comparator in C locale - Copyright (C) 1998-1999, 2005-2006, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2006, 2009-2011 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/cmpbuf.c b/contrib/diffutils/lib/cmpbuf.c index 7413210b36..91e199960d 100644 --- a/contrib/diffutils/lib/cmpbuf.c +++ b/contrib/diffutils/lib/cmpbuf.c @@ -1,6 +1,6 @@ /* Buffer primitives for comparison operations. - Copyright (C) 1993, 1995, 1998, 2001-2002, 2006, 2009-2010 Free Software + Copyright (C) 1993, 1995, 1998, 2001-2002, 2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -20,28 +20,14 @@ #include #include - #include -#ifndef SA_RESTART -# ifdef SA_INTERRUPT /* e.g. SunOS 4.1.x */ -# define SA_RESTART SA_INTERRUPT -# else -# define SA_RESTART 0 -# endif -#endif - #include +#include #include #include #include "cmpbuf.h" #include "intprops.h" -#ifndef PTRDIFF_MAX -# define PTRDIFF_MAX TYPE_MAXIMUM (ptrdiff_t) -#endif -#ifndef SIZE_MAX -# define SIZE_MAX TYPE_MAXIMUM (size_t) -#endif #ifndef SSIZE_MAX # define SSIZE_MAX TYPE_MAXIMUM (ssize_t) #endif diff --git a/contrib/diffutils/lib/cmpbuf.h b/contrib/diffutils/lib/cmpbuf.h index 9d155f4e1c..2296766dee 100644 --- a/contrib/diffutils/lib/cmpbuf.h +++ b/contrib/diffutils/lib/cmpbuf.h @@ -1,6 +1,6 @@ /* Buffer primitives for comparison operations. - Copyright (C) 2002, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2002, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/diffseq.h b/contrib/diffutils/lib/diffseq.h index 6370221515..1cdc985523 100644 --- a/contrib/diffutils/lib/diffseq.h +++ b/contrib/diffutils/lib/diffseq.h @@ -1,6 +1,6 @@ /* Analyze differences between two vectors. - Copyright (C) 1988-1989, 1992-1995, 2001-2004, 2006-2010 Free Software + Copyright (C) 1988-1989, 1992-1995, 2001-2004, 2006-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/dirname-lgpl.c b/contrib/diffutils/lib/dirname-lgpl.c index d4506e060d..f5b0c0ff01 100644 --- a/contrib/diffutils/lib/dirname-lgpl.c +++ b/contrib/diffutils/lib/dirname-lgpl.c @@ -1,6 +1,6 @@ /* dirname.c -- return all but the last element in a file name - Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2010 Free Software + Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/dirname.c b/contrib/diffutils/lib/dirname.c index 953a9acc3d..411ded31b8 100644 --- a/contrib/diffutils/lib/dirname.c +++ b/contrib/diffutils/lib/dirname.c @@ -1,6 +1,6 @@ /* dirname.c -- return all but the last element in a file name - Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2010 Free Software + Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/dirname.h b/contrib/diffutils/lib/dirname.h index fb19508f75..2ef9882445 100644 --- a/contrib/diffutils/lib/dirname.h +++ b/contrib/diffutils/lib/dirname.h @@ -1,6 +1,6 @@ /* Take file names apart into directory and base names. - Copyright (C) 1998, 2001, 2003-2006, 2009-2010 Free Software Foundation, + Copyright (C) 1998, 2001, 2003-2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -21,44 +21,16 @@ # include # include +# include "dosname.h" # ifndef DIRECTORY_SEPARATOR # define DIRECTORY_SEPARATOR '/' # endif -# ifndef ISSLASH -# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR) -# endif - -# ifndef FILE_SYSTEM_PREFIX_LEN -# if FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX - /* This internal macro assumes ASCII, but all hosts that support drive - letters use ASCII. */ -# define _IS_DRIVE_LETTER(c) (((unsigned int) (c) | ('a' - 'A')) - 'a' \ - <= 'z' - 'a') -# define FILE_SYSTEM_PREFIX_LEN(Filename) \ - (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0) -# else -# define FILE_SYSTEM_PREFIX_LEN(Filename) 0 -# endif -# endif - -# ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE -# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0 -# endif - # ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT # define DOUBLE_SLASH_IS_DISTINCT_ROOT 0 # endif -# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE -# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)]) -# else -# define IS_ABSOLUTE_FILE_NAME(F) \ - (ISSLASH ((F)[0]) || 0 < FILE_SYSTEM_PREFIX_LEN (F)) -# endif -# define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F)) - # if GNULIB_DIRNAME char *base_name (char const *file); char *dir_name (char const *file); diff --git a/contrib/diffutils/lib/dosname.h b/contrib/diffutils/lib/dosname.h new file mode 100644 index 0000000000..acdd03b156 --- /dev/null +++ b/contrib/diffutils/lib/dosname.h @@ -0,0 +1,53 @@ +/* File names on MS-DOS/Windows systems. + + Copyright (C) 2000-2001, 2004-2006, 2009-2011 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + From Paul Eggert and Jim Meyering. */ + +#ifndef _DOSNAME_H +#define _DOSNAME_H + +#if (defined _WIN32 || defined __WIN32__ || \ + defined __MSDOS__ || defined __CYGWIN__ || \ + defined __EMX__ || defined __DJGPP__) + /* This internal macro assumes ASCII, but all hosts that support drive + letters use ASCII. */ +# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \ + <= 'z' - 'a') +# define FILE_SYSTEM_PREFIX_LEN(Filename) \ + (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0) +# ifndef __CYGWIN__ +# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1 +# endif +# define ISSLASH(C) ((C) == '/' || (C) == '\\') +#else +# define FILE_SYSTEM_PREFIX_LEN(Filename) 0 +# define ISSLASH(C) ((C) == '/') +#endif + +#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE +# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0 +#endif + +#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE +# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)]) +# else +# define IS_ABSOLUTE_FILE_NAME(F) \ + (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0) +#endif +#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F)) + +#endif /* DOSNAME_H_ */ diff --git a/contrib/diffutils/lib/dup2.c b/contrib/diffutils/lib/dup2.c index a4422bf3b8..e00dc7b2e3 100644 --- a/contrib/diffutils/lib/dup2.c +++ b/contrib/diffutils/lib/dup2.c @@ -1,6 +1,6 @@ /* Duplicate an open file descriptor to a specified file descriptor. - Copyright (C) 1999, 2004-2007, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 1999, 2004-2007, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -59,6 +59,10 @@ rpl_dup2 (int fd, int desired_fd) errno = EBADF; return -1; } +# elif !defined __linux__ + /* On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC. */ + if (fd == desired_fd) + return fcntl (fd, F_GETFL) == -1 ? -1 : fd; # endif result = dup2 (fd, desired_fd); # ifdef __linux__ diff --git a/contrib/diffutils/lib/error.c b/contrib/diffutils/lib/error.c index c79e8d42cb..7482baacfb 100644 --- a/contrib/diffutils/lib/error.c +++ b/contrib/diffutils/lib/error.c @@ -1,5 +1,5 @@ /* Error handler for noninteractive utilities - Copyright (C) 1990-1998, 2000-2007, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 1990-1998, 2000-2007, 2009-2011 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -88,11 +88,24 @@ extern void __error_at_line (int status, int errnum, const char *file_name, # include # include -# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P +# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +/* Get declarations of the Win32 API functions. */ +# define WIN32_LEAN_AND_MEAN +# include +# endif + +/* The gnulib override of fcntl is not needed in this file. */ +# undef fcntl + +# if !HAVE_DECL_STRERROR_R # ifndef HAVE_DECL_STRERROR_R "this configure-time declaration test was not run" # endif +# if STRERROR_R_CHAR_P char *strerror_r (); +# else +int strerror_r (); +# endif # endif /* The calling program should define program_name and set it to the @@ -104,10 +117,29 @@ extern char *program_name; # endif /* HAVE_STRERROR_R || defined strerror_r */ #endif /* not _LIBC */ +#if !_LIBC +/* Return non-zero if FD is open. */ +static inline int +is_open (int fd) +{ +# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + /* On Win32: The initial state of unassigned standard file descriptors is + that they are open but point to an INVALID_HANDLE_VALUE. There is no + fcntl, and the gnulib replacement fcntl does not support F_GETFL. */ + return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE; +# else +# ifndef F_GETFL +# error Please port fcntl to your platform +# endif + return 0 <= fcntl (fd, F_GETFL); +# endif +} +#endif + static inline void flush_stdout (void) { -#if !_LIBC && defined F_GETFL +#if !_LIBC int stdout_fd; # if GNULIB_FREOPEN_SAFER @@ -124,7 +156,7 @@ flush_stdout (void) /* POSIX states that fflush (stdout) after fclose is unspecified; it is safe in glibc, but not on all other platforms. fflush (NULL) is always defined, but too draconian. */ - if (0 <= stdout_fd && 0 <= fcntl (stdout_fd, F_GETFL)) + if (0 <= stdout_fd && is_open (stdout_fd)) #endif fflush (stdout); } diff --git a/contrib/diffutils/lib/error.h b/contrib/diffutils/lib/error.h index 9deef02d2f..80f81bcef2 100644 --- a/contrib/diffutils/lib/error.h +++ b/contrib/diffutils/lib/error.h @@ -1,6 +1,6 @@ /* Declaration for error-reporting function - Copyright (C) 1995, 1996, 1997, 2003, 2006, 2008, 2009, 2010 Free Software - Foundation, Inc. + Copyright (C) 1995-1997, 2003, 2006, 2008-2011 Free Software Foundation, + Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -19,16 +19,16 @@ #ifndef _ERROR_H #define _ERROR_H 1 -#ifndef __attribute__ /* The __attribute__ feature is available in gcc versions 2.5 and later. The __-protected variants of the attributes 'format' and 'printf' are accepted by gcc versions 2.6.4 (effectively 2.7) and later. - We enable __attribute__ only if these are supported too, because + We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because gnulib and libintl do '#define printf __printf__' when they override the 'printf' function. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) -# define __attribute__(Spec) /* empty */ -# endif +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) +#else +# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ #endif #ifdef __cplusplus @@ -40,11 +40,11 @@ extern "C" { If STATUS is nonzero, terminate the program with `exit (STATUS)'. */ extern void error (int __status, int __errnum, const char *__format, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); + _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4)); extern void error_at_line (int __status, int __errnum, const char *__fname, unsigned int __lineno, const char *__format, ...) - __attribute__ ((__format__ (__printf__, 5, 6))); + _GL_ATTRIBUTE_FORMAT ((__printf__, 5, 6)); /* If NULL, error will flush stdout, then print on stderr the program name, a colon and a space. Otherwise, error will call this diff --git a/contrib/diffutils/lib/exclude.c b/contrib/diffutils/lib/exclude.c index 34b5636711..df49714a6b 100644 --- a/contrib/diffutils/lib/exclude.c +++ b/contrib/diffutils/lib/exclude.c @@ -1,7 +1,7 @@ /* exclude.c -- exclude file names - Copyright (C) 1992, 1993, 1994, 1997, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1992-1994, 1997, 1999-2007, 2009-2011 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -134,6 +134,26 @@ fnmatch_pattern_has_wildcards (const char *str, int options) return false; } +static void +unescape_pattern (char *str) +{ + int inset = 0; + char *q = str; + do + { + if (inset) + { + if (*q == ']') + inset = 0; + } + else if (*q == '[') + inset = 1; + else if (*q == '\\') + q++; + } + while ((*str++ = *q++)); +} + /* Return a newly allocated and empty exclude list. */ struct exclude * @@ -480,6 +500,8 @@ add_exclude (struct exclude *ex, char const *pattern, int options) seg = new_exclude_segment (ex, exclude_hash, options); str = xstrdup (pattern); + if (options & EXCLUDE_WILDCARDS) + unescape_pattern (str); p = hash_insert (seg->v.table, str); if (p != str) free (str); diff --git a/contrib/diffutils/lib/exclude.h b/contrib/diffutils/lib/exclude.h index 65d3128763..0a314a99fc 100644 --- a/contrib/diffutils/lib/exclude.h +++ b/contrib/diffutils/lib/exclude.h @@ -1,7 +1,7 @@ /* exclude.h -- declarations for excluding file names - Copyright (C) 1992, 1993, 1994, 1997, 1999, 2001, 2002, 2003, 2005, 2006, - 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1992-1994, 1997, 1999, 2001-2003, 2005-2006, 2009-2011 Free + Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/exitfail.c b/contrib/diffutils/lib/exitfail.c index 3b63f8a123..953aa02fe8 100644 --- a/contrib/diffutils/lib/exitfail.c +++ b/contrib/diffutils/lib/exitfail.c @@ -1,7 +1,6 @@ /* Failure exit status - Copyright (C) 2002, 2003, 2005, 2006, 2007, 2009, 2010 Free Software - Foundation, Inc. + Copyright (C) 2002-2003, 2005-2007, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/exitfail.h b/contrib/diffutils/lib/exitfail.h index 7ffffe5c99..6d01d4f91e 100644 --- a/contrib/diffutils/lib/exitfail.h +++ b/contrib/diffutils/lib/exitfail.h @@ -1,6 +1,6 @@ /* Failure exit status - Copyright (C) 2002, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2002, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/fcntl.c b/contrib/diffutils/lib/fcntl.c index c51e8ded56..d6a328c1c0 100644 --- a/contrib/diffutils/lib/fcntl.c +++ b/contrib/diffutils/lib/fcntl.c @@ -1,6 +1,6 @@ /* Provide file descriptor control. - Copyright (C) 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -187,7 +187,21 @@ rpl_fcntl (int fd, int action, /* arg */...) errno = EINVAL; else { + /* Haiku alpha 2 loses fd flags on original. */ + int flags = fcntl (fd, F_GETFD); + if (flags < 0) + { + result = -1; + break; + } result = fcntl (fd, action, target); + if (0 <= result && fcntl (fd, F_SETFD, flags) == -1) + { + int saved_errno = errno; + close (result); + result = -1; + errno = saved_errno; + } # if REPLACE_FCHDIR if (0 <= result) result = _gl_register_dup (fd, result); diff --git a/contrib/diffutils/lib/file-type.c b/contrib/diffutils/lib/file-type.c index 5a2bf7c68d..109db44024 100644 --- a/contrib/diffutils/lib/file-type.c +++ b/contrib/diffutils/lib/file-type.c @@ -1,6 +1,6 @@ /* Return a string describing the type of a file. - Copyright (C) 1993-1994, 2001-2002, 2004-2006, 2009-2010 Free Software + Copyright (C) 1993-1994, 2001-2002, 2004-2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/file-type.h b/contrib/diffutils/lib/file-type.h index 11ccc0777f..0d1b9a4839 100644 --- a/contrib/diffutils/lib/file-type.h +++ b/contrib/diffutils/lib/file-type.h @@ -1,6 +1,6 @@ /* Return a string describing the type of a file. - Copyright (C) 1993-1994, 2001-2002, 2004-2005, 2009-2010 Free Software + Copyright (C) 1993-1994, 2001-2002, 2004-2005, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/filenamecat-lgpl.c b/contrib/diffutils/lib/filenamecat-lgpl.c new file mode 100644 index 0000000000..8cb2da43d1 --- /dev/null +++ b/contrib/diffutils/lib/filenamecat-lgpl.c @@ -0,0 +1,88 @@ +/* Concatenate two arbitrary file names. + + Copyright (C) 1996-2007, 2009-2011 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Jim Meyering. */ + +#include + +/* Specification. */ +#include "filenamecat.h" + +#include +#include + +#include "dirname.h" + +#if ! HAVE_MEMPCPY && ! defined mempcpy +# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N))) +#endif + +/* Return the longest suffix of F that is a relative file name. + If it has no such suffix, return the empty string. */ + +static char const * +longest_relative_suffix (char const *f) +{ + for (f += FILE_SYSTEM_PREFIX_LEN (f); ISSLASH (*f); f++) + continue; + return f; +} + +/* Concatenate two file name components, DIR and ABASE, in + newly-allocated storage and return the result. + The resulting file name F is such that the commands "ls F" and "(cd + DIR; ls BASE)" refer to the same file, where BASE is ABASE with any + file system prefixes and leading separators removed. + Arrange for a directory separator if necessary between DIR and BASE + in the result, removing any redundant separators. + In any case, if BASE_IN_RESULT is non-NULL, set + *BASE_IN_RESULT to point to the copy of ABASE in the returned + concatenation. However, if ABASE begins with more than one slash, + set *BASE_IN_RESULT to point to the sole corresponding slash that + is copied into the result buffer. + + Return NULL if malloc fails. */ + +char * +mfile_name_concat (char const *dir, char const *abase, char **base_in_result) +{ + char const *dirbase = last_component (dir); + size_t dirbaselen = base_len (dirbase); + size_t dirlen = dirbase - dir + dirbaselen; + size_t needs_separator = (dirbaselen && ! ISSLASH (dirbase[dirbaselen - 1])); + + char const *base = longest_relative_suffix (abase); + size_t baselen = strlen (base); + + char *p_concat = malloc (dirlen + needs_separator + baselen + 1); + char *p; + + if (p_concat == NULL) + return NULL; + + p = mempcpy (p_concat, dir, dirlen); + *p = DIRECTORY_SEPARATOR; + p += needs_separator; + + if (base_in_result) + *base_in_result = p - IS_ABSOLUTE_FILE_NAME (abase); + + p = mempcpy (p, base, baselen); + *p = '\0'; + + return p_concat; +} diff --git a/contrib/diffutils/lib/dirname.c b/contrib/diffutils/lib/filenamecat.c similarity index 66% copy from contrib/diffutils/lib/dirname.c copy to contrib/diffutils/lib/filenamecat.c index 953a9acc3d..86b4e077ad 100644 --- a/contrib/diffutils/lib/dirname.c +++ b/contrib/diffutils/lib/filenamecat.c @@ -1,7 +1,6 @@ -/* dirname.c -- return all but the last element in a file name +/* Concatenate two arbitrary file names. - Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2010 Free Software - Foundation, Inc. + Copyright (C) 1996-2007, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,23 +15,27 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +/* Written by Jim Meyering. */ + #include -#include "dirname.h" +/* Specification. */ +#include "filenamecat.h" #include #include + #include "xalloc.h" -/* Just like mdir_name (dirname-lgpl.c), except, rather than +/* Just like mfile_name_concat (filenamecat-lgpl.c), except, rather than returning NULL upon malloc failure, here, we report the "memory exhausted" condition and exit. */ char * -dir_name (char const *file) +file_name_concat (char const *dir, char const *abase, char **base_in_result) { - char *result = mdir_name (file); - if (!result) + char *p = mfile_name_concat (dir, abase, base_in_result); + if (p == NULL) xalloc_die (); - return result; + return p; } diff --git a/contrib/diffutils/lib/file-type.h b/contrib/diffutils/lib/filenamecat.h similarity index 63% copy from contrib/diffutils/lib/file-type.h copy to contrib/diffutils/lib/filenamecat.h index 11ccc0777f..31b33759c2 100644 --- a/contrib/diffutils/lib/file-type.h +++ b/contrib/diffutils/lib/filenamecat.h @@ -1,6 +1,6 @@ -/* Return a string describing the type of a file. +/* Concatenate two arbitrary file names. - Copyright (C) 1993-1994, 2001-2002, 2004-2005, 2009-2010 Free Software + Copyright (C) 1996-1997, 2003, 2005, 2007, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -16,14 +16,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* Written by Paul Eggert and Jim Meyering. */ +/* Written by Jim Meyering. */ -#ifndef FILE_TYPE_H -# define FILE_TYPE_H 1 +#if GNULIB_FILENAMECAT +char *file_name_concat (char const *dir, char const *base, + char **base_in_result); +#endif -# include -# include - -char const *file_type (struct stat const *); - -#endif /* FILE_TYPE_H */ +char *mfile_name_concat (char const *dir, char const *base, + char **base_in_result); diff --git a/contrib/diffutils/lib/fnmatch.c b/contrib/diffutils/lib/fnmatch.c index 178fdaff45..ecfc8fb0cb 100644 --- a/contrib/diffutils/lib/fnmatch.c +++ b/contrib/diffutils/lib/fnmatch.c @@ -1,7 +1,6 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, - 2003, 2004, 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. +/* Copyright (C) 1991-1993, 1996-2007, 2009-2011 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/fnmatch_loop.c b/contrib/diffutils/lib/fnmatch_loop.c index c46099a8d0..06e7d8b6ea 100644 --- a/contrib/diffutils/lib/fnmatch_loop.c +++ b/contrib/diffutils/lib/fnmatch_loop.c @@ -1,7 +1,6 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, - 2003, 2004, 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +/* Copyright (C) 1991-1993, 1996-2006, 2009-2011 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify @@ -203,6 +202,8 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, case L_('['): { /* Nonzero if the sense of the character class is inverted. */ + const CHAR *p_init = p; + const CHAR *n_init = n; register bool not; CHAR cold; UCHAR fn; @@ -413,8 +414,13 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, } #endif else if (c == L_('\0')) - /* [ (unterminated) loses. */ - return FNM_NOMATCH; + { + /* [ unterminated, treat as normal character. */ + p = p_init; + n = n_init; + c = L_('['); + goto normal_match; + } else { bool is_range = false; diff --git a/contrib/diffutils/lib/freopen-safer.c b/contrib/diffutils/lib/freopen-safer.c index 447a0ecf45..5b02817dc6 100644 --- a/contrib/diffutils/lib/freopen-safer.c +++ b/contrib/diffutils/lib/freopen-safer.c @@ -1,6 +1,6 @@ /* Invoke freopen, but avoid some glitches. - Copyright (C) 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/getopt.c b/contrib/diffutils/lib/getopt.c index 3791f12937..7c9f704061 100644 --- a/contrib/diffutils/lib/getopt.c +++ b/contrib/diffutils/lib/getopt.c @@ -2,7 +2,7 @@ NOTE: getopt is part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to drepper@gnu.org before changing it! - Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2010 Free Software + Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2011 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -479,23 +479,28 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, || !strchr (optstring, argv[d->optind][1]))))) { char *nameend; + unsigned int namelen; const struct option *p; const struct option *pfound = NULL; + struct option_list + { + const struct option *p; + struct option_list *next; + } *ambig_list = NULL; int exact = 0; - int ambig = 0; int indfound = -1; int option_index; for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; + namelen = nameend - d->__nextchar; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar)) + if (!strncmp (p->name, d->__nextchar, namelen)) { - if ((unsigned int) (nameend - d->__nextchar) - == (unsigned int) strlen (p->name)) + if (namelen == (unsigned int) strlen (p->name)) { /* Exact match found. */ pfound = p; @@ -513,35 +518,71 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val) - /* Second or later nonexact match found. */ - ambig = 1; + { + /* Second or later nonexact match found. */ + struct option_list *newp = malloc (sizeof (*newp)); + newp->p = p; + newp->next = ambig_list; + ambig_list = newp; + } } - if (ambig && !exact) + if (ambig_list != NULL && !exact) { if (print_errors) { + struct option_list first; + first.p = pfound; + first.next = ambig_list; + ambig_list = &first; + #if defined _LIBC && defined USE_IN_LIBIO - char *buf; + char *buf = NULL; + size_t buflen = 0; - if (__asprintf (&buf, _("%s: option '%s' is ambiguous\n"), - argv[0], argv[d->optind]) >= 0) + FILE *fp = open_memstream (&buf, &buflen); + if (fp != NULL) { - _IO_flockfile (stderr); + fprintf (fp, + _("%s: option '%s' is ambiguous; possibilities:"), + argv[0], argv[d->optind]); - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + do + { + fprintf (fp, " '--%s'", ambig_list->p->name); + ambig_list = ambig_list->next; + } + while (ambig_list != NULL); - __fxprintf (NULL, "%s", buf); + fputc_unlocked ('\n', fp); - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); + if (__builtin_expect (fclose (fp) != EOF, 1)) + { + _IO_flockfile (stderr); - free (buf); + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + + __fxprintf (NULL, "%s", buf); + + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + + free (buf); + } } #else - fprintf (stderr, _("%s: option '%s' is ambiguous\n"), + fprintf (stderr, + _("%s: option '%s' is ambiguous; possibilities:"), argv[0], argv[d->optind]); + do + { + fprintf (stderr, " '--%s'", ambig_list->p->name); + ambig_list = ambig_list->next; + } + while (ambig_list != NULL); + + fputc ('\n', stderr); #endif } d->__nextchar += strlen (d->__nextchar); @@ -550,6 +591,13 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, return '?'; } + while (ambig_list != NULL) + { + struct option_list *pn = ambig_list->next; + free (ambig_list); + ambig_list = pn; + } + if (pfound != NULL) { option_index = indfound; @@ -791,6 +839,9 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, int indfound = 0; int option_index; + if (longopts == NULL) + goto no_longs; + /* This is an option that requires an argument. */ if (*d->__nextchar != '\0') { @@ -998,8 +1049,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, } return pfound->val; } - d->__nextchar = NULL; - return 'W'; /* Let the application handle it. */ + + no_longs: + d->__nextchar = NULL; + return 'W'; /* Let the application handle it. */ } if (temp[1] == ':') { diff --git a/contrib/diffutils/lib/getopt1.c b/contrib/diffutils/lib/getopt1.c index 046d69f940..36568024cc 100644 --- a/contrib/diffutils/lib/getopt1.c +++ b/contrib/diffutils/lib/getopt1.c @@ -1,6 +1,6 @@ /* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, - 1998, 2004, 2006, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2011 Free Software + Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/getopt_int.h b/contrib/diffutils/lib/getopt_int.h index 980b7507f1..9f0c7131a1 100644 --- a/contrib/diffutils/lib/getopt_int.h +++ b/contrib/diffutils/lib/getopt_int.h @@ -1,5 +1,5 @@ /* Internal declarations for getopt. - Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2010 Free Software + Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2011 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -108,7 +108,7 @@ struct _getopt_data #if defined _LIBC && defined USE_NONOPTION_FLAGS int __nonoption_flags_max_len; int __nonoption_flags_len; -# endif +#endif }; /* The initializer is necessary to set OPTIND and OPTERR to their diff --git a/contrib/diffutils/lib/gettext.h b/contrib/diffutils/lib/gettext.h index 0b054db7d2..ef0444317d 100644 --- a/contrib/diffutils/lib/gettext.h +++ b/contrib/diffutils/lib/gettext.h @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Convenience header for conditional use of GNU . - Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2010 Free Software + Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2011 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -56,7 +56,7 @@ it now, to make later inclusions of a NOP. */ #if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) # include -# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H +# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H # include # endif #endif @@ -95,6 +95,12 @@ #endif +/* Prefer gnulib's setlocale override over libintl's setlocale override. */ +#ifdef GNULIB_defined_setlocale +# undef setlocale +# define setlocale rpl_setlocale +#endif + /* A pseudo function call that serves as a marker for the automated extraction of messages, but does not call gettext(). The run-time translation is done at a different place in the code. diff --git a/contrib/diffutils/lib/gettime.c b/contrib/diffutils/lib/gettime.c index 044b26f0f3..6dbb4574c6 100644 --- a/contrib/diffutils/lib/gettime.c +++ b/contrib/diffutils/lib/gettime.c @@ -1,6 +1,6 @@ /* gettime -- get the system clock - Copyright (C) 2002, 2004-2007, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2002, 2004-2007, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/hard-locale.c b/contrib/diffutils/lib/hard-locale.c index c868ac0f13..26e614b74b 100644 --- a/contrib/diffutils/lib/hard-locale.c +++ b/contrib/diffutils/lib/hard-locale.c @@ -1,7 +1,7 @@ /* hard-locale.c -- Determine whether a locale is hard. - Copyright (C) 1997, 1998, 1999, 2002, 2003, 2004, 2006, 2007, 2009, 2010 - Free Software Foundation, Inc. + Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2011 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,6 +26,8 @@ #ifdef __GLIBC__ # define GLIBC_VERSION __GLIBC__ +#elif defined __UCLIBC__ +# define GLIBC_VERSION 2 #else # define GLIBC_VERSION 0 #endif diff --git a/contrib/diffutils/lib/hard-locale.h b/contrib/diffutils/lib/hard-locale.h index a1ce5bfb8b..7540628ea3 100644 --- a/contrib/diffutils/lib/hard-locale.h +++ b/contrib/diffutils/lib/hard-locale.h @@ -1,6 +1,6 @@ /* Determine whether a locale is hard. - Copyright (C) 1999, 2003, 2004, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1999, 2003-2004, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/hash.c b/contrib/diffutils/lib/hash.c index f9abb9fd8a..4d76f765e9 100644 --- a/contrib/diffutils/lib/hash.c +++ b/contrib/diffutils/lib/hash.c @@ -1,6 +1,6 @@ /* hash - hashing table processing. - Copyright (C) 1998-2004, 2006-2007, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 1998-2004, 2006-2007, 2009-2011 Free Software Foundation, Inc. Written by Jim Meyering, 1992. @@ -27,7 +27,7 @@ #include "hash.h" #include "bitrotate.h" -#include "xalloc.h" +#include "xalloc-oversized.h" #include #include @@ -243,19 +243,26 @@ hash_print_statistics (const Hash_table *table, FILE *stream) (unsigned long int) max_bucket_length); } +/* Hash KEY and return a pointer to the selected bucket. + If TABLE->hasher misbehaves, abort. */ +static struct hash_entry * +safe_hasher (const Hash_table *table, const void *key) +{ + size_t n = table->hasher (key, table->n_buckets); + if (! (n < table->n_buckets)) + abort (); + return table->bucket + n; +} + /* If ENTRY matches an entry already in the hash table, return the entry from the table. Otherwise, return NULL. */ void * hash_lookup (const Hash_table *table, const void *entry) { - struct hash_entry const *bucket - = table->bucket + table->hasher (entry, table->n_buckets); + struct hash_entry const *bucket = safe_hasher (table, entry); struct hash_entry const *cursor; - if (! (bucket < table->bucket_limit)) - abort (); - if (bucket->data == NULL) return NULL; @@ -299,17 +306,18 @@ hash_get_first (const Hash_table *table) void * hash_get_next (const Hash_table *table, const void *entry) { - struct hash_entry const *bucket - = table->bucket + table->hasher (entry, table->n_buckets); + struct hash_entry const *bucket = safe_hasher (table, entry); struct hash_entry const *cursor; - if (! (bucket < table->bucket_limit)) - abort (); - /* Find next entry in the same bucket. */ - for (cursor = bucket; cursor; cursor = cursor->next) - if (cursor->data == entry && cursor->next) - return cursor->next->data; + cursor = bucket; + do + { + if (cursor->data == entry && cursor->next) + return cursor->next->data; + cursor = cursor->next; + } + while (cursor != NULL); /* Find first entry in any subsequent bucket. */ while (++bucket < table->bucket_limit) @@ -782,13 +790,9 @@ static void * hash_find_entry (Hash_table *table, const void *entry, struct hash_entry **bucket_head, bool delete) { - struct hash_entry *bucket - = table->bucket + table->hasher (entry, table->n_buckets); + struct hash_entry *bucket = safe_hasher (table, entry); struct hash_entry *cursor; - if (! (bucket < table->bucket_limit)) - abort (); - *bucket_head = bucket; /* Test for empty bucket. */ @@ -873,10 +877,7 @@ transfer_entries (Hash_table *dst, Hash_table *src, bool safe) for (cursor = bucket->next; cursor; cursor = next) { data = cursor->data; - new_bucket = (dst->bucket + dst->hasher (data, dst->n_buckets)); - - if (! (new_bucket < dst->bucket_limit)) - abort (); + new_bucket = safe_hasher (dst, data); next = cursor->next; @@ -903,10 +904,7 @@ transfer_entries (Hash_table *dst, Hash_table *src, bool safe) bucket->next = NULL; if (safe) continue; - new_bucket = (dst->bucket + dst->hasher (data, dst->n_buckets)); - - if (! (new_bucket < dst->bucket_limit)) - abort (); + new_bucket = safe_hasher (dst, data); if (new_bucket->data) { @@ -1020,25 +1018,39 @@ hash_rehash (Hash_table *table, size_t candidate) return false; } -/* If ENTRY matches an entry already in the hash table, return the pointer - to the entry from the table. Otherwise, insert ENTRY and return ENTRY. - Return NULL if the storage required for insertion cannot be allocated. - This implementation does not support duplicate entries or insertion of - NULL. */ - -void * -hash_insert (Hash_table *table, const void *entry) +/* Return -1 upon memory allocation failure. + Return 1 if insertion succeeded. + Return 0 if there is already a matching entry in the table, + and in that case, if MATCHED_ENT is non-NULL, set *MATCHED_ENT + to that entry. + + This interface is easier to use than hash_insert when you must + distinguish between the latter two cases. More importantly, + hash_insert is unusable for some types of ENTRY values. When using + hash_insert, the only way to distinguish those cases is to compare + the return value and ENTRY. That works only when you can have two + different ENTRY values that point to data that compares "equal". Thus, + when the ENTRY value is a simple scalar, you must use hash_insert0. + ENTRY must not be NULL. */ +int +hash_insert0 (Hash_table *table, void const *entry, void const **matched_ent) { void *data; struct hash_entry *bucket; - /* The caller cannot insert a NULL entry. */ + /* The caller cannot insert a NULL entry, since hash_lookup returns NULL + to indicate "not found", and hash_find_entry uses "bucket->data == NULL" + to indicate an empty bucket. */ if (! entry) abort (); /* If there's a matching entry already in the table, return that. */ if ((data = hash_find_entry (table, entry, &bucket, false)) != NULL) - return data; + { + if (matched_ent) + *matched_ent = data; + return 0; + } /* If the growth threshold of the buckets in use has been reached, increase the table size and rehash. There's no point in checking the number of @@ -1062,11 +1074,11 @@ hash_insert (Hash_table *table, const void *entry) * tuning->growth_threshold)); if (SIZE_MAX <= candidate) - return NULL; + return -1; /* If the rehash fails, arrange to return NULL. */ if (!hash_rehash (table, candidate)) - return NULL; + return -1; /* Update the bucket we are interested in. */ if (hash_find_entry (table, entry, &bucket, false) != NULL) @@ -1081,7 +1093,7 @@ hash_insert (Hash_table *table, const void *entry) struct hash_entry *new_entry = allocate_entry (table); if (new_entry == NULL) - return NULL; + return -1; /* Add ENTRY in the overflow of the bucket. */ @@ -1089,7 +1101,7 @@ hash_insert (Hash_table *table, const void *entry) new_entry->next = bucket->next; bucket->next = new_entry; table->n_entries++; - return (void *) entry; + return 1; } /* Add ENTRY right in the bucket head. */ @@ -1098,7 +1110,23 @@ hash_insert (Hash_table *table, const void *entry) table->n_entries++; table->n_buckets_used++; - return (void *) entry; + return 1; +} + +/* If ENTRY matches an entry already in the hash table, return the pointer + to the entry from the table. Otherwise, insert ENTRY and return ENTRY. + Return NULL if the storage required for insertion cannot be allocated. + This implementation does not support duplicate entries or insertion of + NULL. */ + +void * +hash_insert (Hash_table *table, void const *entry) +{ + void const *matched_ent; + int err = hash_insert0 (table, entry, &matched_ent); + return (err == -1 + ? NULL + : (void *) (err == 0 ? matched_ent : entry)); } /* If ENTRY is already in the table, remove it and return the just-deleted diff --git a/contrib/diffutils/lib/hash.h b/contrib/diffutils/lib/hash.h index e795cdc836..9f694be555 100644 --- a/contrib/diffutils/lib/hash.h +++ b/contrib/diffutils/lib/hash.h @@ -1,5 +1,5 @@ /* hash - hashing table processing. - Copyright (C) 1998-1999, 2001, 2003, 2009-2010 Free Software Foundation, + Copyright (C) 1998-1999, 2001, 2003, 2009-2011 Free Software Foundation, Inc. Written by Jim Meyering , 1998. @@ -27,15 +27,12 @@ # include # include -/* The warn_unused_result attribute appeared first in gcc-3.4.0 */ -# ifndef __attribute__ -# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) -# define __attribute__(x) -# endif -# endif - -# ifndef ATTRIBUTE_WUR -# define ATTRIBUTE_WUR __attribute__ ((__warn_unused_result__)) +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The warn_unused_result attribute appeared first in gcc-3.4.0. */ +# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# define _GL_ATTRIBUTE_WUR __attribute__ ((__warn_unused_result__)) +# else +# define _GL_ATTRIBUTE_WUR /* empty */ # endif typedef size_t (*Hash_hasher) (const void *, size_t); @@ -81,13 +78,15 @@ size_t hash_string (const char *, size_t); void hash_reset_tuning (Hash_tuning *); Hash_table *hash_initialize (size_t, const Hash_tuning *, Hash_hasher, Hash_comparator, - Hash_data_freer) ATTRIBUTE_WUR; + Hash_data_freer) _GL_ATTRIBUTE_WUR; void hash_clear (Hash_table *); void hash_free (Hash_table *); /* Insertion and deletion. */ -bool hash_rehash (Hash_table *, size_t) ATTRIBUTE_WUR; -void *hash_insert (Hash_table *, const void *) ATTRIBUTE_WUR; +bool hash_rehash (Hash_table *, size_t) _GL_ATTRIBUTE_WUR; +void *hash_insert (Hash_table *, const void *) _GL_ATTRIBUTE_WUR; +int hash_insert0 (Hash_table *table, const void *entry, + const void **matched_ent); void *hash_delete (Hash_table *, const void *); #endif diff --git a/contrib/diffutils/lib/ignore-value.h b/contrib/diffutils/lib/ignore-value.h index 2eb6918db5..f021a1ac8e 100644 --- a/contrib/diffutils/lib/ignore-value.h +++ b/contrib/diffutils/lib/ignore-value.h @@ -1,6 +1,6 @@ /* ignore a function return without a compiler warning - Copyright (C) 2008-2010 Free Software Foundation, Inc. + Copyright (C) 2008-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,9 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* Written by Jim Meyering. */ +/* Written by Jim Meyering, Eric Blake and Pádraig Brady. */ -/* Use these functions to avoid a warning when using a function declared with +/* Use "ignore_value" to avoid a warning when using a function declared with gcc's warn_unused_result attribute, but for which you really do want to ignore the result. Traditionally, people have used a "(void)" cast to indicate that a function's return value is deliberately unused. However, @@ -32,6 +32,31 @@ "copy.c:233: warning: ignoring return value of 'fchown', declared with attribute warn_unused_result". */ -static inline void ignore_value (int i) { (void) i; } -static inline void ignore_ptr (void* p) { (void) p; } -/* FIXME: what about aggregate types? */ +#ifndef _GL_IGNORE_VALUE_H +# define _GL_IGNORE_VALUE_H + +# ifndef _GL_ATTRIBUTE_DEPRECATED +/* The __attribute__((__deprecated__)) feature + is available in gcc versions 3.1 and newer. */ +# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1) +# define _GL_ATTRIBUTE_DEPRECATED /* empty */ +# else +# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__)) +# endif +# endif + +/* The __attribute__((__warn_unused_result__)) feature + is available in gcc versions 3.4 and newer, + while the typeof feature has been available since 2.7 at least. */ +# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) +# define ignore_value(x) ((void) (x)) +# else +# define ignore_value(x) (({ __typeof__ (x) __x = (x); (void) __x; })) +# endif + +/* ignore_value works for scalars, pointers and aggregates; + deprecate ignore_ptr. */ +static inline void _GL_ATTRIBUTE_DEPRECATED +ignore_ptr (void *p) { (void) p; } /* deprecated: use ignore_value */ + +#endif diff --git a/contrib/diffutils/lib/imaxtostr.c b/contrib/diffutils/lib/imaxtostr.c index 34ef96c450..b91ac98c4e 100644 --- a/contrib/diffutils/lib/imaxtostr.c +++ b/contrib/diffutils/lib/imaxtostr.c @@ -1,4 +1,3 @@ -#define inttostr imaxtostr +#define anytostr imaxtostr #define inttype intmax_t -#define inttype_is_signed 1 -#include "inttostr.c" +#include "anytostr.c" diff --git a/contrib/diffutils/lib/intprops.h b/contrib/diffutils/lib/intprops.h index 46f4d47d70..1f6a539c18 100644 --- a/contrib/diffutils/lib/intprops.h +++ b/contrib/diffutils/lib/intprops.h @@ -1,7 +1,6 @@ /* intprops.h -- properties of integer types - Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009, 2010 Free Software - Foundation, Inc. + Copyright (C) 2001-2005, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,66 +17,303 @@ /* Written by Paul Eggert. */ -#ifndef GL_INTPROPS_H -# define GL_INTPROPS_H +#ifndef _GL_INTPROPS_H +#define _GL_INTPROPS_H -# include +#include + +/* Return an integer value, converted to the same type as the integer + expression E after integer type promotion. V is the unconverted value. */ +#define _GL_INT_CONVERT(e, v) (0 * (e) + (v)) + +/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see + . */ +#define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v)) /* The extra casts in the following macros work around compiler bugs, e.g., in Cray C 5.0.3.0. */ /* True if the arithmetic type T is an integer type. bool counts as an integer. */ -# define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) +#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) /* True if negative values of the signed integer type T use two's complement, ones' complement, or signed magnitude representation, respectively. Much GNU code assumes two's complement, but some people like to be portable to all possible C hosts. */ -# define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1) -# define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0) -# define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1) +#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1) +#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0) +#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1) + +/* True if the signed integer expression E uses two's complement. */ +#define _GL_INT_TWOS_COMPLEMENT(e) (~ _GL_INT_CONVERT (e, 0) == -1) /* True if the arithmetic type T is signed. */ -# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) +#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) -/* The maximum and minimum values for the integer type T. These +/* Return 1 if the integer expression E, after integer promotion, has + a signed type. */ +#define _GL_INT_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0) + + +/* Minimum and maximum values for integer types and expressions. These macros have undefined behavior if T is signed and has padding bits. If this is a problem for you, please let us know how to fix it for your host. */ -# define TYPE_MINIMUM(t) \ - ((t) (! TYPE_SIGNED (t) \ - ? (t) 0 \ - : TYPE_SIGNED_MAGNITUDE (t) \ - ? ~ (t) 0 \ - : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) -# define TYPE_MAXIMUM(t) \ - ((t) (! TYPE_SIGNED (t) \ - ? (t) -1 \ - : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) - -/* Return zero if T can be determined to be an unsigned type. - Otherwise, return 1. - When compiling with GCC, INT_STRLEN_BOUND uses this macro to obtain a - tighter bound. Otherwise, it overestimates the true bound by one byte - when applied to unsigned types of size 2, 4, 16, ... bytes. - The symbol signed_type_or_expr__ is private to this header file. */ -# if __GNUC__ >= 2 -# define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t)) -# else -# define signed_type_or_expr__(t) 1 -# endif + +/* The maximum and minimum values for the integer type T. */ +#define TYPE_MINIMUM(t) \ + ((t) (! TYPE_SIGNED (t) \ + ? (t) 0 \ + : TYPE_SIGNED_MAGNITUDE (t) \ + ? ~ (t) 0 \ + : ~ TYPE_MAXIMUM (t))) +#define TYPE_MAXIMUM(t) \ + ((t) (! TYPE_SIGNED (t) \ + ? (t) -1 \ + : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) + +/* The maximum and minimum values for the type of the expression E, + after integer promotion. E should not have side effects. */ +#define _GL_INT_MINIMUM(e) \ + (_GL_INT_SIGNED (e) \ + ? - _GL_INT_TWOS_COMPLEMENT (e) - _GL_SIGNED_INT_MAXIMUM (e) \ + : _GL_INT_CONVERT (e, 0)) +#define _GL_INT_MAXIMUM(e) \ + (_GL_INT_SIGNED (e) \ + ? _GL_SIGNED_INT_MAXIMUM (e) \ + : _GL_INT_NEGATE_CONVERT (e, 1)) +#define _GL_SIGNED_INT_MAXIMUM(e) \ + (((_GL_INT_CONVERT (e, 1) << (sizeof ((e) + 0) * CHAR_BIT - 2)) - 1) * 2 + 1) + + +/* Return 1 if the __typeof__ keyword works. This could be done by + 'configure', but for now it's easier to do it by hand. */ +#if 2 <= __GNUC__ || 0x5110 <= __SUNPRO_C +# define _GL_HAVE___TYPEOF__ 1 +#else +# define _GL_HAVE___TYPEOF__ 0 +#endif + +/* Return 1 if the integer type or expression T might be signed. Return 0 + if it is definitely unsigned. This macro does not evaluate its argument, + and expands to an integer constant expression. */ +#if _GL_HAVE___TYPEOF__ +# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t)) +#else +# define _GL_SIGNED_TYPE_OR_EXPR(t) 1 +#endif + +/* Bound on length of the string representing an unsigned integer + value representable in B bits. log10 (2.0) < 146/485. The + smallest value of B where this bound is not tight is 2621. */ +#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485) /* Bound on length of the string representing an integer type or expression T. - Subtract 1 for the sign bit if T is signed; log10 (2.0) < 146/485; - add 1 for integer division truncation; add 1 more for a minus sign - if needed. */ -# define INT_STRLEN_BOUND(t) \ - ((sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) * 146 / 485 \ - + signed_type_or_expr__ (t) + 1) + Subtract 1 for the sign bit if T is signed, and then add 1 more for + a minus sign if needed. + + Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is + signed, this macro may overestimate the true bound by one byte when + applied to unsigned types of size 2, 4, 16, ... bytes. */ +#define INT_STRLEN_BOUND(t) \ + (INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT \ + - _GL_SIGNED_TYPE_OR_EXPR (t)) \ + + _GL_SIGNED_TYPE_OR_EXPR (t)) /* Bound on buffer size needed to represent an integer type or expression T, including the terminating null. */ -# define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) +#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) + + +/* Range overflow checks. + + The INT__RANGE_OVERFLOW macros return 1 if the corresponding C + operators might not yield numerically correct answers due to + arithmetic overflow. They do not rely on undefined or + implementation-defined behavior. Their implementations are simple + and straightforward, but they are a bit harder to use than the + INT__OVERFLOW macros described below. + + Example usage: + + long int i = ...; + long int j = ...; + if (INT_MULTIPLY_RANGE_OVERFLOW (i, j, LONG_MIN, LONG_MAX)) + printf ("multiply would overflow"); + else + printf ("product is %ld", i * j); + + Restrictions on *_RANGE_OVERFLOW macros: + + These macros do not check for all possible numerical problems or + undefined or unspecified behavior: they do not check for division + by zero, for bad shift counts, or for shifting negative numbers. + + These macros may evaluate their arguments zero or multiple times, + so the arguments should not have side effects. The arithmetic + arguments (including the MIN and MAX arguments) must be of the same + integer type after the usual arithmetic conversions, and the type + must have minimum value MIN and maximum MAX. Unsigned types should + use a zero MIN of the proper type. + + These macros are tuned for constant MIN and MAX. For commutative + operations such as A + B, they are also tuned for constant B. */ + +/* Return 1 if A + B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. */ +#define INT_ADD_RANGE_OVERFLOW(a, b, min, max) \ + ((b) < 0 \ + ? (a) < (min) - (b) \ + : (max) - (b) < (a)) + +/* Return 1 if A - B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. */ +#define INT_SUBTRACT_RANGE_OVERFLOW(a, b, min, max) \ + ((b) < 0 \ + ? (max) + (b) < (a) \ + : (a) < (min) + (b)) + +/* Return 1 if - A would overflow in [MIN,MAX] arithmetic. + See above for restrictions. */ +#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \ + ((min) < 0 \ + ? (a) < - (max) \ + : 0 < (a)) + +/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. Avoid && and || as they tickle + bugs in Sun C 5.11 2010/08/13 and other compilers; see + . */ +#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \ + ((b) < 0 \ + ? ((a) < 0 \ + ? (a) < (max) / (b) \ + : (b) == -1 \ + ? 0 \ + : (min) / (b) < (a)) \ + : (b) == 0 \ + ? 0 \ + : ((a) < 0 \ + ? (a) < (min) / (b) \ + : (max) / (b) < (a))) + +/* Return 1 if A / B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. Do not check for division by zero. */ +#define INT_DIVIDE_RANGE_OVERFLOW(a, b, min, max) \ + ((min) < 0 && (b) == -1 && (a) < - (max)) + +/* Return 1 if A % B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. Do not check for division by zero. + Mathematically, % should never overflow, but on x86-like hosts + INT_MIN % -1 traps, and the C standard permits this, so treat this + as an overflow too. */ +#define INT_REMAINDER_RANGE_OVERFLOW(a, b, min, max) \ + INT_DIVIDE_RANGE_OVERFLOW (a, b, min, max) + +/* Return 1 if A << B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. Here, MIN and MAX are for A only, and B need + not be of the same type as the other arguments. The C standard says that + behavior is undefined for shifts unless 0 <= B < wordwidth, and that when + A is negative then A << B has undefined behavior and A >> B has + implementation-defined behavior, but do not check these other + restrictions. */ +#define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \ + ((a) < 0 \ + ? (a) < (min) >> (b) \ + : (max) >> (b) < (a)) + + +/* The _GL*_OVERFLOW macros have the same restrictions as the + *_RANGE_OVERFLOW macros, except that they do not assume that operands + (e.g., A and B) have the same type as MIN and MAX. Instead, they assume + that the result (e.g., A + B) has that type. */ +#define _GL_ADD_OVERFLOW(a, b, min, max) \ + ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \ + : (a) < 0 ? (b) <= (a) + (b) \ + : (b) < 0 ? (a) <= (a) + (b) \ + : (a) + (b) < (b)) +#define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \ + ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \ + : (a) < 0 ? 1 \ + : (b) < 0 ? (a) - (b) <= (a) \ + : (a) < (b)) +#define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \ + (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \ + || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max)) +#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \ + ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ + : (a) < 0 ? (b) <= (a) + (b) - 1 \ + : (b) < 0 && (a) + (b) <= (a)) +#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \ + ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ + : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \ + : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max)) + +/* Return a nonzero value if A is a mathematical multiple of B, where + A is unsigned, B is negative, and MAX is the maximum value of A's + type. A's type must be the same as (A % B)'s type. Normally (A % + -B == 0) suffices, but things get tricky if -B would overflow. */ +#define _GL_UNSIGNED_NEG_MULTIPLE(a, b, max) \ + (((b) < -_GL_SIGNED_INT_MAXIMUM (b) \ + ? (_GL_SIGNED_INT_MAXIMUM (b) == (max) \ + ? (a) \ + : (a) % (_GL_INT_CONVERT (a, _GL_SIGNED_INT_MAXIMUM (b)) + 1)) \ + : (a) % - (b)) \ + == 0) + + +/* Integer overflow checks. + + The INT__OVERFLOW macros return 1 if the corresponding C operators + might not yield numerically correct answers due to arithmetic overflow. + They work correctly on all known practical hosts, and do not rely + on undefined behavior due to signed arithmetic overflow. + + Example usage: + + long int i = ...; + long int j = ...; + if (INT_MULTIPLY_OVERFLOW (i, j)) + printf ("multiply would overflow"); + else + printf ("product is %ld", i * j); + + These macros do not check for all possible numerical problems or + undefined or unspecified behavior: they do not check for division + by zero, for bad shift counts, or for shifting negative numbers. + + These macros may evaluate their arguments zero or multiple times, so the + arguments should not have side effects. + + These macros are tuned for their last argument being a constant. + + Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B, + A % B, and A << B would overflow, respectively. */ + +#define INT_ADD_OVERFLOW(a, b) \ + _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW) +#define INT_SUBTRACT_OVERFLOW(a, b) \ + _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW) +#define INT_NEGATE_OVERFLOW(a) \ + INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a)) +#define INT_MULTIPLY_OVERFLOW(a, b) \ + _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW) +#define INT_DIVIDE_OVERFLOW(a, b) \ + _GL_BINARY_OP_OVERFLOW (a, b, _GL_DIVIDE_OVERFLOW) +#define INT_REMAINDER_OVERFLOW(a, b) \ + _GL_BINARY_OP_OVERFLOW (a, b, _GL_REMAINDER_OVERFLOW) +#define INT_LEFT_SHIFT_OVERFLOW(a, b) \ + INT_LEFT_SHIFT_RANGE_OVERFLOW (a, b, \ + _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a)) + +/* Return 1 if the expression A B would overflow, + where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test, + assuming MIN and MAX are the minimum and maximum for the result type. + Arguments should be free of side effects. */ +#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \ + op_result_overflow (a, b, \ + _GL_INT_MINIMUM (0 * (b) + (a)), \ + _GL_INT_MAXIMUM (0 * (b) + (a))) -#endif /* GL_INTPROPS_H */ +#endif /* _GL_INTPROPS_H */ diff --git a/contrib/diffutils/lib/inttostr.c b/contrib/diffutils/lib/inttostr.c index 7a4a47f5f6..c96b5ca39b 100644 --- a/contrib/diffutils/lib/inttostr.c +++ b/contrib/diffutils/lib/inttostr.c @@ -1,54 +1,3 @@ -/* inttostr.c -- convert integers to printable strings - - Copyright (C) 2001, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* Written by Paul Eggert */ - -#include - -#include "inttostr.h" -#include "verify.h" - -/* Convert I to a printable string in BUF, which must be at least - INT_BUFSIZE_BOUND (INTTYPE) bytes long. Return the address of the - printable string, which need not start at BUF. */ - -char * -inttostr (inttype i, char *buf) -{ - verify (TYPE_SIGNED (inttype) == inttype_is_signed); - char *p = buf + INT_STRLEN_BOUND (inttype); - *p = 0; - -#if inttype_is_signed - if (i < 0) - { - do - *--p = '0' - i % 10; - while ((i /= 10) != 0); - - *--p = '-'; - } - else -#endif - { - do - *--p = '0' + i % 10; - while ((i /= 10) != 0); - } - - return p; -} +#define anytostr inttostr +#define inttype int +#include "anytostr.c" diff --git a/contrib/diffutils/lib/inttostr.h b/contrib/diffutils/lib/inttostr.h index f11a5ff672..1825f56478 100644 --- a/contrib/diffutils/lib/inttostr.h +++ b/contrib/diffutils/lib/inttostr.h @@ -1,6 +1,6 @@ /* inttostr.h -- convert integers to printable strings - Copyright (C) 2001-2006, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2001-2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -39,7 +39,8 @@ # define __attribute_warn_unused_result__ /* empty */ #endif -char *offtostr (off_t, char *) __attribute_warn_unused_result__; char *imaxtostr (intmax_t, char *) __attribute_warn_unused_result__; -char *umaxtostr (uintmax_t, char *) __attribute_warn_unused_result__; +char *inttostr (int, char *) __attribute_warn_unused_result__; +char *offtostr (off_t, char *) __attribute_warn_unused_result__; char *uinttostr (unsigned int, char *) __attribute_warn_unused_result__; +char *umaxtostr (uintmax_t, char *) __attribute_warn_unused_result__; diff --git a/contrib/diffutils/lib/localcharset.c b/contrib/diffutils/lib/localcharset.c index 4255174418..d8b5953c23 100644 --- a/contrib/diffutils/lib/localcharset.c +++ b/contrib/diffutils/lib/localcharset.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2006, 2008-2010 Free Software Foundation, Inc. + Copyright (C) 2000-2006, 2008-2011 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -230,8 +230,7 @@ get_charset_aliases (void) { /* Out of memory. */ res_size = 0; - if (old_res_ptr != NULL) - free (old_res_ptr); + free (old_res_ptr); break; } strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1); @@ -371,10 +370,9 @@ locale_charset (void) codeset = nl_langinfo (CODESET); # ifdef __CYGWIN__ - /* Cygwin 1.5.x does not have locales. nl_langinfo (CODESET) always - returns "US-ASCII". As long as this is not fixed, return the suffix - of the locale name from the environment variables (if present) or - the codepage as a number. */ + /* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always + returns "US-ASCII". Return the suffix of the locale name from the + environment variables (if present) or the codepage as a number. */ if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) { const char *locale; diff --git a/contrib/diffutils/lib/localcharset.h b/contrib/diffutils/lib/localcharset.h index 9a67c0deb0..53c8a948b9 100644 --- a/contrib/diffutils/lib/localcharset.h +++ b/contrib/diffutils/lib/localcharset.h @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2003, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2009-2011 Free Software Foundation, Inc. This file is part of the GNU CHARSET Library. This program is free software; you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/lstat.c b/contrib/diffutils/lib/lstat.c index 586ab16b2a..29fc6d25f9 100644 --- a/contrib/diffutils/lib/lstat.c +++ b/contrib/diffutils/lib/lstat.c @@ -1,6 +1,6 @@ /* Work around a bug of lstat on some systems - Copyright (C) 1997-2006, 2008-2010 Free Software Foundation, Inc. + Copyright (C) 1997-2006, 2008-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,6 +17,10 @@ /* written by Jim Meyering */ +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_lstat doesn't recurse to + rpl_lstat. */ +#define __need_system_sys_stat_h #include #if !HAVE_LSTAT @@ -27,7 +31,6 @@ typedef int dummy; #else /* HAVE_LSTAT */ /* Get the original definition of lstat. It might be defined as a macro. */ -# define __need_system_sys_stat_h # include # include # undef __need_system_sys_stat_h diff --git a/contrib/diffutils/lib/malloca.c b/contrib/diffutils/lib/malloca.c index 6b59638e2a..11482c5078 100644 --- a/contrib/diffutils/lib/malloca.c +++ b/contrib/diffutils/lib/malloca.c @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Safe automatic memory allocation. - Copyright (C) 2003, 2006-2007, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2003, 2006-2007, 2009-2011 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software; you can redistribute it and/or modify @@ -18,11 +18,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#define _GL_USE_STDLIB_ALLOC 1 #include /* Specification. */ #include "malloca.h" +#include "verify.h" + /* The speed critical point in this file is freea() applied to an alloca() result: it must be fast, to match the speed of alloca(). The speed of mmalloca() and freea() in the other case are not critical, because they @@ -52,8 +55,7 @@ struct preliminary_header { void *next; char room[MAGIC_SIZE]; }; #define HEADER_SIZE \ (((sizeof (struct preliminary_header) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max) struct header { void *next; char room[HEADER_SIZE - sizeof (struct preliminary_header) + MAGIC_SIZE]; }; -/* Verify that HEADER_SIZE == sizeof (struct header). */ -typedef int verify1[2 * (HEADER_SIZE == sizeof (struct header)) - 1]; +verify (HEADER_SIZE == sizeof (struct header)); /* We make the hash table quite big, so that during lookups the probability of empty hash buckets is quite high. There is no need to make the hash table resizable, because when the hash table gets filled so much that the diff --git a/contrib/diffutils/lib/malloca.h b/contrib/diffutils/lib/malloca.h index b0c78a3fff..933fa7ec70 100644 --- a/contrib/diffutils/lib/malloca.h +++ b/contrib/diffutils/lib/malloca.h @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Safe automatic memory allocation. - Copyright (C) 2003-2007, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2003-2007, 2009-2011 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software; you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/mbchar.c b/contrib/diffutils/lib/mbchar.c index 6ec01950de..c9b0dcdce8 100644 --- a/contrib/diffutils/lib/mbchar.c +++ b/contrib/diffutils/lib/mbchar.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2006, 2009, 2010 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/mbchar.h b/contrib/diffutils/lib/mbchar.h index 012bfcb118..6dcb6cfa60 100644 --- a/contrib/diffutils/lib/mbchar.h +++ b/contrib/diffutils/lib/mbchar.h @@ -1,5 +1,5 @@ /* Multibyte character data type. - Copyright (C) 2001, 2005-2007, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2001, 2005-2007, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/mbiter.h b/contrib/diffutils/lib/mbiter.h index 6b738268f6..38cf6b1afe 100644 --- a/contrib/diffutils/lib/mbiter.h +++ b/contrib/diffutils/lib/mbiter.h @@ -1,5 +1,5 @@ /* Iterating through multibyte strings: macros for multi-byte encodings. - Copyright (C) 2001, 2005, 2007, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2001, 2005, 2007, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/mbscasecmp.c b/contrib/diffutils/lib/mbscasecmp.c index ba9feef487..dfff49c379 100644 --- a/contrib/diffutils/lib/mbscasecmp.c +++ b/contrib/diffutils/lib/mbscasecmp.c @@ -1,5 +1,5 @@ /* Case-insensitive string comparison function. - Copyright (C) 1998-1999, 2005-2010 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2011 Free Software Foundation, Inc. Written by Bruno Haible , 2005, based on earlier glibc code. diff --git a/contrib/diffutils/lib/mbslen.c b/contrib/diffutils/lib/mbslen.c index 5ccede643a..efddd52454 100644 --- a/contrib/diffutils/lib/mbslen.c +++ b/contrib/diffutils/lib/mbslen.c @@ -1,5 +1,5 @@ /* Counting the multibyte characters in a string. - Copyright (C) 2007-2010 Free Software Foundation, Inc. + Copyright (C) 2007-2011 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/mbsstr.c b/contrib/diffutils/lib/mbsstr.c index d44b4c3d4a..611000e6dd 100644 --- a/contrib/diffutils/lib/mbsstr.c +++ b/contrib/diffutils/lib/mbsstr.c @@ -1,5 +1,5 @@ /* Searching in a string. - Copyright (C) 2005-2010 Free Software Foundation, Inc. + Copyright (C) 2005-2011 Free Software Foundation, Inc. Written by Bruno Haible , 2005. This program is free software: you can redistribute it and/or modify @@ -27,6 +27,7 @@ #include "mbuiter.h" /* Knuth-Morris-Pratt algorithm. */ +#define UNIT unsigned char #define CANON_ELEMENT(c) c #include "str-kmp.h" @@ -339,10 +340,12 @@ mbsstr (const char *haystack, const char *needle) if (needle_last_ccount == NULL) { /* Try the Knuth-Morris-Pratt algorithm. */ - const char *result; + const unsigned char *result; bool success = - knuth_morris_pratt_unibyte (haystack, needle - 1, - &result); + knuth_morris_pratt ((const unsigned char *) haystack, + (const unsigned char *) (needle - 1), + strlen (needle - 1), + &result); if (success) return (char *) result; try_kmp = false; diff --git a/contrib/diffutils/lib/mbuiter.h b/contrib/diffutils/lib/mbuiter.h index 3015c4efe9..178f36eeaa 100644 --- a/contrib/diffutils/lib/mbuiter.h +++ b/contrib/diffutils/lib/mbuiter.h @@ -1,5 +1,5 @@ /* Iterating through multibyte strings: macros for multi-byte encodings. - Copyright (C) 2001, 2005, 2007, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2001, 2005, 2007, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/mktime.c b/contrib/diffutils/lib/mktime.c index 6adf3abe77..9b4d1f1426 100644 --- a/contrib/diffutils/lib/mktime.c +++ b/contrib/diffutils/lib/mktime.c @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Convert a `struct tm' to a time_t value. - Copyright (C) 1993-1999, 2002-2007, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 1993-1999, 2002-2007, 2009-2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Paul Eggert . @@ -27,6 +27,24 @@ # include #endif +/* Some of the code in this file assumes that signed integer overflow + silently wraps around. This assumption can't easily be programmed + around, nor can it be checked for portably at compile-time or + easily eliminated at run-time. + + Define WRAPV to 1 if the assumption is valid. Otherwise, define it + to 0; this forces the use of slower code that, while not guaranteed + by the C Standard, works on all production platforms that we know + about. */ +#ifndef WRAPV +# if (__GNUC__ == 4 && 4 <= __GNUC_MINOR__) || 4 < __GNUC__ +# pragma GCC optimize ("wrapv") +# define WRAPV 1 +# else +# define WRAPV 0 +# endif +#endif + /* Assume that leap seconds are possible, unless told otherwise. If the host has a `zic' command with a `-L leapsecondfilename' option, then it supports leap seconds; otherwise it probably doesn't. */ @@ -44,9 +62,21 @@ # include # include /* Make it work even if the system's libc has its own mktime routine. */ +# undef mktime # define mktime my_mktime #endif /* DEBUG */ +/* Verify a requirement at compile-time (unlike assert, which is runtime). */ +#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; } + +/* A signed type that is at least one bit wider than int. */ +#if INT_MAX <= LONG_MAX / 2 +typedef long int long_int; +#else +typedef long long int long_int; +#endif +verify (long_int_is_wide_enough, INT_MAX == INT_MAX * (long_int) 2 / 2); + /* Shift A right by B bits portably, by dividing A by 2**B and truncating towards minus infinity. A and B should be free of side effects, and B should be in the range 0 <= B <= INT_BITS - 2, where @@ -57,9 +87,11 @@ implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift right in the usual way when A < 0, so SHR falls back on division if ordinary A >> B doesn't seem to be the usual signed shift. */ -#define SHR(a, b) \ - (-1 >> 1 == -1 \ - ? (a) >> (b) \ +#define SHR(a, b) \ + ((-1 >> 1 == -1 \ + && (long_int) -1 >> 1 == -1 \ + && ((time_t) -1 >> 1 == -1 || ! TYPE_SIGNED (time_t))) \ + ? (a) >> (b) \ : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) /* The extra casts in the following macros work around compiler bugs, @@ -70,12 +102,8 @@ #define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) /* True if negative values of the signed integer type T use two's - complement, ones' complement, or signed magnitude representation, - respectively. Much GNU code assumes two's complement, but some - people like to be portable to all possible C hosts. */ + complement, or if T is an unsigned integer type. */ #define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1) -#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0) -#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1) /* True if the arithmetic type T is signed. */ #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) @@ -87,13 +115,11 @@ #define TYPE_MINIMUM(t) \ ((t) (! TYPE_SIGNED (t) \ ? (t) 0 \ - : TYPE_SIGNED_MAGNITUDE (t) \ - ? ~ (t) 0 \ - : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) + : ~ TYPE_MAXIMUM (t))) #define TYPE_MAXIMUM(t) \ ((t) (! TYPE_SIGNED (t) \ ? (t) -1 \ - : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) + : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) #ifndef TIME_T_MIN # define TIME_T_MIN TYPE_MINIMUM (time_t) @@ -103,14 +129,11 @@ #endif #define TIME_T_MIDPOINT (SHR (TIME_T_MIN + TIME_T_MAX, 1) + 1) -/* Verify a requirement at compile-time (unlike assert, which is runtime). */ -#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; } - verify (time_t_is_integer, TYPE_IS_INTEGER (time_t)); -verify (twos_complement_arithmetic, TYPE_TWOS_COMPLEMENT (int)); -/* The code also assumes that signed integer overflow silently wraps - around, but this assumption can't be stated without causing a - diagnostic on some hosts. */ +verify (twos_complement_arithmetic, + (TYPE_TWOS_COMPLEMENT (int) + && TYPE_TWOS_COMPLEMENT (long_int) + && TYPE_TWOS_COMPLEMENT (time_t))); #define EPOCH_YEAR 1970 #define TM_YEAR_BASE 1900 @@ -118,7 +141,7 @@ verify (base_year_is_a_multiple_of_100, TM_YEAR_BASE % 100 == 0); /* Return 1 if YEAR + TM_YEAR_BASE is a leap year. */ static inline int -leapyear (long int year) +leapyear (long_int year) { /* Don't add YEAR to TM_YEAR_BASE, as that might overflow. Also, work even if YEAR is negative. */ @@ -152,6 +175,14 @@ const unsigned short int __mon_yday[2][13] = # include "mktime-internal.h" #endif +/* Return 1 if the values A and B differ according to the rules for + tm_isdst: A and B differ if one is zero and the other positive. */ +static int +isdst_differ (int a, int b) +{ + return (!a != !b) & (0 <= a) & (0 <= b); +} + /* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) - (YEAR0-YDAY0 HOUR0:MIN0:SEC0) in seconds, assuming that the clocks were not adjusted between the time stamps. @@ -164,15 +195,10 @@ const unsigned short int __mon_yday[2][13] = detect overflow. */ static inline time_t -ydhms_diff (long int year1, long int yday1, int hour1, int min1, int sec1, +ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1, int year0, int yday0, int hour0, int min0, int sec0) { verify (C99_integer_division, -1 / 2 == 0); -#if 0 /* This assertion fails on 32-bit systems with 64-bit time_t, such as - NetBSD 5 on i386. */ - verify (long_int_year_and_yday_are_wide_enough, - INT_MAX <= LONG_MAX / 2 || TIME_T_MAX <= UINT_MAX); -#endif /* Compute intervening leap days correctly even if year is negative. Take care to avoid integer overflow here. */ @@ -195,6 +221,53 @@ ydhms_diff (long int year1, long int yday1, int hour1, int min1, int sec1, return seconds; } +/* Return the average of A and B, even if A + B would overflow. */ +static time_t +time_t_avg (time_t a, time_t b) +{ + return SHR (a, 1) + SHR (b, 1) + (a & b & 1); +} + +/* Return 1 if A + B does not overflow. If time_t is unsigned and if + B's top bit is set, assume that the sum represents A - -B, and + return 1 if the subtraction does not wrap around. */ +static int +time_t_add_ok (time_t a, time_t b) +{ + if (! TYPE_SIGNED (time_t)) + { + time_t sum = a + b; + return (sum < a) == (TIME_T_MIDPOINT <= b); + } + else if (WRAPV) + { + time_t sum = a + b; + return (sum < a) == (b < 0); + } + else + { + time_t avg = time_t_avg (a, b); + return TIME_T_MIN / 2 <= avg && avg <= TIME_T_MAX / 2; + } +} + +/* Return 1 if A + B does not overflow. */ +static int +time_t_int_add_ok (time_t a, int b) +{ + verify (int_no_wider_than_time_t, INT_MAX <= TIME_T_MAX); + if (WRAPV) + { + time_t sum = a + b; + return (sum < a) == (b < 0); + } + else + { + int a_odd = a & 1; + time_t avg = SHR (a, 1) + (SHR (b, 1) + (a_odd & b)); + return TIME_T_MIN / 2 <= avg && avg <= TIME_T_MAX / 2; + } +} /* Return a time_t value corresponding to (YEAR-YDAY HOUR:MIN:SEC), assuming that *T corresponds to *TP and that no clock adjustments @@ -203,7 +276,7 @@ ydhms_diff (long int year1, long int yday1, int hour1, int min1, int sec1, If overflow occurs, yield the minimal or maximal value, except do not yield a value equal to *T. */ static time_t -guess_time_tm (long int year, long int yday, int hour, int min, int sec, +guess_time_tm (long_int year, long_int yday, int hour, int min, int sec, const time_t *t, const struct tm *tp) { if (tp) @@ -211,9 +284,8 @@ guess_time_tm (long int year, long int yday, int hour, int min, int sec, time_t d = ydhms_diff (year, yday, hour, min, sec, tp->tm_year, tp->tm_yday, tp->tm_hour, tp->tm_min, tp->tm_sec); - time_t t1 = *t + d; - if ((t1 < *t) == (TYPE_SIGNED (time_t) ? d < 0 : TIME_T_MAX / 2 < d)) - return t1; + if (time_t_add_ok (*t, d)) + return *t + d; } /* Overflow occurred one way or another. Return the nearest result @@ -245,9 +317,7 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), they differ by 1. */ while (bad != ok + (bad < 0 ? -1 : 1)) { - time_t mid = *t = (bad < 0 - ? bad + ((ok - bad) >> 1) - : ok + ((bad - ok) >> 1)); + time_t mid = *t = time_t_avg (ok, bad); r = convert (t, tp); if (r) ok = mid; @@ -296,9 +366,7 @@ __mktime_internal (struct tm *tp, int mday = tp->tm_mday; int mon = tp->tm_mon; int year_requested = tp->tm_year; - /* Normalize the value. */ - int isdst = ((tp->tm_isdst >> (8 * sizeof (tp->tm_isdst) - 1)) - | (tp->tm_isdst != 0)); + int isdst = tp->tm_isdst; /* 1 if the previous probe was DST. */ int dst2; @@ -307,8 +375,8 @@ __mktime_internal (struct tm *tp, int mon_remainder = mon % 12; int negative_mon_remainder = mon_remainder < 0; int mon_years = mon / 12 - negative_mon_remainder; - long int lyear_requested = year_requested; - long int year = lyear_requested + mon_years; + long_int lyear_requested = year_requested; + long_int year = lyear_requested + mon_years; /* The other values need not be in range: the remaining code handles minor overflows correctly, @@ -320,8 +388,8 @@ __mktime_internal (struct tm *tp, int mon_yday = ((__mon_yday[leapyear (year)] [mon_remainder + 12 * negative_mon_remainder]) - 1); - long int lmday = mday; - long int yday = mon_yday + lmday; + long_int lmday = mday; + long_int yday = mon_yday + lmday; time_t guessed_offset = *offset; @@ -375,9 +443,9 @@ __mktime_internal (struct tm *tp, int approx_biennia = SHR (t0, ALOG2_SECONDS_PER_BIENNIUM); int diff = approx_biennia - approx_requested_biennia; - int abs_diff = diff < 0 ? - diff : diff; + int abs_diff = diff < 0 ? -1 - diff : diff; - /* IRIX 4.0.5 cc miscaculates TIME_T_MIN / 3: it erroneously + /* IRIX 4.0.5 cc miscalculates TIME_T_MIN / 3: it erroneously gives a positive value of 715827882. Setting a variable first then doing math on it seems to work. (ghazi@caip.rutgers.edu) */ @@ -393,7 +461,7 @@ __mktime_internal (struct tm *tp, time_t repaired_t0 = -1 - t0; approx_biennia = SHR (repaired_t0, ALOG2_SECONDS_PER_BIENNIUM); diff = approx_biennia - approx_requested_biennia; - abs_diff = diff < 0 ? - diff : diff; + abs_diff = diff < 0 ? -1 - diff : diff; if (overflow_threshold < abs_diff) return -1; guessed_offset += repaired_t0 - t0; @@ -428,7 +496,7 @@ __mktime_internal (struct tm *tp, /* We have a match. Check whether tm.tm_isdst has the requested value, if any. */ - if (isdst != tm.tm_isdst && 0 <= isdst && 0 <= tm.tm_isdst) + if (isdst_differ (isdst, tm.tm_isdst)) { /* tm.tm_isdst has the wrong value. Look for a neighboring time with the right value, and use its UTC offset. @@ -461,22 +529,20 @@ __mktime_internal (struct tm *tp, for (delta = stride; delta < delta_bound; delta += stride) for (direction = -1; direction <= 1; direction += 2) - { - time_t ot = t + delta * direction; - if ((ot < t) == (direction < 0)) - { - struct tm otm; - ranged_convert (convert, &ot, &otm); - if (otm.tm_isdst == isdst) - { - /* We found the desired tm_isdst. - Extrapolate back to the desired time. */ - t = guess_time_tm (year, yday, hour, min, sec, &ot, &otm); - ranged_convert (convert, &t, &tm); - goto offset_found; - } - } - } + if (time_t_int_add_ok (t, delta * direction)) + { + time_t ot = t + delta * direction; + struct tm otm; + ranged_convert (convert, &ot, &otm); + if (! isdst_differ (isdst, otm.tm_isdst)) + { + /* We found the desired tm_isdst. + Extrapolate back to the desired time. */ + t = guess_time_tm (year, yday, hour, min, sec, &ot, &otm); + ranged_convert (convert, &t, &tm); + goto offset_found; + } + } } offset_found: @@ -487,11 +553,13 @@ __mktime_internal (struct tm *tp, /* Adjust time to reflect the tm_sec requested, not the normalized value. Also, repair any damage from a false match due to a leap second. */ int sec_adjustment = (sec == 0 && tm.tm_sec == 60) - sec; + if (! time_t_int_add_ok (t, sec_requested)) + return -1; t1 = t + sec_requested; + if (! time_t_int_add_ok (t1, sec_adjustment)) + return -1; t2 = t1 + sec_adjustment; - if (((t1 < t) != (sec_requested < 0)) - | ((t2 < t1) != (sec_adjustment < 0)) - | ! convert (&t2, &tm)) + if (! convert (&t2, &tm)) return -1; t = t2; } @@ -542,7 +610,7 @@ not_equal_tm (const struct tm *a, const struct tm *b) | (a->tm_mon ^ b->tm_mon) | (a->tm_year ^ b->tm_year) | (a->tm_yday ^ b->tm_yday) - | (a->tm_isdst ^ b->tm_isdst)); + | isdst_differ (a->tm_isdst, b->tm_isdst)); } static void @@ -666,6 +734,6 @@ main (int argc, char **argv) /* Local Variables: -compile-command: "gcc -DDEBUG -Wall -W -O -g mktime.c -o mktime" +compile-command: "gcc -DDEBUG -I. -Wall -W -O2 -g mktime.c -o mktime" End: */ diff --git a/contrib/diffutils/lib/offtostr.c b/contrib/diffutils/lib/offtostr.c index 3a60c6e744..96082aafc0 100644 --- a/contrib/diffutils/lib/offtostr.c +++ b/contrib/diffutils/lib/offtostr.c @@ -1,4 +1,3 @@ -#define inttostr offtostr +#define anytostr offtostr #define inttype off_t -#define inttype_is_signed 1 -#include "inttostr.c" +#include "anytostr.c" diff --git a/contrib/diffutils/lib/prepargs.c b/contrib/diffutils/lib/prepargs.c index 7819d043ba..dd78eb1424 100644 --- a/contrib/diffutils/lib/prepargs.c +++ b/contrib/diffutils/lib/prepargs.c @@ -1,6 +1,6 @@ /* Parse arguments from a string and prepend them to an argv. - Copyright (C) 1999-2002, 2006, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 1999-2002, 2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/progname.c b/contrib/diffutils/lib/progname.c index 1415e6a55f..2465748175 100644 --- a/contrib/diffutils/lib/progname.c +++ b/contrib/diffutils/lib/progname.c @@ -1,5 +1,5 @@ /* Program name management. - Copyright (C) 2001-2003, 2005-2010 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2005-2011 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/progname.h b/contrib/diffutils/lib/progname.h index 5ba303bd07..084406607d 100644 --- a/contrib/diffutils/lib/progname.h +++ b/contrib/diffutils/lib/progname.h @@ -1,5 +1,5 @@ /* Program name management. - Copyright (C) 2001-2004, 2006, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006, 2009-2011 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/propername.c b/contrib/diffutils/lib/propername.c index 3971f3f7a5..b74923de95 100644 --- a/contrib/diffutils/lib/propername.c +++ b/contrib/diffutils/lib/propername.c @@ -1,5 +1,5 @@ /* Localization of proper names. - Copyright (C) 2006-2010 Free Software Foundation, Inc. + Copyright (C) 2006-2011 Free Software Foundation, Inc. Written by Bruno Haible , 2006. This program is free software: you can redistribute it and/or modify @@ -198,7 +198,8 @@ proper_name_utf8 (const char *name_ascii, const char *name_utf8) name_converted = alloc_name_converted = xstr_iconv (name_utf8, "UTF-8", locale_code); -# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 \ +# if (((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2) \ + && !defined __UCLIBC__) \ || _LIBICONV_VERSION >= 0x0105 { char *converted_translit; diff --git a/contrib/diffutils/lib/propername.h b/contrib/diffutils/lib/propername.h index eba56f696a..d2a1e3bf0d 100644 --- a/contrib/diffutils/lib/propername.h +++ b/contrib/diffutils/lib/propername.h @@ -1,5 +1,5 @@ /* Localization of proper names. - Copyright (C) 2006, 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2006, 2008-2011 Free Software Foundation, Inc. Written by Bruno Haible , 2006. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/quote.c b/contrib/diffutils/lib/quote.c index 1f64f44c38..1989c8c350 100644 --- a/contrib/diffutils/lib/quote.c +++ b/contrib/diffutils/lib/quote.c @@ -1,7 +1,7 @@ /* quote.c - quote arguments for output - Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005, 2006, 2009, 2010 Free - Software Foundation, Inc. + Copyright (C) 1998-2001, 2003, 2005-2006, 2009-2011 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/quote.h b/contrib/diffutils/lib/quote.h index a986956ab1..d0acb51f02 100644 --- a/contrib/diffutils/lib/quote.h +++ b/contrib/diffutils/lib/quote.h @@ -1,7 +1,6 @@ /* quote.h - prototypes for quote.c - Copyright (C) 1998, 1999, 2000, 2001, 2003, 2009, 2010 Free Software - Foundation, Inc. + Copyright (C) 1998-2001, 2003, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/quotearg.c b/contrib/diffutils/lib/quotearg.c index 5418f512bc..da8ba1eac6 100644 --- a/contrib/diffutils/lib/quotearg.c +++ b/contrib/diffutils/lib/quotearg.c @@ -1,7 +1,6 @@ /* quotearg.c - quote arguments for output - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, - 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1998-2002, 2004-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -169,10 +168,10 @@ set_custom_quoting (struct quoting_options *o, static struct quoting_options quoting_options_from_style (enum quoting_style style) { - struct quoting_options o; + struct quoting_options o = { 0 }; + if (style == custom_quoting_style) + abort (); o.style = style; - o.flags = 0; - memset (o.quote_these_too, 0, sizeof o.quote_these_too); return o; } diff --git a/contrib/diffutils/lib/quotearg.h b/contrib/diffutils/lib/quotearg.h index 084cd1b2de..2756d760aa 100644 --- a/contrib/diffutils/lib/quotearg.h +++ b/contrib/diffutils/lib/quotearg.h @@ -1,7 +1,7 @@ /* quotearg.h - quote arguments for output - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2006, 2008, 2009, 2010 - Free Software Foundation, Inc. + Copyright (C) 1998-2002, 2004, 2006, 2008-2011 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/regcomp.c b/contrib/diffutils/lib/regcomp.c index 5b19124b55..e734f47f6a 100644 --- a/contrib/diffutils/lib/regcomp.c +++ b/contrib/diffutils/lib/regcomp.c @@ -1,8 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Extended regular expression matching and search library. - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free - Software Foundation, Inc. + Copyright (C) 2002-2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . diff --git a/contrib/diffutils/lib/regex.c b/contrib/diffutils/lib/regex.c index 5415c8f1c5..4a473e01e8 100644 --- a/contrib/diffutils/lib/regex.c +++ b/contrib/diffutils/lib/regex.c @@ -1,8 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Extended regular expression matching and search library. - Copyright (C) 2002, 2003, 2005, 2006, 2009, 2010 Free Software Foundation, - Inc. + Copyright (C) 2002-2003, 2005-2006, 2009-2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . @@ -56,6 +55,7 @@ GNU regex allows. Include it before , which correctly #undefs RE_DUP_MAX and sets it to the right value. */ #include +#include #include #include "regex_internal.h" diff --git a/contrib/diffutils/lib/regex.h b/contrib/diffutils/lib/regex.h index ef54b55cf8..52b8598c5c 100644 --- a/contrib/diffutils/lib/regex.h +++ b/contrib/diffutils/lib/regex.h @@ -2,9 +2,8 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Definitions for data structures and routines for the regular expression library. - Copyright (C) 1985, 1989, 1990, 1991, 1992, 1993, 1995, 1996, 1997, 1998, - 2000, 2001, 2002, 2003, 2005, 2006, 2009, 2010 Free Software Foundation, - Inc. + Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2006, 2009-2011 + Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify @@ -116,10 +115,10 @@ typedef unsigned long int reg_syntax_t; /* If this bit is set, then ^ and $ are always anchors (outside bracket expressions, of course). If this bit is not set, then it depends: - ^ is an anchor if it is at the beginning of a regular - expression or after an open-group or an alternation operator; - $ is an anchor if it is at the end of a regular expression, or - before a close-group or an alternation operator. + ^ is an anchor if it is at the beginning of a regular + expression or after an open-group or an alternation operator; + $ is an anchor if it is at the end of a regular expression, or + before a close-group or an alternation operator. This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because POSIX draft 11.2 says that * etc. in leading positions is undefined. @@ -221,8 +220,8 @@ typedef unsigned long int reg_syntax_t; whether ^ should be special. */ # define RE_CARET_ANCHORS_HERE (RE_ICASE << 1) -/* If this bit is set, then \{ cannot be first in an bre or - immediately after an alternation or begin-group operator. */ +/* If this bit is set, then \{ cannot be first in a regex or + immediately after an alternation, open-group or \} operator. */ # define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1) /* If this bit is set, then no_sub will be set to 1 during @@ -497,8 +496,8 @@ struct re_pattern_buffer #endif unsigned int _REG_RE_NAME (regs_allocated) : 2; - /* Set to zero when `regex_compile' compiles a pattern; set to one - by `re_compile_fastmap' if it updates the fastmap. */ + /* Set to zero when `re_compile_pattern' compiles a pattern; set to + one by `re_compile_fastmap' if it updates the fastmap. */ unsigned int _REG_RE_NAME (fastmap_accurate) : 1; /* If set, `re_match_2' does not return information about @@ -612,8 +611,8 @@ extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer, register data. Unless this function is called, the first search or match using - PATTERN_BUFFER will allocate its own register data, without - freeing the old data. */ + BUFFER will allocate its own register data, without freeing the old + data. */ extern void re_set_registers (struct re_pattern_buffer *__buffer, struct re_registers *__regs, __re_size_t __num_regs, diff --git a/contrib/diffutils/lib/regex_internal.c b/contrib/diffutils/lib/regex_internal.c index 38afdeb2ea..dcfb0df67d 100644 --- a/contrib/diffutils/lib/regex_internal.c +++ b/contrib/diffutils/lib/regex_internal.c @@ -1,8 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Extended regular expression matching and search library. - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free - Software Foundation, Inc. + Copyright (C) 2002-2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . @@ -737,15 +736,17 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) mbstate_t cur_state; wchar_t wc2; Idx mlen = raw + pstr->len - p; - unsigned char buf[6]; size_t mbclen; +#if 0 /* dead code: buf is set but never used */ + unsigned char buf[6]; if (BE (pstr->trans != NULL, 0)) { int i = mlen < 6 ? mlen : 6; while (--i >= 0) buf[i] = pstr->trans[p[i]]; } +#endif /* XXX Don't use mbrtowc, we know which conversion to use (UTF-8 -> UCS4). */ memset (&cur_state, 0, sizeof (cur_state)); diff --git a/contrib/diffutils/lib/regex_internal.h b/contrib/diffutils/lib/regex_internal.h index cdeb5c8f93..b25577cffd 100644 --- a/contrib/diffutils/lib/regex_internal.h +++ b/contrib/diffutils/lib/regex_internal.h @@ -1,8 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Extended regular expression matching and search library. - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free - Software Foundation, Inc. + Copyright (C) 2002-2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . @@ -34,9 +33,7 @@ #ifndef _LIBC # include "localcharset.h" #endif -#if defined HAVE_LOCALE_H || defined _LIBC -# include -#endif +#include #include #include @@ -86,7 +83,7 @@ # define SIZE_MAX ((size_t) -1) #endif -#if (defined MB_CUR_MAX && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCSCOLL) || _LIBC +#if (defined MB_CUR_MAX && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCSCOLL) || _LIBC # define RE_ENABLE_I18N #endif @@ -420,11 +417,7 @@ struct re_dfa_t; typedef struct re_dfa_t re_dfa_t; #ifndef _LIBC -# if defined __i386__ && !defined __EMX__ -# define internal_function __attribute ((regparm (3), stdcall)) -# else -# define internal_function -# endif +# define internal_function #endif static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr, @@ -469,6 +462,8 @@ static unsigned int re_string_context_at (const re_string_t *input, Idx idx, # else /* alloca is implemented with malloc, so just use malloc. */ # define __libc_use_alloca(n) 0 +# undef alloca +# define alloca(n) malloc (n) # endif #endif diff --git a/contrib/diffutils/lib/regexec.c b/contrib/diffutils/lib/regexec.c index 4e488cd4a3..ac67aebe98 100644 --- a/contrib/diffutils/lib/regexec.c +++ b/contrib/diffutils/lib/regexec.c @@ -1,8 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Extended regular expression matching and search library. - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free - Software Foundation, Inc. + Copyright (C) 2002-2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . @@ -3412,6 +3411,8 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state) { state->trtable = (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX); + if (BE (state->trtable == NULL, 0)) + return false; return true; } return false; diff --git a/contrib/diffutils/lib/sh-quote.c b/contrib/diffutils/lib/sh-quote.c index 750d1080d8..731567caf1 100644 --- a/contrib/diffutils/lib/sh-quote.c +++ b/contrib/diffutils/lib/sh-quote.c @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Shell quoting. - Copyright (C) 2001-2004, 2006, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006, 2009-2011 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/sh-quote.h b/contrib/diffutils/lib/sh-quote.h index 26ca17c569..339a7c63f6 100644 --- a/contrib/diffutils/lib/sh-quote.h +++ b/contrib/diffutils/lib/sh-quote.h @@ -1,5 +1,5 @@ /* Shell quoting. - Copyright (C) 2001-2002, 2004, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2004, 2009-2011 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/sig-handler.h b/contrib/diffutils/lib/sig-handler.h index 6a634c246a..abb660cdf7 100644 --- a/contrib/diffutils/lib/sig-handler.h +++ b/contrib/diffutils/lib/sig-handler.h @@ -1,6 +1,6 @@ /* Convenience declarations when working with . - Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2008-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/stat-time.h b/contrib/diffutils/lib/stat-time.h index 16300485f3..86d9d4b8f7 100644 --- a/contrib/diffutils/lib/stat-time.h +++ b/contrib/diffutils/lib/stat-time.h @@ -1,6 +1,6 @@ /* stat-related time functions. - Copyright (C) 2005, 2007, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2005, 2007, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -142,7 +142,7 @@ get_stat_mtime (struct stat const *st) } /* Return *ST's birth time, if available; otherwise return a value - with negative tv_nsec. */ + with tv_sec and tv_nsec both equal to -1. */ static inline struct timespec get_stat_birthtime (struct stat const *st) { @@ -161,7 +161,7 @@ get_stat_birthtime (struct stat const *st) t.tv_sec = st->st_ctime; t.tv_nsec = 0; #else - /* Birth time is not supported. Set tv_sec to avoid undefined behavior. */ + /* Birth time is not supported. */ t.tv_sec = -1; t.tv_nsec = -1; /* Avoid a "parameter unused" warning. */ @@ -175,10 +175,12 @@ get_stat_birthtime (struct stat const *st) using zero. Attempt to work around this problem. Alas, this can report failure even for valid time stamps. Also, NetBSD sometimes returns junk in the birth time fields; work around this - bug if it it is detected. There's no need to detect negative - tv_nsec junk as negative tv_nsec already indicates an error. */ - if (t.tv_sec == 0 || 1000000000 <= t.tv_nsec) - t.tv_nsec = -1; + bug if it is detected. */ + if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000)) + { + t.tv_sec = -1; + t.tv_nsec = -1; + } #endif return t; diff --git a/contrib/diffutils/lib/stdio--.h b/contrib/diffutils/lib/stdio--.h index b832308963..adde0f9977 100644 --- a/contrib/diffutils/lib/stdio--.h +++ b/contrib/diffutils/lib/stdio--.h @@ -1,6 +1,6 @@ /* Like stdio.h, but redefine some names to avoid glitches. - Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/stdio-safer.h b/contrib/diffutils/lib/stdio-safer.h index 9a7c4da5aa..62fdf64716 100644 --- a/contrib/diffutils/lib/stdio-safer.h +++ b/contrib/diffutils/lib/stdio-safer.h @@ -1,6 +1,6 @@ /* Invoke stdio functions, but avoid some glitches. - Copyright (C) 2001, 2003, 2006, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/str-kmp.h b/contrib/diffutils/lib/str-kmp.h index 4988171c5d..df48a2ccc0 100644 --- a/contrib/diffutils/lib/str-kmp.h +++ b/contrib/diffutils/lib/str-kmp.h @@ -1,8 +1,8 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -/* Substring search in a NUL terminated string of 'char' elements, +/* Substring search in a NUL terminated string of UNIT elements, using the Knuth-Morris-Pratt algorithm. - Copyright (C) 2005-2010 Free Software Foundation, Inc. + Copyright (C) 2005-2011 Free Software Foundation, Inc. Written by Bruno Haible , 2005. This program is free software; you can redistribute it and/or modify @@ -20,21 +20,26 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* Before including this file, you need to define: + UNIT The element type of the needle and haystack. CANON_ELEMENT(c) A macro that canonicalizes an element right after - it has been fetched from one of the two strings. - The argument is an 'unsigned char'; the result - must be an 'unsigned char' as well. */ + it has been fetched from needle or haystack. + The argument is of type UNIT; the result must be + of type UNIT as well. */ /* Knuth-Morris-Pratt algorithm. See http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm + HAYSTACK is the NUL terminated string in which to search for. + NEEDLE is the string to search for in HAYSTACK, consisting of NEEDLE_LEN + units. Return a boolean indicating success: Return true and set *RESULTP if the search was completed. Return false if it was aborted because not enough memory was available. */ static bool -knuth_morris_pratt_unibyte (const char *haystack, const char *needle, - const char **resultp) +knuth_morris_pratt (const UNIT *haystack, + const UNIT *needle, size_t needle_len, + const UNIT **resultp) { - size_t m = strlen (needle); + size_t m = needle_len; /* Allocate the table. */ size_t *table = (size_t *) nmalloca (m, sizeof (size_t)); @@ -68,14 +73,14 @@ knuth_morris_pratt_unibyte (const char *haystack, const char *needle, The inequality needle[x..i-1] != needle[0..i-1-x] is known to hold for x < table[i-1], by induction. Furthermore, if j>0: needle[i-1-j..i-2] = needle[0..j-1]. */ - unsigned char b = CANON_ELEMENT ((unsigned char) needle[i - 1]); + UNIT b = CANON_ELEMENT (needle[i - 1]); for (;;) { /* Invariants: The inequality needle[x..i-1] != needle[0..i-1-x] is known to hold for x < i-1-j. Furthermore, if j>0: needle[i-1-j..i-2] = needle[0..j-1]. */ - if (b == CANON_ELEMENT ((unsigned char) needle[j])) + if (b == CANON_ELEMENT (needle[j])) { /* Set table[i] := i-1-j. */ table[i] = i - ++j; @@ -110,17 +115,16 @@ knuth_morris_pratt_unibyte (const char *haystack, const char *needle, /* Search, using the table to accelerate the processing. */ { size_t j; - const char *rhaystack; - const char *phaystack; + const UNIT *rhaystack; + const UNIT *phaystack; *resultp = NULL; j = 0; rhaystack = haystack; phaystack = haystack; /* Invariant: phaystack = rhaystack + j. */ - while (*phaystack != '\0') - if (CANON_ELEMENT ((unsigned char) needle[j]) - == CANON_ELEMENT ((unsigned char) *phaystack)) + while (*phaystack != 0) + if (CANON_ELEMENT (needle[j]) == CANON_ELEMENT (*phaystack)) { j++; phaystack++; diff --git a/contrib/diffutils/lib/streq.h b/contrib/diffutils/lib/streq.h index 97ebcbe0e9..067732dd69 100644 --- a/contrib/diffutils/lib/streq.h +++ b/contrib/diffutils/lib/streq.h @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Optimized string comparison. - Copyright (C) 2001-2002, 2007, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2007, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -11,7 +11,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ diff --git a/contrib/diffutils/lib/strerror-override.c b/contrib/diffutils/lib/strerror-override.c new file mode 100644 index 0000000000..d6ecf2ecae --- /dev/null +++ b/contrib/diffutils/lib/strerror-override.c @@ -0,0 +1,279 @@ +/* strerror-override.c --- POSIX compatible system error routine + + Copyright (C) 2010-2011 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2010. */ + +#include + +#include "strerror-override.h" + +#include + +#if GNULIB_defined_ESOCK /* native Windows platforms */ +# if HAVE_WINSOCK2_H +# include +# endif +#endif + +/* If ERRNUM maps to an errno value defined by gnulib, return a string + describing the error. Otherwise return NULL. */ +const char * +strerror_override (int errnum) +{ + /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */ + switch (errnum) + { +#if REPLACE_STRERROR_0 + case 0: + return "Success"; +#endif + +#if GNULIB_defined_ETXTBSY + case ETXTBSY: + return "Text file busy"; +#endif + +#if GNULIB_defined_ESOCK /* native Windows platforms */ + /* EWOULDBLOCK is the same as EAGAIN. */ + case EINPROGRESS: + return "Operation now in progress"; + case EALREADY: + return "Operation already in progress"; + case ENOTSOCK: + return "Socket operation on non-socket"; + case EDESTADDRREQ: + return "Destination address required"; + case EMSGSIZE: + return "Message too long"; + case EPROTOTYPE: + return "Protocol wrong type for socket"; + case ENOPROTOOPT: + return "Protocol not available"; + case EPROTONOSUPPORT: + return "Protocol not supported"; + case ESOCKTNOSUPPORT: + return "Socket type not supported"; + case EOPNOTSUPP: + return "Operation not supported"; + case EPFNOSUPPORT: + return "Protocol family not supported"; + case EAFNOSUPPORT: + return "Address family not supported by protocol"; + case EADDRINUSE: + return "Address already in use"; + case EADDRNOTAVAIL: + return "Cannot assign requested address"; + case ENETDOWN: + return "Network is down"; + case ENETUNREACH: + return "Network is unreachable"; + case ENETRESET: + return "Network dropped connection on reset"; + case ECONNABORTED: + return "Software caused connection abort"; + case ECONNRESET: + return "Connection reset by peer"; + case ENOBUFS: + return "No buffer space available"; + case EISCONN: + return "Transport endpoint is already connected"; + case ENOTCONN: + return "Transport endpoint is not connected"; + case ESHUTDOWN: + return "Cannot send after transport endpoint shutdown"; + case ETOOMANYREFS: + return "Too many references: cannot splice"; + case ETIMEDOUT: + return "Connection timed out"; + case ECONNREFUSED: + return "Connection refused"; + case ELOOP: + return "Too many levels of symbolic links"; + case EHOSTDOWN: + return "Host is down"; + case EHOSTUNREACH: + return "No route to host"; + case EPROCLIM: + return "Too many processes"; + case EUSERS: + return "Too many users"; + case EDQUOT: + return "Disk quota exceeded"; + case ESTALE: + return "Stale NFS file handle"; + case EREMOTE: + return "Object is remote"; +# if HAVE_WINSOCK2_H + /* WSA_INVALID_HANDLE maps to EBADF */ + /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */ + /* WSA_INVALID_PARAMETER maps to EINVAL */ + case WSA_OPERATION_ABORTED: + return "Overlapped operation aborted"; + case WSA_IO_INCOMPLETE: + return "Overlapped I/O event object not in signaled state"; + case WSA_IO_PENDING: + return "Overlapped operations will complete later"; + /* WSAEINTR maps to EINTR */ + /* WSAEBADF maps to EBADF */ + /* WSAEACCES maps to EACCES */ + /* WSAEFAULT maps to EFAULT */ + /* WSAEINVAL maps to EINVAL */ + /* WSAEMFILE maps to EMFILE */ + /* WSAEWOULDBLOCK maps to EWOULDBLOCK */ + /* WSAEINPROGRESS is EINPROGRESS */ + /* WSAEALREADY is EALREADY */ + /* WSAENOTSOCK is ENOTSOCK */ + /* WSAEDESTADDRREQ is EDESTADDRREQ */ + /* WSAEMSGSIZE is EMSGSIZE */ + /* WSAEPROTOTYPE is EPROTOTYPE */ + /* WSAENOPROTOOPT is ENOPROTOOPT */ + /* WSAEPROTONOSUPPORT is EPROTONOSUPPORT */ + /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */ + /* WSAEOPNOTSUPP is EOPNOTSUPP */ + /* WSAEPFNOSUPPORT is EPFNOSUPPORT */ + /* WSAEAFNOSUPPORT is EAFNOSUPPORT */ + /* WSAEADDRINUSE is EADDRINUSE */ + /* WSAEADDRNOTAVAIL is EADDRNOTAVAIL */ + /* WSAENETDOWN is ENETDOWN */ + /* WSAENETUNREACH is ENETUNREACH */ + /* WSAENETRESET is ENETRESET */ + /* WSAECONNABORTED is ECONNABORTED */ + /* WSAECONNRESET is ECONNRESET */ + /* WSAENOBUFS is ENOBUFS */ + /* WSAEISCONN is EISCONN */ + /* WSAENOTCONN is ENOTCONN */ + /* WSAESHUTDOWN is ESHUTDOWN */ + /* WSAETOOMANYREFS is ETOOMANYREFS */ + /* WSAETIMEDOUT is ETIMEDOUT */ + /* WSAECONNREFUSED is ECONNREFUSED */ + /* WSAELOOP is ELOOP */ + /* WSAENAMETOOLONG maps to ENAMETOOLONG */ + /* WSAEHOSTDOWN is EHOSTDOWN */ + /* WSAEHOSTUNREACH is EHOSTUNREACH */ + /* WSAENOTEMPTY maps to ENOTEMPTY */ + /* WSAEPROCLIM is EPROCLIM */ + /* WSAEUSERS is EUSERS */ + /* WSAEDQUOT is EDQUOT */ + /* WSAESTALE is ESTALE */ + /* WSAEREMOTE is EREMOTE */ + case WSASYSNOTREADY: + return "Network subsystem is unavailable"; + case WSAVERNOTSUPPORTED: + return "Winsock.dll version out of range"; + case WSANOTINITIALISED: + return "Successful WSAStartup not yet performed"; + case WSAEDISCON: + return "Graceful shutdown in progress"; + case WSAENOMORE: case WSA_E_NO_MORE: + return "No more results"; + case WSAECANCELLED: case WSA_E_CANCELLED: + return "Call was canceled"; + case WSAEINVALIDPROCTABLE: + return "Procedure call table is invalid"; + case WSAEINVALIDPROVIDER: + return "Service provider is invalid"; + case WSAEPROVIDERFAILEDINIT: + return "Service provider failed to initialize"; + case WSASYSCALLFAILURE: + return "System call failure"; + case WSASERVICE_NOT_FOUND: + return "Service not found"; + case WSATYPE_NOT_FOUND: + return "Class type not found"; + case WSAEREFUSED: + return "Database query was refused"; + case WSAHOST_NOT_FOUND: + return "Host not found"; + case WSATRY_AGAIN: + return "Nonauthoritative host not found"; + case WSANO_RECOVERY: + return "Nonrecoverable error"; + case WSANO_DATA: + return "Valid name, no data record of requested type"; + /* WSA_QOS_* omitted */ +# endif +#endif + +#if GNULIB_defined_ENOMSG + case ENOMSG: + return "No message of desired type"; +#endif + +#if GNULIB_defined_EIDRM + case EIDRM: + return "Identifier removed"; +#endif + +#if GNULIB_defined_ENOLINK + case ENOLINK: + return "Link has been severed"; +#endif + +#if GNULIB_defined_EPROTO + case EPROTO: + return "Protocol error"; +#endif + +#if GNULIB_defined_EMULTIHOP + case EMULTIHOP: + return "Multihop attempted"; +#endif + +#if GNULIB_defined_EBADMSG + case EBADMSG: + return "Bad message"; +#endif + +#if GNULIB_defined_EOVERFLOW + case EOVERFLOW: + return "Value too large for defined data type"; +#endif + +#if GNULIB_defined_ENOTSUP + case ENOTSUP: + return "Not supported"; +#endif + +#if GNULIB_defined_ENETRESET + case ENETRESET: + return "Network dropped connection on reset"; +#endif + +#if GNULIB_defined_ECONNABORTED + case ECONNABORTED: + return "Software caused connection abort"; +#endif + +#if GNULIB_defined_ESTALE + case ESTALE: + return "Stale NFS file handle"; +#endif + +#if GNULIB_defined_EDQUOT + case EDQUOT: + return "Disk quota exceeded"; +#endif + +#if GNULIB_defined_ECANCELED + case ECANCELED: + return "Operation canceled"; +#endif + + default: + return NULL; + } +} diff --git a/contrib/diffutils/lib/strerror-override.h b/contrib/diffutils/lib/strerror-override.h new file mode 100644 index 0000000000..81e4a50759 --- /dev/null +++ b/contrib/diffutils/lib/strerror-override.h @@ -0,0 +1,52 @@ +/* strerror-override.h --- POSIX compatible system error routine + + Copyright (C) 2010-2011 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _GL_STRERROR_OVERRIDE_H +# define _GL_STRERROR_OVERRIDE_H + +# include +# include + +/* Reasonable buffer size that should never trigger ERANGE; if this + proves too small, we intentionally abort(), to remind us to fix + this value. */ +# define STACKBUF_LEN 256 + +/* If ERRNUM maps to an errno value defined by gnulib, return a string + describing the error. Otherwise return NULL. */ +# if REPLACE_STRERROR_0 \ + || GNULIB_defined_ETXTBSY \ + || GNULIB_defined_ESOCK \ + || GNULIB_defined_ENOMSG \ + || GNULIB_defined_EIDRM \ + || GNULIB_defined_ENOLINK \ + || GNULIB_defined_EPROTO \ + || GNULIB_defined_EMULTIHOP \ + || GNULIB_defined_EBADMSG \ + || GNULIB_defined_EOVERFLOW \ + || GNULIB_defined_ENOTSUP \ + || GNULIB_defined_ENETRESET \ + || GNULIB_defined_ECONNABORTED \ + || GNULIB_defined_ESTALE \ + || GNULIB_defined_EDQUOT \ + || GNULIB_defined_ECANCELED +extern const char *strerror_override (int errnum); +# else +# define strerror_override(ignored) NULL +# endif + +#endif /* _GL_STRERROR_OVERRIDE_H */ diff --git a/contrib/diffutils/lib/strftime.c b/contrib/diffutils/lib/strftime.c index 01c0c5516d..acebc9adfa 100644 --- a/contrib/diffutils/lib/strftime.c +++ b/contrib/diffutils/lib/strftime.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc. +/* Copyright (C) 1991-2001, 2003-2007, 2009-2011 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. @@ -48,8 +48,11 @@ extern char *tzname[]; GB18030, EUC-TW, BIG5, BIG5-HKSCS, CP950, EUC-JP, EUC-KR, CP949, SHIFT_JIS, CP932, JOHAB) are safe for formats, because the byte '%' cannot occur in a multibyte character except in the first byte. - But this does not hold for the DEC-HANYU encoding used on OSF/1. */ -#if !defined __osf__ + + The DEC-HANYU encoding used on OSF/1 is not safe for formats, but + this encoding has never been seen in real-life use, so we ignore + it. */ +#if !(defined __osf__ && 0) # define MULTIBYTE_IS_FORMAT_SAFE 1 #endif #define DO_MULTIBYTE (! MULTIBYTE_IS_FORMAT_SAFE) @@ -169,15 +172,16 @@ extern char *tzname[]; #define add(n, f) \ do \ { \ - int _n = (n); \ - int _delta = width - _n; \ - int _incr = _n + (_delta > 0 ? _delta : 0); \ - if ((size_t) _incr >= maxsize - i) \ + size_t _n = (n); \ + size_t _w = (width < 0 ? 0 : width); \ + size_t _incr = _n < _w ? _w : _n; \ + if (_incr >= maxsize - i) \ return 0; \ if (p) \ { \ - if (digits == 0 && _delta > 0) \ + if (digits == 0 && _n < _w) \ { \ + size_t _delta = width - _n; \ if (pad == L_('0')) \ memset_zero (p, _delta); \ else \ diff --git a/contrib/diffutils/lib/strftime.h b/contrib/diffutils/lib/strftime.h index bf14540421..3410568a9a 100644 --- a/contrib/diffutils/lib/strftime.h +++ b/contrib/diffutils/lib/strftime.h @@ -1,6 +1,6 @@ /* declarations for strftime.c - Copyright (C) 2002, 2004, 2008-2010 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2008-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/striconv.c b/contrib/diffutils/lib/striconv.c index 096a01b0c1..4fdeb74386 100644 --- a/contrib/diffutils/lib/striconv.c +++ b/contrib/diffutils/lib/striconv.c @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Charset conversion. - Copyright (C) 2001-2007, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2001-2007, 2010-2011 Free Software Foundation, Inc. Written by Bruno Haible and Simon Josefsson. This program is free software; you can redistribute it and/or modify @@ -52,7 +52,8 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd, /* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */ # if defined _LIBICONV_VERSION \ - || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) + || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \ + || defined __sun) /* Set to the initial state. */ iconv (cd, NULL, NULL, NULL, NULL); # endif @@ -84,7 +85,7 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd, else return -1; } -# if !defined _LIBICONV_VERSION && !defined __GLIBC__ +# if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__) /* Irix iconv() inserts a NUL byte if it cannot convert. NetBSD iconv() inserts a question mark if it cannot convert. Only GNU libiconv and GNU libc are known to prefer to fail rather @@ -99,7 +100,8 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd, } /* Avoid glibc-2.1 bug and Solaris 2.7 bug. */ # if defined _LIBICONV_VERSION \ - || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) + || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \ + || defined __sun) { char *outptr = tmpbuf; size_t outsize = tmpbufsize; @@ -133,7 +135,8 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd, /* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */ # if defined _LIBICONV_VERSION \ - || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) + || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \ + || defined __sun) /* Return to the initial state. */ iconv (cd, NULL, NULL, NULL, NULL); # endif @@ -158,7 +161,7 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd, else goto fail; } -# if !defined _LIBICONV_VERSION && !defined __GLIBC__ +# if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__) /* Irix iconv() inserts a NUL byte if it cannot convert. NetBSD iconv() inserts a question mark if it cannot convert. Only GNU libiconv and GNU libc are known to prefer to fail rather @@ -172,7 +175,8 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd, } /* Avoid glibc-2.1 bug and Solaris 2.7 bug. */ # if defined _LIBICONV_VERSION \ - || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) + || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \ + || defined __sun) { size_t res = iconv (cd, NULL, NULL, &outptr, &outsize); @@ -209,7 +213,7 @@ str_cd_iconv (const char *src, iconv_t cd) to a trailing NUL byte in the output. But not for UTF-7. So that this function is usable for UTF-7, we have to exclude the NUL byte from the conversion and add it by hand afterwards. */ -# if !defined _LIBICONV_VERSION && !defined __GLIBC__ +# if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__) /* Irix iconv() inserts a NUL byte if it cannot convert. NetBSD iconv() inserts a question mark if it cannot convert. Only GNU libiconv and GNU libc are known to prefer to fail rather @@ -274,7 +278,8 @@ str_cd_iconv (const char *src, iconv_t cd) /* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */ # if defined _LIBICONV_VERSION \ - || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) + || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \ + || defined __sun) /* Set to the initial state. */ iconv (cd, NULL, NULL, NULL, NULL); # endif @@ -326,7 +331,8 @@ str_cd_iconv (const char *src, iconv_t cd) } /* Avoid glibc-2.1 bug and Solaris 2.7 bug. */ # if defined _LIBICONV_VERSION \ - || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) + || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \ + || defined __sun) for (;;) { /* Here outptr + outbytes_remaining = result + result_size - 1. */ @@ -412,7 +418,8 @@ str_iconv (const char *src, const char *from_codeset, const char *to_codeset) char *result; /* Avoid glibc-2.1 bug with EUC-KR. */ -# if (__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) && !defined _LIBICONV_VERSION +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \ + && !defined _LIBICONV_VERSION if (c_strcasecmp (from_codeset, "EUC-KR") == 0 || c_strcasecmp (to_codeset, "EUC-KR") == 0) { diff --git a/contrib/diffutils/lib/striconv.h b/contrib/diffutils/lib/striconv.h index bc864e0ab8..30bc1f8f9c 100644 --- a/contrib/diffutils/lib/striconv.h +++ b/contrib/diffutils/lib/striconv.h @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Charset conversion. - Copyright (C) 2001-2004, 2006-2007, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006-2007, 2009-2011 Free Software Foundation, Inc. Written by Bruno Haible and Simon Josefsson. This program is free software; you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/stripslash.c b/contrib/diffutils/lib/stripslash.c index 3a5996fd90..1212440b5a 100644 --- a/contrib/diffutils/lib/stripslash.c +++ b/contrib/diffutils/lib/stripslash.c @@ -1,6 +1,6 @@ /* stripslash.c -- remove redundant trailing slashes from a file name - Copyright (C) 1990, 2001, 2003-2006, 2009-2010 Free Software Foundation, + Copyright (C) 1990, 2001, 2003-2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/strnlen1.c b/contrib/diffutils/lib/strnlen1.c index b8cd2bff03..f64ce104a3 100644 --- a/contrib/diffutils/lib/strnlen1.c +++ b/contrib/diffutils/lib/strnlen1.c @@ -1,5 +1,5 @@ /* Find the length of STRING + 1, but scan at most MAXLEN bytes. - Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/strnlen1.h b/contrib/diffutils/lib/strnlen1.h index dfaf62dcbd..1bb13de60d 100644 --- a/contrib/diffutils/lib/strnlen1.h +++ b/contrib/diffutils/lib/strnlen1.h @@ -1,5 +1,5 @@ /* Find the length of STRING + 1, but scan at most MAXLEN bytes. - Copyright (C) 2005, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2005, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/tempname.c b/contrib/diffutils/lib/tempname.c index 134908b42c..139e0c3441 100644 --- a/contrib/diffutils/lib/tempname.c +++ b/contrib/diffutils/lib/tempname.c @@ -1,6 +1,6 @@ /* tempname.c - generate the name of a temporary file. - Copyright (C) 1991-2003, 2005-2007, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 1991-2003, 2005-2007, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/tempname.h b/contrib/diffutils/lib/tempname.h index 349bc362c4..f27b9ba36b 100644 --- a/contrib/diffutils/lib/tempname.h +++ b/contrib/diffutils/lib/tempname.h @@ -1,6 +1,6 @@ /* Create a temporary file or directory. - Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/timegm.c b/contrib/diffutils/lib/timegm.c deleted file mode 100644 index f39756b21b..0000000000 --- a/contrib/diffutils/lib/timegm.c +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- buffer-read-only: t -*- vi: set ro: */ -/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -/* Convert UTC calendar time to simple time. Like mktime but assumes UTC. - - Copyright (C) 1994, 1997, 2003, 2004, 2006, 2007, 2009, 2010 Free Software - Foundation, Inc. This file is part of the GNU C Library. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifndef _LIBC -# include -#endif - -#include - -#ifndef _LIBC -# undef __gmtime_r -# define __gmtime_r gmtime_r -# define __mktime_internal mktime_internal -# include "mktime-internal.h" -#endif - -time_t -timegm (struct tm *tmp) -{ - static time_t gmtime_offset; - tmp->tm_isdst = 0; - return __mktime_internal (tmp, __gmtime_r, &gmtime_offset); -} diff --git a/contrib/diffutils/lib/timespec.h b/contrib/diffutils/lib/timespec.h index 81b342300e..acf815c8db 100644 --- a/contrib/diffutils/lib/timespec.h +++ b/contrib/diffutils/lib/timespec.h @@ -1,6 +1,6 @@ /* timespec -- System time interface - Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2010 Free Software + Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -22,15 +22,58 @@ # include /* Return negative, zero, positive if A < B, A == B, A > B, respectively. - Assume the nanosecond components are in range, or close to it. */ + + For each time stamp T, this code assumes that either: + + * T.tv_nsec is in the range 0..999999999; or + * T.tv_sec corresponds to a valid leap second on a host that supports + leap seconds, and T.tv_nsec is in the range 1000000000..1999999999; or + * T.tv_sec is the minimum time_t value and T.tv_nsec is -1; or + T.tv_sec is the maximum time_t value and T.tv_nsec is 2000000000. + This allows for special struct timespec values that are less or + greater than all possible valid time stamps. + + In all these cases, it is safe to subtract two tv_nsec values and + convert the result to integer without worrying about overflow on + any platform of interest to the GNU project, since all such + platforms have 32-bit int or wider. + + Replacing "(int) (a.tv_nsec - b.tv_nsec)" with something like + "a.tv_nsec < b.tv_nsec ? -1 : a.tv_nsec > b.tv_nsec" would cause + this function to work in some cases where the above assumption is + violated, but not in all cases (e.g., a.tv_sec==1, a.tv_nsec==-2, + b.tv_sec==0, b.tv_nsec==999999999) and is arguably not worth the + extra instructions. Using a subtraction has the advantage of + detecting some invalid cases on platforms that detect integer + overflow. + + The (int) cast avoids a gcc -Wconversion warning. */ + static inline int timespec_cmp (struct timespec a, struct timespec b) { return (a.tv_sec < b.tv_sec ? -1 : a.tv_sec > b.tv_sec ? 1 - : a.tv_nsec < b.tv_nsec ? -1 - : a.tv_nsec > b.tv_nsec ? 1 - : 0); + : (int) (a.tv_nsec - b.tv_nsec)); +} + +/* Return -1, 0, 1, depending on the sign of A. A.tv_nsec must be + nonnegative. */ +static inline int +timespec_sign (struct timespec a) +{ + return a.tv_sec < 0 ? -1 : a.tv_sec || a.tv_nsec; +} + +struct timespec timespec_add (struct timespec, struct timespec); +struct timespec timespec_sub (struct timespec, struct timespec); +struct timespec dtotimespec (double); + +/* Return an approximation to A, of type 'double'. */ +static inline double +timespectod (struct timespec a) +{ + return a.tv_sec + a.tv_nsec / 1e9; } void gettime (struct timespec *); diff --git a/contrib/diffutils/lib/trim.c b/contrib/diffutils/lib/trim.c index c8b0c7fe49..155063eed3 100644 --- a/contrib/diffutils/lib/trim.c +++ b/contrib/diffutils/lib/trim.c @@ -1,5 +1,5 @@ /* Removes leading and/or trailing whitespaces - Copyright (C) 2006-2010 Free Software Foundation, Inc. + Copyright (C) 2006-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -65,7 +65,7 @@ trim2 (const char *s, int how) /* Trim trailing whitespaces. */ if (how != TRIM_LEADING) { - int state = 0; + unsigned int state = 0; char *r IF_LINT (= NULL); /* used only while state = 2 */ mbi_init (i, d, strlen (d)); @@ -73,10 +73,7 @@ trim2 (const char *s, int how) for (; mbi_avail (i); mbi_advance (i)) { if (state == 0 && mb_isspace (mbi_cur (i))) - { - state = 0; - continue; - } + continue; if (state == 0 && !mb_isspace (mbi_cur (i))) { @@ -85,10 +82,7 @@ trim2 (const char *s, int how) } if (state == 1 && !mb_isspace (mbi_cur (i))) - { - state = 1; - continue; - } + continue; if (state == 1 && mb_isspace (mbi_cur (i))) { @@ -97,7 +91,7 @@ trim2 (const char *s, int how) } else if (state == 2 && mb_isspace (mbi_cur (i))) { - state = 2; + /* empty */ } else { @@ -114,20 +108,22 @@ trim2 (const char *s, int how) char *p; /* Trim leading whitespaces. */ - if (how != TRIM_TRAILING) { - for (p = d; *p && isspace ((unsigned char) *p); p++) - ; + if (how != TRIM_TRAILING) + { + for (p = d; *p && isspace ((unsigned char) *p); p++) + ; - memmove (d, p, strlen (p) + 1); - } + memmove (d, p, strlen (p) + 1); + } /* Trim trailing whitespaces. */ - if (how != TRIM_LEADING) { - for (p = d + strlen (d) - 1; p >= d && isspace ((unsigned char) *p); p--) - *p = '\0'; - } + if (how != TRIM_LEADING) + { + for (p = d + strlen (d) - 1; + p >= d && isspace ((unsigned char) *p); p--) + *p = '\0'; + } } return d; } - diff --git a/contrib/diffutils/lib/trim.h b/contrib/diffutils/lib/trim.h index aa777e499d..0bbb2ffa66 100644 --- a/contrib/diffutils/lib/trim.h +++ b/contrib/diffutils/lib/trim.h @@ -1,5 +1,5 @@ /* Removes leading and/or trailing whitespaces - Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/uinttostr.c b/contrib/diffutils/lib/uinttostr.c index 1662985f40..48fd98f21c 100644 --- a/contrib/diffutils/lib/uinttostr.c +++ b/contrib/diffutils/lib/uinttostr.c @@ -1,4 +1,3 @@ -#define inttostr uinttostr +#define anytostr uinttostr #define inttype unsigned int -#define inttype_is_signed 0 -#include "inttostr.c" +#include "anytostr.c" diff --git a/contrib/diffutils/lib/umaxtostr.c b/contrib/diffutils/lib/umaxtostr.c index 914f388d1b..f95bfc3ee0 100644 --- a/contrib/diffutils/lib/umaxtostr.c +++ b/contrib/diffutils/lib/umaxtostr.c @@ -1,4 +1,3 @@ -#define inttostr umaxtostr +#define anytostr umaxtostr #define inttype uintmax_t -#define inttype_is_signed 0 -#include "inttostr.c" +#include "anytostr.c" diff --git a/contrib/diffutils/lib/unistr/u8-mbtoucr.c b/contrib/diffutils/lib/unistr/u8-mbtoucr.c new file mode 100644 index 0000000000..794dfc3665 --- /dev/null +++ b/contrib/diffutils/lib/unistr/u8-mbtoucr.c @@ -0,0 +1,287 @@ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Look at first character in UTF-8 string, returning an error code. + Copyright (C) 1999-2002, 2006-2007, 2009-2011 Free Software Foundation, Inc. + Written by Bruno Haible , 2001. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistr.h" + +int +u8_mbtoucr (ucs4_t *puc, const uint8_t *s, size_t n) +{ + uint8_t c = *s; + + if (c < 0x80) + { + *puc = c; + return 1; + } + else if (c >= 0xc2) + { + if (c < 0xe0) + { + if (n >= 2) + { + if ((s[1] ^ 0x80) < 0x40) + { + *puc = ((unsigned int) (c & 0x1f) << 6) + | (unsigned int) (s[1] ^ 0x80); + return 2; + } + /* invalid multibyte character */ + } + else + { + /* incomplete multibyte character */ + *puc = 0xfffd; + return -2; + } + } + else if (c < 0xf0) + { + if (n >= 2) + { + if ((s[1] ^ 0x80) < 0x40 + && (c >= 0xe1 || s[1] >= 0xa0) + && (c != 0xed || s[1] < 0xa0)) + { + if (n >= 3) + { + if ((s[2] ^ 0x80) < 0x40) + { + *puc = ((unsigned int) (c & 0x0f) << 12) + | ((unsigned int) (s[1] ^ 0x80) << 6) + | (unsigned int) (s[2] ^ 0x80); + return 3; + } + /* invalid multibyte character */ + } + else + { + /* incomplete multibyte character */ + *puc = 0xfffd; + return -2; + } + } + /* invalid multibyte character */ + } + else + { + /* incomplete multibyte character */ + *puc = 0xfffd; + return -2; + } + } + else if (c < 0xf8) + { + if (n >= 2) + { + if ((s[1] ^ 0x80) < 0x40 + && (c >= 0xf1 || s[1] >= 0x90) +#if 1 + && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90)) +#endif + ) + { + if (n >= 3) + { + if ((s[2] ^ 0x80) < 0x40) + { + if (n >= 4) + { + if ((s[3] ^ 0x80) < 0x40) + { + *puc = ((unsigned int) (c & 0x07) << 18) + | ((unsigned int) (s[1] ^ 0x80) << 12) + | ((unsigned int) (s[2] ^ 0x80) << 6) + | (unsigned int) (s[3] ^ 0x80); + return 4; + } + /* invalid multibyte character */ + } + else + { + /* incomplete multibyte character */ + *puc = 0xfffd; + return -2; + } + } + /* invalid multibyte character */ + } + else + { + /* incomplete multibyte character */ + *puc = 0xfffd; + return -2; + } + } + /* invalid multibyte character */ + } + else + { + /* incomplete multibyte character */ + *puc = 0xfffd; + return -2; + } + } +#if 0 + else if (c < 0xfc) + { + if (n >= 2) + { + if ((s[1] ^ 0x80) < 0x40 + && (c >= 0xf9 || s[1] >= 0x88)) + { + if (n >= 3) + { + if ((s[2] ^ 0x80) < 0x40) + { + if (n >= 4) + { + if ((s[3] ^ 0x80) < 0x40) + { + if (n >= 5) + { + if ((s[4] ^ 0x80) < 0x40) + { + *puc = ((unsigned int) (c & 0x03) << 24) + | ((unsigned int) (s[1] ^ 0x80) << 18) + | ((unsigned int) (s[2] ^ 0x80) << 12) + | ((unsigned int) (s[3] ^ 0x80) << 6) + | (unsigned int) (s[4] ^ 0x80); + return 5; + } + /* invalid multibyte character */ + } + else + { + /* incomplete multibyte character */ + *puc = 0xfffd; + return -2; + } + } + /* invalid multibyte character */ + } + else + { + /* incomplete multibyte character */ + *puc = 0xfffd; + return -2; + } + } + /* invalid multibyte character */ + } + else + { + /* incomplete multibyte character */ + *puc = 0xfffd; + return -2; + } + } + /* invalid multibyte character */ + } + else + { + /* incomplete multibyte character */ + *puc = 0xfffd; + return -2; + } + } + else if (c < 0xfe) + { + if (n >= 2) + { + if ((s[1] ^ 0x80) < 0x40 + && (c >= 0xfd || s[1] >= 0x84)) + { + if (n >= 3) + { + if ((s[2] ^ 0x80) < 0x40) + { + if (n >= 4) + { + if ((s[3] ^ 0x80) < 0x40) + { + if (n >= 5) + { + if ((s[4] ^ 0x80) < 0x40) + { + if (n >= 6) + { + if ((s[5] ^ 0x80) < 0x40) + { + *puc = ((unsigned int) (c & 0x01) << 30) + | ((unsigned int) (s[1] ^ 0x80) << 24) + | ((unsigned int) (s[2] ^ 0x80) << 18) + | ((unsigned int) (s[3] ^ 0x80) << 12) + | ((unsigned int) (s[4] ^ 0x80) << 6) + | (unsigned int) (s[5] ^ 0x80); + return 6; + } + /* invalid multibyte character */ + } + else + { + /* incomplete multibyte character */ + *puc = 0xfffd; + return -2; + } + } + /* invalid multibyte character */ + } + else + { + /* incomplete multibyte character */ + *puc = 0xfffd; + return -2; + } + } + /* invalid multibyte character */ + } + else + { + /* incomplete multibyte character */ + *puc = 0xfffd; + return -2; + } + } + /* invalid multibyte character */ + } + else + { + /* incomplete multibyte character */ + *puc = 0xfffd; + return -2; + } + } + /* invalid multibyte character */ + } + else + { + /* incomplete multibyte character */ + *puc = 0xfffd; + return -2; + } + } +#endif + } + /* invalid multibyte character */ + *puc = 0xfffd; + return -1; +} diff --git a/contrib/diffutils/lib/unistr/u8-uctomb-aux.c b/contrib/diffutils/lib/unistr/u8-uctomb-aux.c new file mode 100644 index 0000000000..206487c022 --- /dev/null +++ b/contrib/diffutils/lib/unistr/u8-uctomb-aux.c @@ -0,0 +1,71 @@ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Conversion UCS-4 to UTF-8. + Copyright (C) 2002, 2006-2007, 2009-2011 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistr.h" + +int +u8_uctomb_aux (uint8_t *s, ucs4_t uc, int n) +{ + int count; + + if (uc < 0x80) + /* The case n >= 1 is already handled by the caller. */ + return -2; + else if (uc < 0x800) + count = 2; + else if (uc < 0x10000) + { + if (uc < 0xd800 || uc >= 0xe000) + count = 3; + else + return -1; + } +#if 0 + else if (uc < 0x200000) + count = 4; + else if (uc < 0x4000000) + count = 5; + else if (uc <= 0x7fffffff) + count = 6; +#else + else if (uc < 0x110000) + count = 4; +#endif + else + return -1; + + if (n < count) + return -2; + + switch (count) /* note: code falls through cases! */ + { +#if 0 + case 6: s[5] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x4000000; + case 5: s[4] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x200000; +#endif + case 4: s[3] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x10000; + case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800; + case 2: s[1] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0xc0; + /*case 1:*/ s[0] = uc; + } + return count; +} diff --git a/contrib/diffutils/lib/unistr/u8-uctomb.c b/contrib/diffutils/lib/unistr/u8-uctomb.c new file mode 100644 index 0000000000..8aa1849d25 --- /dev/null +++ b/contrib/diffutils/lib/unistr/u8-uctomb.c @@ -0,0 +1,90 @@ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Store a character in UTF-8 string. + Copyright (C) 2002, 2005-2006, 2009-2011 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +#if defined IN_LIBUNISTRING +/* Tell unistr.h to declare u8_uctomb as 'extern', not 'static inline'. */ +# include "unistring-notinline.h" +#endif + +/* Specification. */ +#include "unistr.h" + +#if !HAVE_INLINE + +int +u8_uctomb (uint8_t *s, ucs4_t uc, int n) +{ + if (uc < 0x80) + { + if (n > 0) + { + s[0] = uc; + return 1; + } + /* else return -2, below. */ + } + else + { + int count; + + if (uc < 0x800) + count = 2; + else if (uc < 0x10000) + { + if (uc < 0xd800 || uc >= 0xe000) + count = 3; + else + return -1; + } +#if 0 + else if (uc < 0x200000) + count = 4; + else if (uc < 0x4000000) + count = 5; + else if (uc <= 0x7fffffff) + count = 6; +#else + else if (uc < 0x110000) + count = 4; +#endif + else + return -1; + + if (n >= count) + { + switch (count) /* note: code falls through cases! */ + { +#if 0 + case 6: s[5] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x4000000; + case 5: s[4] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x200000; +#endif + case 4: s[3] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x10000; + case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800; + case 2: s[1] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0xc0; + /*case 1:*/ s[0] = uc; + } + return count; + } + } + return -2; +} + +#endif diff --git a/contrib/diffutils/lib/unitypes.h b/contrib/diffutils/lib/unitypes.h deleted file mode 100644 index 61571c3c47..0000000000 --- a/contrib/diffutils/lib/unitypes.h +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- buffer-read-only: t -*- vi: set ro: */ -/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -/* Elementary types for the GNU UniString library. - Copyright (C) 2002, 2005-2006, 2009-2010 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _UNITYPES_H -#define _UNITYPES_H - -/* Get uint8_t, uint16_t, uint32_t. */ -#include - -/* Type representing a Unicode character. */ -typedef uint32_t ucs4_t; - -#endif /* _UNITYPES_H */ diff --git a/contrib/diffutils/lib/uniwidth.h b/contrib/diffutils/lib/uniwidth.h deleted file mode 100644 index 30e1923567..0000000000 --- a/contrib/diffutils/lib/uniwidth.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- buffer-read-only: t -*- vi: set ro: */ -/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -/* Display width functions. - Copyright (C) 2001-2002, 2005, 2007, 2009-2010 Free Software Foundation, - Inc. - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _UNIWIDTH_H -#define _UNIWIDTH_H - -#include "unitypes.h" - -/* Get size_t. */ -#include - -/* Get locale_charset() declaration. */ -#include "localcharset.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Display width. */ - -/* These functions are locale dependent. The encoding argument identifies - the encoding (e.g. "ISO-8859-2" for Polish). */ - -/* Determine number of column positions required for UC. */ -extern int - uc_width (ucs4_t uc, const char *encoding); - -/* Determine number of column positions required for first N units - (or fewer if S ends before this) in S. */ -extern int - u8_width (const uint8_t *s, size_t n, const char *encoding); -extern int - u16_width (const uint16_t *s, size_t n, const char *encoding); -extern int - u32_width (const uint32_t *s, size_t n, const char *encoding); - -/* Determine number of column positions required for S. */ -extern int - u8_strwidth (const uint8_t *s, const char *encoding); -extern int - u16_strwidth (const uint16_t *s, const char *encoding); -extern int - u32_strwidth (const uint32_t *s, const char *encoding); - - -#ifdef __cplusplus -} -#endif - -#endif /* _UNIWIDTH_H */ diff --git a/contrib/diffutils/lib/uniwidth/cjk.h b/contrib/diffutils/lib/uniwidth/cjk.h index c2b69cc6c3..5f7b3b3125 100644 --- a/contrib/diffutils/lib/uniwidth/cjk.h +++ b/contrib/diffutils/lib/uniwidth/cjk.h @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Test for CJK encoding. - Copyright (C) 2001-2002, 2005-2007, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2005-2007, 2009-2011 Free Software Foundation, Inc. Written by Bruno Haible , 2002. This program is free software: you can redistribute it and/or modify it @@ -12,7 +12,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ diff --git a/contrib/diffutils/lib/uniwidth/width.c b/contrib/diffutils/lib/uniwidth/width.c index 2dba811d62..3fab5eaa1b 100644 --- a/contrib/diffutils/lib/uniwidth/width.c +++ b/contrib/diffutils/lib/uniwidth/width.c @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Determine display width of Unicode character. - Copyright (C) 2001-2002, 2006-2010 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2006-2011 Free Software Foundation, Inc. Written by Bruno Haible , 2002. This program is free software: you can redistribute it and/or modify it @@ -12,7 +12,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -34,7 +34,7 @@ * - Zero width characters; generated from * "grep '^[^;]*;ZERO WIDTH ' UnicodeData.txt" */ -static const unsigned char nonspacing_table_data[26*64] = { +static const unsigned char nonspacing_table_data[27*64] = { /* 0x0000-0x01ff */ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0x0000-0x003f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x0040-0x007f */ @@ -64,20 +64,20 @@ static const unsigned char nonspacing_table_data[26*64] = { 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x05c0-0x05ff */ /* 0x0600-0x07ff */ 0x0f, 0x00, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, /* 0x0600-0x063f */ - 0x00, 0xf8, 0xff, 0x7f, 0x00, 0x00, 0x01, 0x00, /* 0x0640-0x067f */ + 0x00, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x01, 0x00, /* 0x0640-0x067f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0680-0x06bf */ - 0x00, 0x00, 0xc0, 0xff, 0x9f, 0x3d, 0x00, 0x00, /* 0x06c0-0x06ff */ + 0x00, 0x00, 0xc0, 0xbf, 0x9f, 0x3d, 0x00, 0x00, /* 0x06c0-0x06ff */ 0x00, 0x80, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, /* 0x0700-0x073f */ 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0740-0x077f */ 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x01, 0x00, /* 0x0780-0x07bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, /* 0x07c0-0x07ff */ /* 0x0800-0x09ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0800-0x083f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0840-0x087f */ + 0x00, 0x00, 0xc0, 0xfb, 0xef, 0x3e, 0x00, 0x00, /* 0x0800-0x083f */ + 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, /* 0x0840-0x087f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0880-0x08bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08c0-0x08ff */ - 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0900-0x093f */ - 0xfe, 0x21, 0x1e, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0940-0x097f */ + 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, /* 0x0900-0x093f */ + 0xfe, 0x21, 0xfe, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0940-0x097f */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0980-0x09bf */ 0x1e, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x09c0-0x09ff */ /* 0x0a00-0x0bff */ @@ -105,12 +105,12 @@ static const unsigned char nonspacing_table_data[26*64] = { 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0ec0-0x0eff */ 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0xa0, 0x02, /* 0x0f00-0x0f3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, /* 0x0f40-0x0f7f */ - 0xdf, 0x00, 0xff, 0xfe, 0xff, 0xff, 0xff, 0x1f, /* 0x0f80-0x0fbf */ + 0xdf, 0xe0, 0xff, 0xfe, 0xff, 0xff, 0xff, 0x1f, /* 0x0f80-0x0fbf */ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0fc0-0x0fff */ /* 0x1000-0x11ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfd, 0x66, /* 0x1000-0x103f */ 0x00, 0x00, 0x00, 0xc3, 0x01, 0x00, 0x1e, 0x00, /* 0x1040-0x107f */ - 0x64, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1080-0x10bf */ + 0x64, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, /* 0x1080-0x10bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10c0-0x10ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1100-0x113f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1140-0x117f */ @@ -122,7 +122,7 @@ static const unsigned char nonspacing_table_data[26*64] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1280-0x12bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x12c0-0x12ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1300-0x133f */ - 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, /* 0x1340-0x137f */ + 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, /* 0x1340-0x137f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1380-0x13bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13c0-0x13ff */ /* 0x1600-0x17ff */ @@ -145,22 +145,22 @@ static const unsigned char nonspacing_table_data[26*64] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x19c0-0x19ff */ /* 0x1a00-0x1bff */ 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, /* 0x1a00-0x1a3f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1a40-0x1a7f */ + 0x00, 0x00, 0x40, 0x7f, 0xe5, 0x1f, 0xf8, 0x9f, /* 0x1a40-0x1a7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1a80-0x1abf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1ac0-0x1aff */ 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x17, /* 0x1b00-0x1b3f */ 0x04, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, /* 0x1b40-0x1b7f */ 0x03, 0x00, 0x00, 0x00, 0x3c, 0x03, 0x00, 0x00, /* 0x1b80-0x1bbf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bc0-0x1bff */ + 0x00, 0x00, 0x00, 0x00, 0x40, 0xa3, 0x03, 0x00, /* 0x1bc0-0x1bff */ /* 0x1c00-0x1dff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xcf, 0x00, /* 0x1c00-0x1c3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1c40-0x1c7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1c80-0x1cbf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1cc0-0x1cff */ + 0x00, 0x00, 0xf7, 0xff, 0xfd, 0x21, 0x00, 0x00, /* 0x1cc0-0x1cff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d00-0x1d3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d40-0x1d7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d80-0x1dbf */ - 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xc0, /* 0x1dc0-0x1dff */ + 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, /* 0x1dc0-0x1dff */ /* 0x2000-0x21ff */ 0x00, 0xf8, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, /* 0x2000-0x203f */ 0x00, 0x00, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0x00, /* 0x2040-0x207f */ @@ -174,9 +174,9 @@ static const unsigned char nonspacing_table_data[26*64] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c00-0x2c3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c40-0x2c7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c80-0x2cbf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2cc0-0x2cff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, /* 0x2cc0-0x2cff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2d00-0x2d3f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2d40-0x2d7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x2d40-0x2d7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2d80-0x2dbf */ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, /* 0x2dc0-0x2dff */ /* 0x3000-0x31ff */ @@ -192,7 +192,7 @@ static const unsigned char nonspacing_table_data[26*64] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa600-0xa63f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x30, /* 0xa640-0xa67f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa680-0xa6bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa6c0-0xa6ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, /* 0xa6c0-0xa6ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa700-0xa73f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa740-0xa77f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa780-0xa7bf */ @@ -201,20 +201,20 @@ static const unsigned char nonspacing_table_data[26*64] = { 0x44, 0x08, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, /* 0xa800-0xa83f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa840-0xa87f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa880-0xa8bf */ - 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8c0-0xa8ff */ + 0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x00, /* 0xa8c0-0xa8ff */ 0x00, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, /* 0xa900-0xa93f */ 0x80, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa940-0xa97f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa980-0xa9bf */ + 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x13, /* 0xa980-0xa9bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa9c0-0xa9ff */ /* 0xaa00-0xabff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x66, 0x00, /* 0xaa00-0xaa3f */ 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xaa40-0xaa7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xaa80-0xaabf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xaac0-0xaaff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9d, 0xc1, /* 0xaa80-0xaabf */ + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xaac0-0xaaff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab00-0xab3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab40-0xab7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab80-0xabbf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xabc0-0xabff */ + 0x00, 0x00, 0x00, 0x00, 0x20, 0x21, 0x00, 0x00, /* 0xabc0-0xabff */ /* 0xfa00-0xfbff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa00-0xfa3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa40-0xfa7f */ @@ -251,13 +251,22 @@ static const unsigned char nonspacing_table_data[26*64] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b40-0x10b7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b80-0x10bbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10bc0-0x10bff */ + /* 0x11000-0x111ff */ + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* 0x11000-0x1103f */ + 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11040-0x1107f */ + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x26, /* 0x11080-0x110bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x110c0-0x110ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11100-0x1113f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11140-0x1117f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11180-0x111bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x111c0-0x111ff */ /* 0x1d000-0x1d1ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d000-0x1d03f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d040-0x1d07f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d080-0x1d0bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d0c0-0x1d0ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d100-0x1d13f */ - 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0xf8, /* 0x1d140-0x1d17f */ + 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0xf8, 0xff, /* 0x1d140-0x1d17f */ 0xe7, 0x0f, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* 0x1d180-0x1d1bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d1c0-0x1d1ff */ /* 0x1d200-0x1d3ff */ @@ -288,7 +297,7 @@ static const signed char nonspacing_table_ind[240] = { -1, -1, -1, -1, -1, -1, -1, -1, /* 0xe000-0xefff */ -1, -1, -1, -1, -1, 20, -1, 21, /* 0xf000-0xffff */ 22, -1, -1, -1, -1, 23, -1, -1, /* 0x10000-0x10fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x11000-0x11fff */ + 24, -1, -1, -1, -1, -1, -1, -1, /* 0x11000-0x11fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x12000-0x12fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x13000-0x13fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x14000-0x14fff */ @@ -300,7 +309,7 @@ static const signed char nonspacing_table_ind[240] = { -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1a000-0x1afff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1b000-0x1bfff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1c000-0x1cfff */ - 24, 25, -1, -1, -1, -1, -1, -1 /* 0x1d000-0x1dfff */ + 25, 26, -1, -1, -1, -1, -1, -1 /* 0x1d000-0x1dfff */ }; /* Determine number of column positions required for UC. */ @@ -334,8 +343,8 @@ uc_width (ucs4_t uc, const char *encoding) } } /* Test for double-width character. - * Generated from "grep '^....;[WF]' EastAsianWidth.txt" - * and "grep '^....;[^WF]' EastAsianWidth.txt" + * Generated from "grep '^[^;]\{4,5\};[WF]' EastAsianWidth.txt" + * and "grep '^[^;]\{4,5\};[^WF]' EastAsianWidth.txt" */ if (uc >= 0x1100 && ((uc < 0x1160) /* Hangul Jamo */ @@ -348,8 +357,8 @@ uc_width (ucs4_t uc, const char *encoding) || (uc >= 0xfe30 && uc < 0xfe70) /* CJK Compatibility Forms */ || (uc >= 0xff00 && uc < 0xff61) /* Fullwidth Forms */ || (uc >= 0xffe0 && uc < 0xffe7) /* Fullwidth Signs */ - || (uc >= 0x20000 && uc <= 0x2a6d6) /* CJK */ - || (uc >= 0x2f800 && uc <= 0x2fa1d) /* CJK Compatibility Ideographs */ + || (uc >= 0x20000 && uc <= 0x2ffff) /* Supplementary Ideographic Plane */ + || (uc >= 0x30000 && uc <= 0x3ffff) /* Tertiary Ideographic Plane */ ) ) return 2; /* In ancient CJK encodings, Cyrillic and most other characters are diff --git a/contrib/diffutils/lib/unlocked-io.h b/contrib/diffutils/lib/unlocked-io.h index 75bf89f6c9..901cbdd836 100644 --- a/contrib/diffutils/lib/unlocked-io.h +++ b/contrib/diffutils/lib/unlocked-io.h @@ -1,6 +1,6 @@ /* Prefer faster, non-thread-safe stdio functions if available. - Copyright (C) 2001-2004, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/verify.h b/contrib/diffutils/lib/verify.h index bcd3f5a09d..9a8caad001 100644 --- a/contrib/diffutils/lib/verify.h +++ b/contrib/diffutils/lib/verify.h @@ -1,6 +1,6 @@ /* Compile-time assert-like macros. - Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,21 +17,41 @@ /* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ -#ifndef VERIFY_H -# define VERIFY_H 1 +#ifndef _GL_VERIFY_H +# define _GL_VERIFY_H + + +/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per the + C1X draft N1548 section 6.7.10. This is supported by GCC 4.6.0 and + later, in C mode, and its use here generates easier-to-read diagnostics + when verify (R) fails. + + Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per the + C++0X draft N3242 section 7.(4). + This will likely be supported by future GCC versions, in C++ mode. + + Use this only with GCC. If we were willing to slow 'configure' + down we could also use it with other compilers, but since this + affects only the quality of diagnostics, why bother? */ +# if (4 < __GNUC__ || (__GNUC__ == 4 && 6 <= __GNUC_MINOR__)) && !defined __cplusplus +# define _GL_HAVE__STATIC_ASSERT 1 +# endif +/* The condition (99 < __GNUC__) is temporary, until we know about the + first G++ release that supports static_assert. */ +# if (99 < __GNUC__) && defined __cplusplus +# define _GL_HAVE_STATIC_ASSERT 1 +# endif /* Each of these macros verifies that its argument R is nonzero. To be portable, R should be an integer constant expression. Unlike assert (R), there is no run-time overhead. - There are two macros, since no single macro can be used in all - contexts in C. verify_true (R) is for scalar contexts, including - integer constant expression contexts. verify (R) is for declaration - contexts, e.g., the top level. - - Symbols ending in "__" are private to this header. + If _Static_assert works, verify (R) uses it directly. Similarly, + _GL_VERIFY_TRUE works by packaging a _Static_assert inside a struct + that is an operand of sizeof. - The code below uses several ideas. + The code below uses several ideas for C++ compilers, and for C + compilers that do not support _Static_assert: * The first step is ((R) ? 1 : -1). Given an expression R, of integral or boolean or floating-point type, this yields an @@ -39,7 +59,9 @@ constant and nonnegative. * Next this expression W is wrapped in a type - struct verify_type__ { unsigned int verify_error_if_negative_size__: W; }. + struct _gl_verify_type { + unsigned int _gl_verify_error_if_negative: W; + }. If W is negative, this yields a compile-time error. No compiler can deal with a bit-field of negative size. @@ -53,7 +75,7 @@ void function (int n) { verify (n < 0); } - * For the verify macro, the struct verify_type__ will need to + * For the verify macro, the struct _gl_verify_type will need to somehow be embedded into a declaration. To be portable, this declaration must declare an object, a constant, a function, or a typedef name. If the declared entity uses the type directly, @@ -69,13 +91,14 @@ if the entity names are not disambiguated. A workaround is to attach the current line number to the entity name: - #define GL_CONCAT0(x, y) x##y - #define GL_CONCAT(x, y) GL_CONCAT0 (x, y) - extern struct {...} * GL_CONCAT(dummy,__LINE__); + #define _GL_CONCAT0(x, y) x##y + #define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) + extern struct {...} * _GL_CONCAT (dummy, __LINE__); But this has the problem that two invocations of verify from within the same macro would collide, since the __LINE__ value - would be the same for both invocations. + would be the same for both invocations. (The GCC __COUNTER__ + macro solves this problem, but is not portable.) A solution is to use the sizeof operator. It yields a number, getting rid of the identity of the type. Declarations like @@ -90,11 +113,11 @@ Which of the following alternatives can be used? extern int dummy [sizeof (struct {...})]; - extern int dummy [sizeof (struct verify_type__ {...})]; + extern int dummy [sizeof (struct _gl_verify_type {...})]; extern void dummy (int [sizeof (struct {...})]); - extern void dummy (int [sizeof (struct verify_type__ {...})]); + extern void dummy (int [sizeof (struct _gl_verify_type {...})]); extern int (*dummy (void)) [sizeof (struct {...})]; - extern int (*dummy (void)) [sizeof (struct verify_type__ {...})]; + extern int (*dummy (void)) [sizeof (struct _gl_verify_type {...})]; In the second and sixth case, the struct type is exported to the outer scope; two such declarations therefore collide. GCC warns @@ -103,38 +126,118 @@ extern int (*dummy (void)) [sizeof (struct {...})]; - * This implementation exploits the fact that GCC does not warn about - the last declaration mentioned above. If a future version of GCC - introduces a warning for this, the problem could be worked around - by using code specialized to GCC, e.g.,: + * GCC warns about duplicate declarations of the dummy function if + -Wredundant_decls is used. GCC 4.3 and later have a builtin + __COUNTER__ macro that can let us generate unique identifiers for + each dummy function, to suppress this warning. - #if 4 <= __GNUC__ - # define verify(R) \ - extern int (* verify_function__ (void)) \ - [__builtin_constant_p (R) && (R) ? 1 : -1] - #endif + * This implementation exploits the fact that older versions of GCC, + which do not support _Static_assert, also do not warn about the + last declaration mentioned above. * In C++, any struct definition inside sizeof is invalid. Use a template type to work around the problem. */ +/* Concatenate two preprocessor tokens. */ +# define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) +# define _GL_CONCAT0(x, y) x##y -/* Verify requirement R at compile-time, as an integer constant expression. - Return 1. */ +/* _GL_COUNTER is an integer, preferably one that changes each time we + use it. Use __COUNTER__ if it works, falling back on __LINE__ + otherwise. __LINE__ isn't perfect, but it's better than a + constant. */ +# if defined __COUNTER__ && __COUNTER__ != __COUNTER__ +# define _GL_COUNTER __COUNTER__ +# else +# define _GL_COUNTER __LINE__ +# endif + +/* Generate a symbol with the given prefix, making it unique if + possible. */ +# define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER) + +/* Verify requirement R at compile-time, as an integer constant expression + that returns 1. If R is false, fail at compile-time, preferably + with a diagnostic that includes the string-literal DIAGNOSTIC. */ + +# define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \ + (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC))) # ifdef __cplusplus +# if !GNULIB_defined_struct__gl_verify_type template - struct verify_type__ { unsigned int verify_error_if_negative_size__: w; }; -# define verify_true(R) \ - (!!sizeof (verify_type__<(R) ? 1 : -1>)) + struct _gl_verify_type { + unsigned int _gl_verify_error_if_negative: w; + }; +# define GNULIB_defined_struct__gl_verify_type 1 +# endif +# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ + _gl_verify_type<(R) ? 1 : -1> +# elif defined _GL_HAVE__STATIC_ASSERT +# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ + struct { \ + _Static_assert (R, DIAGNOSTIC); \ + int _gl_dummy; \ + } +# else +# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ + struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; } +# endif + +/* Verify requirement R at compile-time, as a declaration without a + trailing ';'. If R is false, fail at compile-time, preferably + with a diagnostic that includes the string-literal DIAGNOSTIC. + + Unfortunately, unlike C1X, this implementation must appear as an + ordinary declaration, and cannot appear inside struct { ... }. */ + +# ifdef _GL_HAVE__STATIC_ASSERT +# define _GL_VERIFY _Static_assert # else -# define verify_true(R) \ - (!!sizeof \ - (struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; })) +# define _GL_VERIFY(R, DIAGNOSTIC) \ + extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ + [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] # endif +/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */ +# ifdef _GL_STATIC_ASSERT_H +# if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert +# define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC) +# endif +# if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert +# define static_assert _Static_assert /* Draft C1X requires this #define. */ +# endif +# endif + +/* @assert.h omit start@ */ + +/* Each of these macros verifies that its argument R is nonzero. To + be portable, R should be an integer constant expression. Unlike + assert (R), there is no run-time overhead. + + There are two macros, since no single macro can be used in all + contexts in C. verify_true (R) is for scalar contexts, including + integer constant expression contexts. verify (R) is for declaration + contexts, e.g., the top level. */ + +/* Verify requirement R at compile-time, as an integer constant expression. + Return 1. This is equivalent to verify_expr (R, 1). + + verify_true is obsolescent; please use verify_expr instead. */ + +# define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")") + +/* Verify requirement R at compile-time. Return the value of the + expression E. */ + +# define verify_expr(R, E) \ + (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E)) + /* Verify requirement R at compile-time, as a declaration without a trailing ';'. */ -# define verify(R) extern int (* verify_function__ (void)) [verify_true (R)] +# define verify(R) _GL_VERIFY (R, "verify (" #R ")") + +/* @assert.h omit end@ */ #endif diff --git a/contrib/diffutils/lib/version-etc-fsf.c b/contrib/diffutils/lib/version-etc-fsf.c index fc837a895d..c82158302c 100644 --- a/contrib/diffutils/lib/version-etc-fsf.c +++ b/contrib/diffutils/lib/version-etc-fsf.c @@ -1,5 +1,5 @@ /* Variable with FSF copyright information, for version-etc. - Copyright (C) 1999-2006, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 1999-2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/version-etc.c b/contrib/diffutils/lib/version-etc.c index 19c873d016..b8d4724b56 100644 --- a/contrib/diffutils/lib/version-etc.c +++ b/contrib/diffutils/lib/version-etc.c @@ -1,5 +1,5 @@ /* Print --version and bug-reporting information in a consistent format. - Copyright (C) 1999-2010 Free Software Foundation, Inc. + Copyright (C) 1999-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -38,7 +38,7 @@ # define PACKAGE PACKAGE_TARNAME #endif -enum { COPYRIGHT_YEAR = 2010 }; +enum { COPYRIGHT_YEAR = 2011 }; /* The three functions below display the --version information the standard way. diff --git a/contrib/diffutils/lib/version-etc.h b/contrib/diffutils/lib/version-etc.h index 629fe83013..a9b313d23a 100644 --- a/contrib/diffutils/lib/version-etc.h +++ b/contrib/diffutils/lib/version-etc.h @@ -1,5 +1,5 @@ /* Print --version and bug-reporting information in a consistent format. - Copyright (C) 1999, 2003, 2005, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 1999, 2003, 2005, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,11 +23,11 @@ # include /* The `sentinel' attribute was added in gcc 4.0. */ -#ifndef ATTRIBUTE_SENTINEL +#ifndef _GL_ATTRIBUTE_SENTINEL # if 4 <= __GNUC__ -# define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__)) +# define _GL_ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__)) # else -# define ATTRIBUTE_SENTINEL /* empty */ +# define _GL_ATTRIBUTE_SENTINEL /* empty */ # endif #endif @@ -70,7 +70,7 @@ extern void version_etc (FILE *stream, const char *command_name, const char *package, const char *version, /* const char *author1, ..., NULL */ ...) - ATTRIBUTE_SENTINEL; + _GL_ATTRIBUTE_SENTINEL; /* Display the usual `Report bugs to' stanza */ extern void emit_bug_reporting_address (void); diff --git a/contrib/diffutils/lib/wcwidth.c b/contrib/diffutils/lib/wcwidth.c index 66b5b15e0b..a006ca7a83 100644 --- a/contrib/diffutils/lib/wcwidth.c +++ b/contrib/diffutils/lib/wcwidth.c @@ -1,5 +1,5 @@ /* Determine the number of screen columns needed for a character. - Copyright (C) 2006-2007, 2010 Free Software Foundation, Inc. + Copyright (C) 2006-2007, 2010-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/xalloc-die.c b/contrib/diffutils/lib/xalloc-die.c index 4b220403b0..80b4194345 100644 --- a/contrib/diffutils/lib/xalloc-die.c +++ b/contrib/diffutils/lib/xalloc-die.c @@ -1,7 +1,7 @@ /* Report a memory allocation failure and exit. - Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2006, 2009, 2010 - Free Software Foundation, Inc. + Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2011 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,7 +33,7 @@ xalloc_die (void) { error (exit_failure, 0, "%s", _("memory exhausted")); - /* The `noreturn' cannot be given to error, since it may return if + /* _Noreturn cannot be given to error, since it may return if its first argument is 0. To help compilers understand the xalloc_die does not return, call abort. Also, the abort is a safety feature if exit_failure is 0 (which shouldn't happen). */ diff --git a/contrib/diffutils/lib/xalloc-oversized.h b/contrib/diffutils/lib/xalloc-oversized.h new file mode 100644 index 0000000000..ab19bcf2f9 --- /dev/null +++ b/contrib/diffutils/lib/xalloc-oversized.h @@ -0,0 +1,38 @@ +/* xalloc-oversized.h -- memory allocation size checking + + Copyright (C) 1990-2000, 2003-2004, 2006-2011 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef XALLOC_OVERSIZED_H_ +# define XALLOC_OVERSIZED_H_ + +# include + +/* Return 1 if an array of N objects, each of size S, cannot exist due + to size arithmetic overflow. S must be positive and N must be + nonnegative. This is a macro, not an inline function, so that it + works correctly even when SIZE_MAX < N. + + By gnulib convention, SIZE_MAX represents overflow in size + calculations, so the conservative dividend to use here is + SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value. + However, malloc (SIZE_MAX) fails on all known hosts where + sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for + exactly-SIZE_MAX allocations on such hosts; this avoids a test and + branch when S is known to be 1. */ +# define xalloc_oversized(n, s) \ + ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n)) + +#endif /* !XALLOC_OVERSIZED_H_ */ diff --git a/contrib/diffutils/lib/xalloc.h b/contrib/diffutils/lib/xalloc.h index 6122cc58b0..987791bf2a 100644 --- a/contrib/diffutils/lib/xalloc.h +++ b/contrib/diffutils/lib/xalloc.h @@ -1,8 +1,6 @@ /* xalloc.h -- malloc with out-of-memory checking - Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2003, 2004, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, - Inc. + Copyright (C) 1990-2000, 2003-2004, 2006-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,28 +20,23 @@ # include +# include "xalloc-oversized.h" # ifdef __cplusplus extern "C" { # endif -# ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) -# define __attribute__(x) -# endif -# endif - -# ifndef ATTRIBUTE_NORETURN -# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +# if __GNUC__ >= 3 +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define _GL_ATTRIBUTE_MALLOC # endif -# ifndef ATTRIBUTE_MALLOC -# if __GNUC__ >= 3 -# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) -# else -# define ATTRIBUTE_MALLOC -# endif +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) +# else +# define _GL_ATTRIBUTE_ALLOC_SIZE(args) # endif /* This function is always triggered when memory is exhausted. @@ -51,31 +44,21 @@ extern "C" { or by using gnulib's xalloc-die module. This is the function to call when one wants the program to die because of a memory allocation failure. */ -extern void xalloc_die (void) ATTRIBUTE_NORETURN; - -void *xmalloc (size_t s) ATTRIBUTE_MALLOC; -void *xzalloc (size_t s) ATTRIBUTE_MALLOC; -void *xcalloc (size_t n, size_t s) ATTRIBUTE_MALLOC; -void *xrealloc (void *p, size_t s); +extern _Noreturn void xalloc_die (void); + +void *xmalloc (size_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); +void *xzalloc (size_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); +void *xcalloc (size_t n, size_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)); +void *xrealloc (void *p, size_t s) + _GL_ATTRIBUTE_ALLOC_SIZE ((2)); void *x2realloc (void *p, size_t *pn); -void *xmemdup (void const *p, size_t s) ATTRIBUTE_MALLOC; -char *xstrdup (char const *str) ATTRIBUTE_MALLOC; - -/* Return 1 if an array of N objects, each of size S, cannot exist due - to size arithmetic overflow. S must be positive and N must be - nonnegative. This is a macro, not an inline function, so that it - works correctly even when SIZE_MAX < N. - - By gnulib convention, SIZE_MAX represents overflow in size - calculations, so the conservative dividend to use here is - SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value. - However, malloc (SIZE_MAX) fails on all known hosts where - sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for - exactly-SIZE_MAX allocations on such hosts; this avoids a test and - branch when S is known to be 1. */ -# define xalloc_oversized(n, s) \ - ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n)) - +void *xmemdup (void const *p, size_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((2)); +char *xstrdup (char const *str) + _GL_ATTRIBUTE_MALLOC; /* In the following macros, T must be an elementary or structure/union or typedef'ed type, or a pointer to such a type. To apply one of the @@ -106,10 +89,13 @@ char *xstrdup (char const *str) ATTRIBUTE_MALLOC; # if HAVE_INLINE # define static_inline static inline # else -void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC; -void *xnrealloc (void *p, size_t n, size_t s); +void *xnmalloc (size_t n, size_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)); +void *xnrealloc (void *p, size_t n, size_t s) + _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3)); void *x2nrealloc (void *p, size_t *pn, size_t s); -char *xcharalloc (size_t n) ATTRIBUTE_MALLOC; +char *xcharalloc (size_t n) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); # endif # ifdef static_inline @@ -117,7 +103,8 @@ char *xcharalloc (size_t n) ATTRIBUTE_MALLOC; /* Allocate an array of N objects, each with S bytes of memory, dynamically, with error checking. S must be nonzero. */ -static_inline void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC; +static_inline void *xnmalloc (size_t n, size_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)); static_inline void * xnmalloc (size_t n, size_t s) { @@ -129,6 +116,8 @@ xnmalloc (size_t n, size_t s) /* Change the size of an allocated block of memory P to an array of N objects each of S bytes, with error checking. S must be nonzero. */ +static_inline void *xnrealloc (void *p, size_t n, size_t s) + _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3)); static_inline void * xnrealloc (void *p, size_t n, size_t s) { @@ -203,9 +192,9 @@ x2nrealloc (void *p, size_t *pn, size_t s) { /* The approximate size to use for initial small allocation requests, when the invoking code specifies an old size of - zero. 64 bytes is the largest "small" request for the - GNU C library malloc. */ - enum { DEFAULT_MXFAST = 64 }; + zero. This is the largest "small" request for the GNU C + library malloc. */ + enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 }; n = DEFAULT_MXFAST / s; n += !n; @@ -229,7 +218,8 @@ x2nrealloc (void *p, size_t *pn, size_t s) /* Return a pointer to a new buffer of N bytes. This is like xmalloc, except it returns char *. */ -static_inline char *xcharalloc (size_t n) ATTRIBUTE_MALLOC; +static_inline char *xcharalloc (size_t n) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); static_inline char * xcharalloc (size_t n) { diff --git a/contrib/diffutils/lib/xfreopen.c b/contrib/diffutils/lib/xfreopen.c index 297bda4e0f..33a2b5703a 100644 --- a/contrib/diffutils/lib/xfreopen.c +++ b/contrib/diffutils/lib/xfreopen.c @@ -1,5 +1,5 @@ /* a wrapper for frepoen - Copyright (C) 2008-2010 Free Software Foundation, Inc. + Copyright (C) 2008-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/xmalloc.c b/contrib/diffutils/lib/xmalloc.c index ecce529690..08c30fb8a3 100644 --- a/contrib/diffutils/lib/xmalloc.c +++ b/contrib/diffutils/lib/xmalloc.c @@ -1,8 +1,6 @@ /* xmalloc.c -- malloc with out of memory checking - Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 Free Software - Foundation, Inc. + Copyright (C) 1990-2000, 2002-2006, 2008-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,8 +28,8 @@ /* 1 if calloc is known to be compatible with GNU calloc. This matters if we are not also using the calloc module, which defines - HAVE_CALLOC and supports the GNU API even on non-GNU platforms. */ -#if defined HAVE_CALLOC || defined __GLIBC__ + HAVE_CALLOC_GNU and supports the GNU API even on non-GNU platforms. */ +#if defined HAVE_CALLOC_GNU || (defined __GLIBC__ && !defined __UCLIBC__) enum { HAVE_GNU_CALLOC = 1 }; #else enum { HAVE_GNU_CALLOC = 0 }; @@ -54,8 +52,16 @@ xmalloc (size_t n) void * xrealloc (void *p, size_t n) { + if (!n && p) + { + /* The GNU and C99 realloc behaviors disagree here. Act like + GNU, even if the underlying realloc is C99. */ + free (p); + return NULL; + } + p = realloc (p, n); - if (!p && n != 0) + if (!p && n) xalloc_die (); return p; } diff --git a/contrib/diffutils/lib/xstriconv.c b/contrib/diffutils/lib/xstriconv.c index 7c8c142149..9e4498fa5c 100644 --- a/contrib/diffutils/lib/xstriconv.c +++ b/contrib/diffutils/lib/xstriconv.c @@ -1,5 +1,5 @@ /* Charset conversion with out-of-memory checking. - Copyright (C) 2001-2004, 2006, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006, 2009-2011 Free Software Foundation, Inc. Written by Bruno Haible. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/xstriconv.h b/contrib/diffutils/lib/xstriconv.h index 72b2aa370c..eba6b167ab 100644 --- a/contrib/diffutils/lib/xstriconv.h +++ b/contrib/diffutils/lib/xstriconv.h @@ -1,5 +1,5 @@ /* Charset conversion with out-of-memory checking. - Copyright (C) 2001-2004, 2006-2007, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006-2007, 2009-2011 Free Software Foundation, Inc. Written by Bruno Haible and Simon Josefsson. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/xstrndup.c b/contrib/diffutils/lib/xstrndup.c index 414f9f4f95..d58302a13d 100644 --- a/contrib/diffutils/lib/xstrndup.c +++ b/contrib/diffutils/lib/xstrndup.c @@ -1,6 +1,6 @@ /* Duplicate a bounded initial segment of a string, with out-of-memory checking. - Copyright (C) 2003, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2003, 2006-2007, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/xstrndup.h b/contrib/diffutils/lib/xstrndup.h index 009fdb0864..f96a538dfd 100644 --- a/contrib/diffutils/lib/xstrndup.h +++ b/contrib/diffutils/lib/xstrndup.h @@ -1,6 +1,6 @@ /* Duplicate a bounded initial segment of a string, with out-of-memory checking. - Copyright (C) 2003, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2003, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/diffutils/lib/xstrtol-error.c b/contrib/diffutils/lib/xstrtol-error.c index 014fc1c570..52e712c10b 100644 --- a/contrib/diffutils/lib/xstrtol-error.c +++ b/contrib/diffutils/lib/xstrtol-error.c @@ -1,6 +1,6 @@ /* A more useful interface to strtol. - Copyright (C) 1995-1996, 1998-1999, 2001-2004, 2006-2010 Free Software + Copyright (C) 1995-1996, 1998-1999, 2001-2004, 2006-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/xstrtol.c b/contrib/diffutils/lib/xstrtol.c index 43f5ada719..97ebd9078b 100644 --- a/contrib/diffutils/lib/xstrtol.c +++ b/contrib/diffutils/lib/xstrtol.c @@ -1,6 +1,6 @@ /* A more useful interface to strtol. - Copyright (C) 1995-1996, 1998-2001, 2003-2007, 2009-2010 Free Software + Copyright (C) 1995-1996, 1998-2001, 2003-2007, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/diffutils/lib/xstrtol.h b/contrib/diffutils/lib/xstrtol.h index 3a94a9c6da..ad134ab8b4 100644 --- a/contrib/diffutils/lib/xstrtol.h +++ b/contrib/diffutils/lib/xstrtol.h @@ -1,6 +1,6 @@ /* A more useful interface to strtol. - Copyright (C) 1995-1996, 1998-1999, 2001-2004, 2006-2010 Free Software + Copyright (C) 1995-1996, 1998-1999, 2001-2004, 2006-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -51,16 +51,6 @@ _DECLARE_XSTRTOL (xstrtoll, long long int) _DECLARE_XSTRTOL (xstrtoull, unsigned long long int) #endif -#ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) -# define __attribute__(x) -# endif -#endif - -#ifndef ATTRIBUTE_NORETURN -# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) -#endif - /* Report an error for an invalid integer in an option argument. ERR is the error code returned by one of the xstrto* functions. @@ -76,8 +66,8 @@ _DECLARE_XSTRTOL (xstrtoull, unsigned long long int) After reporting an error, exit with a failure status. */ -void xstrtol_fatal (enum strtol_error, - int, char, struct option const *, - char const *) ATTRIBUTE_NORETURN; +void _Noreturn xstrtol_fatal (enum strtol_error, + int, char, struct option const *, + char const *); #endif /* not XSTRTOL_H_ */ diff --git a/contrib/diffutils/man/diff.1 b/contrib/diffutils/man/diff.1 index 718b891bc1..bf2a98cc24 100644 --- a/contrib/diffutils/man/diff.1 +++ b/contrib/diffutils/man/diff.1 @@ -1,98 +1,149 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. -.TH DIFF "1" "April 2010" "diffutils 2.9.19-4065" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.39.2. +.TH DIFF "1" "September 2011" "diffutils 3.2" "User Commands" .SH NAME diff \- compare files line by line .SH SYNOPSIS .B diff [\fIOPTION\fR]... \fIFILES\fR .SH DESCRIPTION -Compare files line by line. +Compare FILES line by line. +.PP +Mandatory arguments to long options are mandatory for short options too. .TP -\fB\-i\fR \fB\-\-ignore\-case\fR -Ignore case differences in file contents. +\fB\-\-normal\fR +output a normal diff (the default) .TP -\fB\-\-ignore\-file\-name\-case\fR -Ignore case when comparing file names. +\fB\-q\fR, \fB\-\-brief\fR +report only when files differ .TP -\fB\-\-no\-ignore\-file\-name\-case\fR -Consider case when comparing file names. +\fB\-s\fR, \fB\-\-report\-identical\-files\fR +report when two files are the same .TP -\fB\-E\fR \fB\-\-ignore\-tab\-expansion\fR -Ignore changes due to tab expansion. +\fB\-c\fR, \fB\-C\fR NUM, \fB\-\-context\fR[=\fINUM\fR] +output NUM (default 3) lines of copied context .TP -\fB\-b\fR \fB\-\-ignore\-space\-change\fR -Ignore changes in the amount of white space. +\fB\-u\fR, \fB\-U\fR NUM, \fB\-\-unified\fR[=\fINUM\fR] +output NUM (default 3) lines of unified context .TP -\fB\-w\fR \fB\-\-ignore\-all\-space\fR -Ignore all white space. +\fB\-e\fR, \fB\-\-ed\fR +output an ed script .TP -\fB\-B\fR \fB\-\-ignore\-blank\-lines\fR -Ignore changes whose lines are all blank. +\fB\-n\fR, \fB\-\-rcs\fR +output an RCS format diff .TP -\fB\-I\fR RE \fB\-\-ignore\-matching\-lines\fR=\fIRE\fR -Ignore changes whose lines all match RE. +\fB\-y\fR, \fB\-\-side\-by\-side\fR +output in two columns .TP -\fB\-\-strip\-trailing\-cr\fR -Strip trailing carriage return on input. +\fB\-W\fR, \fB\-\-width\fR=\fINUM\fR +output at most NUM (default 130) print columns +.TP +\fB\-\-left\-column\fR +output only the left column of common lines .TP -\fB\-a\fR \fB\-\-text\fR -Treat all files as text. +\fB\-\-suppress\-common\-lines\fR +do not output common lines .TP -\fB\-c\fR \fB\-C\fR NUM \fB\-\-context\fR[=\fINUM\fR] -Output NUM (default 3) lines of copied context. +\fB\-p\fR, \fB\-\-show\-c\-function\fR +show which C function each change is in .TP -\fB\-u\fR \fB\-U\fR NUM \fB\-\-unified\fR[=\fINUM\fR] -Output NUM (default 3) lines of unified context. +\fB\-F\fR, \fB\-\-show\-function\-line\fR=\fIRE\fR +show the most recent line matching RE .TP \fB\-\-label\fR LABEL -Use LABEL instead of file name. +use LABEL instead of file name +(can be repeated) .TP -\fB\-p\fR \fB\-\-show\-c\-function\fR -Show which C function each change is in. +\fB\-t\fR, \fB\-\-expand\-tabs\fR +expand tabs to spaces in output .TP -\fB\-F\fR RE \fB\-\-show\-function\-line\fR=\fIRE\fR -Show the most recent line matching RE. +\fB\-T\fR, \fB\-\-initial\-tab\fR +make tabs line up by prepending a tab .TP -\fB\-q\fR \fB\-\-brief\fR -Output only whether files differ. +\fB\-\-tabsize\fR=\fINUM\fR +tab stops every NUM (default 8) print columns .TP -\fB\-e\fR \fB\-\-ed\fR -Output an ed script. +\fB\-\-suppress\-blank\-empty\fR +suppress space or tab before empty output lines .TP -\fB\-\-normal\fR -Output a normal diff. +\fB\-l\fR, \fB\-\-paginate\fR +pass output through `pr' to paginate it .TP -\fB\-n\fR \fB\-\-rcs\fR -Output an RCS format diff. +\fB\-r\fR, \fB\-\-recursive\fR +recursively compare any subdirectories found .TP -\fB\-y\fR \fB\-\-side\-by\-side\fR -Output in two columns. +\fB\-N\fR, \fB\-\-new\-file\fR +treat absent files as empty .TP -\fB\-W\fR NUM \fB\-\-width\fR=\fINUM\fR -Output at most NUM (default 130) print columns. +\fB\-\-unidirectional\-new\-file\fR +treat absent first files as empty .TP -\fB\-\-left\-column\fR -Output only the left column of common lines. +\fB\-\-ignore\-file\-name\-case\fR +ignore case when comparing file names .TP -\fB\-\-suppress\-common\-lines\fR -Do not output common lines. +\fB\-\-no\-ignore\-file\-name\-case\fR +consider case when comparing file names +.TP +\fB\-x\fR, \fB\-\-exclude\fR=\fIPAT\fR +exclude files that match PAT +.TP +\fB\-X\fR, \fB\-\-exclude\-from\fR=\fIFILE\fR +exclude files that match any pattern in FILE +.TP +\fB\-S\fR, \fB\-\-starting\-file\fR=\fIFILE\fR +start with FILE when comparing directories +.TP +\fB\-\-from\-file\fR=\fIFILE1\fR +compare FILE1 to all operands; +FILE1 can be a directory +.TP +\fB\-\-to\-file\fR=\fIFILE2\fR +compare all operands to FILE2; +FILE2 can be a directory +.TP +\fB\-i\fR, \fB\-\-ignore\-case\fR +ignore case differences in file contents +.TP +\fB\-E\fR, \fB\-\-ignore\-tab\-expansion\fR +ignore changes due to tab expansion +.TP +\fB\-b\fR, \fB\-\-ignore\-space\-change\fR +ignore changes in the amount of white space +.TP +\fB\-w\fR, \fB\-\-ignore\-all\-space\fR +ignore all white space +.TP +\fB\-B\fR, \fB\-\-ignore\-blank\-lines\fR +ignore changes whose lines are all blank +.TP +\fB\-I\fR, \fB\-\-ignore\-matching\-lines\fR=\fIRE\fR +ignore changes whose lines all match RE .TP -\fB\-D\fR NAME \fB\-\-ifdef\fR=\fINAME\fR -Output merged file to show `#ifdef NAME' diffs. +\fB\-a\fR, \fB\-\-text\fR +treat all files as text +.TP +\fB\-\-strip\-trailing\-cr\fR +strip trailing carriage return on input +.TP +\fB\-D\fR, \fB\-\-ifdef\fR=\fINAME\fR +output merged file with `#ifdef NAME' diffs .TP \fB\-\-GTYPE\-group\-format\fR=\fIGFMT\fR -Similar, but format GTYPE input groups with GFMT. +format GTYPE input groups with GFMT .TP \fB\-\-line\-format\fR=\fILFMT\fR -Similar, but format all input lines with LFMT. +format all input lines with LFMT .TP \fB\-\-LTYPE\-line\-format\fR=\fILFMT\fR -Similar, but format LTYPE input lines with LFMT. +format LTYPE input lines with LFMT +.IP +These format options provide fine\-grained control over the output +.IP +of diff, generalizing \fB\-D\fR/\-\-ifdef. .TP LTYPE is `old', `new', or `unchanged'. GTYPE is LTYPE or `changed'. .IP -GFMT may contain: +GFMT (only) may contain: .TP %< lines from FILE1 @@ -122,8 +173,11 @@ F\-1 .TP M L+1 +.TP +%(A=B?T:E) +if A equals B then T else E .IP -LFMT may contain: +LFMT (only) may contain: .TP %L contents of line @@ -134,7 +188,7 @@ contents of line, excluding any trailing newline %[\-][WIDTH][.[PREC]]{doxX}n printf\-style spec for input line number .IP -Either GFMT or LFMT may contain: +Both GFMT and LFMT may contain: .TP %% % @@ -145,65 +199,26 @@ the single character C %c'\eOOO' the character with octal code OOO .TP -\fB\-l\fR \fB\-\-paginate\fR -Pass the output through `pr' to paginate it. -.TP -\fB\-t\fR \fB\-\-expand\-tabs\fR -Expand tabs to spaces in output. -.TP -\fB\-T\fR \fB\-\-initial\-tab\fR -Make tabs line up by prepending a tab. +C +the character C (other characters represent themselves) .TP -\fB\-\-tabsize\fR=\fINUM\fR -Tab stops are every NUM (default 8) print columns. -.TP -\fB\-\-suppress\-blank\-empty\fR -Suppress space or tab before empty output lines. -.TP -\fB\-r\fR \fB\-\-recursive\fR -Recursively compare any subdirectories found. -.TP -\fB\-N\fR \fB\-\-new\-file\fR -Treat absent files as empty. -.TP -\fB\-\-unidirectional\-new\-file\fR -Treat absent first files as empty. -.TP -\fB\-s\fR \fB\-\-report\-identical\-files\fR -Report when two files are the same. -.TP -\fB\-x\fR PAT \fB\-\-exclude\fR=\fIPAT\fR -Exclude files that match PAT. -.TP -\fB\-X\fR FILE \fB\-\-exclude\-from\fR=\fIFILE\fR -Exclude files that match any pattern in FILE. -.TP -\fB\-S\fR FILE \fB\-\-starting\-file\fR=\fIFILE\fR -Start with FILE when comparing directories. -.TP -\fB\-\-from\-file\fR=\fIFILE1\fR -Compare FILE1 to all operands. FILE1 can be a directory. -.TP -\fB\-\-to\-file\fR=\fIFILE2\fR -Compare all operands to FILE2. FILE2 can be a directory. +\fB\-d\fR, \fB\-\-minimal\fR +try hard to find a smaller set of changes .TP \fB\-\-horizon\-lines\fR=\fINUM\fR -Keep NUM lines of the common prefix and suffix. -.TP -\fB\-d\fR \fB\-\-minimal\fR -Try hard to find a smaller set of changes. +keep NUM lines of the common prefix and suffix .TP \fB\-\-speed\-large\-files\fR -Assume large files and many scattered small changes. -.TP -\fB\-v\fR \fB\-\-version\fR -Output version info. +assume large files and many scattered small changes .TP \fB\-\-help\fR -Output this help. +display this help and exit +.TP +\fB\-v\fR, \fB\-\-version\fR +output version information and exit .PP FILES are `FILE1 FILE2' or `DIR1 DIR2' or `DIR FILE...' or `FILE... DIR'. -If \fB\-\-from\-file\fR or \fB\-\-to\-file\fR is given, there are no restrictions on FILES. +If \fB\-\-from\-file\fR or \fB\-\-to\-file\fR is given, there are no restrictions on FILE(s). If a FILE is `\-', read standard input. Exit status is 0 if inputs are the same, 1 if different, 2 if trouble. .SH AUTHOR @@ -211,15 +226,19 @@ Written by Paul Eggert, Mike Haertel, David Hayes, Richard Stallman, and Len Tower. .SH "REPORTING BUGS" Report bugs to: bug\-diffutils@gnu.org +.br GNU diffutils home page: +.br General help using GNU software: .SH COPYRIGHT -Copyright \(co 2010 Free Software Foundation, Inc. +Copyright \(co 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH "SEE ALSO" +wdiff(1), cmp(1), diff3(1), sdiff(1), patch(1) +.PP The full documentation for .B diff is maintained as a Texinfo manual. If the diff --git a/contrib/diffutils/man/diff3.1 b/contrib/diffutils/man/diff3.1 index 270020fab1..d265e8523f 100644 --- a/contrib/diffutils/man/diff3.1 +++ b/contrib/diffutils/man/diff3.1 @@ -1,5 +1,5 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. -.TH DIFF3 "1" "April 2010" "diffutils 2.9.19-4065" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.39.2. +.TH DIFF3 "1" "September 2011" "diffutils 3.2" "User Commands" .SH NAME diff3 \- compare three files line by line .SH SYNOPSIS @@ -7,51 +7,66 @@ diff3 \- compare three files line by line [\fIOPTION\fR]... \fIMYFILE OLDFILE YOURFILE\fR .SH DESCRIPTION Compare three files line by line. +.PP +Mandatory arguments to long options are mandatory for short options too. .TP -\fB\-e\fR \fB\-\-ed\fR -Output unmerged changes from OLDFILE to YOURFILE into MYFILE. -.TP -\fB\-E\fR \fB\-\-show\-overlap\fR -Output unmerged changes, bracketing conflicts. -.TP -\fB\-A\fR \fB\-\-show\-all\fR -Output all changes, bracketing conflicts. +\fB\-A\fR, \fB\-\-show\-all\fR +output all changes, bracketing conflicts .TP -\fB\-x\fR \fB\-\-overlap\-only\fR -Output overlapping changes. +\fB\-e\fR, \fB\-\-ed\fR +output ed script incorporating changes +from OLDFILE to YOURFILE into MYFILE .TP -\fB\-X\fR -Output overlapping changes, bracketing them. +\fB\-E\fR, \fB\-\-show\-overlap\fR +like \fB\-e\fR, but bracket conflicts .TP -\fB\-3\fR \fB\-\-easy\-only\fR -Output unmerged nonoverlapping changes. +\fB\-3\fR, \fB\-\-easy\-only\fR +like \fB\-e\fR, but incorporate only nonoverlapping changes .TP -\fB\-m\fR \fB\-\-merge\fR -Output merged file instead of ed script (default \fB\-A\fR). +\fB\-x\fR, \fB\-\-overlap\-only\fR +like \fB\-e\fR, but incorporate only overlapping changes .TP -\fB\-L\fR LABEL \fB\-\-label\fR=\fILABEL\fR -Use LABEL instead of file name. +\fB\-X\fR +like \fB\-x\fR, but bracket conflicts .TP \fB\-i\fR -Append `w' and `q' commands to ed scripts. +append `w' and `q' commands to ed scripts +.TP +\fB\-m\fR, \fB\-\-merge\fR +output actual merged file, according to +\fB\-A\fR if no other options are given .TP -\fB\-a\fR \fB\-\-text\fR -Treat all files as text. +\fB\-a\fR, \fB\-\-text\fR +treat all files as text .TP \fB\-\-strip\-trailing\-cr\fR -Strip trailing carriage return on input. +strip trailing carriage return on input .TP -\fB\-T\fR \fB\-\-initial\-tab\fR -Make tabs line up by prepending a tab. +\fB\-T\fR, \fB\-\-initial\-tab\fR +make tabs line up by prepending a tab .TP \fB\-\-diff\-program\fR=\fIPROGRAM\fR -Use PROGRAM to compare files. +use PROGRAM to compare files .TP -\fB\-v\fR \fB\-\-version\fR -Output version info. +\fB\-L\fR, \fB\-\-label\fR=\fILABEL\fR +use LABEL instead of file name +(can be repeated up to three times) .TP \fB\-\-help\fR -Output this help. +display this help and exit +.TP +\fB\-v\fR, \fB\-\-version\fR +output version information and exit +.PP +The default output format is a somewhat human\-readable representation of +the changes. +.PP +The \fB\-e\fR, \fB\-E\fR, \fB\-x\fR, \fB\-X\fR (and corresponding long) options cause an ed script +to be output instead of the default. +.PP +Finally, the \fB\-m\fR (\fB\-\-merge\fR) option causes diff3 to do the merge internally +and output the actual merged file. For unusual input, this is more +robust than using ed. .PP If a FILE is `\-', read standard input. Exit status is 0 if successful, 1 if conflicts, 2 if trouble. @@ -59,15 +74,19 @@ Exit status is 0 if successful, 1 if conflicts, 2 if trouble. Written by Randy Smith. .SH "REPORTING BUGS" Report bugs to: bug\-diffutils@gnu.org +.br GNU diffutils home page: +.br General help using GNU software: .SH COPYRIGHT -Copyright \(co 2010 Free Software Foundation, Inc. +Copyright \(co 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH "SEE ALSO" +cmp(1), diff(1), sdiff(1) +.PP The full documentation for .B diff3 is maintained as a Texinfo manual. If the @@ -76,6 +95,6 @@ and .B diff3 programs are properly installed at your site, the command .IP -.B info diff +.B info diff3 .PP should give you access to the complete manual. diff --git a/contrib/diffutils/man/sdiff.1 b/contrib/diffutils/man/sdiff.1 index 3af194fdd5..8d793727c3 100644 --- a/contrib/diffutils/man/sdiff.1 +++ b/contrib/diffutils/man/sdiff.1 @@ -1,69 +1,71 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. -.TH SDIFF "1" "April 2010" "diffutils 2.9.19-4065" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.39.2. +.TH SDIFF "1" "September 2011" "diffutils 3.2" "User Commands" .SH NAME sdiff \- side-by-side merge of file differences .SH SYNOPSIS .B sdiff [\fIOPTION\fR]... \fIFILE1 FILE2\fR .SH DESCRIPTION -Side\-by\-side merge of file differences. +Side\-by\-side merge of differences between FILE1 and FILE2. +.PP +Mandatory arguments to long options are mandatory for short options too. .TP -\fB\-o\fR FILE \fB\-\-output\fR=\fIFILE\fR -Operate interactively, sending output to FILE. +\fB\-o\fR, \fB\-\-output\fR=\fIFILE\fR +operate interactively, sending output to FILE .TP -\fB\-i\fR \fB\-\-ignore\-case\fR -Consider upper\- and lower\-case to be the same. +\fB\-i\fR, \fB\-\-ignore\-case\fR +consider upper\- and lower\-case to be the same .TP -\fB\-E\fR \fB\-\-ignore\-tab\-expansion\fR -Ignore changes due to tab expansion. +\fB\-E\fR, \fB\-\-ignore\-tab\-expansion\fR +ignore changes due to tab expansion .TP -\fB\-b\fR \fB\-\-ignore\-space\-change\fR -Ignore changes in the amount of white space. +\fB\-b\fR, \fB\-\-ignore\-space\-change\fR +ignore changes in the amount of white space .TP -\fB\-W\fR \fB\-\-ignore\-all\-space\fR -Ignore all white space. +\fB\-W\fR, \fB\-\-ignore\-all\-space\fR +ignore all white space .TP -\fB\-B\fR \fB\-\-ignore\-blank\-lines\fR -Ignore changes whose lines are all blank. +\fB\-B\fR, \fB\-\-ignore\-blank\-lines\fR +ignore changes whose lines are all blank .TP -\fB\-I\fR RE \fB\-\-ignore\-matching\-lines\fR=\fIRE\fR -Ignore changes whose lines all match RE. +\fB\-I\fR, \fB\-\-ignore\-matching\-lines\fR=\fIRE\fR +ignore changes whose lines all match RE .TP \fB\-\-strip\-trailing\-cr\fR -Strip trailing carriage return on input. +strip trailing carriage return on input .TP -\fB\-a\fR \fB\-\-text\fR -Treat all files as text. +\fB\-a\fR, \fB\-\-text\fR +treat all files as text .TP -\fB\-w\fR NUM \fB\-\-width\fR=\fINUM\fR -Output at most NUM (default 130) print columns. +\fB\-w\fR, \fB\-\-width\fR=\fINUM\fR +output at most NUM (default 130) print columns .TP -\fB\-l\fR \fB\-\-left\-column\fR -Output only the left column of common lines. +\fB\-l\fR, \fB\-\-left\-column\fR +output only the left column of common lines .TP -\fB\-s\fR \fB\-\-suppress\-common\-lines\fR -Do not output common lines. +\fB\-s\fR, \fB\-\-suppress\-common\-lines\fR +do not output common lines .TP -\fB\-t\fR \fB\-\-expand\-tabs\fR -Expand tabs to spaces in output. +\fB\-t\fR, \fB\-\-expand\-tabs\fR +expand tabs to spaces in output .TP \fB\-\-tabsize\fR=\fINUM\fR -Tab stops are every NUM (default 8) print columns. +tab stops at every NUM (default 8) print columns .TP -\fB\-d\fR \fB\-\-minimal\fR -Try hard to find a smaller set of changes. +\fB\-d\fR, \fB\-\-minimal\fR +try hard to find a smaller set of changes .TP -\fB\-H\fR \fB\-\-speed\-large\-files\fR -Assume large files and many scattered small changes. +\fB\-H\fR, \fB\-\-speed\-large\-files\fR +assume large files, many scattered small changes .TP \fB\-\-diff\-program\fR=\fIPROGRAM\fR -Use PROGRAM to compare files. -.TP -\fB\-v\fR \fB\-\-version\fR -Output version info. +use PROGRAM to compare files .TP \fB\-\-help\fR -Output this help. +display this help and exit +.TP +\fB\-v\fR, \fB\-\-version\fR +output version information and exit .PP If a FILE is `\-', read standard input. Exit status is 0 if inputs are the same, 1 if different, 2 if trouble. @@ -71,15 +73,19 @@ Exit status is 0 if inputs are the same, 1 if different, 2 if trouble. Written by Thomas Lord. .SH "REPORTING BUGS" Report bugs to: bug\-diffutils@gnu.org +.br GNU diffutils home page: +.br General help using GNU software: .SH COPYRIGHT -Copyright \(co 2010 Free Software Foundation, Inc. +Copyright \(co 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH "SEE ALSO" +cmp(1), diff(1), diff3(1) +.PP The full documentation for .B sdiff is maintained as a Texinfo manual. If the @@ -88,6 +94,6 @@ and .B sdiff programs are properly installed at your site, the command .IP -.B info diff +.B info sdiff .PP should give you access to the complete manual. diff --git a/contrib/diffutils/src/analyze.c b/contrib/diffutils/src/analyze.c index e7972487d2..f88c45e400 100644 --- a/contrib/diffutils/src/analyze.c +++ b/contrib/diffutils/src/analyze.c @@ -1,7 +1,7 @@ /* Analyze file differences for GNU DIFF. Copyright (C) 1988-1989, 1992-1995, 1998, 2001-2002, 2004, 2006-2007, - 2009-2010 Free Software Foundation, Inc. + 2009-2011 Free Software Foundation, Inc. This file is part of GNU DIFF. diff --git a/contrib/diffutils/src/context.c b/contrib/diffutils/src/context.c index 0be8cc5a72..690506b963 100644 --- a/contrib/diffutils/src/context.c +++ b/contrib/diffutils/src/context.c @@ -1,6 +1,6 @@ /* Context-format output routines for GNU DIFF. - Copyright (C) 1988-1989, 1991-1995, 1998, 2001-2002, 2004, 2006, 2009-2010 + Copyright (C) 1988-1989, 1991-1995, 1998, 2001-2002, 2004, 2006, 2009-2011 Free Software Foundation, Inc. This file is part of GNU DIFF. @@ -20,7 +20,6 @@ #include "diff.h" #include "c-ctype.h" -#include #include #include diff --git a/contrib/diffutils/src/diff.c b/contrib/diffutils/src/diff.c index cc1b611573..c0964069e7 100644 --- a/contrib/diffutils/src/diff.c +++ b/contrib/diffutils/src/diff.c @@ -1,7 +1,7 @@ /* diff - compare files line by line Copyright (C) 1988-1989, 1992-1994, 1996, 1998, 2001-2002, 2004, 2006-2007, - 2009-2010 Free Software Foundation, Inc. + 2009-2011 Free Software Foundation, Inc. This file is part of GNU DIFF. @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -106,7 +107,7 @@ static bool unidirectional_new_file; static bool report_identical_files; static char const shortopts[] = -"0123456789abBcC:dD:eEfF:hHiI:lL:nNpPqrsS:tTuU:vwW:x:X:y"; +"0123456789abBcC:dD:eEfF:hHiI:lL:nNpPqrsS:tTuU:vwW:x:X:yZ"; /* Values for long options that do not have single-letter equivalents. */ enum @@ -177,6 +178,7 @@ static struct option const longopts[] = {"ignore-matching-lines", 1, 0, 'I'}, {"ignore-space-change", 0, 0, 'b'}, {"ignore-tab-expansion", 0, 0, 'E'}, + {"ignore-trailing-space", 0, 0, 'Z'}, {"inhibit-hunk-merge", 0, 0, INHIBIT_HUNK_MERGE_OPTION}, {"initial-tab", 0, 0, 'T'}, {"label", 1, 0, 'L'}, @@ -319,6 +321,11 @@ main (int argc, char **argv) ignore_white_space = IGNORE_SPACE_CHANGE; break; + case 'Z': + if (ignore_white_space < IGNORE_SPACE_CHANGE) + ignore_white_space |= IGNORE_TRAILING_SPACE; + break; + case 'B': ignore_blank_lines = true; break; @@ -380,8 +387,8 @@ main (int argc, char **argv) break; case 'E': - if (ignore_white_space < IGNORE_TAB_EXPANSION) - ignore_white_space = IGNORE_TAB_EXPANSION; + if (ignore_white_space < IGNORE_SPACE_CHANGE) + ignore_white_space |= IGNORE_TAB_EXPANSION; break; case 'f': @@ -479,7 +486,7 @@ main (int argc, char **argv) break; case 'v': - version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, PACKAGE_VERSION, + version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS, (char *) NULL); check_stdout (); return EXIT_SUCCESS; @@ -841,41 +848,64 @@ check_stdout (void) } static char const * const option_help_msgid[] = { - N_("Compare files line by line."), + N_(" --normal output a normal diff (the default)"), + N_("-q, --brief report only when files differ"), + N_("-s, --report-identical-files report when two files are the same"), + N_("-c, -C NUM, --context[=NUM] output NUM (default 3) lines of copied context"), + N_("-u, -U NUM, --unified[=NUM] output NUM (default 3) lines of unified context"), + N_("-e, --ed output an ed script"), + N_("-n, --rcs output an RCS format diff"), + N_("-y, --side-by-side output in two columns"), + N_("-W, --width=NUM output at most NUM (default 130) print columns"), + N_(" --left-column output only the left column of common lines"), + N_(" --suppress-common-lines do not output common lines"), + "", + N_("-p, --show-c-function show which C function each change is in"), + N_("-F, --show-function-line=RE show the most recent line matching RE"), + N_(" --label LABEL use LABEL instead of file name\n" + " (can be repeated)"), + "", + N_("-t, --expand-tabs expand tabs to spaces in output"), + N_("-T, --initial-tab make tabs line up by prepending a tab"), + N_(" --tabsize=NUM tab stops every NUM (default 8) print columns"), + N_(" --suppress-blank-empty suppress space or tab before empty output lines"), + N_("-l, --paginate pass output through `pr' to paginate it"), "", - N_("-i --ignore-case Ignore case differences in file contents."), - N_("--ignore-file-name-case Ignore case when comparing file names."), - N_("--no-ignore-file-name-case Consider case when comparing file names."), - N_("-E --ignore-tab-expansion Ignore changes due to tab expansion."), - N_("-b --ignore-space-change Ignore changes in the amount of white space."), - N_("-w --ignore-all-space Ignore all white space."), - N_("-B --ignore-blank-lines Ignore changes whose lines are all blank."), - N_("-I RE --ignore-matching-lines=RE Ignore changes whose lines all match RE."), - N_("--strip-trailing-cr Strip trailing carriage return on input."), + N_("-r, --recursive recursively compare any subdirectories found"), + N_("-N, --new-file treat absent files as empty"), + N_(" --unidirectional-new-file treat absent first files as empty"), + N_(" --ignore-file-name-case ignore case when comparing file names"), + N_(" --no-ignore-file-name-case consider case when comparing file names"), + N_("-x, --exclude=PAT exclude files that match PAT"), + N_("-X, --exclude-from=FILE exclude files that match any pattern in FILE"), + N_("-S, --starting-file=FILE start with FILE when comparing directories"), + N_(" --from-file=FILE1 compare FILE1 to all operands;\n" + " FILE1 can be a directory"), + N_(" --to-file=FILE2 compare all operands to FILE2;\n" + " FILE2 can be a directory"), + "", + N_("-i, --ignore-case ignore case differences in file contents"), + N_("-E, --ignore-tab-expansion ignore changes due to tab expansion"), + N_("-Z, --ignore-trailing-space ignore white space at line end"), + N_("-b, --ignore-space-change ignore changes in the amount of white space"), + N_("-w, --ignore-all-space ignore all white space"), + N_("-B, --ignore-blank-lines ignore changes whose lines are all blank"), + N_("-I, --ignore-matching-lines=RE ignore changes whose lines all match RE"), + "", + N_("-a, --text treat all files as text"), + N_(" --strip-trailing-cr strip trailing carriage return on input"), #if O_BINARY - N_("--binary Read and write data in binary mode."), + N_(" --binary read and write data in binary mode"), #endif - N_("-a --text Treat all files as text."), "", - N_("-c -C NUM --context[=NUM] Output NUM (default 3) lines of copied context.\n\ --u -U NUM --unified[=NUM] Output NUM (default 3) lines of unified context.\n\ - --label LABEL Use LABEL instead of file name.\n\ - -p --show-c-function Show which C function each change is in.\n\ - -F RE --show-function-line=RE Show the most recent line matching RE."), - N_("-q --brief Output only whether files differ."), - N_("-e --ed Output an ed script."), - N_("--normal Output a normal diff."), - N_("-n --rcs Output an RCS format diff."), - N_("-y --side-by-side Output in two columns.\n\ - -W NUM --width=NUM Output at most NUM (default 130) print columns.\n\ - --left-column Output only the left column of common lines.\n\ - --suppress-common-lines Do not output common lines."), - N_("-D NAME --ifdef=NAME Output merged file to show `#ifdef NAME' diffs."), - N_("--GTYPE-group-format=GFMT Similar, but format GTYPE input groups with GFMT."), - N_("--line-format=LFMT Similar, but format all input lines with LFMT."), - N_("--LTYPE-line-format=LFMT Similar, but format LTYPE input lines with LFMT."), + N_("-D, --ifdef=NAME output merged file with `#ifdef NAME' diffs"), + N_(" --GTYPE-group-format=GFMT format GTYPE input groups with GFMT"), + N_(" --line-format=LFMT format all input lines with LFMT"), + N_(" --LTYPE-line-format=LFMT format LTYPE input lines with LFMT"), + N_(" These format options provide fine-grained control over the output\n" + " of diff, generalizing -D/--ifdef."), N_(" LTYPE is `old', `new', or `unchanged'. GTYPE is LTYPE or `changed'."), - N_(" GFMT may contain:\n\ + N_(" GFMT (only) may contain:\n\ %< lines from FILE1\n\ %> lines from FILE2\n\ %= lines common to FILE1 and FILE2\n\ @@ -885,41 +915,27 @@ static char const * const option_help_msgid[] = { L last line number\n\ N number of lines = L-F+1\n\ E F-1\n\ - M L+1"), - N_(" LFMT may contain:\n\ + M L+1\n\ + %(A=B?T:E) if A equals B then T else E"), + N_(" LFMT (only) may contain:\n\ %L contents of line\n\ %l contents of line, excluding any trailing newline\n\ %[-][WIDTH][.[PREC]]{doxX}n printf-style spec for input line number"), - N_(" Either GFMT or LFMT may contain:\n\ + N_(" Both GFMT and LFMT may contain:\n\ %% %\n\ %c'C' the single character C\n\ - %c'\\OOO' the character with octal code OOO"), - "", - N_("-l --paginate Pass the output through `pr' to paginate it."), - N_("-t --expand-tabs Expand tabs to spaces in output."), - N_("-T --initial-tab Make tabs line up by prepending a tab."), - N_("--tabsize=NUM Tab stops are every NUM (default 8) print columns."), - N_("--suppress-blank-empty Suppress space or tab before empty output lines."), + %c'\\OOO' the character with octal code OOO\n\ + C the character C (other characters represent themselves)"), "", - N_("-r --recursive Recursively compare any subdirectories found."), - N_("-N --new-file Treat absent files as empty."), - N_("--unidirectional-new-file Treat absent first files as empty."), - N_("-s --report-identical-files Report when two files are the same."), - N_("-x PAT --exclude=PAT Exclude files that match PAT."), - N_("-X FILE --exclude-from=FILE Exclude files that match any pattern in FILE."), - N_("-S FILE --starting-file=FILE Start with FILE when comparing directories."), - N_("--from-file=FILE1 Compare FILE1 to all operands. FILE1 can be a directory."), - N_("--to-file=FILE2 Compare all operands to FILE2. FILE2 can be a directory."), + N_("-d, --minimal try hard to find a smaller set of changes"), + N_(" --horizon-lines=NUM keep NUM lines of the common prefix and suffix"), + N_(" --speed-large-files assume large files and many scattered small changes"), "", - N_("--horizon-lines=NUM Keep NUM lines of the common prefix and suffix."), - N_("-d --minimal Try hard to find a smaller set of changes."), - N_("--speed-large-files Assume large files and many scattered small changes."), - "", - N_("-v --version Output version info."), - N_("--help Output this help."), + N_(" --help display this help and exit"), + N_("-v, --version output version information and exit"), "", N_("FILES are `FILE1 FILE2' or `DIR1 DIR2' or `DIR FILE...' or `FILE... DIR'."), - N_("If --from-file or --to-file is given, there are no restrictions on FILES."), + N_("If --from-file or --to-file is given, there are no restrictions on FILE(s)."), N_("If a FILE is `-', read standard input."), N_("Exit status is 0 if inputs are the same, 1 if different, 2 if trouble."), 0 @@ -931,6 +947,11 @@ usage (void) char const * const *p; printf (_("Usage: %s [OPTION]... FILES\n"), program_name); + printf ("%s\n\n", _("Compare FILES line by line.")); + + fputs (_("\ +Mandatory arguments to long options are mandatory for short options too.\n\ +"), stdout); for (p = option_help_msgid; *p; p++) { @@ -958,7 +979,7 @@ usage (void) static void specify_value (char const **var, char const *value, char const *option) { - if (*var && strcmp (*var, value) != 0) + if (*var && ! STREQ (*var, value)) { error (0, 0, _("conflicting %s option value `%s'"), option, value); try_help (NULL, NULL); @@ -1067,9 +1088,9 @@ compare_files (struct comparison const *parent, else { cmp.file[0].name = free0 - = dir_file_pathname (parent->file[0].name, name0); + = file_name_concat (parent->file[0].name, name0, NULL); cmp.file[1].name = free1 - = dir_file_pathname (parent->file[1].name, name1); + = file_name_concat (parent->file[1].name, name1, NULL); } /* Stat the files. */ @@ -1156,7 +1177,7 @@ compare_files (struct comparison const *parent, char const *fnm = cmp.file[fnm_arg].name; char const *dir = cmp.file[dir_arg].name; char const *filename = cmp.file[dir_arg].name = free0 - = dir_file_pathname (dir, last_component (fnm)); + = find_dir_file_pathname (dir, last_component (fnm)); if (STREQ (fnm, "-")) fatal ("cannot compare `-' to a directory"); diff --git a/contrib/diffutils/src/diff.h b/contrib/diffutils/src/diff.h index 71b33f4762..578c4eab80 100644 --- a/contrib/diffutils/src/diff.h +++ b/contrib/diffutils/src/diff.h @@ -1,6 +1,6 @@ /* Shared definitions for GNU DIFF - Copyright (C) 1988-1989, 1991-1995, 1998, 2001-2002, 2004, 2009-2010 Free + Copyright (C) 1988-1989, 1991-1995, 1998, 2001-2002, 2004, 2009-2011 Free Software Foundation, Inc. This file is part of GNU DIFF. @@ -98,7 +98,7 @@ XTERN bool text; XTERN lin horizon_lines; /* The significance of white space during comparisons. */ -XTERN enum +enum DIFF_white_space { /* All white space is significant (the default). */ IGNORE_NO_WHITE_SPACE, @@ -106,12 +106,21 @@ XTERN enum /* Ignore changes due to tab expansion (-E). */ IGNORE_TAB_EXPANSION, + /* Ignore changes in trailing horizontal white space (-Z). */ + IGNORE_TRAILING_SPACE, + + /* IGNORE_TAB_EXPANSION and IGNORE_TRAILING_SPACE are a special case + because they are independent and can be ORed together, yielding + IGNORE_TAB_EXPANSION_AND_TRAILING_SPACE. */ + IGNORE_TAB_EXPANSION_AND_TRAILING_SPACE, + /* Ignore changes in horizontal white space (-b). */ IGNORE_SPACE_CHANGE, /* Ignore all horizontal white space (-w). */ IGNORE_ALL_SPACE -} ignore_white_space; +}; +XTERN enum DIFF_white_space ignore_white_space; /* Ignore changes that affect only blank lines (-B). */ XTERN bool ignore_blank_lines; @@ -316,58 +325,64 @@ XTERN FILE *outfile; /* Declare various functions. */ /* analyze.c */ -int diff_2_files (struct comparison *); +extern int diff_2_files (struct comparison *); /* context.c */ -void print_context_header (struct file_data[], bool); -void print_context_script (struct change *, bool); +extern void print_context_header (struct file_data[], bool); +extern void print_context_script (struct change *, bool); /* dir.c */ -int diff_dirs (struct comparison const *, int (*) (struct comparison const *, char const *, char const *)); +extern int diff_dirs (struct comparison const *, + int (*) (struct comparison const *, + char const *, char const *)); +extern char *find_dir_file_pathname (char const *, char const *); /* ed.c */ -void print_ed_script (struct change *); -void pr_forward_ed_script (struct change *); +extern void print_ed_script (struct change *); +extern void pr_forward_ed_script (struct change *); /* ifdef.c */ -void print_ifdef_script (struct change *); +extern void print_ifdef_script (struct change *); /* io.c */ -void file_block_read (struct file_data *, size_t); -bool read_files (struct file_data[], bool); +extern void file_block_read (struct file_data *, size_t); +extern bool read_files (struct file_data[], bool); /* normal.c */ -void print_normal_script (struct change *); +extern void print_normal_script (struct change *); /* rcs.c */ -void print_rcs_script (struct change *); +extern void print_rcs_script (struct change *); /* side.c */ -void print_sdiff_script (struct change *); +extern void print_sdiff_script (struct change *); /* util.c */ extern char const change_letter[4]; extern char const pr_program[]; -char *concat (char const *, char const *, char const *); -char *dir_file_pathname (char const *, char const *); -bool lines_differ (char const *, char const *); -lin translate_line_number (struct file_data const *, lin); -struct change *find_change (struct change *); -struct change *find_reverse_change (struct change *); -void *zalloc (size_t); -enum changes analyze_hunk (struct change *, lin *, lin *, lin *, lin *); -void begin_output (void); -void debug_script (struct change *); -void fatal (char const *) __attribute__((noreturn)); -void finish_output (void); -void message (char const *, char const *, char const *); -void message5 (char const *, char const *, char const *, char const *, char const *); -void output_1_line (char const *, char const *, char const *, char const *); -void perror_with_name (char const *); -void pfatal_with_name (char const *) __attribute__((noreturn)); -void print_1_line (char const *, char const * const *); -void print_message_queue (void); -void print_number_range (char, struct file_data *, lin, lin); -void print_script (struct change *, struct change * (*) (struct change *), void (*) (struct change *)); -void setup_output (char const *, char const *, bool); -void translate_range (struct file_data const *, lin, lin, long int *, long int *); +extern char *concat (char const *, char const *, char const *); +extern bool lines_differ (char const *, char const *); +extern lin translate_line_number (struct file_data const *, lin); +extern struct change *find_change (struct change *); +extern struct change *find_reverse_change (struct change *); +extern void *zalloc (size_t); +extern enum changes analyze_hunk (struct change *, lin *, lin *, lin *, lin *); +extern void begin_output (void); +extern void debug_script (struct change *); +extern void fatal (char const *) __attribute__((noreturn)); +extern void finish_output (void); +extern void message (char const *, char const *, char const *); +extern void message5 (char const *, char const *, char const *, + char const *, char const *); +extern void output_1_line (char const *, char const *, char const *, + char const *); +extern void perror_with_name (char const *); +extern void pfatal_with_name (char const *) __attribute__((noreturn)); +extern void print_1_line (char const *, char const * const *); +extern void print_message_queue (void); +extern void print_number_range (char, struct file_data *, lin, lin); +extern void print_script (struct change *, struct change * (*) (struct change *), + void (*) (struct change *)); +extern void setup_output (char const *, char const *, bool); +extern void translate_range (struct file_data const *, lin, lin, + long int *, long int *); diff --git a/contrib/diffutils/src/diff3.c b/contrib/diffutils/src/diff3.c index 0f11fdc0fd..343c055342 100644 --- a/contrib/diffutils/src/diff3.c +++ b/contrib/diffutils/src/diff3.c @@ -1,6 +1,6 @@ /* diff3 - compare three files line by line - Copyright (C) 1988-1989, 1992-1996, 1998, 2001-2002, 2004, 2006, 2009-2010 + Copyright (C) 1988-1989, 1992-1996, 1998, 2001-2002, 2004, 2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -280,7 +279,7 @@ main (int argc, char **argv) strip_trailing_cr = true; break; case 'v': - version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, PACKAGE_VERSION, + version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS, (char *) NULL); check_stdout (); return EXIT_SUCCESS; @@ -362,7 +361,7 @@ main (int argc, char **argv) rev_mapping[mapping[i]] = i; for (i = 0; i < 3; i++) - if (strcmp (file[i], "-") != 0) + if (! STREQ (file[i], "-")) { if (stat (file[i], &statb) < 0) perror_with_exit (file[i]); @@ -426,23 +425,28 @@ check_stdout (void) } static char const * const option_help_msgid[] = { - N_("-e --ed Output unmerged changes from OLDFILE to YOURFILE into MYFILE."), - N_("-E --show-overlap Output unmerged changes, bracketing conflicts."), - N_("-A --show-all Output all changes, bracketing conflicts."), - N_("-x --overlap-only Output overlapping changes."), - N_("-X Output overlapping changes, bracketing them."), - N_("-3 --easy-only Output unmerged nonoverlapping changes."), + N_("-A, --show-all output all changes, bracketing conflicts"), "", - N_("-m --merge Output merged file instead of ed script (default -A)."), - N_("-L LABEL --label=LABEL Use LABEL instead of file name."), - N_("-i Append `w' and `q' commands to ed scripts."), - N_("-a --text Treat all files as text."), - N_("--strip-trailing-cr Strip trailing carriage return on input."), - N_("-T --initial-tab Make tabs line up by prepending a tab."), - N_("--diff-program=PROGRAM Use PROGRAM to compare files."), + N_("-e, --ed output ed script incorporating changes\n" + " from OLDFILE to YOURFILE into MYFILE"), + N_("-E, --show-overlap like -e, but bracket conflicts"), + N_("-3, --easy-only like -e, but incorporate only nonoverlapping changes"), + N_("-x, --overlap-only like -e, but incorporate only overlapping changes"), + N_("-X like -x, but bracket conflicts"), + N_("-i append `w' and `q' commands to ed scripts"), "", - N_("-v --version Output version info."), - N_("--help Output this help."), + N_("-m, --merge output actual merged file, according to\n" + " -A if no other options are given"), + "", + N_("-a, --text treat all files as text"), + N_(" --strip-trailing-cr strip trailing carriage return on input"), + N_("-T, --initial-tab make tabs line up by prepending a tab"), + N_(" --diff-program=PROGRAM use PROGRAM to compare files"), + N_("-L, --label=LABEL use LABEL instead of file name\n" + " (can be repeated up to three times)"), + "", + N_(" --help display this help and exit"), + N_("-v, --version output version information and exit"), 0 }; @@ -454,11 +458,25 @@ usage (void) printf (_("Usage: %s [OPTION]... MYFILE OLDFILE YOURFILE\n"), program_name); printf ("%s\n\n", _("Compare three files line by line.")); + + fputs (_("\ +Mandatory arguments to long options are mandatory for short options too.\n\ +"), stdout); for (p = option_help_msgid; *p; p++) if (**p) printf (" %s\n", _(*p)); else putchar ('\n'); + fputs (_("\n\ +The default output format is a somewhat human-readable representation of\n\ +the changes.\n\ +\n\ +The -e, -E, -x, -X (and corresponding long) options cause an ed script\n\ +to be output instead of the default.\n\ +\n\ +Finally, the -m (--merge) option causes diff3 to do the merge internally\n\ +and output the actual merged file. For unusual input, this is more\n\ +robust than using ed.\n"), stdout); printf ("\n%s\n%s\n", _("If a FILE is `-', read standard input."), _("Exit status is 0 if successful, 1 if conflicts, 2 if trouble.")); @@ -1144,7 +1162,7 @@ read_diff (char const *filea, int werrno = 0; struct stat pipestat; -#if HAVE_WORKING_FORK || HAVE_WORKING_VFORK +#if HAVE_WORKING_FORK char const *argv[9]; char const **ap; @@ -1166,7 +1184,7 @@ read_diff (char const *filea, if (pipe (fds) != 0) perror_with_exit ("pipe"); - pid = vfork (); + pid = fork (); if (pid == 0) { /* Child */ @@ -1255,7 +1273,7 @@ read_diff (char const *filea, *output_placement = diff_result; -#if ! (HAVE_WORKING_FORK || HAVE_WORKING_VFORK) +#if ! HAVE_WORKING_FORK wstatus = pclose (fpipe); if (wstatus == -1) diff --git a/contrib/diffutils/src/dir.c b/contrib/diffutils/src/dir.c index 5b4eaec445..20626d1a28 100644 --- a/contrib/diffutils/src/dir.c +++ b/contrib/diffutils/src/dir.c @@ -1,7 +1,7 @@ /* Read, sort and compare two directories. Used for GNU DIFF. Copyright (C) 1988-1989, 1992-1995, 1998, 2001-2002, 2004, 2006-2007, - 2009-2010 Free Software Foundation, Inc. + 2009-2011 Free Software Foundation, Inc. This file is part of GNU DIFF. @@ -21,6 +21,7 @@ #include "diff.h" #include #include +#include #include #include @@ -161,19 +162,19 @@ compare_names (char const *name1, char const *name2) return r; } - return (ignore_file_name_case - ? strcasecmp (name1, name2) - : file_name_cmp (name1, name2)); + return file_name_cmp (name1, name2); } -/* A wrapper for compare_names suitable as an argument for qsort. */ +/* Compare names FILE1 and FILE2 when sorting a directory. + Prefer filtered comparison, breaking ties with file_name_cmp. */ static int compare_names_for_qsort (void const *file1, void const *file2) { char const *const *f1 = file1; char const *const *f2 = file2; - return compare_names (*f1, *f2); + int diff = compare_names (*f1, *f2); + return diff ? diff : file_name_cmp (*f1, *f2); } /* Compare the contents of two directories named in CMP. @@ -253,6 +254,41 @@ diff_dirs (struct comparison const *cmp, pretend the "next name" in that dir is very large. */ int nameorder = (!*names[0] ? 1 : !*names[1] ? -1 : compare_names (*names[0], *names[1])); + + /* Prefer a file_name_cmp match if available. This algorithm is + O(N**2), where N is the number of names in a directory + that compare_names says are all equal, but in practice N + is so small it's not worth tuning. */ + if (nameorder == 0) + { + int raw_order = file_name_cmp (*names[0], *names[1]); + if (raw_order != 0) + { + int greater_side = raw_order < 0; + int lesser_side = 1 - greater_side; + char const **lesser = names[lesser_side]; + char const *greater_name = *names[greater_side]; + char const **p; + + for (p = lesser + 1; + *p && compare_names (*p, greater_name) == 0; + p++) + { + int c = file_name_cmp (*p, greater_name); + if (0 <= c) + { + if (c == 0) + { + memmove (lesser + 1, lesser, + (char *) p - (char *) lesser); + *lesser = greater_name; + } + break; + } + } + } + } + int v1 = (*handle_file) (cmp, 0 < nameorder ? 0 : *names[0]++, nameorder < 0 ? 0 : *names[1]++); @@ -281,3 +317,48 @@ dir_loop (struct comparison const *cmp, int i) return true; return false; } + +/* Find a matching filename in a directory. */ + +char * +find_dir_file_pathname (char const *dir, char const *file) +{ + char *val; + char const *match = file; + struct dirdata dirdata; + dirdata.names = NULL; + dirdata.data = NULL; + + if (ignore_file_name_case) + { + struct file_data filedata; + filedata.name = dir; + filedata.desc = 0; + + if (dir_read (&filedata, &dirdata)) + { + locale_specific_sorting = true; + if (setjmp (failed_locale_specific_sorting)) + match = file; /* longjmp may mess up MATCH. */ + else + { + for (char const **p = dirdata.names; *p; p++) + if (compare_names (*p, file) == 0) + { + if (file_name_cmp (*p, file) == 0) + { + match = *p; + break; + } + if (match == file) + match = *p; + } + } + } + } + + val = file_name_concat (dir, match, NULL); + free (dirdata.names); + free (dirdata.data); + return val; +} diff --git a/contrib/diffutils/src/ed.c b/contrib/diffutils/src/ed.c index 08acf50c9d..88b617c7c5 100644 --- a/contrib/diffutils/src/ed.c +++ b/contrib/diffutils/src/ed.c @@ -1,6 +1,6 @@ /* Output routines for ed-script format. - Copyright (C) 1988-1989, 1991-1993, 1995, 1998, 2001, 2004, 2006, 2009-2010 + Copyright (C) 1988-1989, 1991-1993, 1995, 1998, 2001, 2004, 2006, 2009-2011 Free Software Foundation, Inc. This file is part of GNU DIFF. diff --git a/contrib/diffutils/src/ifdef.c b/contrib/diffutils/src/ifdef.c index a48f830994..bc5c8c5d37 100644 --- a/contrib/diffutils/src/ifdef.c +++ b/contrib/diffutils/src/ifdef.c @@ -1,6 +1,6 @@ /* #ifdef-format output routines for GNU DIFF. - Copyright (C) 1989, 1991-1994, 2001-2002, 2004, 2006, 2009-2010 Free + Copyright (C) 1989, 1991-1994, 2001-2002, 2004, 2006, 2009-2011 Free Software Foundation, Inc. This file is part of GNU DIFF. diff --git a/contrib/diffutils/src/io.c b/contrib/diffutils/src/io.c index 031be3dc08..0a75ab5cde 100644 --- a/contrib/diffutils/src/io.c +++ b/contrib/diffutils/src/io.c @@ -1,6 +1,6 @@ /* File I/O for GNU DIFF. - Copyright (C) 1988-1989, 1992-1995, 1998, 2001-2002, 2004, 2006, 2009-2010 + Copyright (C) 1988-1989, 1992-1995, 1998, 2001-2002, 2004, 2006, 2009-2011 Free Software Foundation, Inc. This file is part of GNU DIFF. @@ -198,9 +198,7 @@ slurp (struct file_data *current) static void find_and_hash_each_line (struct file_data *current) { - hash_value h; char const *p = current->prefix_end; - unsigned char c; lin i, *bucket; size_t length; @@ -215,122 +213,70 @@ find_and_hash_each_line (struct file_data *current) lin eqs_alloc = equivs_alloc; char const *suffix_begin = current->suffix_begin; char const *bufend = FILE_BUFFER (current) + current->buffered; + bool ig_case = ignore_case; + enum DIFF_white_space ig_white_space = ignore_white_space; bool diff_length_compare_anyway = - ignore_white_space != IGNORE_NO_WHITE_SPACE; + ig_white_space != IGNORE_NO_WHITE_SPACE; bool same_length_diff_contents_compare_anyway = - diff_length_compare_anyway | ignore_case; + diff_length_compare_anyway | ig_case; while (p < suffix_begin) { char const *ip = p; - - h = 0; + hash_value h = 0; + unsigned char c; /* Hash this line until we find a newline. */ - if (ignore_case) - switch (ignore_white_space) - { - case IGNORE_ALL_SPACE: - while ((c = *p++) != '\n') - if (! isspace (c)) - h = HASH (h, tolower (c)); - break; - - case IGNORE_SPACE_CHANGE: - while ((c = *p++) != '\n') - { - if (isspace (c)) - { - do - if ((c = *p++) == '\n') - goto hashing_done; - while (isspace (c)); - - h = HASH (h, ' '); - } - - /* C is now the first non-space. */ - h = HASH (h, tolower (c)); - } - break; + switch (ig_white_space) + { + case IGNORE_ALL_SPACE: + while ((c = *p++) != '\n') + if (! isspace (c)) + h = HASH (h, ig_case ? tolower (c) : c); + break; - case IGNORE_TAB_EXPANSION: + case IGNORE_SPACE_CHANGE: + while ((c = *p++) != '\n') { - size_t column = 0; - while ((c = *p++) != '\n') + if (isspace (c)) { - size_t repetitions = 1; - - switch (c) - { - case '\b': - column -= 0 < column; - break; - - case '\t': - c = ' '; - repetitions = tabsize - column % tabsize; - column = (column + repetitions < column - ? 0 - : column + repetitions); - break; - - case '\r': - column = 0; - break; - - default: - c = tolower (c); - column++; - break; - } - do - h = HASH (h, c); - while (--repetitions != 0); + if ((c = *p++) == '\n') + goto hashing_done; + while (isspace (c)); + + h = HASH (h, ' '); } + + /* C is now the first non-space. */ + h = HASH (h, ig_case ? tolower (c) : c); } - break; + break; - default: - while ((c = *p++) != '\n') - h = HASH (h, tolower (c)); - break; - } - else - switch (ignore_white_space) + case IGNORE_TAB_EXPANSION: + case IGNORE_TAB_EXPANSION_AND_TRAILING_SPACE: + case IGNORE_TRAILING_SPACE: { - case IGNORE_ALL_SPACE: - while ((c = *p++) != '\n') - if (! isspace (c)) - h = HASH (h, c); - break; - - case IGNORE_SPACE_CHANGE: + size_t column = 0; while ((c = *p++) != '\n') { - if (isspace (c)) + if (ig_white_space & IGNORE_TRAILING_SPACE + && isspace (c)) { + char const *p1 = p; + unsigned char c1; do - if ((c = *p++) == '\n') - goto hashing_done; - while (isspace (c)); - - h = HASH (h, ' '); + if ((c1 = *p1++) == '\n') + { + p = p1; + goto hashing_done; + } + while (isspace (c1)); } - /* C is now the first non-space. */ - h = HASH (h, c); - } - break; - - case IGNORE_TAB_EXPANSION: - { - size_t column = 0; - while ((c = *p++) != '\n') - { - size_t repetitions = 1; + size_t repetitions = 1; + if (ig_white_space & IGNORE_TAB_EXPANSION) switch (c) { case '\b': @@ -354,18 +300,25 @@ find_and_hash_each_line (struct file_data *current) break; } - do - h = HASH (h, c); - while (--repetitions != 0); - } - } - break; + if (ig_case) + c = tolower (c); + + do + h = HASH (h, c); + while (--repetitions != 0); + } + } + break; - default: + default: + if (ig_case) + while ((c = *p++) != '\n') + h = HASH (h, tolower (c)); + else while ((c = *p++) != '\n') h = HASH (h, c); - break; - } + break; + } hashing_done:; @@ -381,7 +334,7 @@ find_and_hash_each_line (struct file_data *current) complete line, put it into buckets[-1] so that it can compare equal only to the other file's incomplete line (if one exists). */ - if (ignore_white_space < IGNORE_SPACE_CHANGE) + if (ig_white_space < IGNORE_TRAILING_SPACE) bucket = &buckets[-1]; } diff --git a/contrib/diffutils/src/normal.c b/contrib/diffutils/src/normal.c index 154efaa543..2c43b3b58f 100644 --- a/contrib/diffutils/src/normal.c +++ b/contrib/diffutils/src/normal.c @@ -1,6 +1,6 @@ /* Normal-format output routines for GNU DIFF. - Copyright (C) 1988-1989, 1993, 1995, 1998, 2001, 2006, 2009-2010 Free + Copyright (C) 1988-1989, 1993, 1995, 1998, 2001, 2006, 2009-2011 Free Software Foundation, Inc. This file is part of GNU DIFF. diff --git a/contrib/diffutils/src/sdiff.c b/contrib/diffutils/src/sdiff.c index 4344e8d14c..e0b29f0535 100644 --- a/contrib/diffutils/src/sdiff.c +++ b/contrib/diffutils/src/sdiff.c @@ -1,6 +1,6 @@ /* sdiff - side-by-side merge of file differences - Copyright (C) 1992-1996, 1998, 2001-2002, 2004, 2006-2007, 2009-2010 Free + Copyright (C) 1992-1996, 1998, 2001-2002, 2004, 2006-2007, 2009-2011 Free Software Foundation, Inc. This file is part of GNU DIFF. @@ -50,7 +50,7 @@ static char const **diffargv; static char * volatile tmpname; static FILE *tmp; -#if HAVE_WORKING_FORK || HAVE_WORKING_VFORK +#if HAVE_WORKING_FORK static pid_t volatile diffpid; #endif @@ -85,7 +85,6 @@ static int const sigs[] = { #endif #ifdef SIGPIPE SIGPIPE, -# define handler_index_of_SIGPIPE (NUM_SIGS - 2) #endif SIGINT #define handler_index_of_SIGINT (NUM_SIGS - 1) @@ -102,29 +101,6 @@ static int const sigs[] = { # define signal_handler(sig, handler) signal (sig, handler) #endif -#if ! HAVE_SIGPROCMASK -# define sigset_t int -# define sigemptyset(s) (*(s) = 0) -# ifndef sigmask -# define sigmask(sig) (1 << ((sig) - 1)) -# endif -# define sigaddset(s, sig) (*(s) |= sigmask (sig)) -# ifndef SIG_BLOCK -# define SIG_BLOCK 0 -# endif -# ifndef SIG_SETMASK -# define SIG_SETMASK (! SIG_BLOCK) -# endif -# if ! HAVE_SIGBLOCK -# define sigblock(mask) (mask) -# define sigsetmask(mask) (mask) -# endif -# define sigprocmask(how, n, o) \ - ((how) == SIG_BLOCK \ - ? ((o) ? (*(sigset_t *) (o) = sigblock (*(n))) : sigblock (*(n))) \ - : sigsetmask (*(n))) -#endif - static bool diraccess (char const *); static int temporary_file (void); @@ -156,6 +132,7 @@ static struct option const longopts[] = {"ignore-matching-lines", 1, 0, 'I'}, {"ignore-space-change", 0, 0, 'b'}, {"ignore-tab-expansion", 0, 0, 'E'}, + {"ignore-trailing-space", 0, 0, 'Z'}, {"left-column", 0, 0, 'l'}, {"minimal", 0, 0, 'd'}, {"output", 1, 0, 'o'}, @@ -190,30 +167,31 @@ check_stdout (void) } static char const * const option_help_msgid[] = { - N_("-o FILE --output=FILE Operate interactively, sending output to FILE."), + N_("-o, --output=FILE operate interactively, sending output to FILE"), "", - N_("-i --ignore-case Consider upper- and lower-case to be the same."), - N_("-E --ignore-tab-expansion Ignore changes due to tab expansion."), - N_("-b --ignore-space-change Ignore changes in the amount of white space."), - N_("-W --ignore-all-space Ignore all white space."), - N_("-B --ignore-blank-lines Ignore changes whose lines are all blank."), - N_("-I RE --ignore-matching-lines=RE Ignore changes whose lines all match RE."), - N_("--strip-trailing-cr Strip trailing carriage return on input."), - N_("-a --text Treat all files as text."), + N_("-i, --ignore-case consider upper- and lower-case to be the same"), + N_("-E, --ignore-tab-expansion ignore changes due to tab expansion"), + N_("-Z, --ignore-trailing-space ignore white space at line end"), + N_("-b, --ignore-space-change ignore changes in the amount of white space"), + N_("-W, --ignore-all-space ignore all white space"), + N_("-B, --ignore-blank-lines ignore changes whose lines are all blank"), + N_("-I, --ignore-matching-lines=RE ignore changes whose lines all match RE"), + N_(" --strip-trailing-cr strip trailing carriage return on input"), + N_("-a, --text treat all files as text"), "", - N_("-w NUM --width=NUM Output at most NUM (default 130) print columns."), - N_("-l --left-column Output only the left column of common lines."), - N_("-s --suppress-common-lines Do not output common lines."), + N_("-w, --width=NUM output at most NUM (default 130) print columns"), + N_("-l, --left-column output only the left column of common lines"), + N_("-s, --suppress-common-lines do not output common lines"), "", - N_("-t --expand-tabs Expand tabs to spaces in output."), - N_("--tabsize=NUM Tab stops are every NUM (default 8) print columns."), + N_("-t, --expand-tabs expand tabs to spaces in output"), + N_(" --tabsize=NUM tab stops at every NUM (default 8) print columns"), "", - N_("-d --minimal Try hard to find a smaller set of changes."), - N_("-H --speed-large-files Assume large files and many scattered small changes."), - N_("--diff-program=PROGRAM Use PROGRAM to compare files."), + N_("-d, --minimal try hard to find a smaller set of changes"), + N_("-H, --speed-large-files assume large files, many scattered small changes"), + N_(" --diff-program=PROGRAM use PROGRAM to compare files"), "", - N_("-v --version Output version info."), - N_("--help Output this help."), + N_(" --help display this help and exit"), + N_("-v, --version output version information and exit"), 0 }; @@ -223,7 +201,12 @@ usage (void) char const * const *p; printf (_("Usage: %s [OPTION]... FILE1 FILE2\n"), program_name); - printf ("%s\n\n", _("Side-by-side merge of file differences.")); + printf ("%s\n\n", + _("Side-by-side merge of differences between FILE1 and FILE2.")); + + fputs (_("\ +Mandatory arguments to long options are mandatory for short options too.\n\ +"), stdout); for (p = option_help_msgid; *p; p++) if (**p) printf (" %s\n", _(*p)); @@ -240,7 +223,7 @@ usage (void) static void cleanup (int signo __attribute__((unused))) { -#if HAVE_WORKING_FORK || HAVE_WORKING_VFORK +#if HAVE_WORKING_FORK if (0 < diffpid) kill (diffpid, SIGPIPE); #endif @@ -477,7 +460,7 @@ main (int argc, char *argv[]) diffarg (DEFAULT_DIFF_PROGRAM); /* parse command line args */ - while ((opt = getopt_long (argc, argv, "abBdEHiI:lo:stvw:W", longopts, 0)) + while ((opt = getopt_long (argc, argv, "abBdEHiI:lo:stvw:WZ", longopts, 0)) != -1) { switch (opt) @@ -532,7 +515,7 @@ main (int argc, char *argv[]) break; case 'v': - version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, PACKAGE_VERSION, + version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS, (char *) NULL); check_stdout (); return EXIT_SUCCESS; @@ -546,6 +529,10 @@ main (int argc, char *argv[]) diffarg ("-w"); break; + case 'Z': + diffarg ("-Z"); + break; + case DIFF_PROGRAM_OPTION: diffargv[0] = optarg; break; @@ -618,7 +605,7 @@ main (int argc, char *argv[]) trapsigs (); -#if ! (HAVE_WORKING_FORK || HAVE_WORKING_VFORK) +#if ! HAVE_WORKING_FORK { size_t cmdsize = 1; char *p, *command; @@ -642,22 +629,11 @@ main (int argc, char *argv[]) #else { int diff_fds[2]; -# if HAVE_WORKING_VFORK - sigset_t procmask; - sigset_t blocked; -# endif if (pipe (diff_fds) != 0) perror_fatal ("pipe"); -# if HAVE_WORKING_VFORK - /* Block SIGINT and SIGPIPE. */ - sigemptyset (&blocked); - sigaddset (&blocked, SIGINT); - sigaddset (&blocked, SIGPIPE); - sigprocmask (SIG_BLOCK, &blocked, &procmask); -# endif - diffpid = vfork (); + diffpid = fork (); if (diffpid < 0) perror_fatal ("fork"); if (! diffpid) @@ -669,10 +645,6 @@ main (int argc, char *argv[]) if (initial_handler (handler_index_of_SIGINT) != SIG_IGN) signal_handler (SIGINT, SIG_IGN); signal_handler (SIGPIPE, SIG_DFL); -# if HAVE_WORKING_VFORK - /* Stop blocking SIGINT and SIGPIPE in the child. */ - sigprocmask (SIG_SETMASK, &procmask, 0); -# endif close (diff_fds[0]); if (diff_fds[1] != STDOUT_FILENO) { @@ -684,19 +656,6 @@ main (int argc, char *argv[]) _exit (errno == ENOENT ? 127 : 126); } -# if HAVE_WORKING_VFORK - /* Restore the parent's SIGINT and SIGPIPE behavior. */ - if (initial_handler (handler_index_of_SIGINT) != SIG_IGN) - signal_handler (SIGINT, catchsig); - if (initial_handler (handler_index_of_SIGPIPE) != SIG_IGN) - signal_handler (SIGPIPE, catchsig); - else - signal_handler (SIGPIPE, SIG_IGN); - - /* Stop blocking SIGINT and SIGPIPE in the parent. */ - sigprocmask (SIG_SETMASK, &procmask, 0); -# endif - close (diff_fds[1]); diffout = fdopen (diff_fds[0], "r"); if (! diffout) @@ -718,7 +677,7 @@ main (int argc, char *argv[]) int wstatus; int werrno = 0; -#if ! (HAVE_WORKING_FORK || HAVE_WORKING_VFORK) +#if ! HAVE_WORKING_FORK wstatus = pclose (diffout); if (wstatus == -1) werrno = errno; @@ -1065,7 +1024,7 @@ edit (struct line_filter *left, char const *lname, lin lline, lin llen, checksigs (); { -#if ! (HAVE_WORKING_FORK || HAVE_WORKING_VFORK) +#if ! HAVE_WORKING_FORK char *command = xmalloc (shell_quote_length (editor_program) + 1 + strlen (tmpname) + 1); @@ -1078,7 +1037,7 @@ edit (struct line_filter *left, char const *lname, lin lline, lin llen, #else pid_t pid; - pid = vfork (); + pid = fork (); if (pid == 0) { char const *argv[3]; diff --git a/contrib/diffutils/src/side.c b/contrib/diffutils/src/side.c index 6aa96a9290..e43585683e 100644 --- a/contrib/diffutils/src/side.c +++ b/contrib/diffutils/src/side.c @@ -1,6 +1,6 @@ /* sdiff-format output routines for GNU DIFF. - Copyright (C) 1991-1993, 1998, 2001-2002, 2004, 2009-2010 Free Software + Copyright (C) 1991-1993, 1998, 2001-2002, 2004, 2009-2011 Free Software Foundation, Inc. This file is part of GNU DIFF. diff --git a/contrib/diffutils/src/system.h b/contrib/diffutils/src/system.h index 8942296c9f..594ef6e8ed 100644 --- a/contrib/diffutils/src/system.h +++ b/contrib/diffutils/src/system.h @@ -1,6 +1,6 @@ /* System dependent declarations. - Copyright (C) 1988-1989, 1992-1995, 1998, 2001-2002, 2004, 2006, 2009-2010 + Copyright (C) 1988-1989, 1992-1995, 1998, 2001-2002, 2004, 2006, 2009-2011 Free Software Foundation, Inc. This file is part of GNU DIFF. @@ -54,12 +54,6 @@ #include #include -#ifndef WEXITSTATUS -# define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) -#endif -#ifndef WIFEXITED -# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) -#endif #include #ifndef _D_EXACT_NAMLEN @@ -111,13 +105,6 @@ int strcasecmp (char const *, char const *); #include #include -#ifndef SA_RESTART -# ifdef SA_INTERRUPT /* e.g. SunOS 4.1.x */ -# define SA_RESTART SA_INTERRUPT -# else -# define SA_RESTART 0 -# endif -#endif #if !defined SIGCHLD && defined SIGCLD # define SIGCHLD SIGCLD #endif @@ -128,17 +115,9 @@ int strcasecmp (char const *, char const *); #define MAX(a, b) ((a) >= (b) ? (a) : (b)) #include - -#if HAVE_VFORK_H -# include -#endif - -#if ! HAVE_WORKING_VFORK -# define vfork fork -#endif - #include #include "propername.h" +#include "version.h" /* Type used for fast comparison of several bytes at a time. */ diff --git a/contrib/diffutils/src/util.c b/contrib/diffutils/src/util.c index 3be03e9478..580843475a 100644 --- a/contrib/diffutils/src/util.c +++ b/contrib/diffutils/src/util.c @@ -1,6 +1,6 @@ /* Support routines for GNU DIFF. - Copyright (C) 1988-1989, 1992-1995, 1998, 2001-2002, 2004, 2006, 2009-2010 + Copyright (C) 1988-1989, 1992-1995, 1998, 2001-2002, 2004, 2006, 2009-2011 Free Software Foundation, Inc. This file is part of GNU DIFF. @@ -162,7 +162,7 @@ setup_output (char const *name0, char const *name1, bool recursive) outfile = 0; } -#if HAVE_WORKING_FORK || HAVE_WORKING_VFORK +#if HAVE_WORKING_FORK static pid_t pr_pid; #endif @@ -192,13 +192,13 @@ begin_output (void) /* Make OUTFILE a pipe to a subsidiary `pr'. */ { -#if HAVE_WORKING_FORK || HAVE_WORKING_VFORK +#if HAVE_WORKING_FORK int pipes[2]; if (pipe (pipes) != 0) pfatal_with_name ("pipe"); - pr_pid = vfork (); + pr_pid = fork (); if (pr_pid < 0) pfatal_with_name ("fork"); @@ -282,7 +282,7 @@ finish_output (void) int werrno = 0; if (ferror (outfile)) fatal ("write failed"); -#if ! (HAVE_WORKING_FORK || HAVE_WORKING_VFORK) +#if ! HAVE_WORKING_FORK wstatus = pclose (outfile); if (wstatus == -1) werrno = errno; @@ -395,6 +395,33 @@ lines_differ (char const *s1, char const *s2) break; + case IGNORE_TRAILING_SPACE: + case IGNORE_TAB_EXPANSION_AND_TRAILING_SPACE: + if (isspace (c1) && isspace (c2)) + { + unsigned char c; + if (c1 != '\n') + { + char const *p = t1; + while ((c = *p) != '\n' && isspace (c)) + ++p; + if (c != '\n') + break; + } + if (c2 != '\n') + { + char const *p = t2; + while ((c = *p) != '\n' && isspace (c)) + ++p; + if (c != '\n') + break; + } + /* Both lines have nothing but whitespace left. */ + return false; + } + if (ignore_white_space == IGNORE_TRAILING_SPACE) + break; + /* Fall through. */ case IGNORE_TAB_EXPANSION: if ((c1 == ' ' && c2 == '\t') || (c1 == '\t' && c2 == ' ')) @@ -674,8 +701,11 @@ analyze_hunk (struct change *hunk, size_t trivial_length = ignore_blank_lines - 1; /* If 0, ignore zero-length lines; if SIZE_MAX, do not ignore lines just because of their length. */ + + bool skip_white_space = + ignore_blank_lines && IGNORE_TRAILING_SPACE <= ignore_white_space; bool skip_leading_white_space = - (ignore_blank_lines && IGNORE_SPACE_CHANGE <= ignore_white_space); + skip_white_space && IGNORE_SPACE_CHANGE <= ignore_white_space; char const * const *linbuf0 = files[0].linbuf; /* Help the compiler. */ char const * const *linbuf1 = files[1].linbuf; @@ -699,9 +729,14 @@ analyze_hunk (struct change *hunk, char const *newline = linbuf0[i + 1] - 1; size_t len = newline - line; char const *p = line; - if (skip_leading_white_space) - while (isspace ((unsigned char) *p) && *p != '\n') - p++; + if (skip_white_space) + for (; *p != '\n'; p++) + if (! isspace ((unsigned char) *p)) + { + if (! skip_leading_white_space) + p = line; + break; + } if (newline - p != trivial_length && (! ignore_regexp.fastmap || re_search (&ignore_regexp, line, len, 0, len, 0) < 0)) @@ -714,9 +749,14 @@ analyze_hunk (struct change *hunk, char const *newline = linbuf1[i + 1] - 1; size_t len = newline - line; char const *p = line; - if (skip_leading_white_space) - while (isspace ((unsigned char) *p) && *p != '\n') - p++; + if (skip_white_space) + for (; *p != '\n'; p++) + if (! isspace ((unsigned char) *p)) + { + if (! skip_leading_white_space) + p = line; + break; + } if (newline - p != trivial_length && (! ignore_regexp.fastmap || re_search (&ignore_regexp, line, len, 0, len, 0) < 0)) @@ -756,18 +796,6 @@ zalloc (size_t size) memset (p, 0, size); return p; } - -/* Yield the newly malloc'd pathname - of the file in DIR whose filename is FILE. */ - -char * -dir_file_pathname (char const *dir, char const *file) -{ - char const *base = last_component (dir); - size_t baselen = base_len (base); - bool omit_slash = baselen == 0 || base[baselen - 1] == '/'; - return concat (dir, "/" + omit_slash, file); -} void debug_script (struct change *sp) -- 2.41.0