mirror of
https://https.git.savannah.gnu.org/git/diffutils.git
synced 2026-01-26 15:03:22 +00:00
* src/cmp.c: Don't include <setmode.h>.
(specify_ignore_initial): Reword to avoid gcc -W warnings. (main): Use freopen instead of setmode, since freopen is in POSIX. * src/context.c: Revert most 2004-09-01 changes. Then: (TIMESPEC_NS): Remove. All uses replaced by get_stat_mtime_ns. Include stat-time.h, strftime.h. (nstrtime): Remove decl. * src/diff.c: Revert most 2004-09-01 changes. Then: Don't include <posixver.h>, <quotesys.h>, <setmode.h>. Include <sh-quote.h>, <stat-time.h>, <timespec.h>. All uses of quotesys replaced by sh-quote. (main, compare_files): Use freopen instead of setmode, since freopen is in POSIX. (main): Don't complain about "diff -NUM'. (main, set_mtime_to_now): Adjust to stat-time.h macros when accessing nanoseconds. * src/diff3.c: Include sh-quote.h rather than quotesys. All uses changed. * src/dir.c (dir_read): excluded_filename renamed to excluded_file_name. * src/io.c: Don't include <setmode.h>. (sip, read_files): Remove binary file stuff, leaving a FIXME behind. A DOS expert needs to look at this. * src/diff.c: Include sh-quote.h rather than quotesys.h. All uses changed. * src/system.h: Include verify.h. (verify): Remove. All uses changed to verify.h version. Include <intprops.h>. (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove. Now uses intprops.h versions. (O_BINARY): New defns, taken from coreutils. * src/util.c: Include sh-quote.h rather than quotesys.h. All uses changed.
This commit is contained in:
parent
174ab83965
commit
91b8605708
137
AUTHORS
137
AUTHORS
@ -1,112 +1,53 @@
|
||||
Authors of GNU diffutils.
|
||||
GNU diff was written by Paul Eggert, Mike Haertel, David Hayes,
|
||||
Richard Stallman, and Len Tower.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
GNU diff3 was written by Randy Smith.
|
||||
|
||||
This file is part of GNU diffutils.
|
||||
GNU sdiff was written by Thomas Lord.
|
||||
|
||||
GNU diffutils 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 2, or (at your option)
|
||||
any later version.
|
||||
GNU cmp was written by Torbjorn Granlund and David MacKenzie.
|
||||
|
||||
GNU diffutils 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.
|
||||
The diffutils manual was written by David MacKenzie, Paul Eggert, and
|
||||
Richard Stallman. Parts are adapted by from a manual page written by
|
||||
Larry Wall, with his permission.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU diffutils; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
Many other people have contributed to GNU diffutils, including Wayne
|
||||
Davison, Patrick D'Cruze, F. Thomas May, Greg McGary, Chip Rosenthal,
|
||||
and Eli Zaretskii.
|
||||
|
||||
The following contributions warranted legal paper exchanges with the
|
||||
Free Software Foundation. Also see files ChangeLog and THANKS.
|
||||
Free Software Foundation. Also see the files ChangeLog and THANKS.
|
||||
|
||||
DIFFUTILS Leonard H. Tower Jr. US 1949 1987-03-09
|
||||
Assigns diff (diff.c, initial version).
|
||||
Leonard H. Tower Jr.
|
||||
Torbjorn Granlund
|
||||
Mike Haertel
|
||||
David S. Hayes
|
||||
Randall Smith
|
||||
Richard Stallman
|
||||
F. Thomas May
|
||||
Wayne Davison
|
||||
Paul R. Eggert
|
||||
Chip Rosenthal
|
||||
Wayne Davison
|
||||
Patrick D'Cruze
|
||||
Eli Zaretskii
|
||||
|
||||
DIFFUTILS Torbjorn Granlund Sweden 1961 1988-01-11
|
||||
Assigns cmp.
|
||||
tege@matematik.su.se
|
||||
|
||||
DIFFUTILS Mike Haertel US 1967 1988-09-16
|
||||
Assigns changes to diff.
|
||||
Copyright (C) 2001, 2006 Free Software Foundation, Inc.
|
||||
|
||||
DIFFUTILS David S. Hayes US ? 1988-01-12
|
||||
Assigns changes to diff.
|
||||
This file is part of GNU diffutils.
|
||||
|
||||
DIFFUTILS Randall Smith US 1964 1988-09-21
|
||||
Assigns diff3.
|
||||
GNU diffutils 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 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
DIFFUTILS Richard Stallman US 1953 1988-01-15
|
||||
Assigns changes to GNU Diff.
|
||||
GNU diffutils 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.
|
||||
|
||||
DIFFUTILS F. Thomas May US 1965 1989-08-22
|
||||
Assigns changes to diff (for -D).
|
||||
|
||||
DIFFUTILS Optimal Solutions, Inc. 1989-08-14
|
||||
Disclaims changes by Thomas May to diff.
|
||||
|
||||
DIFFUTILS Wayne Davison 1990-09-10
|
||||
Disclaims changes to diff.
|
||||
|
||||
DIFFUTILS Digital Research Inc. 1990-09-13
|
||||
Disclaims changes by Wayne Davison to diff.
|
||||
|
||||
DIFFUTILS Paul Eggert 1990-03-16
|
||||
Disclaims changes to diff.
|
||||
eggert@twinsun.com
|
||||
|
||||
DIFFUTILS Paul Eggert 1990-08-14
|
||||
Disclaims changes to GNU Diff.
|
||||
eggert@twinsun.com
|
||||
|
||||
DIFFUTILS Twin Sun Inc. 1990-03-16
|
||||
Disclaims changes to GNU Diff by Paul Eggert.
|
||||
|
||||
DIFFUTILS Twin Sun Inc. 1990-08-14
|
||||
Disclaims changes to GNU Diff by Paul Eggert.
|
||||
|
||||
DIFFUTILS Chip Rosenthal US 1959 1990-03-06
|
||||
Assigns changes to diff.
|
||||
chip@chinacat.Unicom.COM
|
||||
|
||||
DIFFUTILS Unicom Systems Development 1990-03-06
|
||||
Disclaims changes by Chip Rosenthal to diff.
|
||||
|
||||
GCC DIFFUTILS Paul Eggert and Twin Sun Inc. 1992-03-11
|
||||
Disclaims changes by Paul Eggert to gcc and diff.
|
||||
eggert@twinsun.com
|
||||
|
||||
DIFF Wayne Davison 1993-06-20
|
||||
Disclaims diffcvt.c.
|
||||
|
||||
DIFFUTILS Francois Pinard Canada 1949 1993-01-15
|
||||
Assigns wdiff and future changes submitted to the FSF.
|
||||
pinard@iro.umontreal.ca
|
||||
|
||||
DIFFUTILS Patrick D'Cruze Australia 1971 1994-11-10
|
||||
Assigns changes (makefile.in, analyze.c, cmp.c, error.c, diff.c,
|
||||
diff3.c, getopt.c, getopt1.c, regex.c, sdiff.c, util.c, xmalloc.c;
|
||||
new file: language.++)
|
||||
|
||||
DIFFUTILS Paul R. Eggert US 1954 1997-04-07
|
||||
Assigns past and future changes.
|
||||
eggert@twinsun.com
|
||||
|
||||
DIFFUTILS Paul R. Eggert US 1954 1997-04-07
|
||||
Assigns past and future changes to manual.
|
||||
eggert@twinsun.com
|
||||
|
||||
ANY DIFFUTILS GNATS Cyclic Software 1997-11-11
|
||||
Assigns past and future works (work for hire by Tim Pierce (diffutils) and
|
||||
Abe Feldman (GNATS)).
|
||||
kingdon@cyclic.com
|
||||
|
||||
WEBPAGES Gregory B. Harvey Canada 1976 1998-02-14
|
||||
Assigns web pages describing GNU Diffutils and future changes.
|
||||
|
||||
DIFFUTILS Olga Nikulin Russia 1965 2001-01-11
|
||||
Assigns changes to diff. (diffutils-2.7.2/analyze.c, context.c, diff.[ch],
|
||||
ed.c, ifdef.c, io.c, normal.c, side.c, util.c)
|
||||
onikulin@yahoo.com
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU diffutils; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
136
ChangeLog
136
ChangeLog
@ -1,8 +1,118 @@
|
||||
2006-01-04 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* AUTHORS: Simplify list by removing legalisms.
|
||||
* THANKS: Add Larry Wall, who contributed to manual. Update email
|
||||
addresses.
|
||||
* Makefile.am (SUBDIRS): Remove m4. Put lib first, then other
|
||||
source files, so documentation can rely on programs being built.
|
||||
* bootstrap: Import changes from Bison bootstrap. Add gettext,
|
||||
gettime, sh-quote, stat-time, verify, version-etc-fsf modules.
|
||||
Remove posixver module. Retrieve doc/fdl.texi from gnulib.
|
||||
* configure.ac (AC_PREREQ): Bump to 2.59.
|
||||
(AC_INIT): Bump version to 2.8.7-cvs.
|
||||
(AC_CONFIG_AUX_DIR): Change from config to build-aux.
|
||||
Prefer AC_CHECK_HEADERS_ONCE to AC_CHECK_HEADERS
|
||||
and AC_CHECK_FUNCS_ONCE to AC_CHECK_FUNCS.
|
||||
Remove jm_AC_TYPE_INTMAX_T, jm_AC_TYPE_UINTMAX_T,
|
||||
AC_STRUCT_ST_MTIM_NSEC.
|
||||
(DIFFUTILS_PREREQUISITES): New macro. Call it.
|
||||
(REGEX_MALLOC): Remove; no longer needed.
|
||||
(AM_GNU_GETTEXT_VERSION): Now 0.14.15.
|
||||
(AM_GNU_GETTEXT): Call.
|
||||
(LIB_CLOCK_GETTIME): Remove; bootstrap now does that.
|
||||
(AC_FUNC_SETMODE_DOS): Remove.
|
||||
(AC_CONFIG_FILES): Remove m4/Makefile.
|
||||
* doc/diff.texi: Use @- at end of lines that should end in white space,
|
||||
so that Emacs doesn't remove the white space.
|
||||
(diff Options): "diff -NUM" is a pure extension to POSIX, so support
|
||||
it unconditionally.
|
||||
* lib/Makefile.am (noinst_HEADERS): Remove quotesys.h.
|
||||
(lib_SOURCES): Remove quotesys.c.
|
||||
(DISTCLEANFILES): Remove.
|
||||
(EXTRA_DIST): Remove setmode.h, waitpid.c.
|
||||
* lib/cmpbuf.c (block_read): Reword to avoid gcc -W warning.
|
||||
* lib/setmode.c, lib/setmode.h: Remove.
|
||||
* m4/setmode.m4, m4/gnu-source.m4, m4/Makefile.am.in: Remove.
|
||||
* m4/jm-glibc-io.m4: Remove.
|
||||
* src/cmp.c: Don't include <setmode.h>.
|
||||
(specify_ignore_initial): Reword to avoid gcc -W warnings.
|
||||
(main): Use freopen instead of setmode, since freopen is in POSIX.
|
||||
* src/context.c: Revert most 2004-09-01 changes. Then:
|
||||
(TIMESPEC_NS): Remove. All uses replaced by
|
||||
get_stat_mtime_ns.
|
||||
Include stat-time.h, strftime.h.
|
||||
(nstrtime): Remove decl.
|
||||
* src/diff.c: Revert most 2004-09-01 changes. Then:
|
||||
Don't include <posixver.h>, <quotesys.h>, <setmode.h>.
|
||||
Include <sh-quote.h>, <stat-time.h>, <timespec.h>.
|
||||
All uses of quotesys replaced by sh-quote.
|
||||
(main, compare_files):
|
||||
Use freopen instead of setmode, since freopen is in POSIX.
|
||||
(main): Don't complain about "diff -NUM'.
|
||||
(main, set_mtime_to_now):
|
||||
Adjust to stat-time.h macros when accessing nanoseconds.
|
||||
* src/diff3.c: Include sh-quote.h rather than quotesys. All uses
|
||||
changed.
|
||||
* src/dir.c (dir_read): excluded_filename renamed to
|
||||
excluded_file_name.
|
||||
* src/io.c: Don't include <setmode.h>.
|
||||
(sip, read_files): Remove binary file stuff, leaving a FIXME behind.
|
||||
A DOS expert needs to look at this.
|
||||
* src/diff.c: Include sh-quote.h rather than quotesys.h.
|
||||
All uses changed.
|
||||
* src/system.h: Include verify.h.
|
||||
(verify): Remove. All uses changed to verify.h version.
|
||||
Include <intprops.h>.
|
||||
(TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove. Now uses
|
||||
intprops.h versions.
|
||||
(O_BINARY): New defns, taken from coreutils.
|
||||
* src/util.c: Include sh-quote.h rather than quotesys.h.
|
||||
All uses changed.
|
||||
|
||||
2004-09-01 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* src/diff.c (recursive, new_file, unidirectional_new_file):
|
||||
(report_identical_files):
|
||||
Move into struct diffopt. All uses changed.
|
||||
(exclude_options, compare_files, specify_style, check_stdout):
|
||||
New arg OPT. All uses changed.
|
||||
(GDIFF_MAIN): Remove. All uses removed.
|
||||
(function_regexp_list, ignore_regexp_list): No longer static; now
|
||||
locals in 'main'.
|
||||
(main): Set opt.function_regexp, opt.ignore_regexp if using regexps;
|
||||
all other code now tests these pointers rather than inspecting fastmap
|
||||
internals.
|
||||
New local OPT to hold former statics; initialize it.
|
||||
(init_regexp_list): New function, used by main.
|
||||
(summarize_regexp_list): Now returns struct re_pattern_buffer *, and
|
||||
assumes reglist->regexps is not NULL. All uses changed.
|
||||
|
||||
* src/context.c (find_function_last_search): Move into struct diffopt.
|
||||
All uses changed.
|
||||
(pr_context_label, pr_context_header,
|
||||
print_context_script, find_function, find_hunk, mark_ignorable,
|
||||
pr_context_hunk, pr_unidiff_hunk): New arg OPT. All uses changed.
|
||||
(print_context_number_range,
|
||||
print_unidiff_number_range): New arg OUT. All uses changed.
|
||||
|
||||
2004-07-19 Stepan Kasal <kasal@ucw.cz>
|
||||
|
||||
* src/ed.c (print_ed_hunk): Optimize the case where an insert's
|
||||
last line is a single-dot line.
|
||||
|
||||
2004-06-30 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* lib/setmode.c:
|
||||
Don't include <stdbool.h>, since setmode.h now does this.
|
||||
Include setmode.h first, to catch interface errors.
|
||||
Assume HAVE_SETMODE_DOS is defined.
|
||||
|
||||
* lib/setmode.h: Include stdbool.h.
|
||||
|
||||
2004-04-26 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* bootstrap: Don't remove po/en.po.
|
||||
|
||||
2004-04-13 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* NEWS, configure.ac (AC_INIT): Version 2.8.7.
|
||||
@ -48,7 +158,7 @@
|
||||
the above.
|
||||
(AC_CONFIG_FILES): Remove lib/posix/Makefile.
|
||||
(AC_CONFIG_COMMANDS): Remove.
|
||||
|
||||
|
||||
* doc/diff.texi (dircategory): Change to "Text creation and
|
||||
manipulation" from "GNU packages".
|
||||
(Translations): New node.
|
||||
@ -3862,22 +3972,12 @@ Thu Nov 3 16:30:24 1988 Randall Smith (randy at gluteus.ai.mit.edu)
|
||||
the sake of System V (too simple not to do).
|
||||
|
||||
|
||||
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1997, 1998, 1999,
|
||||
2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
-----
|
||||
|
||||
This file is part of GNU Diffutils.
|
||||
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1997,
|
||||
1998, 1999, 2000, 2001, 2002, 2004, 2006 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 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that they 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; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
Copying and distribution of this file, with or without
|
||||
modification, are permitted provided the copyright notice and this
|
||||
notice are preserved.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Main Automakefile for GNU diffutils.
|
||||
|
||||
# Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001, 2002, 2004, 2006 Free Software Foundation, Inc.
|
||||
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
@ -18,6 +18,6 @@
|
||||
## 02111-1307, USA.
|
||||
|
||||
EXTRA_DIST = bootstrap exgettext
|
||||
SUBDIRS = doc lib m4 ms src man po
|
||||
SUBDIRS = lib ms src doc man po
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
13
NEWS
13
NEWS
@ -1,3 +1,16 @@
|
||||
User-visible changes since 2.8.7 (in "version" 2.8.7-cvs):
|
||||
|
||||
* Bring back support for `diff -NUM', where NUM is a number,
|
||||
even when conforming to POSIX 1003.1-2001. This change reverts to
|
||||
the behavior of GNU diff 2.7 and earlier. This is a change only
|
||||
when conforming to POSIX 1003.1-2001; there is no effect when
|
||||
conforming to older POSIX versions.
|
||||
|
||||
This change is in response to decisions taken in the January 2005
|
||||
Austin Group standardization meeting. For more details, please see
|
||||
"Utility Syntax Guidelines" in the Minutes of the January 2005
|
||||
Meeting <http://www.opengroup.org/austin/docs/austin_239.html>.
|
||||
|
||||
Version 2.8.7 contains no user-visible changes.
|
||||
|
||||
User-visible changes in version 2.8.6:
|
||||
|
||||
23
THANKS
23
THANKS
@ -1,22 +1,23 @@
|
||||
Thanks to all the following for their contributions to GNU diffutils:
|
||||
|
||||
Thomas Bushnell <tb@becket.net>
|
||||
Wayne Davison <wayned@users.sourceforge.net>
|
||||
Thomas Bushnell, BSG <tb@becket.net>
|
||||
Wayne Davison <wayne@opencoder.net>
|
||||
Ulrich Drepper <drepper@redhat.com>
|
||||
Paul Eggert <eggert@twinsun.com>
|
||||
Jay Fenlason <hack@gnu.org>
|
||||
John Gilmore <gnu@cygnus.com>
|
||||
Paul Eggert <eggert@cs.ucla.edu>
|
||||
Jay Fenlason <fenlason@redhat.com>
|
||||
John Gilmore <gnu@toad.com>
|
||||
Torbjorn Granlund <tege@swox.com>
|
||||
Mike Haertel <mike@ichips.intel.com>
|
||||
Bruno Haible <haible@ilog.fr>
|
||||
Bruno Haible <haible@clisp.org>
|
||||
Chris Hanson <cph@gnu.org>
|
||||
Jim Kingdon <kingdon@panix.com>
|
||||
Tom Lord <lord@gnu.org>
|
||||
David J. MacKenzie <djm@gnu.org>
|
||||
Roland McGrath <roland@gnu.org>
|
||||
Jim Meyering <meyering@lucent.com>
|
||||
Eugene W. Myers <gene@cs.arizona.edu>
|
||||
Roland McGrath <roland@redhat.com>
|
||||
Jim Meyering <jim@meyering.net>
|
||||
Gene Myers <gene@eecs.berkeley.edu>
|
||||
Randy Smith <randy@gnu.org>
|
||||
Richard Stallman <rms@gnu.org>
|
||||
Leonard H. Tower Jr. <tower@ai.mit.edu>
|
||||
Eli Zaretskii <eliz@is.elta.co.il>
|
||||
Leonard H. Tower Jr. <tower@art.net>
|
||||
Larry Wall <larry@wall.org>
|
||||
Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
150
bootstrap
150
bootstrap
@ -2,7 +2,7 @@
|
||||
|
||||
# Bootstrap this package from CVS.
|
||||
|
||||
# Copyright (C) 2003, 2004 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -16,27 +16,31 @@
|
||||
|
||||
# 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., 59 Temple Place - Suite 330, Boston, MA
|
||||
# 02111-1307, USA.
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
|
||||
# Written by Paul Eggert.
|
||||
|
||||
package=diffutils
|
||||
|
||||
# Ensure file names are sorted consistently across platforms;
|
||||
# e.g., m4/ulonglong_gl.m4 should follow m4/ulonglong.m4.
|
||||
# Also, ensure diagnostics are in English, e.g., "wget --help" below.
|
||||
LC_ALL=C
|
||||
export LC_ALL
|
||||
|
||||
# Parse options.
|
||||
|
||||
for option
|
||||
do
|
||||
case $option in
|
||||
--help)
|
||||
echo "$0: usage: $0 [--gnulib-srcdir=DIR] [--cvs-auth=AUTH-METHOD] [--cvs-user=USERNAME] [--skip-po]"
|
||||
echo "$0: usage: $0 [--gnulib-srcdir=DIR] [--cvs-user=USERNAME] [--skip-po]"
|
||||
exit;;
|
||||
--gnulib-srcdir=*)
|
||||
GNULIB_SRCDIR=`expr "$1" : '--gnulib-srcdir=\(.*\)'`;;
|
||||
--cvs-auth=*)
|
||||
CVS_AUTH=`expr "$1" : '--cvs-auth=\(.*\)'`;;
|
||||
GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
|
||||
--cvs-user=*)
|
||||
CVS_USER=`expr "$1" : '--cvs-user=\(.*\)'`;;
|
||||
CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
|
||||
--skip-po)
|
||||
SKIP_PO=t;;
|
||||
*)
|
||||
@ -47,11 +51,10 @@ done
|
||||
|
||||
echo "$0: Bootstrapping CVS $package..."
|
||||
|
||||
build_cvs_prefix() {
|
||||
CVS_PREFIX=:${1}:
|
||||
if [ "${2}" != - ]; then
|
||||
CVS_PREFIX=${CVS_PREFIX}${2}@
|
||||
fi
|
||||
cleanup_gnulib() {
|
||||
status=$?
|
||||
rm -fr gnulib
|
||||
exit $status
|
||||
}
|
||||
|
||||
# Get gnulib files.
|
||||
@ -61,26 +64,26 @@ case ${GNULIB_SRCDIR--} in
|
||||
if [ ! -d gnulib ]; then
|
||||
echo "$0: getting gnulib files..."
|
||||
|
||||
trap exit 1 2 13 15
|
||||
trap 'rm -fr gnulib; exit 1' 0
|
||||
|
||||
case "${CVS_AUTH--}" in
|
||||
-) : ${CVS_RSH:?}
|
||||
CVS_PREFIX="";;
|
||||
pserver) build_cvs_prefix $CVS_AUTH ${CVS_USER:-anoncvs};;
|
||||
gserver|server)
|
||||
build_cvs_prefix $CVS_AUTH ${CVS_USER--};;
|
||||
ext) : ${CVS_RSH:?}
|
||||
build_cvs_prefix $CVS_AUTH ${CVS_USER--};;
|
||||
*) echo "$0: Unknown CVS access method" >&2
|
||||
exit 1;;
|
||||
case ${CVS_AUTH-pserver} in
|
||||
pserver)
|
||||
CVS_PREFIX=':pserver:anonymous@';;
|
||||
ssh)
|
||||
CVS_PREFIX="$CVS_USER${CVS_USER+@}";;
|
||||
*)
|
||||
echo "$0: $CVS_AUTH: Unknown CVS access method" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
if [ "${CVS_AUTH--}" = "pserver" ]; then
|
||||
cvs -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/gnulib login || exit
|
||||
fi
|
||||
cvs -q -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/gnulib co gnulib || exit
|
||||
|
||||
trap 0
|
||||
case $CVS_RSH in
|
||||
'') export CVS_RSH=ssh;;
|
||||
esac
|
||||
|
||||
trap cleanup_gnulib 1 2 13 15
|
||||
|
||||
cvs -z3 -q -d ${CVS_PREFIX}cvs.savannah.gnu.org:/cvsroot/gnulib co gnulib ||
|
||||
cleanup_gnulib
|
||||
|
||||
trap - 1 2 13 15
|
||||
fi
|
||||
GNULIB_SRCDIR=gnulib
|
||||
esac
|
||||
@ -97,16 +100,21 @@ exitfail
|
||||
file-type
|
||||
fnmatch-gnu
|
||||
getopt
|
||||
gettext
|
||||
gettime
|
||||
hard-locale
|
||||
inttostr
|
||||
mkstemp
|
||||
posixver
|
||||
regex
|
||||
sh-quote
|
||||
stat-time
|
||||
strcase
|
||||
strftime
|
||||
strtoumax
|
||||
unlocked-io
|
||||
verify
|
||||
version-etc
|
||||
version-etc-fsf
|
||||
xalloc
|
||||
xstrtoumax
|
||||
'
|
||||
@ -126,7 +134,9 @@ gnulib_files=`
|
||||
(for gnulib_module in $gnulib_modules; do
|
||||
$GNULIB_SRCDIR/gnulib-tool --extract-filelist $gnulib_module
|
||||
done) | sort -u
|
||||
`
|
||||
`'
|
||||
doc/fdl.texi
|
||||
'
|
||||
|
||||
gnulib_dirs=`echo "$gnulib_files" | sed 's,/[^/]*$,,' | sort -u`
|
||||
mkdir -p $gnulib_dirs || exit
|
||||
@ -136,6 +146,14 @@ for gnulib_file in $gnulib_files; do
|
||||
|
||||
case $gnulib_file in
|
||||
m4/onceonly_2_57.m4) dest=m4/onceonly.m4;;
|
||||
# These will be overwritten by autopoint, which still uses
|
||||
# old jm_.* macro names, so we have to keep both copies.
|
||||
# m4/gettext.m4 isn't mentioned here, since it's patched below.
|
||||
m4/glibc21.m4 | m4/inttypes_h.m4 | m4/lib-ld.m4 | \
|
||||
m4/lib-prefix.m4 | m4/longlong.m4 | \
|
||||
m4/po.m4 | m4/stdint_h.m4 | m4/uintmax_t.m4 | \
|
||||
m4/ulonglong.m4)
|
||||
dest=`expr $gnulib_file : '\(.*\).m4'`_gl.m4;;
|
||||
esac
|
||||
|
||||
rm -f $dest &&
|
||||
@ -148,22 +166,25 @@ done
|
||||
|
||||
case $SKIP_PO in
|
||||
'')
|
||||
echo "$0: getting translations into po..."
|
||||
case `wget --help` in
|
||||
*'--no-cache'*)
|
||||
no_cache='--no-cache';;
|
||||
*'--cache=on/off'*)
|
||||
no_cache='--cache=off';;
|
||||
*)
|
||||
no_cache='';;
|
||||
esac
|
||||
|
||||
echo "$0: getting translations into po (please ignore the robots.txt ERROR 404)..."
|
||||
(cd po &&
|
||||
rm -f dummy `ls | sed -n '/\.gmo$/p; /^en\.po$d/; /\.po/p'` &&
|
||||
wget -nv -nd -r -l 1 -A .po -C off \
|
||||
http://www2.iro.umontreal.ca/~gnutra/po/maint/$package/ &&
|
||||
rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'` &&
|
||||
wget -nv -nd -r -l 1 -A .po $no_cache \
|
||||
http://www.iro.umontreal.ca/translation/maint/$package/ &&
|
||||
ls *.po | sed 's/\.po$//' >LINGUAS
|
||||
) || exit;;
|
||||
esac
|
||||
|
||||
|
||||
# Reconfigure, getting other files.
|
||||
|
||||
echo "$0: autoreconf --verbose --install --force ..."
|
||||
autoreconf --verbose --install --force || exit
|
||||
|
||||
|
||||
# Generate autoconf and automake snippets.
|
||||
|
||||
(echo '# This file is generated automatically by "bootstrap".' &&
|
||||
@ -177,4 +198,47 @@ autoreconf --verbose --install --force || exit
|
||||
) >lib/gnulib.mk || exit
|
||||
|
||||
|
||||
# Reconfigure, getting other files.
|
||||
|
||||
echo "$0: autoreconf --verbose --install --force ..."
|
||||
autoreconf --verbose --install --force || exit
|
||||
|
||||
|
||||
# We don't need intl, so remove it.
|
||||
# Remove aclocal.m4 too, so that it gets rebuilt.
|
||||
intl_files_to_remove='
|
||||
aclocal.m4
|
||||
intl
|
||||
m4/gettext.m4
|
||||
m4/glibc2.m4
|
||||
m4/glibc21.m4
|
||||
m4/intdiv0.m4
|
||||
m4/intmax.m4
|
||||
m4/inttypes_h.m4
|
||||
m4/inttypes.m4
|
||||
m4/inttypes-pri.m4
|
||||
m4/isc-posix.m4
|
||||
m4/lcmessage.m4
|
||||
m4/lib-ld.m4
|
||||
m4/lib-prefix.m4
|
||||
m4/longdouble.m4
|
||||
m4/longlong.m4
|
||||
m4/po.m4
|
||||
m4/printf-posix.m4
|
||||
m4/signed.m4
|
||||
m4/size_max.m4
|
||||
m4/stdint_h.m4
|
||||
m4/uintmax_t.m4
|
||||
m4/ulonglong.m4
|
||||
m4/wchar_t.m4
|
||||
m4/wint_t.m4
|
||||
m4/xsize.m4
|
||||
'
|
||||
echo $0: rm -fr $intl_files_to_remove ...
|
||||
rm -fr $intl_files_to_remove || exit
|
||||
|
||||
# Put bug-reporting address into po/Makevars.
|
||||
echo "$0: sed '/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-bison@gnu.org/' po/Makevars.template >po/Makevars ..."
|
||||
sed '/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-bison@gnu.org/' po/Makevars.template >po/Makevars
|
||||
|
||||
echo "$0: done. Now you can run './configure'."
|
||||
|
||||
55
configure.ac
55
configure.ac
@ -1,6 +1,6 @@
|
||||
# Configure template for GNU Diffutils.
|
||||
|
||||
# Copyright (C) 1994, 1995, 1998, 2001, 2002, 2004 Free Software
|
||||
# Copyright (C) 1994, 1995, 1998, 2001, 2002, 2004, 2006 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
@ -18,11 +18,11 @@
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
# 02111-1307, USA.
|
||||
|
||||
AC_PREREQ(2.53)
|
||||
AC_PREREQ(2.59)
|
||||
|
||||
AC_INIT([GNU diffutils], [2.8.7], [bug-gnu-utils@gnu.org])
|
||||
AC_INIT([GNU diffutils], [2.8.7-cvs], [bug-gnu-utils@gnu.org])
|
||||
AC_CONFIG_SRCDIR([src/diff.c])
|
||||
AC_CONFIG_AUX_DIR([config])
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AM_INIT_AUTOMAKE([gnits])
|
||||
@ -32,7 +32,7 @@ gl_USE_SYSTEM_EXTENSIONS
|
||||
AC_PROG_AWK
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_STDC
|
||||
AM_MISSING_PROG(HELP2MAN, help2man)
|
||||
AM_MISSING_PROG([HELP2MAN], [help2man])
|
||||
AC_PROG_RANLIB
|
||||
|
||||
AC_SYS_LARGEFILE
|
||||
@ -40,52 +40,35 @@ AC_SYS_LARGEFILE
|
||||
AC_C_INLINE
|
||||
AC_C_VARARRAYS
|
||||
|
||||
AC_DEFINE(DEFAULT_EDITOR_PROGRAM, "ed",
|
||||
AC_DEFINE([DEFAULT_EDITOR_PROGRAM], ["ed"],
|
||||
[Name of editor program, unless overridden.])
|
||||
|
||||
AC_PATH_PROG(PR_PROGRAM, pr, "")
|
||||
AC_DEFINE_UNQUOTED(PR_PROGRAM, "$PR_PROGRAM", [Name of "pr" program.])
|
||||
AC_PATH_PROG([PR_PROGRAM], [pr], [""])
|
||||
AC_DEFINE_UNQUOTED([PR_PROGRAM], ["$PR_PROGRAM"], [Name of "pr" program.])
|
||||
|
||||
AC_CHECK_HEADERS(fcntl.h locale.h sys/file.h unistd.h)
|
||||
AC_CHECK_HEADERS_ONCE([fcntl.h locale.h sys/file.h unistd.h])
|
||||
AC_CHECK_MEMBERS([struct stat.st_blksize])
|
||||
AC_CHECK_MEMBERS([struct stat.st_rdev])
|
||||
jm_AC_TYPE_INTMAX_T
|
||||
jm_AC_TYPE_UINTMAX_T
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_STRUCT_ST_MTIM_NSEC
|
||||
AC_TYPE_PID_T
|
||||
|
||||
AC_CHECK_FUNCS(dup2 gettimeofday sigaction sigprocmask strcasecoll stricoll)
|
||||
AC_REPLACE_FUNCS(waitpid)
|
||||
AC_DEFUN([DIFFUTILS_PREREQUISITES], [
|
||||
AC_REQUIRE([gl_AC_TYPE_INTMAX_T])
|
||||
AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])
|
||||
])
|
||||
DIFFUTILS_PREREQUISITES
|
||||
|
||||
AC_CHECK_FUNCS_ONCE([dup2 sigaction sigprocmask strcasecoll stricoll])
|
||||
AC_FUNC_CLOSEDIR_VOID
|
||||
AC_FUNC_FORK
|
||||
AC_DEFINE([REGEX_MALLOC], 1,
|
||||
[Define to 1 to avoid alloca in the regular-expression implementation.])
|
||||
|
||||
|
||||
GNULIB_AUTOCONF_SNIPPET
|
||||
AM_GNU_GETTEXT_VERSION([0.14.1])
|
||||
AM_GNU_GETTEXT([external], [need-ngettext])
|
||||
AM_GNU_GETTEXT_VERSION([0.14.5])
|
||||
XGETTEXT="AWK='$AWK' \$(SHELL) \$(top_srcdir)/exgettext $XGETTEXT"
|
||||
|
||||
|
||||
# Check for clock_gettime and its library. Solaris puts it in -lrt or
|
||||
# -lposix4, but we don't want to link that library unless we have to.
|
||||
diff_saved_libs=$LIBS
|
||||
AC_SEARCH_LIBS(clock_gettime, [rt posix4])
|
||||
case $ac_cv_search_clock_gettime in
|
||||
no | 'none required')
|
||||
LIB_CLOCK_GETTIME=;;
|
||||
*)
|
||||
LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime;;
|
||||
esac
|
||||
AC_SUBST([LIB_CLOCK_GETTIME])
|
||||
AC_CHECK_FUNCS(clock_gettime)
|
||||
LIBS=$diff_saved_libs
|
||||
|
||||
AC_FUNC_SETMODE_DOS
|
||||
|
||||
AC_CONFIG_FILES([Makefile doc/Makefile \
|
||||
lib/Makefile man/Makefile \
|
||||
m4/Makefile ms/Makefile po/Makefile.in src/Makefile])
|
||||
ms/Makefile po/Makefile.in src/Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
@ -15,8 +15,8 @@ and documents the @acronym{GNU} @command{diff}, @command{diff3},
|
||||
differences between files and the @acronym{GNU} @command{patch} command for
|
||||
using their output to update files.
|
||||
|
||||
Copyright @copyright{} 1992, 1993, 1994, 1998, 2001, 2002, 2004 Free
|
||||
Software Foundation, Inc.
|
||||
Copyright @copyright{} 1992, 1993, 1994, 1998, 2001, 2002, 2004, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
@quotation
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
@ -635,7 +635,7 @@ hunks have run together, because their contents overlap.
|
||||
--- 1,6 ----
|
||||
The Nameless is the origin of Heaven and Earth;
|
||||
! The named is the mother of all things.
|
||||
!
|
||||
! @-
|
||||
Therefore let there always be non-being,
|
||||
so we may see their subtlety,
|
||||
And let there always be being,
|
||||
@ -670,7 +670,7 @@ most one context line is reported here.
|
||||
--- 1,4 ----
|
||||
The Nameless is the origin of Heaven and Earth;
|
||||
! The named is the mother of all things.
|
||||
!
|
||||
! @-
|
||||
Therefore let there always be non-being,
|
||||
***************
|
||||
*** 11 ****
|
||||
@ -1087,7 +1087,7 @@ files.
|
||||
< The Named is the mother of all things.
|
||||
---
|
||||
> The named is the mother of all things.
|
||||
>
|
||||
> @-
|
||||
11a11,13
|
||||
> They both may be called deep and profound.
|
||||
> Deeper and more profound,
|
||||
@ -2026,7 +2026,7 @@ files.
|
||||
2:2,3c
|
||||
3:4,5c
|
||||
The named is the mother of all things.
|
||||
|
||||
@-
|
||||
====3
|
||||
1:8c
|
||||
2:7c
|
||||
@ -2040,7 +2040,7 @@ files.
|
||||
Deeper and more profound,
|
||||
The door of all subtleties!
|
||||
3:13,14c
|
||||
|
||||
@-
|
||||
-- The Way of Lao-Tzu, tr. Wing-tsit Chan
|
||||
@end example
|
||||
|
||||
@ -3708,11 +3708,10 @@ context, or three if @var{lines} is not given. @xref{Context Format}.
|
||||
For proper operation, @command{patch} typically needs at least two lines of
|
||||
context.
|
||||
|
||||
On older systems, @command{diff} supports an obsolete option
|
||||
@option{-@var{lines}} that has effect when combined with @option{-c}
|
||||
or @option{-p}. @acronym{POSIX} 1003.1-2001 (@pxref{Standards
|
||||
conformance}) does not allow this; use @option{-C @var{lines}}
|
||||
instead.
|
||||
For compatibility @command{diff} also supports an obsolete option
|
||||
syntax @option{-@var{lines}} that has effect when combined with
|
||||
@option{-c}, @option{-p}, or @option{-u}. New scripts should use
|
||||
@option{-C @var{lines}} or @option{-U @var{lines}} instead.
|
||||
|
||||
@item --changed-group-format=@var{format}
|
||||
Use @var{format} to output a line group containing differing lines from
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Automakefile for GNU Diffutils library.
|
||||
|
||||
# Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001, 2002, 2004, 2006 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
|
||||
@ -19,17 +19,16 @@
|
||||
|
||||
noinst_LIBRARIES = libdiffutils.a
|
||||
|
||||
noinst_HEADERS = cmpbuf.h prepargs.h quotesys.h
|
||||
noinst_HEADERS = cmpbuf.h prepargs.h
|
||||
|
||||
libdiffutils_a_SOURCES = $(lib_SOURCES)
|
||||
lib_SOURCES = cmpbuf.c prepargs.c quotesys.c
|
||||
lib_SOURCES = cmpbuf.c prepargs.c
|
||||
|
||||
libdiffutils_a_LIBADD = @ALLOCA@ @LIBOBJS@
|
||||
libdiffutils_a_DEPENDENCIES = $(libdiffutils_a_LIBADD)
|
||||
|
||||
BUILT_SOURCES =
|
||||
DISTCLEANFILES =
|
||||
EXTRA_DIST = setmode.h waitpid.c
|
||||
EXTRA_DIST =
|
||||
MOSTLYCLEANFILES =
|
||||
|
||||
include gnulib.mk
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
/* Buffer primitives for comparison operations.
|
||||
|
||||
Copyright (C) 1993, 1995, 1998, 2001, 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993, 1995, 1998, 2001, 2002, 2006 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
|
||||
@ -85,11 +86,12 @@ block_read (int fd, char *buf, size_t nbytes)
|
||||
{
|
||||
char *bp = buf;
|
||||
char const *buflim = buf + nbytes;
|
||||
size_t readlim = SSIZE_MAX;
|
||||
size_t readlim = MIN (SSIZE_MAX, SIZE_MAX);
|
||||
|
||||
do
|
||||
{
|
||||
size_t bytes_to_read = MIN (buflim - bp, readlim);
|
||||
size_t bytes_remaining = buflim - bp;
|
||||
size_t bytes_to_read = MIN (bytes_remaining, readlim);
|
||||
ssize_t nread = read (fd, bp, bytes_to_read);
|
||||
if (nread <= 0)
|
||||
{
|
||||
|
||||
@ -1,566 +0,0 @@
|
||||
/* Definitions for data structures and routines for the regular
|
||||
expression library, version 0.12.
|
||||
Copyright (C) 1985,1989-93,1995-98,2000,2001 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 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _REGEX_H
|
||||
#define _REGEX_H 1
|
||||
|
||||
/* Allow the use in C++ code. */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* POSIX says that <sys/types.h> must be included (by the caller) before
|
||||
<regex.h>. */
|
||||
|
||||
#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS
|
||||
/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
|
||||
should be there. */
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
|
||||
/* The following two types have to be signed and unsigned integer type
|
||||
wide enough to hold a value of a pointer. For most ANSI compilers
|
||||
ptrdiff_t and size_t should be likely OK. Still size of these two
|
||||
types is 2 for Microsoft C. Ugh... */
|
||||
typedef long int s_reg_t;
|
||||
typedef unsigned long int active_reg_t;
|
||||
|
||||
/* The following bits are used to determine the regexp syntax we
|
||||
recognize. The set/not-set meanings are chosen so that Emacs syntax
|
||||
remains the value 0. The bits are given in alphabetical order, and
|
||||
the definitions shifted by one from the previous bit; thus, when we
|
||||
add or remove a bit, only one other definition need change. */
|
||||
typedef unsigned long int reg_syntax_t;
|
||||
|
||||
/* If this bit is not set, then \ inside a bracket expression is literal.
|
||||
If set, then such a \ quotes the following character. */
|
||||
#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
|
||||
|
||||
/* If this bit is not set, then + and ? are operators, and \+ and \? are
|
||||
literals.
|
||||
If set, then \+ and \? are operators and + and ? are literals. */
|
||||
#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
|
||||
|
||||
/* If this bit is set, then character classes are supported. They are:
|
||||
[:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
|
||||
[:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
|
||||
If not set, then character classes are not supported. */
|
||||
#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
|
||||
|
||||
/* 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.
|
||||
|
||||
This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
|
||||
POSIX draft 11.2 says that * etc. in leading positions is undefined.
|
||||
We already implemented a previous draft which made those constructs
|
||||
invalid, though, so we haven't changed the code back. */
|
||||
#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
|
||||
|
||||
/* If this bit is set, then special characters are always special
|
||||
regardless of where they are in the pattern.
|
||||
If this bit is not set, then special characters are special only in
|
||||
some contexts; otherwise they are ordinary. Specifically,
|
||||
* + ? and intervals are only special when not after the beginning,
|
||||
open-group, or alternation operator. */
|
||||
#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
|
||||
|
||||
/* If this bit is set, then *, +, ?, and { cannot be first in an re or
|
||||
immediately after an alternation or begin-group operator. */
|
||||
#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
|
||||
|
||||
/* If this bit is set, then . matches newline.
|
||||
If not set, then it doesn't. */
|
||||
#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
|
||||
|
||||
/* If this bit is set, then . doesn't match NUL.
|
||||
If not set, then it does. */
|
||||
#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
|
||||
|
||||
/* If this bit is set, nonmatching lists [^...] do not match newline.
|
||||
If not set, they do. */
|
||||
#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
|
||||
|
||||
/* If this bit is set, either \{...\} or {...} defines an
|
||||
interval, depending on RE_NO_BK_BRACES.
|
||||
If not set, \{, \}, {, and } are literals. */
|
||||
#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
|
||||
|
||||
/* If this bit is set, +, ? and | aren't recognized as operators.
|
||||
If not set, they are. */
|
||||
#define RE_LIMITED_OPS (RE_INTERVALS << 1)
|
||||
|
||||
/* If this bit is set, newline is an alternation operator.
|
||||
If not set, newline is literal. */
|
||||
#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
|
||||
|
||||
/* If this bit is set, then `{...}' defines an interval, and \{ and \}
|
||||
are literals.
|
||||
If not set, then `\{...\}' defines an interval. */
|
||||
#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
|
||||
|
||||
/* If this bit is set, (...) defines a group, and \( and \) are literals.
|
||||
If not set, \(...\) defines a group, and ( and ) are literals. */
|
||||
#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
|
||||
|
||||
/* If this bit is set, then \<digit> matches <digit>.
|
||||
If not set, then \<digit> is a back-reference. */
|
||||
#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
|
||||
|
||||
/* If this bit is set, then | is an alternation operator, and \| is literal.
|
||||
If not set, then \| is an alternation operator, and | is literal. */
|
||||
#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
|
||||
|
||||
/* If this bit is set, then an ending range point collating higher
|
||||
than the starting range point, as in [z-a], is invalid.
|
||||
If not set, then when ending range point collates higher than the
|
||||
starting range point, the range is ignored. */
|
||||
#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
|
||||
|
||||
/* If this bit is set, then an unmatched ) is ordinary.
|
||||
If not set, then an unmatched ) is invalid. */
|
||||
#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
|
||||
|
||||
/* If this bit is set, succeed as soon as we match the whole pattern,
|
||||
without further backtracking. */
|
||||
#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
|
||||
|
||||
/* If this bit is set, do not process the GNU regex operators.
|
||||
If not set, then the GNU regex operators are recognized. */
|
||||
#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
|
||||
|
||||
/* If this bit is set, turn on internal regex debugging.
|
||||
If not set, and debugging was on, turn it off.
|
||||
This only works if regex.c is compiled -DDEBUG.
|
||||
We define this bit always, so that all that's needed to turn on
|
||||
debugging is to recompile regex.c; the calling code can always have
|
||||
this bit set, and it won't affect anything in the normal case. */
|
||||
#define RE_DEBUG (RE_NO_GNU_OPS << 1)
|
||||
|
||||
/* If this bit is set, a syntactically invalid interval is treated as
|
||||
a string of ordinary characters. For example, the ERE 'a{1' is
|
||||
treated as 'a\{1'. */
|
||||
#define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
|
||||
|
||||
/* This global variable defines the particular regexp syntax to use (for
|
||||
some interfaces). When a regexp is compiled, the syntax used is
|
||||
stored in the pattern buffer, so changing this does not affect
|
||||
already-compiled regexps. */
|
||||
extern reg_syntax_t re_syntax_options;
|
||||
|
||||
/* Define combinations of the above bits for the standard possibilities.
|
||||
(The [[[ comments delimit what gets put into the Texinfo file, so
|
||||
don't delete them!) */
|
||||
/* [[[begin syntaxes]]] */
|
||||
#define RE_SYNTAX_EMACS 0
|
||||
|
||||
#define RE_SYNTAX_AWK \
|
||||
(RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
|
||||
| RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
|
||||
| RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
|
||||
|
||||
#define RE_SYNTAX_GNU_AWK \
|
||||
((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \
|
||||
& ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS))
|
||||
|
||||
#define RE_SYNTAX_POSIX_AWK \
|
||||
(RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
|
||||
| RE_INTERVALS | RE_NO_GNU_OPS)
|
||||
|
||||
#define RE_SYNTAX_GREP \
|
||||
(RE_BK_PLUS_QM | RE_CHAR_CLASSES \
|
||||
| RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
|
||||
| RE_NEWLINE_ALT)
|
||||
|
||||
#define RE_SYNTAX_EGREP \
|
||||
(RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
|
||||
| RE_NEWLINE_ALT | RE_NO_BK_PARENS \
|
||||
| RE_NO_BK_VBAR)
|
||||
|
||||
#define RE_SYNTAX_POSIX_EGREP \
|
||||
(RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \
|
||||
| RE_INVALID_INTERVAL_ORD)
|
||||
|
||||
/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
|
||||
#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
|
||||
|
||||
#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
|
||||
|
||||
/* Syntax bits common to both basic and extended POSIX regex syntax. */
|
||||
#define _RE_SYNTAX_POSIX_COMMON \
|
||||
(RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
|
||||
| RE_INTERVALS | RE_NO_EMPTY_RANGES)
|
||||
|
||||
#define RE_SYNTAX_POSIX_BASIC \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
|
||||
|
||||
/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
|
||||
RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
|
||||
isn't minimal, since other operators, such as \`, aren't disabled. */
|
||||
#define RE_SYNTAX_POSIX_MINIMAL_BASIC \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
|
||||
|
||||
#define RE_SYNTAX_POSIX_EXTENDED \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_VBAR \
|
||||
| RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
|
||||
|
||||
/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
|
||||
removed and RE_NO_BK_REFS is added. */
|
||||
#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
|
||||
| RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
|
||||
/* [[[end syntaxes]]] */
|
||||
|
||||
/* Maximum number of duplicates an interval can allow. Some systems
|
||||
(erroneously) define this in other header files, but we want our
|
||||
value, so remove any previous define. */
|
||||
#ifdef RE_DUP_MAX
|
||||
# undef RE_DUP_MAX
|
||||
#endif
|
||||
/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */
|
||||
#define RE_DUP_MAX (0x7fff)
|
||||
|
||||
|
||||
/* POSIX `cflags' bits (i.e., information for `regcomp'). */
|
||||
|
||||
/* If this bit is set, then use extended regular expression syntax.
|
||||
If not set, then use basic regular expression syntax. */
|
||||
#define REG_EXTENDED 1
|
||||
|
||||
/* If this bit is set, then ignore case when matching.
|
||||
If not set, then case is significant. */
|
||||
#define REG_ICASE (REG_EXTENDED << 1)
|
||||
|
||||
/* If this bit is set, then anchors do not match at newline
|
||||
characters in the string.
|
||||
If not set, then anchors do match at newlines. */
|
||||
#define REG_NEWLINE (REG_ICASE << 1)
|
||||
|
||||
/* If this bit is set, then report only success or fail in regexec.
|
||||
If not set, then returns differ between not matching and errors. */
|
||||
#define REG_NOSUB (REG_NEWLINE << 1)
|
||||
|
||||
|
||||
/* POSIX `eflags' bits (i.e., information for regexec). */
|
||||
|
||||
/* If this bit is set, then the beginning-of-line operator doesn't match
|
||||
the beginning of the string (presumably because it's not the
|
||||
beginning of a line).
|
||||
If not set, then the beginning-of-line operator does match the
|
||||
beginning of the string. */
|
||||
#define REG_NOTBOL 1
|
||||
|
||||
/* Like REG_NOTBOL, except for the end-of-line. */
|
||||
#define REG_NOTEOL (1 << 1)
|
||||
|
||||
|
||||
/* If any error codes are removed, changed, or added, update the
|
||||
`re_error_msg' table in regex.c. */
|
||||
typedef enum
|
||||
{
|
||||
#ifdef _XOPEN_SOURCE
|
||||
REG_ENOSYS = -1, /* This will never happen for this implementation. */
|
||||
#endif
|
||||
|
||||
REG_NOERROR = 0, /* Success. */
|
||||
REG_NOMATCH, /* Didn't find a match (for regexec). */
|
||||
|
||||
/* POSIX regcomp return error codes. (In the order listed in the
|
||||
standard.) */
|
||||
REG_BADPAT, /* Invalid pattern. */
|
||||
REG_ECOLLATE, /* Not implemented. */
|
||||
REG_ECTYPE, /* Invalid character class name. */
|
||||
REG_EESCAPE, /* Trailing backslash. */
|
||||
REG_ESUBREG, /* Invalid back reference. */
|
||||
REG_EBRACK, /* Unmatched left bracket. */
|
||||
REG_EPAREN, /* Parenthesis imbalance. */
|
||||
REG_EBRACE, /* Unmatched \{. */
|
||||
REG_BADBR, /* Invalid contents of \{\}. */
|
||||
REG_ERANGE, /* Invalid range end. */
|
||||
REG_ESPACE, /* Ran out of memory. */
|
||||
REG_BADRPT, /* No preceding re for repetition op. */
|
||||
|
||||
/* Error codes we've added. */
|
||||
REG_EEND, /* Premature end. */
|
||||
REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
|
||||
REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
|
||||
} reg_errcode_t;
|
||||
|
||||
/* This data structure represents a compiled pattern. Before calling
|
||||
the pattern compiler, the fields `buffer', `allocated', `fastmap',
|
||||
`translate', and `no_sub' can be set. After the pattern has been
|
||||
compiled, the `re_nsub' field is available. All other fields are
|
||||
private to the regex routines. */
|
||||
|
||||
#ifndef RE_TRANSLATE_TYPE
|
||||
# define RE_TRANSLATE_TYPE char *
|
||||
#endif
|
||||
|
||||
struct re_pattern_buffer
|
||||
{
|
||||
/* [[[begin pattern_buffer]]] */
|
||||
/* Space that holds the compiled pattern. It is declared as
|
||||
`unsigned char *' because its elements are
|
||||
sometimes used as array indexes. */
|
||||
unsigned char *buffer;
|
||||
|
||||
/* Number of bytes to which `buffer' points. */
|
||||
unsigned long int allocated;
|
||||
|
||||
/* Number of bytes actually used in `buffer'. */
|
||||
unsigned long int used;
|
||||
|
||||
/* Syntax setting with which the pattern was compiled. */
|
||||
reg_syntax_t syntax;
|
||||
|
||||
/* Pointer to a fastmap, if any, otherwise zero. re_search uses
|
||||
the fastmap, if there is one, to skip over impossible
|
||||
starting points for matches. */
|
||||
char *fastmap;
|
||||
|
||||
/* Either a translate table to apply to all characters before
|
||||
comparing them, or zero for no translation. The translation
|
||||
is applied to a pattern when it is compiled and to a string
|
||||
when it is matched. */
|
||||
RE_TRANSLATE_TYPE translate;
|
||||
|
||||
/* Number of subexpressions found by the compiler. */
|
||||
size_t re_nsub;
|
||||
|
||||
/* Zero if this pattern cannot match the empty string, one else.
|
||||
Well, in truth it's used only in `re_search_2', to see
|
||||
whether or not we should use the fastmap, so we don't set
|
||||
this absolutely perfectly; see `re_compile_fastmap' (the
|
||||
`duplicate' case). */
|
||||
unsigned can_be_null : 1;
|
||||
|
||||
/* If REGS_UNALLOCATED, allocate space in the `regs' structure
|
||||
for `max (RE_NREGS, re_nsub + 1)' groups.
|
||||
If REGS_REALLOCATE, reallocate space if necessary.
|
||||
If REGS_FIXED, use what's there. */
|
||||
#define REGS_UNALLOCATED 0
|
||||
#define REGS_REALLOCATE 1
|
||||
#define REGS_FIXED 2
|
||||
unsigned regs_allocated : 2;
|
||||
|
||||
/* Set to zero when `regex_compile' compiles a pattern; set to one
|
||||
by `re_compile_fastmap' if it updates the fastmap. */
|
||||
unsigned fastmap_accurate : 1;
|
||||
|
||||
/* If set, `re_match_2' does not return information about
|
||||
subexpressions. */
|
||||
unsigned no_sub : 1;
|
||||
|
||||
/* If set, a beginning-of-line anchor doesn't match at the
|
||||
beginning of the string. */
|
||||
unsigned not_bol : 1;
|
||||
|
||||
/* Similarly for an end-of-line anchor. */
|
||||
unsigned not_eol : 1;
|
||||
|
||||
/* If true, an anchor at a newline matches. */
|
||||
unsigned newline_anchor : 1;
|
||||
|
||||
/* [[[end pattern_buffer]]] */
|
||||
};
|
||||
|
||||
typedef struct re_pattern_buffer regex_t;
|
||||
|
||||
/* Type for byte offsets within the string. POSIX mandates this. */
|
||||
typedef int regoff_t;
|
||||
|
||||
|
||||
/* This is the structure we store register match data in. See
|
||||
regex.texinfo for a full description of what registers match. */
|
||||
struct re_registers
|
||||
{
|
||||
unsigned num_regs;
|
||||
regoff_t *start;
|
||||
regoff_t *end;
|
||||
};
|
||||
|
||||
|
||||
/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
|
||||
`re_match_2' returns information about at least this many registers
|
||||
the first time a `regs' structure is passed. */
|
||||
#ifndef RE_NREGS
|
||||
# define RE_NREGS 30
|
||||
#endif
|
||||
|
||||
|
||||
/* POSIX specification for registers. Aside from the different names than
|
||||
`re_registers', POSIX uses an array of structures, instead of a
|
||||
structure of arrays. */
|
||||
typedef struct
|
||||
{
|
||||
regoff_t rm_so; /* Byte offset from string's start to substring's start. */
|
||||
regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
|
||||
} regmatch_t;
|
||||
|
||||
/* Declarations for routines. */
|
||||
|
||||
/* To avoid duplicating every routine declaration -- once with a
|
||||
prototype (if we are ANSI), and once without (if we aren't) -- we
|
||||
use the following macro to declare argument types. This
|
||||
unfortunately clutters up the declarations a bit, but I think it's
|
||||
worth it. */
|
||||
|
||||
#if __STDC__
|
||||
|
||||
# define _RE_ARGS(args) args
|
||||
|
||||
#else /* not __STDC__ */
|
||||
|
||||
# define _RE_ARGS(args) ()
|
||||
|
||||
#endif /* not __STDC__ */
|
||||
|
||||
/* Sets the current default syntax to SYNTAX, and return the old syntax.
|
||||
You can also simply assign to the `re_syntax_options' variable. */
|
||||
extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
|
||||
|
||||
/* Compile the regular expression PATTERN, with length LENGTH
|
||||
and syntax given by the global `re_syntax_options', into the buffer
|
||||
BUFFER. Return NULL if successful, and an error string if not. */
|
||||
extern const char *re_compile_pattern
|
||||
_RE_ARGS ((const char *pattern, size_t length,
|
||||
struct re_pattern_buffer *buffer));
|
||||
|
||||
|
||||
/* Compile a fastmap for the compiled pattern in BUFFER; used to
|
||||
accelerate searches. Return 0 if successful and -2 if was an
|
||||
internal error. */
|
||||
extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
|
||||
|
||||
|
||||
/* Search in the string STRING (with length LENGTH) for the pattern
|
||||
compiled into BUFFER. Start searching at position START, for RANGE
|
||||
characters. Return the starting position of the match, -1 for no
|
||||
match, or -2 for an internal error. Also return register
|
||||
information in REGS (if REGS and BUFFER->no_sub are nonzero). */
|
||||
extern int re_search
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
|
||||
int length, int start, int range, struct re_registers *regs));
|
||||
|
||||
|
||||
/* Like `re_search', but search in the concatenation of STRING1 and
|
||||
STRING2. Also, stop searching at index START + STOP. */
|
||||
extern int re_search_2
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
|
||||
int length1, const char *string2, int length2,
|
||||
int start, int range, struct re_registers *regs, int stop));
|
||||
|
||||
|
||||
/* Like `re_search', but return how many characters in STRING the regexp
|
||||
in BUFFER matched, starting at position START. */
|
||||
extern int re_match
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
|
||||
int length, int start, struct re_registers *regs));
|
||||
|
||||
|
||||
/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
|
||||
extern int re_match_2
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
|
||||
int length1, const char *string2, int length2,
|
||||
int start, struct re_registers *regs, int stop));
|
||||
|
||||
|
||||
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
|
||||
ENDS. Subsequent matches using BUFFER and REGS will use this memory
|
||||
for recording register information. STARTS and ENDS must be
|
||||
allocated with malloc, and must each be at least `NUM_REGS * sizeof
|
||||
(regoff_t)' bytes long.
|
||||
|
||||
If NUM_REGS == 0, then subsequent matches should allocate their own
|
||||
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. */
|
||||
extern void re_set_registers
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
|
||||
unsigned num_regs, regoff_t *starts, regoff_t *ends));
|
||||
|
||||
#if defined _REGEX_RE_COMP || defined _LIBC
|
||||
# ifndef _CRAY
|
||||
/* 4.2 bsd compatibility. */
|
||||
extern char *re_comp _RE_ARGS ((const char *));
|
||||
extern int re_exec _RE_ARGS ((const char *));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* GCC 2.95 and later have "__restrict"; C99 compilers have
|
||||
"restrict", and "configure" may have defined "restrict". */
|
||||
#ifndef __restrict
|
||||
# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
|
||||
# if defined restrict || 199901L <= __STDC_VERSION__
|
||||
# define __restrict restrict
|
||||
# else
|
||||
# define __restrict
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
/* gcc 3.1 and up support the [restrict] syntax. */
|
||||
#ifndef __restrict_arr
|
||||
# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
|
||||
# define __restrict_arr __restrict
|
||||
# else
|
||||
# define __restrict_arr
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* POSIX compatibility. */
|
||||
extern int regcomp _RE_ARGS ((regex_t *__restrict __preg,
|
||||
const char *__restrict __pattern,
|
||||
int __cflags));
|
||||
|
||||
extern int regexec _RE_ARGS ((const regex_t *__restrict __preg,
|
||||
const char *__restrict __string, size_t __nmatch,
|
||||
regmatch_t __pmatch[__restrict_arr],
|
||||
int __eflags));
|
||||
|
||||
extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
|
||||
char *__errbuf, size_t __errbuf_size));
|
||||
|
||||
extern void regfree _RE_ARGS ((regex_t *__preg));
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* C++ */
|
||||
|
||||
#endif /* regex.h */
|
||||
|
||||
/*
|
||||
Local variables:
|
||||
make-backup-files: t
|
||||
version-control: t
|
||||
trim-versions-without-asking: nil
|
||||
End:
|
||||
*/
|
||||
@ -1,53 +0,0 @@
|
||||
/* Set a file descriptor's mode to binary or to text.
|
||||
|
||||
Copyright (C) 2001, 2004 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 2, 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; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "setmode.h"
|
||||
#undef set_binary_mode
|
||||
|
||||
#include <io.h>
|
||||
#if HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef __attribute__
|
||||
# if __GNUC__ < 3 || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Set the binary mode of FD to MODE, returning its previous mode.
|
||||
MODE is true for binary and false for text. If setting the mode might
|
||||
cause problems, ignore the request and return MODE. */
|
||||
|
||||
bool
|
||||
set_binary_mode (int fd, bool mode)
|
||||
{
|
||||
if (isatty (fd))
|
||||
return mode;
|
||||
return setmode (fd, mode ? O_BINARY : O_TEXT) != O_TEXT;
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
/* Set a file descriptor's mode to binary or to text.
|
||||
|
||||
Copyright (C) 2001, 2004 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 2, 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; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef set_binary_mode
|
||||
bool set_binary_mode (int, bool);
|
||||
# if ! HAVE_SETMODE_DOS
|
||||
# define set_binary_mode(fd, mode) true
|
||||
# endif
|
||||
#endif
|
||||
@ -1,12 +0,0 @@
|
||||
## This is a template from which Makefile.am is generated. -*-Makefile-*-
|
||||
|
||||
Makefile.am: Makefile.am.in
|
||||
rm -f $@ $@t
|
||||
(echo "## Process this file with automake to produce Makefile.in."; \
|
||||
echo EXTRA_DIST =; \
|
||||
echo "EXTRA_DIST += Makefile.am.in"; \
|
||||
ls -1 *.m4 | sed 's/^/EXTRA_DIST += /'; echo ) \
|
||||
>> $@t
|
||||
sed -n '/^Makefile\.am:/,$$p' $@.in >> $@t
|
||||
chmod a-w $@t
|
||||
mv $@t $@
|
||||
@ -1,12 +0,0 @@
|
||||
# AC_GNU_SOURCE
|
||||
# --------------
|
||||
AC_DEFUN([AC_GNU_SOURCE],
|
||||
[AH_VERBATIM([_GNU_SOURCE],
|
||||
[/* Enable GNU extensions on systems that have them. */
|
||||
#ifndef _GNU_SOURCE
|
||||
# undef _GNU_SOURCE
|
||||
#endif])dnl
|
||||
AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
|
||||
AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
|
||||
AC_DEFINE([_GNU_SOURCE])
|
||||
])
|
||||
@ -1,14 +0,0 @@
|
||||
#serial 7 -*- autoconf -*-
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl
|
||||
dnl See if the glibc *_unlocked I/O macros are available.
|
||||
dnl Use only those *_unlocked macros that are declared.
|
||||
dnl
|
||||
|
||||
AC_DEFUN([jm_FUNC_GLIBC_UNLOCKED_IO],
|
||||
[AC_CHECK_DECLS(
|
||||
[clearerr_unlocked, feof_unlocked, ferror_unlocked,
|
||||
fflush_unlocked, fgets_unlocked, fputc_unlocked, fputs_unlocked,
|
||||
fread_unlocked, fwrite_unlocked, getc_unlocked,
|
||||
getchar_unlocked, putc_unlocked, putchar_unlocked])])
|
||||
@ -1,39 +0,0 @@
|
||||
# Check for setmode, DOS style.
|
||||
|
||||
# Copyright (C) 2001, 2002, 2004 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 2, 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., 59 Temple Place - Suite 330, Boston, MA
|
||||
# 02111-1307, USA.
|
||||
|
||||
AC_DEFUN([AC_FUNC_SETMODE_DOS],
|
||||
[AC_CHECK_HEADERS(fcntl.h unistd.h)
|
||||
AC_CACHE_CHECK([for DOS-style setmode],
|
||||
[ac_cv_func_setmode_dos],
|
||||
[AC_TRY_LINK(
|
||||
[#include <io.h>
|
||||
#if HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif],
|
||||
[int ret = setmode && setmode (1, O_BINARY);],
|
||||
[ac_cv_func_setmode_dos=yes],
|
||||
[ac_cv_func_setmode_dos=no])])
|
||||
if test $ac_cv_func_setmode_dos = yes; then
|
||||
AC_LIBOBJ(setmode)
|
||||
AC_DEFINE(HAVE_SETMODE_DOS, 1,
|
||||
[Define to 1 if you have the DOS-style `setmode' function.])
|
||||
fi])
|
||||
24
src/cmp.c
24
src/cmp.c
@ -1,7 +1,7 @@
|
||||
/* cmp - compare two files byte by byte
|
||||
|
||||
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2001,
|
||||
2002, 2004 Free Software Foundation, Inc.
|
||||
2002, 2004, 2006 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
|
||||
@ -32,7 +32,6 @@
|
||||
#include <getopt.h>
|
||||
#include <hard-locale.h>
|
||||
#include <inttostr.h>
|
||||
#include <setmode.h>
|
||||
#include <unlocked-io.h>
|
||||
#include <version-etc.h>
|
||||
#include <xalloc.h>
|
||||
@ -126,15 +125,14 @@ static void
|
||||
specify_ignore_initial (int f, char **argptr, char delimiter)
|
||||
{
|
||||
uintmax_t val;
|
||||
off_t o;
|
||||
char const *arg = *argptr;
|
||||
strtol_error e = xstrtoumax (arg, argptr, 0, &val, valid_suffixes);
|
||||
if (! (e == LONGINT_OK
|
||||
|| (e == LONGINT_INVALID_SUFFIX_CHAR && **argptr == delimiter))
|
||||
|| (o = val) < 0 || o != val || val == UINTMAX_MAX)
|
||||
|| TYPE_MAXIMUM (off_t) < val)
|
||||
try_help ("invalid --ignore-initial value `%s'", arg);
|
||||
if (ignore_initial[f] < o)
|
||||
ignore_initial[f] = o;
|
||||
if (ignore_initial[f] < val)
|
||||
ignore_initial[f] = val;
|
||||
}
|
||||
|
||||
/* Specify the output format. */
|
||||
@ -284,9 +282,15 @@ main (int argc, char **argv)
|
||||
&& file_name_cmp (file[0], file[1]) == 0)
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
file_desc[f1] = (strcmp (file[f1], "-") == 0
|
||||
? STDIN_FILENO
|
||||
: open (file[f1], O_RDONLY, 0));
|
||||
if (strcmp (file[f1], "-") == 0)
|
||||
{
|
||||
file_desc[f1] = STDIN_FILENO;
|
||||
if (O_BINARY && ! isatty (STDIN_FILENO))
|
||||
freopen (NULL, "rb", stdin);
|
||||
}
|
||||
else
|
||||
file_desc[f1] = open (file[f1], O_RDONLY | O_BINARY, 0);
|
||||
|
||||
if (file_desc[f1] < 0 || fstat (file_desc[f1], stat_buf + f1) != 0)
|
||||
{
|
||||
if (file_desc[f1] < 0 && comparison_type == type_status)
|
||||
@ -294,8 +298,6 @@ main (int argc, char **argv)
|
||||
else
|
||||
error (EXIT_TROUBLE, errno, "%s", file[f1]);
|
||||
}
|
||||
|
||||
set_binary_mode (file_desc[f1], true);
|
||||
}
|
||||
|
||||
/* If the files are links to the same inode and have the same file position,
|
||||
|
||||
207
src/context.c
207
src/context.c
@ -1,7 +1,7 @@
|
||||
/* Context-format output routines for GNU DIFF.
|
||||
|
||||
Copyright (C) 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1998, 2001,
|
||||
2002, 2004 Free Software Foundation, Inc.
|
||||
2002, 2004, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU DIFF.
|
||||
|
||||
@ -22,73 +22,70 @@
|
||||
|
||||
#include "diff.h"
|
||||
#include <inttostr.h>
|
||||
#include <stat-time.h>
|
||||
#include <strftime.h>
|
||||
|
||||
#ifdef ST_MTIM_NSEC
|
||||
# define TIMESPEC_NS(timespec) ((timespec).ST_MTIM_NSEC)
|
||||
#else
|
||||
# define TIMESPEC_NS(timespec) 0
|
||||
#endif
|
||||
static char const *find_function (char const * const *, lin);
|
||||
static struct change *find_hunk (struct change *);
|
||||
static void mark_ignorable (struct change *);
|
||||
static void pr_context_hunk (struct change *);
|
||||
static void pr_unidiff_hunk (struct change *);
|
||||
|
||||
size_t nstrftime (char *, size_t, char const *, struct tm const *, int, int);
|
||||
/* Last place find_function started searching from. */
|
||||
static lin find_function_last_search;
|
||||
|
||||
static char const *find_function (char const * const *, lin, struct diffopt *);
|
||||
static struct change *find_hunk (struct change *, struct diffopt const *opt);
|
||||
static void mark_ignorable (struct change *, struct diffopt *);
|
||||
static void pr_context_hunk (struct change *, struct diffopt *);
|
||||
static void pr_unidiff_hunk (struct change *, struct diffopt *);
|
||||
/* The value find_function returned when it started searching there. */
|
||||
static lin find_function_last_match;
|
||||
|
||||
/* Print a label for a context diff, with a file name and date or a label. */
|
||||
|
||||
static void
|
||||
print_context_label (char const *mark,
|
||||
struct file_data *inf,
|
||||
char const *label,
|
||||
struct diffopt const *opt)
|
||||
char const *label)
|
||||
{
|
||||
if (label)
|
||||
fprintf (opt->out, "%s %s\n", mark, label);
|
||||
fprintf (outfile, "%s %s\n", mark, label);
|
||||
else
|
||||
{
|
||||
char buf[MAX (INT_STRLEN_BOUND (int) + 32,
|
||||
INT_STRLEN_BOUND (time_t) + 11)];
|
||||
struct tm const *tm = localtime (&inf->stat.st_mtime);
|
||||
int nsec = TIMESPEC_NS (inf->stat.st_mtim);
|
||||
if (! (tm && nstrftime (buf, sizeof buf, opt->time_format, tm, 0, nsec)))
|
||||
int nsec = get_stat_mtime_ns (&inf->stat);
|
||||
if (! (tm && nstrftime (buf, sizeof buf, time_format, tm, 0, nsec)))
|
||||
{
|
||||
long int sec = inf->stat.st_mtime;
|
||||
verify (info_preserved, sizeof inf->stat.st_mtime <= sizeof sec);
|
||||
verify (sizeof inf->stat.st_mtime <= sizeof sec);
|
||||
sprintf (buf, "%ld.%.9d", sec, nsec);
|
||||
}
|
||||
fprintf (opt->out, "%s %s\t%s\n", mark, inf->name, buf);
|
||||
fprintf (outfile, "%s %s\t%s\n", mark, inf->name, buf);
|
||||
}
|
||||
}
|
||||
|
||||
/* Print a header for a context diff, with the file names and dates. */
|
||||
|
||||
void
|
||||
print_context_header (struct file_data inf[], bool unidiff,
|
||||
struct diffopt const *opt)
|
||||
print_context_header (struct file_data inf[], bool unidiff)
|
||||
{
|
||||
if (unidiff)
|
||||
{
|
||||
print_context_label ("---", &inf[0], opt->file_label[0], opt);
|
||||
print_context_label ("+++", &inf[1], opt->file_label[1], opt);
|
||||
print_context_label ("---", &inf[0], file_label[0]);
|
||||
print_context_label ("+++", &inf[1], file_label[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_context_label ("***", &inf[0], opt->file_label[0], opt);
|
||||
print_context_label ("---", &inf[1], opt->file_label[1], opt);
|
||||
print_context_label ("***", &inf[0], file_label[0]);
|
||||
print_context_label ("---", &inf[1], file_label[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Print an edit script in context format. */
|
||||
|
||||
void
|
||||
print_context_script (struct change *script, bool unidiff,
|
||||
struct diffopt *opt)
|
||||
print_context_script (struct change *script, bool unidiff)
|
||||
{
|
||||
if (opt->ignore_blank_lines || opt->ignore_regexp)
|
||||
mark_ignorable (script, opt);
|
||||
if (ignore_blank_lines || ignore_regexp.fastmap)
|
||||
mark_ignorable (script);
|
||||
else
|
||||
{
|
||||
struct change *e;
|
||||
@ -96,13 +93,13 @@ print_context_script (struct change *script, bool unidiff,
|
||||
e->ignore = false;
|
||||
}
|
||||
|
||||
opt->find_function.last_search = - opt->file[0].prefix_lines;
|
||||
opt->find_function.last_match = LIN_MAX;
|
||||
find_function_last_search = - files[0].prefix_lines;
|
||||
find_function_last_match = LIN_MAX;
|
||||
|
||||
if (unidiff)
|
||||
print_script (script, find_hunk, pr_unidiff_hunk, opt);
|
||||
print_script (script, find_hunk, pr_unidiff_hunk);
|
||||
else
|
||||
print_script (script, find_hunk, pr_context_hunk, opt);
|
||||
print_script (script, find_hunk, pr_context_hunk);
|
||||
}
|
||||
|
||||
/* Print a pair of line numbers with a comma, translated for file FILE.
|
||||
@ -112,8 +109,7 @@ print_context_script (struct change *script, bool unidiff,
|
||||
We print the translated (real) line numbers. */
|
||||
|
||||
static void
|
||||
print_context_number_range (FILE *out, struct file_data const *file,
|
||||
lin a, lin b)
|
||||
print_context_number_range (struct file_data const *file, lin a, lin b)
|
||||
{
|
||||
long int trans_a, trans_b;
|
||||
translate_range (file, a, b, &trans_a, &trans_b);
|
||||
@ -128,9 +124,9 @@ print_context_number_range (FILE *out, struct file_data const *file,
|
||||
specification. */
|
||||
|
||||
if (trans_b <= trans_a)
|
||||
fprintf (out, "%ld", trans_b);
|
||||
fprintf (outfile, "%ld", trans_b);
|
||||
else
|
||||
fprintf (out, "%ld,%ld", trans_a, trans_b);
|
||||
fprintf (outfile, "%ld,%ld", trans_a, trans_b);
|
||||
}
|
||||
|
||||
/* Print FUNCTION in a context header. */
|
||||
@ -147,13 +143,12 @@ print_context_function (FILE *out, char const *function)
|
||||
/* Print a portion of an edit script in context format.
|
||||
HUNK is the beginning of the portion to be printed.
|
||||
The end is marked by a `link' that has been nulled out.
|
||||
OPT is the diff options.
|
||||
|
||||
Prints out lines from both files, and precedes each
|
||||
line with the appropriate flag-character. */
|
||||
|
||||
static void
|
||||
pr_context_hunk (struct change *hunk, struct diffopt *opt)
|
||||
pr_context_hunk (struct change *hunk)
|
||||
{
|
||||
lin first0, last0, first1, last1, i;
|
||||
char const *prefix;
|
||||
@ -162,32 +157,31 @@ pr_context_hunk (struct change *hunk, struct diffopt *opt)
|
||||
|
||||
/* Determine range of line numbers involved in each file. */
|
||||
|
||||
enum changes changes = analyze_hunk (hunk, &first0, &last0, &first1, &last1,
|
||||
opt);
|
||||
enum changes changes = analyze_hunk (hunk, &first0, &last0, &first1, &last1);
|
||||
if (! changes)
|
||||
return;
|
||||
|
||||
/* Include a context's width before and after. */
|
||||
|
||||
i = - opt->file[0].prefix_lines;
|
||||
first0 = MAX (first0 - opt->context, i);
|
||||
first1 = MAX (first1 - opt->context, i);
|
||||
if (last0 < opt->file[0].valid_lines - opt->context)
|
||||
last0 += opt->context;
|
||||
i = - files[0].prefix_lines;
|
||||
first0 = MAX (first0 - context, i);
|
||||
first1 = MAX (first1 - context, i);
|
||||
if (last0 < files[0].valid_lines - context)
|
||||
last0 += context;
|
||||
else
|
||||
last0 = opt->file[0].valid_lines - 1;
|
||||
if (last1 < opt->file[1].valid_lines - opt->context)
|
||||
last1 += opt->context;
|
||||
last0 = files[0].valid_lines - 1;
|
||||
if (last1 < files[1].valid_lines - context)
|
||||
last1 += context;
|
||||
else
|
||||
last1 = opt->file[1].valid_lines - 1;
|
||||
last1 = files[1].valid_lines - 1;
|
||||
|
||||
/* If desired, find the preceding function definition line in file 0. */
|
||||
function = 0;
|
||||
if (opt->function_regexp)
|
||||
function = find_function (opt->file[0].linbuf, first0, opt);
|
||||
function = NULL;
|
||||
if (function_regexp.fastmap)
|
||||
function = find_function (files[0].linbuf, first0);
|
||||
|
||||
begin_output (opt);
|
||||
out = opt->out;
|
||||
begin_output ();
|
||||
out = outfile;
|
||||
|
||||
fprintf (out, "***************");
|
||||
|
||||
@ -195,7 +189,7 @@ pr_context_hunk (struct change *hunk, struct diffopt *opt)
|
||||
print_context_function (out, function);
|
||||
|
||||
fprintf (out, "\n*** ");
|
||||
print_context_number_range (opt->out, &opt->file[0], first0, last0);
|
||||
print_context_number_range (&files[0], first0, last0);
|
||||
fprintf (out, " ****\n");
|
||||
|
||||
if (changes & OLD)
|
||||
@ -219,12 +213,12 @@ pr_context_hunk (struct change *hunk, struct diffopt *opt)
|
||||
Otherwise it is "deleted". */
|
||||
prefix = (next->inserted > 0 ? "!" : "-");
|
||||
|
||||
print_1_line (prefix, &opt->file[0].linbuf[i], opt);
|
||||
print_1_line (prefix, &files[0].linbuf[i]);
|
||||
}
|
||||
}
|
||||
|
||||
fprintf (out, "--- ");
|
||||
print_context_number_range (opt->out, &opt->file[1], first1, last1);
|
||||
print_context_number_range (&files[1], first1, last1);
|
||||
fprintf (out, " ----\n");
|
||||
|
||||
if (changes & NEW)
|
||||
@ -248,7 +242,7 @@ pr_context_hunk (struct change *hunk, struct diffopt *opt)
|
||||
Otherwise it is "inserted". */
|
||||
prefix = (next->deleted > 0 ? "!" : "+");
|
||||
|
||||
print_1_line (prefix, &opt->file[1].linbuf[i], opt);
|
||||
print_1_line (prefix, &files[1].linbuf[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -258,13 +252,10 @@ pr_context_hunk (struct change *hunk, struct diffopt *opt)
|
||||
If the numbers are equal, print just one number.
|
||||
|
||||
Args A and B are internal line numbers.
|
||||
We print the translated (real) line numbers.
|
||||
|
||||
OPT is the diff options. */
|
||||
We print the translated (real) line numbers. */
|
||||
|
||||
static void
|
||||
print_unidiff_number_range (FILE *out, struct file_data const *file,
|
||||
lin a, lin b)
|
||||
print_unidiff_number_range (struct file_data const *file, lin a, lin b)
|
||||
{
|
||||
long int trans_a, trans_b;
|
||||
translate_range (file, a, b, &trans_a, &trans_b);
|
||||
@ -274,9 +265,9 @@ print_unidiff_number_range (FILE *out, struct file_data const *file,
|
||||
which is B. It would be more logical to print A, but
|
||||
'patch' expects B in order to detect diffs against empty files. */
|
||||
if (trans_b <= trans_a)
|
||||
fprintf (out, trans_b < trans_a ? "%ld,0" : "%ld", trans_b);
|
||||
fprintf (outfile, trans_b < trans_a ? "%ld,0" : "%ld", trans_b);
|
||||
else
|
||||
fprintf (out, "%ld,%ld", trans_a, trans_b - trans_a + 1);
|
||||
fprintf (outfile, "%ld,%ld", trans_a, trans_b - trans_a + 1);
|
||||
}
|
||||
|
||||
/* Print a portion of an edit script in unidiff format.
|
||||
@ -284,12 +275,10 @@ print_unidiff_number_range (FILE *out, struct file_data const *file,
|
||||
The end is marked by a `link' that has been nulled out.
|
||||
|
||||
Prints out lines from both files, and precedes each
|
||||
line with the appropriate flag-character.
|
||||
|
||||
OPT is the diff options. */
|
||||
line with the appropriate flag-character. */
|
||||
|
||||
static void
|
||||
pr_unidiff_hunk (struct change *hunk, struct diffopt *opt)
|
||||
pr_unidiff_hunk (struct change *hunk)
|
||||
{
|
||||
lin first0, last0, first1, last1;
|
||||
lin i, j, k;
|
||||
@ -299,35 +288,35 @@ pr_unidiff_hunk (struct change *hunk, struct diffopt *opt)
|
||||
|
||||
/* Determine range of line numbers involved in each file. */
|
||||
|
||||
if (! analyze_hunk (hunk, &first0, &last0, &first1, &last1, opt))
|
||||
if (! analyze_hunk (hunk, &first0, &last0, &first1, &last1))
|
||||
return;
|
||||
|
||||
/* Include a context's width before and after. */
|
||||
|
||||
i = - opt->file[0].prefix_lines;
|
||||
first0 = MAX (first0 - opt->context, i);
|
||||
first1 = MAX (first1 - opt->context, i);
|
||||
if (last0 < opt->file[0].valid_lines - opt->context)
|
||||
last0 += opt->context;
|
||||
i = - files[0].prefix_lines;
|
||||
first0 = MAX (first0 - context, i);
|
||||
first1 = MAX (first1 - context, i);
|
||||
if (last0 < files[0].valid_lines - context)
|
||||
last0 += context;
|
||||
else
|
||||
last0 = opt->file[0].valid_lines - 1;
|
||||
if (last1 < opt->file[1].valid_lines - opt->context)
|
||||
last1 += opt->context;
|
||||
last0 = files[0].valid_lines - 1;
|
||||
if (last1 < files[1].valid_lines - context)
|
||||
last1 += context;
|
||||
else
|
||||
last1 = opt->file[1].valid_lines - 1;
|
||||
last1 = files[1].valid_lines - 1;
|
||||
|
||||
/* If desired, find the preceding function definition line in file 0. */
|
||||
function = 0;
|
||||
if (opt->function_regexp)
|
||||
function = find_function (opt->file[0].linbuf, first0, opt);
|
||||
function = NULL;
|
||||
if (function_regexp.fastmap)
|
||||
function = find_function (files[0].linbuf, first0);
|
||||
|
||||
begin_output (opt);
|
||||
out = opt->out;
|
||||
begin_output ();
|
||||
out = outfile;
|
||||
|
||||
fprintf (out, "@@ -");
|
||||
print_unidiff_number_range (opt->out, &opt->file[0], first0, last0);
|
||||
print_unidiff_number_range (&files[0], first0, last0);
|
||||
fprintf (out, " +");
|
||||
print_unidiff_number_range (opt->out, &opt->file[1], first1, last1);
|
||||
print_unidiff_number_range (&files[1], first1, last1);
|
||||
fprintf (out, " @@");
|
||||
|
||||
if (function)
|
||||
@ -346,8 +335,8 @@ pr_unidiff_hunk (struct change *hunk, struct diffopt *opt)
|
||||
|
||||
if (!next || i < next->line0)
|
||||
{
|
||||
putc (opt->initial_tab ? '\t' : ' ', out);
|
||||
print_1_line (0, &opt->file[0].linbuf[i++], opt);
|
||||
putc (initial_tab ? '\t' : ' ', out);
|
||||
print_1_line (NULL, &files[0].linbuf[i++]);
|
||||
j++;
|
||||
}
|
||||
else
|
||||
@ -358,9 +347,9 @@ pr_unidiff_hunk (struct change *hunk, struct diffopt *opt)
|
||||
while (k--)
|
||||
{
|
||||
putc ('-', out);
|
||||
if (opt->initial_tab)
|
||||
if (initial_tab)
|
||||
putc ('\t', out);
|
||||
print_1_line (0, &opt->file[0].linbuf[i++], opt);
|
||||
print_1_line (NULL, &files[0].linbuf[i++]);
|
||||
}
|
||||
|
||||
/* Then output the inserted part. */
|
||||
@ -369,9 +358,9 @@ pr_unidiff_hunk (struct change *hunk, struct diffopt *opt)
|
||||
while (k--)
|
||||
{
|
||||
putc ('+', out);
|
||||
if (opt->initial_tab)
|
||||
if (initial_tab)
|
||||
putc ('\t', out);
|
||||
print_1_line (0, &opt->file[1].linbuf[j++], opt);
|
||||
print_1_line (NULL, &files[1].linbuf[j++]);
|
||||
}
|
||||
|
||||
/* We're done with this hunk, so on to the next! */
|
||||
@ -386,7 +375,7 @@ pr_unidiff_hunk (struct change *hunk, struct diffopt *opt)
|
||||
to the `struct change' for the last change before those lines. */
|
||||
|
||||
static struct change *
|
||||
find_hunk (struct change *start, struct diffopt const *opt)
|
||||
find_hunk (struct change *start)
|
||||
{
|
||||
struct change *prev;
|
||||
lin top0, top1;
|
||||
@ -396,8 +385,8 @@ find_hunk (struct change *start, struct diffopt const *opt)
|
||||
changes, but only CONTEXT if one is ignorable. Watch out for
|
||||
integer overflow, though. */
|
||||
lin non_ignorable_threshold =
|
||||
(LIN_MAX - 1) / 2 < opt->context ? LIN_MAX : 2 * opt->context + 1;
|
||||
lin ignorable_threshold = opt->context;
|
||||
(LIN_MAX - 1) / 2 < context ? LIN_MAX : 2 * context + 1;
|
||||
lin ignorable_threshold = context;
|
||||
|
||||
do
|
||||
{
|
||||
@ -426,7 +415,7 @@ find_hunk (struct change *start, struct diffopt const *opt)
|
||||
are ignorable lines. */
|
||||
|
||||
static void
|
||||
mark_ignorable (struct change *script, struct diffopt *opt)
|
||||
mark_ignorable (struct change *script)
|
||||
{
|
||||
while (script)
|
||||
{
|
||||
@ -438,7 +427,7 @@ mark_ignorable (struct change *script, struct diffopt *opt)
|
||||
|
||||
/* Determine whether this change is ignorable. */
|
||||
script->ignore = ! analyze_hunk (script,
|
||||
&first0, &last0, &first1, &last1, opt);
|
||||
&first0, &last0, &first1, &last1);
|
||||
|
||||
/* Reconnect the chain as before. */
|
||||
script->link = next;
|
||||
@ -449,17 +438,15 @@ mark_ignorable (struct change *script, struct diffopt *opt)
|
||||
}
|
||||
|
||||
/* Find the last function-header line in LINBUF prior to line number LINENUM.
|
||||
This is a line containing a match for the regexp in `opt->function_regexp'.
|
||||
OPT is the diff options.
|
||||
Return the address of the text, or 0 if no function-header is found. */
|
||||
This is a line containing a match for the regexp in `function_regexp'.
|
||||
Return the address of the text, or NULL if no function-header is found. */
|
||||
|
||||
static char const *
|
||||
find_function (char const * const *linbuf, lin linenum,
|
||||
struct diffopt *opt)
|
||||
find_function (char const * const *linbuf, lin linenum)
|
||||
{
|
||||
lin i = linenum;
|
||||
lin last = opt->find_function.last_search;
|
||||
opt->find_function.last_search = i;
|
||||
lin last = find_function_last_search;
|
||||
find_function_last_search = i;
|
||||
|
||||
while (last <= --i)
|
||||
{
|
||||
@ -470,16 +457,16 @@ find_function (char const * const *linbuf, lin linenum,
|
||||
/* FIXME: re_search's size args should be size_t, not int. */
|
||||
int len = MIN (linelen, INT_MAX);
|
||||
|
||||
if (0 <= re_search (opt->function_regexp, line, len, 0, len, 0))
|
||||
if (0 <= re_search (&function_regexp, line, len, 0, len, NULL))
|
||||
{
|
||||
opt->find_function.last_match = i;
|
||||
find_function_last_match = i;
|
||||
return line;
|
||||
}
|
||||
}
|
||||
/* If we search back to where we started searching the previous time,
|
||||
find the line we found last time. */
|
||||
if (opt->find_function.last_match != LIN_MAX)
|
||||
return linbuf[opt->find_function.last_match];
|
||||
if (find_function_last_match != LIN_MAX)
|
||||
return linbuf[find_function_last_match];
|
||||
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
516
src/diff.c
516
src/diff.c
File diff suppressed because it is too large
Load Diff
16
src/diff3.c
16
src/diff3.c
@ -1,7 +1,7 @@
|
||||
/* diff3 - compare three files line by line
|
||||
|
||||
Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1998, 2001,
|
||||
2002, 2004 Free Software Foundation, Inc.
|
||||
2002, 2004, 2006 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
|
||||
@ -31,7 +31,7 @@
|
||||
#include <file-type.h>
|
||||
#include <getopt.h>
|
||||
#include <inttostr.h>
|
||||
#include <quotesys.h>
|
||||
#include <sh-quote.h>
|
||||
#include <version-etc.h>
|
||||
#include <xalloc.h>
|
||||
|
||||
@ -1192,14 +1192,14 @@ read_diff (char const *filea,
|
||||
|
||||
FILE *fpipe;
|
||||
char const args[] = " --horizon-lines=100 -- ";
|
||||
char *command = xmalloc (quote_system_arg (0, diff_program)
|
||||
char *command = xmalloc (shell_quote_length (diff_program)
|
||||
+ sizeof "-a"
|
||||
+ sizeof "--strip-trailing-cr"
|
||||
+ sizeof args - 1
|
||||
+ quote_system_arg (0, filea) + 1
|
||||
+ quote_system_arg (0, fileb) + 1);
|
||||
+ shell_quote_length (filea) + 1
|
||||
+ shell_quote_length (fileb) + 1);
|
||||
char *p = command;
|
||||
p += quote_system_arg (p, diff_program);
|
||||
p = shell_quote_copy (p, diff_program);
|
||||
if (text)
|
||||
{
|
||||
strcpy (p, " -a");
|
||||
@ -1212,9 +1212,9 @@ read_diff (char const *filea,
|
||||
}
|
||||
strcpy (p, args);
|
||||
p += sizeof args - 1;
|
||||
p += quote_system_arg (p, filea);
|
||||
p = shell_quote_copy (p, filea);
|
||||
*p++ = ' ';
|
||||
p += quote_system_arg (p, fileb);
|
||||
p = shell_quote_copy (p, fileb);
|
||||
*p = 0;
|
||||
errno = 0;
|
||||
fpipe = popen (command, "r");
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/* Read, sort and compare two directories. Used for GNU DIFF.
|
||||
|
||||
Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1998, 2001, 2002,
|
||||
2004 Free Software Foundation, Inc.
|
||||
2004, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU DIFF.
|
||||
|
||||
@ -99,7 +99,7 @@ dir_read (struct file_data const *dir, struct dirdata *dirdata)
|
||||
&& (d_name[1] == 0 || (d_name[1] == '.' && d_name[2] == 0)))
|
||||
continue;
|
||||
|
||||
if (excluded_filename (excluded, d_name))
|
||||
if (excluded_file_name (excluded, d_name))
|
||||
continue;
|
||||
|
||||
while (data_alloc < data_used + d_size)
|
||||
|
||||
34
src/io.c
34
src/io.c
@ -1,7 +1,7 @@
|
||||
/* File I/O for GNU DIFF.
|
||||
|
||||
Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1998, 2001, 2002,
|
||||
2004 Free Software Foundation, Inc.
|
||||
2004, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU DIFF.
|
||||
|
||||
@ -23,7 +23,6 @@
|
||||
#include "diff.h"
|
||||
#include <cmpbuf.h>
|
||||
#include <file-type.h>
|
||||
#include <setmode.h>
|
||||
#include <xalloc.h>
|
||||
|
||||
/* Rotate an unsigned value to the left. */
|
||||
@ -34,7 +33,7 @@
|
||||
|
||||
/* The type of a hash value. */
|
||||
typedef size_t hash_value;
|
||||
verify (hash_value_is_unsigned, ! TYPE_SIGNED (hash_value));
|
||||
verify (! TYPE_SIGNED (hash_value));
|
||||
|
||||
/* Lines are put into equivalence classes of lines that match in lines_differ.
|
||||
Each equivalence class is represented by one of these structures,
|
||||
@ -114,26 +113,11 @@ sip (struct file_data *current, bool skip_test)
|
||||
{
|
||||
/* Check first part of file to see if it's a binary file. */
|
||||
|
||||
bool was_binary = set_binary_mode (current->desc, true);
|
||||
off_t buffered;
|
||||
/* FIXME: if O_BINARY, this should revert to text mode
|
||||
if the file is not binary. */
|
||||
|
||||
file_block_read (current, current->bufsize);
|
||||
buffered = current->buffered;
|
||||
|
||||
if (! was_binary)
|
||||
{
|
||||
/* Revert to text mode and seek back to the beginning to
|
||||
reread the file. Use relative seek, since file
|
||||
descriptors like stdin might not start at offset
|
||||
zero. */
|
||||
|
||||
if (lseek (current->desc, - buffered, SEEK_CUR) == -1)
|
||||
pfatal_with_name (current->name);
|
||||
set_binary_mode (current->desc, false);
|
||||
current->buffered = 0;
|
||||
current->eof = false;
|
||||
}
|
||||
|
||||
return binary_file_p (current->buffer, buffered);
|
||||
return binary_file_p (current->buffer, current->buffered);
|
||||
}
|
||||
}
|
||||
|
||||
@ -796,8 +780,7 @@ static unsigned char const prime_offset[] =
|
||||
|
||||
/* Verify that this host's size_t is not too wide for the above table. */
|
||||
|
||||
verify (enough_prime_offsets,
|
||||
sizeof (size_t) * CHAR_BIT <= sizeof prime_offset);
|
||||
verify (sizeof (size_t) * CHAR_BIT <= sizeof prime_offset);
|
||||
|
||||
/* Given a vector of two file_data objects, read the file associated
|
||||
with each one, and build the table of equivalence classes.
|
||||
@ -821,8 +804,7 @@ read_files (struct file_data filevec[], bool pretend_binary)
|
||||
}
|
||||
if (appears_binary)
|
||||
{
|
||||
set_binary_mode (filevec[0].desc, true);
|
||||
set_binary_mode (filevec[1].desc, true);
|
||||
/* FIXME: If O_BINARY, this should set both files to binary mode. */
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
14
src/sdiff.c
14
src/sdiff.c
@ -1,7 +1,7 @@
|
||||
/* sdiff - side-by-side merge of file differences
|
||||
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 2001, 2002, 2004
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 2001, 2002, 2004,
|
||||
2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU DIFF.
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
#include <exitfail.h>
|
||||
#include <file-type.h>
|
||||
#include <getopt.h>
|
||||
#include <quotesys.h>
|
||||
#include <sh-quote.h>
|
||||
#include <version-etc.h>
|
||||
#include <xalloc.h>
|
||||
|
||||
@ -614,11 +614,11 @@ main (int argc, char *argv[])
|
||||
int i;
|
||||
|
||||
for (i = 0; diffargv[i]; i++)
|
||||
cmdsize += quote_system_arg (0, diffargv[i]) + 1;
|
||||
cmdsize += shell_quote_length (diffargv[i]) + 1;
|
||||
command = p = xmalloc (cmdsize);
|
||||
for (i = 0; diffargv[i]; i++)
|
||||
{
|
||||
p += quote_system_arg (p, diffargv[i]);
|
||||
p = shell_quote_copy (diffargv[i]);
|
||||
*p++ = ' ';
|
||||
}
|
||||
p[-1] = 0;
|
||||
@ -1056,9 +1056,9 @@ edit (struct line_filter *left, char const *lname, lin lline, lin llen,
|
||||
{
|
||||
#if ! (HAVE_WORKING_FORK || HAVE_WORKING_VFORK)
|
||||
char *command =
|
||||
xmalloc (quote_system_arg (0, editor_program)
|
||||
xmalloc (shell_quote_length (editor_program)
|
||||
+ 1 + strlen (tmpname) + 1);
|
||||
sprintf (command + quote_system_arg (command, editor_program),
|
||||
sprintf (shell_quote_copy (command, editor_program),
|
||||
" %s", tmpname);
|
||||
wstatus = system (command);
|
||||
if (wstatus == -1)
|
||||
|
||||
47
src/system.h
47
src/system.h
@ -1,7 +1,7 @@
|
||||
/* System dependent declarations.
|
||||
|
||||
Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1998, 2001, 2002,
|
||||
2004 Free Software Foundation, Inc.
|
||||
2004, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU DIFF.
|
||||
|
||||
@ -37,26 +37,7 @@
|
||||
# define volatile
|
||||
#endif
|
||||
|
||||
/* Verify a requirement at compile-time (unlike assert, which is runtime). */
|
||||
#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
|
||||
|
||||
|
||||
/* Determine whether an integer type is signed, and its bounds.
|
||||
This code assumes two's (or one's!) complement with no holes. */
|
||||
|
||||
/* The extra casts work around common compiler bugs,
|
||||
e.g. Cray C 5.0.3.0 when t == time_t. */
|
||||
#ifndef TYPE_SIGNED
|
||||
# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||
#endif
|
||||
#ifndef TYPE_MINIMUM
|
||||
# define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
|
||||
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
|
||||
: (t) 0))
|
||||
#endif
|
||||
#ifndef TYPE_MAXIMUM
|
||||
# define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
|
||||
#endif
|
||||
#include <verify.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@ -119,6 +100,22 @@
|
||||
# define S_IWUSR 0200
|
||||
#endif
|
||||
|
||||
/* For systems that distinguish between text and binary I/O.
|
||||
O_BINARY is usually declared in fcntl.h */
|
||||
#if !defined O_BINARY && defined _O_BINARY
|
||||
/* For MSC-compatible compilers. */
|
||||
# define O_BINARY _O_BINARY
|
||||
#endif
|
||||
|
||||
#ifdef __BEOS__
|
||||
/* BeOS 5 has O_BINARY, but it has no effect. */
|
||||
# undef O_BINARY
|
||||
#endif
|
||||
|
||||
#ifndef O_BINARY
|
||||
# define O_BINARY 0
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_WAIT_H
|
||||
# include <sys/wait.h>
|
||||
#endif
|
||||
@ -240,6 +237,8 @@ int strcasecmp (char const *, char const *);
|
||||
# define vfork fork
|
||||
#endif
|
||||
|
||||
#include <intprops.h>
|
||||
|
||||
/* Type used for fast comparison of several bytes at a time. */
|
||||
|
||||
#ifndef word
|
||||
@ -251,9 +250,9 @@ int strcasecmp (char const *, char const *);
|
||||
|
||||
typedef ptrdiff_t lin;
|
||||
#define LIN_MAX PTRDIFF_MAX
|
||||
verify (lin_is_signed, TYPE_SIGNED (lin));
|
||||
verify (lin_is_wide_enough, sizeof (ptrdiff_t) <= sizeof (lin));
|
||||
verify (lin_is_printable_as_long_int, sizeof (lin) <= sizeof (long int));
|
||||
verify (TYPE_SIGNED (lin));
|
||||
verify (sizeof (ptrdiff_t) <= sizeof (lin));
|
||||
verify (sizeof (lin) <= sizeof (long int));
|
||||
|
||||
/* This section contains POSIX-compliant defaults for macros
|
||||
that are meant to be overridden by hand in config.h as needed. */
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/* Support routines for GNU DIFF.
|
||||
|
||||
Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1998, 2001, 2002,
|
||||
2004 Free Software Foundation, Inc.
|
||||
2004, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU DIFF.
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#include "diff.h"
|
||||
#include <dirname.h>
|
||||
#include <error.h>
|
||||
#include <quotesys.h>
|
||||
#include <sh-quote.h>
|
||||
#include <xalloc.h>
|
||||
|
||||
char const pr_program[] = PR_PROGRAM;
|
||||
@ -226,11 +226,11 @@ begin_output (void)
|
||||
}
|
||||
#else
|
||||
char *command = xmalloc (sizeof pr_program - 1 + 7
|
||||
+ quote_system_arg ((char *) 0, name) + 1);
|
||||
+ shell_quote_length (name) + 1);
|
||||
char *p;
|
||||
sprintf (command, "%s -f -h ", pr_program);
|
||||
p = command + sizeof pr_program - 1 + 7;
|
||||
p += quote_system_arg (p, name);
|
||||
p = shell_quote_copy (name);
|
||||
*p = 0;
|
||||
errno = 0;
|
||||
outfile = popen (command, "w");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user