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.
* help2man 1.33 <ftp://ftp.gnu.org/gnu/help2man/help2man-1.33.1.tar.gz>
* Texinfo 4.7 <ftp://ftp.gnu.org/gnu/texinfo/texinfo-4.7.tar.gz>
+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 <bug-gnu-utils@gnu.org>.
-----
-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 <http://www.gnu.org/licenses/>.
+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.
-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
\1f
-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:
* Index:: Index.
\1f
-File: diff.info, Node: Overview, Next: Comparison, Prev: Top, Up: Top
+File: diffutils.info, Node: Overview, Next: Comparison, Prev: Top, Up: Top
Overview
********
by Larry Wall, with his permission.
\1f
-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
***********************
* Binary:: Comparing binary files or forcing text comparisons.
\1f
-File: diff.info, Node: Hunks, Next: White Space, Up: Comparison
+File: diffutils.info, Node: Hunks, Next: White Space, Up: Comparison
1.1 Hunks
=========
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::).
\1f
-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
newline-related changes; it ignores only other white space changes.
\1f
-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.
-- 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.
\1f
-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
against each regular expression.
\1f
-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
================================
use the `-i' or `--ignore-case' option.
\1f
-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
==================================
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
two files.
\1f
-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
=============================================
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'
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.
line by using the `-a' or `--text' option.
\1f
-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
***********************
* If-then-else:: Merging files with if-then-else.
\1f
-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
==========================
last three lines of `tzu'.
\1f
-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
========================================
* Alternate Names:: Showing alternate file names in context headers.
\1f
-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
--------------------
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:
* Detailed Context:: A detailed description of the context output format.
\1f
-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
....................................
+ The door of all subtleties!
\1f
-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
......................................................
+ The door of all subtleties!
\1f
-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
..............................................
of TO-FILE are omitted.
\1f
-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.
* Detailed Unified:: A detailed description of unified format.
\1f
-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
....................................
+The door of all subtleties!
\1f
-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
..............................................
A line was removed here from the first file.
\1f
-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
-----------------------------------------------
* C Function Headings:: Showing headings of C functions.
\1f
-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
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.
\1f
-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.
\1f
-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
----------------------------------
--- modified
\1f
-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
====================================
* Example Side by Side:: Sample side by side output.
\1f
-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
entirely.
\1f
-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
---------------------------------------
> The door of all subtleties!
\1f
-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
=======================================
* Detailed Normal:: A detailed description of normal output format.
\1f
-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
---------------------------------
> The door of all subtleties!
\1f
-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
-------------------------------------------
after line 3 of file 2.
\1f
-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
=======================
* RCS:: A special `diff' output format used by RCS.
\1f
-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
------------------
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
* Detailed ed:: A detailed description of `ed' format.
\1f
-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
...........................
1,2d
\1f
-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
...........................................
`5,7d' means delete lines 5-7 of file 1.
\1f
-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
--------------------------
`--forward-ed' option to select it.
\1f
-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.
The door of all subtleties!
\1f
-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
===================================
* Detailed If-then-else:: A detailed description of if-then-else format.
\1f
-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
------------------------
0, to `1 line' if N is 1, and to `%dN lines' otherwise.
\1f
-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
------------------
old new
\1f
-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
---------------------------------------
#endif /* TWO */
\1f
-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
-------------------------------------------------
file; *Note patch Options::.
\1f
-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
******************
.
\1f
-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
***********************
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
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
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.
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.
\1f
-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
*******************************
* Pagination:: Page numbering and time-stamping `diff' output.
\1f
-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
=================================
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
`--initial-tab' option.
\1f
-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
============================
accepted by GNU `patch' as well.
\1f
-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
\1f
-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
******************************
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.
nicer in some cases.
\1f
-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
***********************
* Detailed diff3 Normal:: A detailed description of normal output format.
\1f
-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
=============================
-- The Way of Lao-Tzu, tr. Wing-tsit Chan
\1f
-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
=======================================
-- The Way of Lao-Tzu, tr. Wing-tsit Chan
\1f
-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
=================================================
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.
a following line that starts with `\'.
\1f
-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
=================
file.
\1f
-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
********************************
* Saving the Changed File:: Emulating System V behavior.
\1f
-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
.
\1f
-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
=====================
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
-- 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
=======
rather than from files named `A', `B' and `C'.
\1f
-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.
>>>>>>> tao
\1f
-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
=======================================
newline had been present.
\1f
-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
===========================
and is incompatible with the merged output option `-m'.
\1f
-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
* Merge Commands:: Merging two files interactively.
\1f
-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'
========================================
*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
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::).
\1f
-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
==================
variable if it is set. The default is system-dependent.
\1f
-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'
***********************
* patch and Tradition:: GNU versus traditional `patch'.
\1f
-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
=======================================
unified diff.
\1f
-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
=====================
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
`VERSION_CONTROL' environment variable (*note Backup Names::).
\1f
-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
===============================
* Dry Runs:: Predicting what `patch' will do.
\1f
-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
------------------------------------------------
line of the context must still match a line in the input file.
\1f
-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.
process.
\1f
-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
-------------------------------------------
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
from.
\1f
-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
--------------------------------------
without the `--dry-run' option.
\1f
-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.
asks for confirmation before applying the patch.
\1f
-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
==========================================
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
confused by the patched files' times.
\1f
-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
===============================
POSIX.
\1f
-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
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
that directory.
\1f
-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
=================
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
file.
\1f
-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
======================
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
use `~', but this should be fixed in the next release.
\1f
-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
=======================
name.
\1f
-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'
=========================================
status, so you don't apply a later patch to a partially patched file.
\1f
-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'
--------------------------------------------
occurs, by using the `-s', `--quiet', or `--silent' option.
\1f
-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.
* 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
* Assume that patches are reversed if they look like they are.
\1f
-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
-----------------------------
change in a future version of `patch'.
\1f
-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
====================================
\1f
-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'
=========================================
`//' 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
\1f
-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
************************************
* Generating Smaller Patches:: How to generate smaller patches.
\1f
-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
=============================
when generating a patch.
\1f
-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
=============================
patches, try upgrading to a recent version of GNU `patch'.
\1f
-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
=============================
the wrong order.
\1f
-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
===============================
proper operation when patches do not exactly match the input files.
\1f
-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'
*****************
* cmp Options:: Summary of options to `cmp'.
\1f
-File: diff.info, Node: cmp Options, Up: Invoking cmp
+File: diffutils.info, Node: cmp Options, Up: Invoking cmp
12.1 Options to `cmp'
=====================
extension to IEC 60027-2.)
\1f
-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'
******************
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
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'.
\1f
-File: diff.info, Node: diff Options, Up: Invoking diff
+File: diffutils.info, Node: diff Options, Up: Invoking diff
13.1 Options to `diff'
======================
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
*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::)
`--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::.
+
\1f
-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'
*******************
* diff3 Options:: Summary of options to `diff3'.
\1f
-File: diff.info, Node: diff3 Options, Up: Invoking diff3
+File: diffutils.info, Node: diff3 Options, Up: Invoking diff3
14.1 Options to `diff3'
=======================
Which Changes::.
\1f
-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'
*******************
* patch Options:: Summary table of options to `patch'.
\1f
-File: diff.info, Node: patch Options, Up: Invoking patch
+File: diffutils.info, Node: patch Options, Up: Invoking patch
15.1 Options to `patch'
=======================
\1f
-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'
*******************
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
* sdiff Options:: Summary of options to `diff'.
\1f
-File: diff.info, Node: sdiff Options, Up: Invoking sdiff
+File: diffutils.info, Node: sdiff Options, Up: Invoking sdiff
16.1 Options to `sdiff'
=======================
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::.
+
\1f
-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
************************
in your environment.
\1f
-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
******************
* Bugs:: Reporting bugs.
\1f
-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'
============================================================
* Speedups:: Improving performance.
\1f
-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
------------------------------------------------------
of `diff', so more work needs to be done in this area.
\1f
-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
--------------------------------------------------
understand these extensions.
\1f
-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
-----------------------------------------------------------
and `patch' should be extended to understand these extensions.
\1f
-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
-------------------------------------------------
of `diff' output should be extended to handle all possible file names.
\1f
-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
-------------------------------------------
time stamp order.
\1f
-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
-------------------------------
However, this outputs the filtered text, not the original.
\1f
-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
----------------------------
the same content. *Note diff Performance::.
\1f
-File: diff.info, Node: Bugs, Prev: Shortcomings, Up: Projects
+File: diffutils.info, Node: Bugs, Prev: Shortcomings, Up: Projects
18.2 Reporting Bugs
===================
directory `ftp://alpha.gnu.org/gnu/diffutils/'.
\1f
-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
******************************
permit their use in free software.
\1f
-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
**************************************
`http://openlab.ring.gr.jp/gnujdoc/cvsweb/cvsweb.cgi/gnujdoc/'.
\1f
-File: diff.info, Node: Index, Prev: Translations, Up: Top
+File: diffutils.info, Node: Index, Prev: Translations, Up: Top
Appendix C Index
****************
\1f
Tag Table:
-Node: Top\7f1675
-Node: Overview\7f4135
-Node: Comparison\7f7759
-Node: Hunks\7f10457
-Node: White Space\7f11895
-Node: Blank Lines\7f13623
-Node: Specified Lines\7f14653
-Node: Case Folding\7f15775
-Node: Brief\7f16187
-Node: Binary\7f17506
-Node: Output Formats\7f21591
-Node: Sample diff Input\7f22311
-Node: Context\7f23805
-Node: Context Format\7f25377
-Node: Example Context\7f26164
-Node: Less Context\7f27666
-Node: Detailed Context\7f28850
-Node: Unified Format\7f31043
-Node: Example Unified\7f31834
-Node: Detailed Unified\7f32867
-Node: Sections\7f34509
-Node: Specified Headings\7f35263
-Node: C Function Headings\7f36812
-Node: Alternate Names\7f37654
-Node: Side by Side\7f38563
-Node: Side by Side Format\7f40707
-Node: Example Side by Side\7f41605
-Node: Normal\7f42940
-Node: Example Normal\7f43935
-Node: Detailed Normal\7f44666
-Node: Scripts\7f46400
-Node: ed Scripts\7f46800
-Node: Example ed\7f48002
-Node: Detailed ed\7f48447
-Node: Forward ed\7f50201
-Node: RCS\7f50972
-Node: If-then-else\7f52184
-Node: Line Group Formats\7f53857
-Node: Line Formats\7f59728
-Node: Example If-then-else\7f62993
-Node: Detailed If-then-else\7f64067
-Node: Incomplete Lines\7f65945
-Node: Comparing Directories\7f67577
-Node: Adjusting Output\7f71621
-Node: Tabs\7f72123
-Node: Trailing Blanks\7f73733
-Node: Pagination\7f74954
-Node: diff Performance\7f75418
-Node: Comparing Three Files\7f78501
-Node: Sample diff3 Input\7f79374
-Node: Example diff3 Normal\7f80317
-Node: Detailed diff3 Normal\7f81362
-Node: diff3 Hunks\7f83117
-Node: diff3 Merging\7f84408
-Node: Which Changes\7f86647
-Node: Marking Conflicts\7f88046
-Node: Bypassing ed\7f90500
-Node: Merging Incomplete Lines\7f91839
-Node: Saving the Changed File\7f92560
-Node: Interactive Merging\7f93171
-Node: sdiff Option Summary\7f93876
-Node: Merge Commands\7f95047
-Node: Merging with patch\7f96331
-Node: patch Input\7f98698
-Node: Revision Control\7f99375
-Node: Imperfect\7f100541
-Node: Changed White Space\7f101684
-Node: Reversed Patches\7f102476
-Node: Inexact\7f103936
-Node: Dry Runs\7f107490
-Node: Creating and Removing\7f108349
-Node: Patching Time Stamps\7f109395
-Node: Multiple Patches\7f111593
-Node: patch Directories\7f114251
-Node: Backups\7f115872
-Node: Backup Names\7f116933
-Ref: Backup Names-Footnote-1\7f119897
-Node: Reject Names\7f120024
-Node: patch Messages\7f120608
-Node: More or Fewer Messages\7f121663
-Node: patch and Keyboard Input\7f122289
-Node: patch Quoting Style\7f123315
-Node: patch and POSIX\7f124460
-Node: patch and Tradition\7f125295
-Node: Making Patches\7f128747
-Node: Tips for Patch Producers\7f129568
-Node: Tips for Patch Consumers\7f130819
-Node: Avoiding Common Mistakes\7f131451
-Node: Generating Smaller Patches\7f133971
-Node: Invoking cmp\7f135727
-Node: cmp Options\7f137145
-Node: Invoking diff\7f140632
-Node: diff Options\7f142485
-Node: Invoking diff3\7f150912
-Node: diff3 Options\7f151545
-Node: Invoking patch\7f154573
-Node: patch Options\7f155776
-Node: Invoking sdiff\7f160998
-Node: sdiff Options\7f162140
-Node: Standards conformance\7f165015
-Node: Projects\7f166756
-Node: Shortcomings\7f167462
-Node: Internationalization\7f168559
-Node: Changing Structure\7f169720
-Node: Special Files\7f170819
-Node: Unusual File Names\7f171926
-Node: Time Stamp Order\7f172560
-Node: Ignoring Changes\7f173198
-Node: Speedups\7f173963
-Node: Bugs\7f174422
-Node: Copying This Manual\7f175270
-Node: Translations\7f200404
-Node: Index\7f200771
+Node: Top\7f1433
+Node: Overview\7f3646
+Node: Comparison\7f7275
+Node: Hunks\7f9978
+Node: White Space\7f11420
+Node: Blank Lines\7f13259
+Node: Specified Lines\7f14251
+Node: Case Folding\7f15377
+Node: Brief\7f15794
+Node: Binary\7f17117
+Node: Output Formats\7f21202
+Node: Sample diff Input\7f21927
+Node: Context\7f23426
+Node: Context Format\7f25003
+Node: Example Context\7f25795
+Node: Less Context\7f27302
+Node: Detailed Context\7f28491
+Node: Unified Format\7f30689
+Node: Example Unified\7f31486
+Node: Detailed Unified\7f32524
+Node: Sections\7f34171
+Node: Specified Headings\7f34930
+Node: C Function Headings\7f36481
+Node: Alternate Names\7f37326
+Node: Side by Side\7f38240
+Node: Side by Side Format\7f40389
+Node: Example Side by Side\7f41290
+Node: Normal\7f42630
+Node: Example Normal\7f43630
+Node: Detailed Normal\7f44366
+Node: Scripts\7f46105
+Node: ed Scripts\7f46510
+Node: Example ed\7f47716
+Node: Detailed ed\7f48166
+Node: Forward ed\7f49925
+Node: RCS\7f50701
+Node: If-then-else\7f51916
+Node: Line Group Formats\7f53594
+Node: Line Formats\7f59470
+Node: Example If-then-else\7f62740
+Node: Detailed If-then-else\7f63819
+Node: Incomplete Lines\7f65702
+Node: Comparing Directories\7f67339
+Node: Adjusting Output\7f71383
+Node: Tabs\7f71890
+Node: Trailing Blanks\7f73504
+Node: Pagination\7f74730
+Node: diff Performance\7f75198
+Node: Comparing Three Files\7f78285
+Node: Sample diff3 Input\7f79163
+Node: Example diff3 Normal\7f80111
+Node: Detailed diff3 Normal\7f81161
+Node: diff3 Hunks\7f82920
+Node: diff3 Merging\7f84216
+Node: Which Changes\7f86460
+Node: Marking Conflicts\7f87860
+Node: Bypassing ed\7f90316
+Node: Merging Incomplete Lines\7f91659
+Node: Saving the Changed File\7f92385
+Node: Interactive Merging\7f93001
+Node: sdiff Option Summary\7f93710
+Node: Merge Commands\7f94913
+Node: Merging with patch\7f96202
+Node: patch Input\7f98574
+Node: Revision Control\7f99256
+Node: Imperfect\7f100426
+Node: Changed White Space\7f101574
+Node: Reversed Patches\7f102371
+Node: Inexact\7f103835
+Node: Dry Runs\7f107393
+Node: Creating and Removing\7f108257
+Node: Patching Time Stamps\7f109306
+Node: Multiple Patches\7f111505
+Node: patch Directories\7f114168
+Node: Backups\7f115793
+Node: Backup Names\7f116858
+Ref: Backup Names-Footnote-1\7f119825
+Node: Reject Names\7f119952
+Node: patch Messages\7f120541
+Node: More or Fewer Messages\7f121601
+Node: patch and Keyboard Input\7f122232
+Node: patch Quoting Style\7f123261
+Node: patch and POSIX\7f124411
+Node: patch and Tradition\7f125251
+Node: Making Patches\7f128707
+Node: Tips for Patch Producers\7f129533
+Node: Tips for Patch Consumers\7f130789
+Node: Avoiding Common Mistakes\7f131426
+Node: Generating Smaller Patches\7f133951
+Node: Invoking cmp\7f135712
+Node: cmp Options\7f137135
+Node: Invoking diff\7f140627
+Node: diff Options\7f142483
+Node: Invoking diff3\7f151185
+Node: diff3 Options\7f151823
+Node: Invoking patch\7f154856
+Node: patch Options\7f156064
+Node: Invoking sdiff\7f161291
+Node: sdiff Options\7f162434
+Node: Standards conformance\7f165405
+Node: Projects\7f167151
+Node: Shortcomings\7f167862
+Node: Internationalization\7f168964
+Node: Changing Structure\7f170130
+Node: Special Files\7f171234
+Node: Unusual File Names\7f172346
+Node: Time Stamp Order\7f172985
+Node: Ignoring Changes\7f173628
+Node: Speedups\7f174398
+Node: Bugs\7f174862
+Node: Copying This Manual\7f175715
+Node: Translations\7f200854
+Node: Index\7f201226
\1f
End Tag Table
-/* 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
/* 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 <config.h>
#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
*--p = '-';
}
else
-#endif
{
do
*--p = '0' + i % 10;
/* 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
/* 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
/* 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
/* 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
<ctype.h> 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
/* 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
#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 <stdlib.h>
#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
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)));
/* 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)))
{
#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)))
{
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
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. */
/* 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
/* -*- 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
/* -*- 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
/* -*- 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
/* 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
#include <errno.h>
#include <limits.h>
-
#include <signal.h>
-#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 <unistd.h>
+#include <stdint.h>
#include <inttypes.h>
#include <sys/types.h>
#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
/* 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
/* 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
/* 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
/* 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
/* 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
# include <stdbool.h>
# include <stddef.h>
+# 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);
--- /dev/null
+/* 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 <http://www.gnu.org/licenses/>.
+
+ 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_ */
/* 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
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__
/* 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
# include <fcntl.h>
# include <unistd.h>
-# 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 <windows.h>
+# 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
# 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
/* 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);
}
/* 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
#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
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
/* 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
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 *
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);
/* 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
/* 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
/* 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
/* 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
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);
/* 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
/* 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
--- /dev/null
+/* 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 <http://www.gnu.org/licenses/>. */
+
+/* Written by Jim Meyering. */
+
+#include <config.h>
+
+/* Specification. */
+#include "filenamecat.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#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;
+}
-/* 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
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* Written by Jim Meyering. */
+
#include <config.h>
-#include "dirname.h"
+/* Specification. */
+#include "filenamecat.h"
#include <stdlib.h>
#include <string.h>
+
#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;
}
-/* Failure exit status
+/* Concatenate two arbitrary file names.
- Copyright (C) 2002, 2003, 2005, 2006, 2007, 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
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include <config.h>
+/* Written by Jim Meyering. */
-#include "exitfail.h"
+#if GNULIB_FILENAMECAT
+char *file_name_concat (char const *dir, char const *base,
+ char **base_in_result);
+#endif
-#include <stdlib.h>
-
-int volatile exit_failure = EXIT_FAILURE;
+char *mfile_name_concat (char const *dir, char const *base,
+ char **base_in_result);
/* -*- 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
/* -*- 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
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;
}
#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;
/* 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
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.
|| !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;
|| 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);
return '?';
}
+ while (ambig_list != NULL)
+ {
+ struct option_list *pn = ambig_list->next;
+ free (ambig_list);
+ ambig_list = pn;
+ }
+
if (pfound != NULL)
{
option_index = indfound;
int indfound = 0;
int option_index;
+ if (longopts == NULL)
+ goto no_longs;
+
/* This is an option that requires an argument. */
if (*d->__nextchar != '\0')
{
}
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] == ':')
{
/* 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
/* 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.
#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
/* -*- buffer-read-only: t -*- vi: set ro: */
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Convenience header for conditional use of GNU <libintl.h>.
- 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
it now, to make later inclusions of <libintl.h> a NOP. */
#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
# include <cstdlib>
-# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
+# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
# include <libintl.h>
# endif
#endif
#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.
/* 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
/* 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
#ifdef __GLIBC__
# define GLIBC_VERSION __GLIBC__
+#elif defined __UCLIBC__
+# define GLIBC_VERSION 2
#else
# define GLIBC_VERSION 0
#endif
/* 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
/* 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.
#include "hash.h"
#include "bitrotate.h"
-#include "xalloc.h"
+#include "xalloc-oversized.h"
#include <stdint.h>
#include <stdio.h>
(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;
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)
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. */
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;
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)
{
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
* 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)
struct hash_entry *new_entry = allocate_entry (table);
if (new_entry == NULL)
- return NULL;
+ return -1;
/* Add ENTRY in the overflow of the bucket. */
new_entry->next = bucket->next;
bucket->next = new_entry;
table->n_entries++;
- return (void *) entry;
+ return 1;
}
/* Add ENTRY right in the bucket head. */
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
/* 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 <meyering@ascend.com>, 1998.
# include <stdio.h>
# include <stdbool.h>
-/* 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);
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
/* 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
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-/* 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,
"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
-#define inttostr imaxtostr
+#define anytostr imaxtostr
#define inttype intmax_t
-#define inttype_is_signed 1
-#include "inttostr.c"
+#include "anytostr.c"
/* 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
/* Written by Paul Eggert. */
-#ifndef GL_INTPROPS_H
-# define GL_INTPROPS_H
+#ifndef _GL_INTPROPS_H
+#define _GL_INTPROPS_H
-# include <limits.h>
+#include <limits.h>
+
+/* 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
+ <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>. */
+#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_<op>_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_<op>_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
+ <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>. */
+#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_<op>_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 <op> 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 */
-/* 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 <http://www.gnu.org/licenses/>. */
-
-/* Written by Paul Eggert */
-
-#include <config.h>
-
-#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"
/* 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
# 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__;
/* 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
{
/* 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);
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;
/* -*- 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
/* 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
/* written by Jim Meyering */
+/* If the user's config.h happens to include <sys/stat.h>, let it include only
+ the system's <sys/stat.h> here, so that orig_lstat doesn't recurse to
+ rpl_lstat. */
+#define __need_system_sys_stat_h
#include <config.h>
#if !HAVE_LSTAT
#else /* HAVE_LSTAT */
/* Get the original definition of lstat. It might be defined as a macro. */
-# define __need_system_sys_stat_h
# include <sys/types.h>
# include <sys/stat.h>
# undef __need_system_sys_stat_h
/* -*- 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 <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify
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 <config.h>
/* 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
#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
/* -*- 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 <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify
-/* 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
/* 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
/* 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
/* 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 <bruno@clisp.org>, 2005,
based on earlier glibc code.
/* 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 <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify
/* Searching in a string.
- Copyright (C) 2005-2010 Free Software Foundation, Inc.
+ Copyright (C) 2005-2011 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2005.
This program is free software: you can redistribute it and/or modify
#include "mbuiter.h"
/* Knuth-Morris-Pratt algorithm. */
+#define UNIT unsigned char
#define CANON_ELEMENT(c) c
#include "str-kmp.h"
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;
/* 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
/* -*- 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 <eggert@twinsun.com>.
# include <config.h>
#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. */
# include <stdio.h>
# include <stdlib.h>
/* 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
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,
#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))
#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)
#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
/* 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. */
# 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.
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. */
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
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)
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
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;
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;
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,
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;
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) */
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;
/* 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.
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:
/* 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;
}
| (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
\f
/*
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:
*/
-#define inttostr offtostr
+#define anytostr offtostr
#define inttype off_t
-#define inttype_is_signed 1
-#include "inttostr.c"
+#include "anytostr.c"
/* 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
/* 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 <bruno@clisp.org>, 2001.
This program is free software: you can redistribute it and/or modify
/* 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 <bruno@clisp.org>, 2001.
This program is free software: you can redistribute it and/or modify
/* Localization of proper names.
- Copyright (C) 2006-2010 Free Software Foundation, Inc.
+ Copyright (C) 2006-2011 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2006.
This program is free software: you can redistribute it and/or modify
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;
/* 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 <bruno@clisp.org>, 2006.
This program is free software: you can redistribute it and/or modify
/* 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
/* 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
/* 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
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;
}
/* 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
/* -*- 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 <isamu@yamato.ibm.com>.
/* -*- 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 <isamu@yamato.ibm.com>.
GNU regex allows. Include it before <regex.h>, which correctly
#undefs RE_DUP_MAX and sets it to the right value. */
#include <limits.h>
+#include <strings.h>
#include <regex.h>
#include "regex_internal.h"
/* 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
/* 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.
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
#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
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,
/* -*- 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 <isamu@yamato.ibm.com>.
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));
/* -*- 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 <isamu@yamato.ibm.com>.
#ifndef _LIBC
# include "localcharset.h"
#endif
-#if defined HAVE_LOCALE_H || defined _LIBC
-# include <locale.h>
-#endif
+#include <locale.h>
#include <wchar.h>
#include <wctype.h>
# 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
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,
# 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
/* -*- 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 <isamu@yamato.ibm.com>.
{
state->trtable = (re_dfastate_t **)
calloc (sizeof (re_dfastate_t *), SBC_MAX);
+ if (BE (state->trtable == NULL, 0))
+ return false;
return true;
}
return false;
/* -*- 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 <haible@clisp.cons.org>, 2001.
This program is free software: you can redistribute it and/or modify
/* 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 <haible@clisp.cons.org>, 2001.
This program is free software: you can redistribute it and/or modify
/* Convenience declarations when working with <signal.h>.
- 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
/* 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
}
/* 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)
{
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. */
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;
/* 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
/* 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
/* -*- 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 <bruno@clisp.org>, 2005.
This program is free software; you can redistribute it and/or modify
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));
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;
/* 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++;
/* -*- 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
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 <http://www.gnu.org/licenses/>. */
--- /dev/null
+/* 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 <http://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2010. */
+
+#include <config.h>
+
+#include "strerror-override.h"
+
+#include <errno.h>
+
+#if GNULIB_defined_ESOCK /* native Windows platforms */
+# if HAVE_WINSOCK2_H
+# include <winsock2.h>
+# 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;
+ }
+}
--- /dev/null
+/* 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 <http://www.gnu.org/licenses/>. */
+
+#ifndef _GL_STRERROR_OVERRIDE_H
+# define _GL_STRERROR_OVERRIDE_H
+
+# include <errno.h>
+# include <stddef.h>
+
+/* 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 */
-/* 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.
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)
#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 \
/* 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
/* -*- 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
/* 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
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
}
/* 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;
/* 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
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
}
/* 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);
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
/* 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
}
/* 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. */
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)
{
/* -*- 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
/* 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
/* 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
/* 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
/* 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
/* 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
+++ /dev/null
-/* -*- 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 <config.h>
-#endif
-
-#include <time.h>
-
-#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);
-}
/* 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
# include <time.h>
/* 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 *);
/* 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
/* 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));
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)))
{
}
if (state == 1 && !mb_isspace (mbi_cur (i)))
- {
- state = 1;
- continue;
- }
+ continue;
if (state == 1 && mb_isspace (mbi_cur (i)))
{
}
else if (state == 2 && mb_isspace (mbi_cur (i)))
{
- state = 2;
+ /* empty */
}
else
{
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;
}
-
/* 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
-#define inttostr uinttostr
+#define anytostr uinttostr
#define inttype unsigned int
-#define inttype_is_signed 0
-#include "inttostr.c"
+#include "anytostr.c"
-#define inttostr umaxtostr
+#define anytostr umaxtostr
#define inttype uintmax_t
-#define inttype_is_signed 0
-#include "inttostr.c"
+#include "anytostr.c"
--- /dev/null
+/* -*- 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 <bruno@clisp.org>, 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 <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* 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