mirror of
https://https.git.savannah.gnu.org/git/patch.git
synced 2026-01-27 01:44:34 +00:00
Import of patch-2.5.4.tar.gz
This commit is contained in:
parent
957f7b6423
commit
79159942f1
70
ChangeLog
70
ChangeLog
@ -1,3 +1,73 @@
|
||||
1999-08-30 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
Version 2.5.4 fixes a few minor bugs, converts C sources to
|
||||
ANSI prototypes, and modernizes auxiliary sources and autoconf
|
||||
scripts.
|
||||
|
||||
* configure.in (VERSION): Version 2.5.4 released.
|
||||
(AC_CANONICAL_HOST): Add.
|
||||
(AC_SYS_LARGEFILE): Add, replacing inline code.
|
||||
(AC_EXEEXT): Add.
|
||||
(jm_AC_HEADER_INTTYPES_H): Add, replacing inline code.
|
||||
(AC_TYPE_PID_T): Add.
|
||||
(jm_STRUCT_UTIMBUF): Add, replacing inline code.
|
||||
(HAVE_MEMCHR): Remove obsolescent test; nobody uses NetBSD 1.0 now.
|
||||
(getopt_long): Append $U to object file basenames.
|
||||
(AC_CHECK_FUNCS): Add fseeko, setmode. Remove mkdir.
|
||||
(AC_REPLACE_FUNCS): Add mkdir, rmdir.
|
||||
(jm_STRUCT_DIRENT_D_INO): Add, replacing inline code.
|
||||
|
||||
* Makefile.in (EXEEXT): New macro.
|
||||
(mandir): New macro.
|
||||
(man1dir): Define in terms of mandir.
|
||||
(SRCS): Add mkdir.c, rmdir.c.
|
||||
(OBJS): Change .o to $U.o for addext, argmatch, backupfile, basename,
|
||||
error, inp, patch ,,pch, quotearg, util, version, xmalloc.
|
||||
(HDRS): Add basename.h, patchlevel.h.
|
||||
(MISC): Add ansi2knr.1, config.guess, config.sub.
|
||||
(MISC, config.hin): Remove acconfig.h; no longer needed.
|
||||
(DISTFILES_M4): New macro.
|
||||
(all): patch -> patch$(EXEEXT).
|
||||
(patch$(EXEEXT)): Renamed from patch. All uses changed.
|
||||
(uninstall): Remove manual page.
|
||||
(configure): Depend on aclocal.m4.
|
||||
(M4DIR, ACINCLUDE_INPUTS): New macros.
|
||||
($(srcdir)/aclocal.m4): New rule.
|
||||
(patchlevel.h): Depend on configure.in, not Makefile,
|
||||
since we now distribute it.
|
||||
(distclean): Don't remove patchlevel.h.
|
||||
(dist): Distribute $(DISTFILES_M4).
|
||||
(addext_.c argmatch_.c backupfile_.c basename_.c error_.c
|
||||
getopt_.c getopt1_.c inp_.c malloc_.c mkdir_.c patch_.c pch_.c
|
||||
rename_.c util_.c version_.c xmalloc_.c): Depend on ansi2knr.
|
||||
Update dependencies to match sources.
|
||||
|
||||
* common.h (_LARGEFILE_SOURCE): Remove; now autoconfigured.
|
||||
(file_offset): Depend on HAVE_FSEEKO, not _LFS_LARGEFILE.
|
||||
|
||||
* patch.c (version_control_context): New variable.
|
||||
Convert to ANSI prototypes.
|
||||
Adjust to new argmatch calling convention.
|
||||
Similarly for get_version.
|
||||
Complain about creating an existing file only if
|
||||
pch_says_nonexistent returns 2 (not merely nonzero).
|
||||
Similarly for time mismatch check.
|
||||
(get_some_switches): Adjust to new get_version calling convention.
|
||||
Similarly for argmatch.
|
||||
|
||||
* pch.c (<basename.h>): Include.
|
||||
(intuit_diff_type): Improve quality of test for empty file.
|
||||
(another_hunk): Don't assume off_t is no longer than long.
|
||||
|
||||
* util.h (backup_type): New decl.
|
||||
* util.c (<basename.h>): Include.
|
||||
(move_file): Adjust to new find_backup_file_name convention.
|
||||
(doprogram, mkdir, rmdir): Remove; now in separate files.
|
||||
(fetchame): Match "/dev/null", not NULL_DEVICE.
|
||||
Ignore names that don't have enough slashes to strip off.
|
||||
|
||||
* version.c: Update copyright notice.
|
||||
|
||||
1998-03-20 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* configure.in (VERSION): Bump to 2.5.3.
|
||||
|
||||
1
INSTALL
1
INSTALL
@ -180,4 +180,3 @@ operates.
|
||||
script, and exit.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options.
|
||||
|
||||
|
||||
82
Makefile.in
82
Makefile.in
@ -1,5 +1,5 @@
|
||||
# Makefile for GNU patch.
|
||||
# Copyright 1993, 1997, 1998 Free Software Foundation, Inc.
|
||||
# Copyright 1993, 1997-1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -33,6 +33,7 @@ transform = @program_transform_name@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
DEFS = @DEFS@
|
||||
EXEEXT = @EXEEXT@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
@ -46,7 +47,8 @@ exec_prefix = @exec_prefix@
|
||||
bindir = $(exec_prefix)/bin
|
||||
|
||||
# Where to put the manual pages.
|
||||
man1dir = $(prefix)/man/man1
|
||||
mandir = @mandir@
|
||||
man1dir = $(mandir)/man1
|
||||
# Extension (including `.') for the manual page filenames.
|
||||
man1ext = .1
|
||||
|
||||
@ -59,25 +61,27 @@ SHELL = /bin/sh
|
||||
|
||||
LIBSRCS = getopt.c getopt1.c malloc.c memchr.c realloc.c rename.c
|
||||
SRCS = addext.c argmatch.c backupfile.c basename.c error.c inp.c maketime.c \
|
||||
partime.c patch.c pch.c quotearg.c quotesys.c \
|
||||
util.c version.c xmalloc.c $(LIBSRCS)
|
||||
OBJS = addext.o argmatch.o backupfile.o basename.o error.o inp.o maketime.o \
|
||||
partime.o patch.o pch.o quotearg$U.o quotesys.o \
|
||||
util.o version.o xmalloc.o $(LIBOBJS)
|
||||
HDRS = argmatch.h backupfile.h common.h error.h getopt.h \
|
||||
inp.h maketime.h partime.h pch.h quotearg.h quotesys.h \
|
||||
mkdir.c partime.c patch.c pch.c quotearg.c quotesys.c \
|
||||
rmdir.c util.c version.c xmalloc.c $(LIBSRCS)
|
||||
OBJS = addext$U.o argmatch$U.o backupfile$U.o basename$U.o error$U.o inp$U.o \
|
||||
maketime.o partime.o patch$U.o pch$U.o quotearg$U.o quotesys.o \
|
||||
util$U.o version$U.o xmalloc$U.o $(LIBOBJS)
|
||||
HDRS = argmatch.h backupfile.h basename.h common.h error.h getopt.h \
|
||||
inp.h maketime.h partime.h patchlevel.h pch.h quotearg.h quotesys.h \
|
||||
util.h version.h xalloc.h
|
||||
MISC = AUTHORS COPYING ChangeLog INSTALL Makefile.in NEWS README \
|
||||
acconfig.h aclocal.m4 ansi2knr.c config.hin configure configure.in \
|
||||
aclocal.m4 ansi2knr.1 ansi2knr.c \
|
||||
config.guess config.hin config.sub configure configure.in \
|
||||
install-sh mkinstalldirs patch.man
|
||||
DISTFILES = $(MISC) $(SRCS) $(HDRS)
|
||||
DISTFILES_M4 = $(ACINCLUDE_INPUTS)
|
||||
DISTFILES_PC = pc/chdirsaf.c
|
||||
DISTFILES_PC_DJGPP = pc/djgpp/README pc/djgpp/config.sed \
|
||||
pc/djgpp/configure.bat pc/djgpp/configure.sed
|
||||
|
||||
patch_name = `echo patch | sed '$(transform)'`
|
||||
|
||||
all:: patch
|
||||
all:: patch$(EXEEXT)
|
||||
|
||||
info::
|
||||
check::
|
||||
@ -89,11 +93,11 @@ COMPILE = $(CC) -c $(CPPFLAGS) $(DEFS) -Ded_PROGRAM=\"$(ed_PROGRAM)\" \
|
||||
.c.o:
|
||||
$(COMPILE) $<
|
||||
|
||||
patch: $(OBJS)
|
||||
patch$(EXEEXT): $(OBJS)
|
||||
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS)
|
||||
|
||||
install:: all installdirs
|
||||
$(INSTALL_PROGRAM) patch $(bindir)/$(patch_name)
|
||||
$(INSTALL_PROGRAM) patch$(EXEEXT) $(bindir)/$(patch_name)$(EXEEXT)
|
||||
-$(INSTALL_DATA) $(srcdir)/patch.man $(man1dir)/$(patch_name)$(man1ext)
|
||||
|
||||
installdirs::
|
||||
@ -103,18 +107,27 @@ install-strip::
|
||||
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
|
||||
|
||||
uninstall::
|
||||
rm -f $(bindir)/$(patch_name) $(man1dir)/$(patch_name)$(man1ext)
|
||||
rm -f $(bindir)/$(patch_name)$(EXEEXT)
|
||||
rm -f $(man1dir)/$(patch_name)$(man1ext)
|
||||
|
||||
Makefile: Makefile.in $(CONFIG_STATUS)
|
||||
$(SHELL) $(CONFIG_STATUS)
|
||||
config.status: configure
|
||||
$(SHELL) $(CONFIG_STATUS) --recheck
|
||||
configure: configure.in
|
||||
configure: configure.in $(srcdir)/aclocal.m4
|
||||
cd $(srcdir) && autoconf
|
||||
config.hin: configure.in acconfig.h
|
||||
config.hin: configure.in
|
||||
cd $(srcdir) && rm -f config.hin && autoheader
|
||||
|
||||
patchlevel.h: Makefile
|
||||
M4DIR = $(srcdir)/m4
|
||||
ACINCLUDE_INPUTS = $(M4DIR)/ccstdc.m4 $(M4DIR)/d-ino.m4 \
|
||||
$(M4DIR)/inttypes_h.m4 $(M4DIR)/largefile.m4 $(M4DIR)/malloc.m4 \
|
||||
$(M4DIR)/protos.m4 $(M4DIR)/realloc.m4 $(M4DIR)/utimbuf.m4
|
||||
|
||||
$(srcdir)/aclocal.m4: $(ACINCLUDE_INPUTS)
|
||||
cat $(ACINCLUDE_INPUTS) >$(srcdir)/aclocal.m4
|
||||
|
||||
patchlevel.h: configure.in
|
||||
echo '#define PATCH_VERSION "$(VERSION)"' >patchlevel.h
|
||||
|
||||
TAGS: $(HDRS) patchlevel.h $(SRCS)
|
||||
@ -124,11 +137,10 @@ mostlyclean::
|
||||
rm -f ansi2knr core* *core *.o *_.c
|
||||
|
||||
clean:: mostlyclean
|
||||
rm -f patch
|
||||
rm -f patch$(EXEEXT)
|
||||
|
||||
distclean:: clean
|
||||
rm -f Makefile config.cache config.log config.status config.h
|
||||
rm -f patchlevel.h
|
||||
|
||||
maintainer-clean::
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@ -138,10 +150,11 @@ maintainer-clean::
|
||||
|
||||
PV = $(PACKAGE)-$(VERSION)
|
||||
|
||||
dist:: $(DISTFILES) $(DISTFILES_PC) $(DISTFILES_PC_DJGPP)
|
||||
dist:: $(DISTFILES) $(DISTFILES_M4) $(DISTFILES_PC) $(DISTFILES_PC_DJGPP)
|
||||
rm -rf $(PV)
|
||||
mkdir $(PV) $(PV)/pc $(PV)/pc/djgpp
|
||||
mkdir $(PV) $(PV)/m4 $(PV)/pc $(PV)/pc/djgpp
|
||||
cp -p $(DISTFILES) $(PV)
|
||||
cp -p $(DISTFILES_M4) $(PV)/m4
|
||||
cp -p $(DISTFILES_PC) $(PV)/pc
|
||||
cp -p $(DISTFILES_PC_DJGPP) $(PV)/pc/djgpp
|
||||
tar -chf - $(PV) | gzip -9 >$(PV).tar.gz
|
||||
@ -150,27 +163,28 @@ dist:: $(DISTFILES) $(DISTFILES_PC) $(DISTFILES_PC_DJGPP)
|
||||
ansi2knr.o: config.h
|
||||
ansi2knr: ansi2knr.o
|
||||
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) ansi2knr.o $(LIBS)
|
||||
quotearg_.c: ansi2knr
|
||||
addext_.c argmatch_.c backupfile_.c basename_.c error_.c \
|
||||
getopt_.c getopt1_.c inp_.c malloc_.c mkdir_.c patch_.c pch_.c quotearg_.c \
|
||||
rename_.c util_.c version_.c xmalloc_.c: ansi2knr
|
||||
.SUFFIXES: _.c
|
||||
.c_.c:
|
||||
./ansi2knr $< $@
|
||||
|
||||
$(OBJS): config.h
|
||||
addext.o: backupfile.h
|
||||
argmatch.o: argmatch.h quotearg.h
|
||||
backupfile.o: argmatch.h backupfile.h
|
||||
basename.o: backupfile.h
|
||||
error.o: error.h
|
||||
getopt.o getopt1.o: getopt.h
|
||||
addext$U.o: backupfile.h
|
||||
argmatch$U.o: argmatch.h error.h quotearg.h
|
||||
backupfile$U.o: argmatch.h backupfile.h
|
||||
error$U.o: error.h
|
||||
getopt$U.o getopt1$U.o: getopt.h
|
||||
inp$U.o: backupfile.h common.h inp.h pch.h quotearg.h util.h xalloc.h
|
||||
maketime.o: maketime.h partime.h
|
||||
inp.o: backupfile.h common.h inp.h pch.h quotearg.h util.h xalloc.h
|
||||
partime.o: partime.h
|
||||
patch.o: argmatch.h backupfile.h common.h getopt.h inp.h \
|
||||
patch$U.o: argmatch.h backupfile.h common.h getopt.h inp.h \
|
||||
pch.h quotearg.h util.h version.h xalloc.h
|
||||
pch.o: common.h inp.h pch.h quotearg.h util.h
|
||||
pch$U.o: backupfile.h basename.h common.h inp.h pch.h quotearg.h util.h
|
||||
quotearg$U.o: quotearg.h xalloc.h
|
||||
quotesys.o: quotesys.h
|
||||
xmalloc.o: xalloc.h
|
||||
util.o: backupfile.h common.h maketime.h \
|
||||
util$U.o: backupfile.h basename.h common.h maketime.h \
|
||||
partime.h quotearg.h quotesys.h util.h version.h xalloc.h
|
||||
version.o: common.h patchlevel.h util.h version.h
|
||||
version$U.o: common.h patchlevel.h util.h version.h
|
||||
xmalloc$U.o: xalloc.h
|
||||
|
||||
26
acconfig.h
26
acconfig.h
@ -1,26 +0,0 @@
|
||||
/* Local acconfig.h for autoheader.
|
||||
Descriptive text for the C preprocessor macros that
|
||||
the patch configure.in can define.
|
||||
autoheader copies the comments into config.hin. */
|
||||
|
||||
/* Define if there is a member named d_ino in the struct describing
|
||||
directory headers. */
|
||||
#undef D_INO_IN_DIRENT
|
||||
|
||||
/* Define if you have a working <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define if memchr works. */
|
||||
#undef HAVE_MEMCHR
|
||||
|
||||
/* Define if `struct utimbuf' is declared -- usually in <utime.h>. */
|
||||
#undef HAVE_STRUCT_UTIMBUF
|
||||
|
||||
/* Define to rpl_malloc if the replacement function should be used. */
|
||||
#undef malloc
|
||||
|
||||
/* Define to 1 if ANSI function prototypes are usable. */
|
||||
#undef PROTOTYPES
|
||||
|
||||
/* Define to rpl_realloc if the replacement function should be used. */
|
||||
#undef realloc
|
||||
434
aclocal.m4
vendored
434
aclocal.m4
vendored
@ -1,115 +1,13 @@
|
||||
#serial 1
|
||||
# The following is taken from automake 1.4,
|
||||
# except that it prefers the compiler option -Ae to "-Aa -D_HPUX_SOURCE"
|
||||
# because only the former supports 64-bit integral types on HP-UX 10.20.
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl Determine whether malloc accepts 0 as its argument.
|
||||
dnl If it doesn't, arrange to use the replacement function.
|
||||
dnl
|
||||
dnl If you use this macro in a package, you should
|
||||
dnl add the following two lines to acconfig.h:
|
||||
dnl /* Define to rpl_malloc if the replacement function should be used. */
|
||||
dnl #undef malloc
|
||||
dnl
|
||||
## ----------------------------------------- ##
|
||||
## ANSIfy the C compiler whenever possible. ##
|
||||
## From Franc,ois Pinard ##
|
||||
## ----------------------------------------- ##
|
||||
|
||||
AC_DEFUN(jm_FUNC_MALLOC,
|
||||
[
|
||||
if test x = y; then
|
||||
dnl This code is deliberately never run via ./configure.
|
||||
dnl FIXME: this is a gross hack to make autoheader put an entry
|
||||
dnl for this symbol in config.h.in.
|
||||
AC_CHECK_FUNCS(DONE_WORKING_MALLOC_CHECK)
|
||||
fi
|
||||
dnl xmalloc.c requires that this symbol be defined so it doesn't
|
||||
dnl mistakenly use a broken malloc -- as it might if this test were omitted.
|
||||
ac_kludge=HAVE_DONE_WORKING_MALLOC_CHECK
|
||||
AC_DEFINE_UNQUOTED($ac_kludge)
|
||||
|
||||
AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
|
||||
[AC_TRY_RUN([
|
||||
char *malloc ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
exit (malloc (0) ? 0 : 1);
|
||||
}
|
||||
],
|
||||
jm_cv_func_working_malloc=yes,
|
||||
jm_cv_func_working_malloc=no,
|
||||
dnl When crosscompiling, assume malloc is broken.
|
||||
jm_cv_func_working_malloc=no)
|
||||
])
|
||||
if test $jm_cv_func_working_malloc = no; then
|
||||
LIBOBJS="$LIBOBJS malloc.o"
|
||||
AC_DEFINE_UNQUOTED(malloc, rpl_malloc)
|
||||
fi
|
||||
])
|
||||
|
||||
#serial 1
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl Determine whether realloc works when both arguments are 0.
|
||||
dnl If it doesn't, arrange to use the replacement function.
|
||||
dnl
|
||||
dnl If you use this macro in a package, you should
|
||||
dnl add the following two lines to acconfig.h:
|
||||
dnl /* Define to rpl_realloc if the replacement function should be used. */
|
||||
dnl #undef realloc
|
||||
dnl
|
||||
|
||||
AC_DEFUN(jm_FUNC_REALLOC,
|
||||
[
|
||||
if test x = y; then
|
||||
dnl This code is deliberately never run via ./configure.
|
||||
dnl FIXME: this is a gross hack to make autoheader put an entry
|
||||
dnl for this symbol in config.h.in.
|
||||
AC_CHECK_FUNCS(DONE_WORKING_REALLOC_CHECK)
|
||||
fi
|
||||
dnl xmalloc.c requires that this symbol be defined so it doesn't
|
||||
dnl mistakenly use a broken realloc -- as it might if this test were omitted.
|
||||
ac_kludge=HAVE_DONE_WORKING_REALLOC_CHECK
|
||||
AC_DEFINE_UNQUOTED($ac_kludge)
|
||||
|
||||
AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc,
|
||||
[AC_TRY_RUN([
|
||||
char *realloc ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
exit (realloc (0, 0) ? 0 : 1);
|
||||
}
|
||||
],
|
||||
jm_cv_func_working_realloc=yes,
|
||||
jm_cv_func_working_realloc=no,
|
||||
dnl When crosscompiling, assume realloc is broken.
|
||||
jm_cv_func_working_realloc=no)
|
||||
])
|
||||
if test $jm_cv_func_working_realloc = no; then
|
||||
LIBOBJS="$LIBOBJS realloc.o"
|
||||
AC_DEFINE_UNQUOTED(realloc, rpl_realloc)
|
||||
fi
|
||||
])
|
||||
|
||||
# serial 1
|
||||
|
||||
AC_DEFUN(AM_C_PROTOTYPES,
|
||||
[AC_REQUIRE([AM_PROG_CC_STDC])
|
||||
AC_MSG_CHECKING([for function prototypes])
|
||||
if test "$am_cv_prog_cc_stdc" != no; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(PROTOTYPES)
|
||||
U= ANSI2KNR=
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
U=_ ANSI2KNR=./ansi2knr
|
||||
# Ensure some checks needed by ansi2knr itself.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(string.h)
|
||||
fi
|
||||
AC_SUBST(U)dnl
|
||||
AC_SUBST(ANSI2KNR)dnl
|
||||
])
|
||||
|
||||
|
||||
# serial 1
|
||||
# serial 2
|
||||
|
||||
# @defmac AC_PROG_CC_STDC
|
||||
# @maindex PROG_CC_STDC
|
||||
@ -146,7 +44,7 @@ ac_save_CC="$CC"
|
||||
# Ultrix and OSF/1 -std1
|
||||
# HP-UX -Aa -D_HPUX_SOURCE
|
||||
# SVR4 -Xc -D__EXTENSIONS__
|
||||
for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
|
||||
for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
|
||||
do
|
||||
CC="$ac_save_CC $ac_arg"
|
||||
AC_TRY_COMPILE(
|
||||
@ -195,3 +93,317 @@ case "x$am_cv_prog_cc_stdc" in
|
||||
*) CC="$CC $am_cv_prog_cc_stdc" ;;
|
||||
esac
|
||||
])
|
||||
#serial 2
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl
|
||||
dnl Check whether struct dirent has a member named d_ino.
|
||||
dnl
|
||||
|
||||
AC_DEFUN(jm_STRUCT_DIRENT_D_INO,
|
||||
[AC_REQUIRE([AC_HEADER_DIRENT])dnl
|
||||
AC_CACHE_CHECK([for d_ino member in directory struct],
|
||||
jm_cv_struct_dirent_d_ino,
|
||||
[AC_TRY_LINK(dnl
|
||||
[
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_DIRENT_H
|
||||
# include <dirent.h>
|
||||
#else /* not HAVE_DIRENT_H */
|
||||
# define dirent direct
|
||||
# ifdef HAVE_SYS_NDIR_H
|
||||
# include <sys/ndir.h>
|
||||
# endif /* HAVE_SYS_NDIR_H */
|
||||
# ifdef HAVE_SYS_DIR_H
|
||||
# include <sys/dir.h>
|
||||
# endif /* HAVE_SYS_DIR_H */
|
||||
# ifdef HAVE_NDIR_H
|
||||
# include <ndir.h>
|
||||
# endif /* HAVE_NDIR_H */
|
||||
#endif /* HAVE_DIRENT_H */
|
||||
],
|
||||
[struct dirent dp; dp.d_ino = 0;],
|
||||
|
||||
jm_cv_struct_dirent_d_ino=yes,
|
||||
jm_cv_struct_dirent_d_ino=no)
|
||||
]
|
||||
)
|
||||
if test $jm_cv_struct_dirent_d_ino = yes; then
|
||||
AC_DEFINE(D_INO_IN_DIRENT, 1,
|
||||
[Define if there is a member named d_ino in the struct describing
|
||||
directory headers.])
|
||||
fi
|
||||
]
|
||||
)
|
||||
#serial 3
|
||||
|
||||
dnl From Paul Eggert.
|
||||
|
||||
# Define HAVE_INTTYPES_H if <inttypes.h> exists,
|
||||
# doesn't clash with <sys/types.h>, and declares uintmax_t.
|
||||
|
||||
AC_DEFUN(jm_AC_HEADER_INTTYPES_H,
|
||||
[
|
||||
AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
|
||||
[AC_TRY_COMPILE(
|
||||
[#include <sys/types.h>
|
||||
#include <inttypes.h>],
|
||||
[uintmax_t i = (uintmax_t) -1;],
|
||||
jm_ac_cv_header_inttypes_h=yes,
|
||||
jm_ac_cv_header_inttypes_h=no)])
|
||||
if test $jm_ac_cv_header_inttypes_h = yes; then
|
||||
AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
|
||||
[Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
|
||||
and declares uintmax_t. ])
|
||||
fi
|
||||
])
|
||||
#serial 5
|
||||
|
||||
dnl By default, many hosts won't let programs access large files;
|
||||
dnl one must use special compiler options to get large-file access to work.
|
||||
dnl For more details about this brain damage please see:
|
||||
dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
|
||||
|
||||
dnl Written by Paul Eggert <eggert@twinsun.com>.
|
||||
|
||||
dnl Internal subroutine of AC_SYS_LARGEFILE.
|
||||
dnl AC_SYS_LARGEFILE_FLAGS(FLAGSNAME)
|
||||
AC_DEFUN(AC_SYS_LARGEFILE_FLAGS,
|
||||
[AC_CACHE_CHECK([for $1 value to request large file support],
|
||||
ac_cv_sys_largefile_$1,
|
||||
[ac_cv_sys_largefile_$1=`($GETCONF LFS_$1) 2>/dev/null` || {
|
||||
ac_cv_sys_largefile_$1=no
|
||||
ifelse($1, CFLAGS,
|
||||
[case "$host_os" in
|
||||
# IRIX 6.2 and later require cc -n32.
|
||||
changequote(, )dnl
|
||||
irix6.[2-9]* | irix6.1[0-9]* | irix[7-9].* | irix[1-9][0-9]*)
|
||||
changequote([, ])dnl
|
||||
if test "$GCC" != yes; then
|
||||
ac_cv_sys_largefile_CFLAGS=-n32
|
||||
fi
|
||||
ac_save_CC="$CC"
|
||||
CC="$CC $ac_cv_sys_largefile_CFLAGS"
|
||||
AC_TRY_LINK(, , , ac_cv_sys_largefile_CFLAGS=no)
|
||||
CC="$ac_save_CC"
|
||||
esac])
|
||||
}])])
|
||||
|
||||
dnl Internal subroutine of AC_SYS_LARGEFILE.
|
||||
dnl AC_SYS_LARGEFILE_SPACE_APPEND(VAR, VAL)
|
||||
AC_DEFUN(AC_SYS_LARGEFILE_SPACE_APPEND,
|
||||
[case $2 in
|
||||
no) ;;
|
||||
?*)
|
||||
case "[$]$1" in
|
||||
'') $1=$2 ;;
|
||||
*) $1=[$]$1' '$2 ;;
|
||||
esac ;;
|
||||
esac])
|
||||
|
||||
dnl Internal subroutine of AC_SYS_LARGEFILE.
|
||||
dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
|
||||
AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
|
||||
[AC_CACHE_CHECK([for $1], $2,
|
||||
[$2=no
|
||||
changequote(, )dnl
|
||||
$4
|
||||
for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
|
||||
case "$ac_flag" in
|
||||
-D$1)
|
||||
$2=1 ;;
|
||||
-D$1=*)
|
||||
$2=`expr " $ac_flag" : '[^=]*=\(.*\)'` ;;
|
||||
esac
|
||||
done
|
||||
changequote([, ])dnl
|
||||
])
|
||||
if test "[$]$2" != no; then
|
||||
AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
|
||||
fi])
|
||||
|
||||
AC_DEFUN(AC_SYS_LARGEFILE,
|
||||
[AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_ARG_ENABLE(largefile,
|
||||
[ --disable-largefile omit support for large files])
|
||||
if test "$enable_largefile" != no; then
|
||||
AC_CHECK_TOOL(GETCONF, getconf)
|
||||
AC_SYS_LARGEFILE_FLAGS(CFLAGS)
|
||||
AC_SYS_LARGEFILE_FLAGS(LDFLAGS)
|
||||
AC_SYS_LARGEFILE_FLAGS(LIBS)
|
||||
|
||||
for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
|
||||
case "$ac_flag" in
|
||||
no) ;;
|
||||
-D_FILE_OFFSET_BITS=*) ;;
|
||||
-D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;;
|
||||
-D_LARGE_FILES | -D_LARGE_FILES=*) ;;
|
||||
-D?* | -I?*)
|
||||
AC_SYS_LARGEFILE_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;;
|
||||
*)
|
||||
AC_SYS_LARGEFILE_SPACE_APPEND(CFLAGS, "$ac_flag") ;;
|
||||
esac
|
||||
done
|
||||
AC_SYS_LARGEFILE_SPACE_APPEND(LDFLAGS, "$ac_cv_sys_largefile_LDFLAGS")
|
||||
AC_SYS_LARGEFILE_SPACE_APPEND(LIBS, "$ac_cv_sys_largefile_LIBS")
|
||||
AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS,
|
||||
ac_cv_sys_file_offset_bits,
|
||||
[Number of bits in a file offset, on hosts where this is settable.],
|
||||
[case "$host_os" in
|
||||
# HP-UX 10.20 and later
|
||||
hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
|
||||
ac_cv_sys_file_offset_bits=64 ;;
|
||||
esac])
|
||||
AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE,
|
||||
ac_cv_sys_largefile_source,
|
||||
[Define to make fseeko etc. visible, on some hosts.],
|
||||
[case "$host_os" in
|
||||
# HP-UX 10.20 and later
|
||||
hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
|
||||
ac_cv_sys_largefile_source=1 ;;
|
||||
esac])
|
||||
AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES,
|
||||
ac_cv_sys_large_files,
|
||||
[Define for large files, on AIX-style hosts.],
|
||||
[case "$host_os" in
|
||||
# AIX 4.2 and later
|
||||
aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)
|
||||
ac_cv_sys_large_files=1 ;;
|
||||
esac])
|
||||
fi
|
||||
])
|
||||
#serial 3
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl Determine whether malloc accepts 0 as its argument.
|
||||
dnl If it doesn't, arrange to use the replacement function.
|
||||
dnl
|
||||
|
||||
AC_DEFUN(jm_FUNC_MALLOC,
|
||||
[
|
||||
dnl xmalloc.c requires that this symbol be defined so it doesn't
|
||||
dnl mistakenly use a broken malloc -- as it might if this test were omitted.
|
||||
AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_MALLOC_CHECK, 1,
|
||||
[Define if the malloc check has been performed. ])
|
||||
|
||||
AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
|
||||
[AC_TRY_RUN([
|
||||
char *malloc ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
exit (malloc (0) ? 0 : 1);
|
||||
}
|
||||
],
|
||||
jm_cv_func_working_malloc=yes,
|
||||
jm_cv_func_working_malloc=no,
|
||||
dnl When crosscompiling, assume malloc is broken.
|
||||
jm_cv_func_working_malloc=no)
|
||||
])
|
||||
if test $jm_cv_func_working_malloc = no; then
|
||||
AC_SUBST(LIBOBJS)
|
||||
LIBOBJS="$LIBOBJS malloc.$ac_objext"
|
||||
AC_DEFINE_UNQUOTED(malloc, rpl_malloc,
|
||||
[Define to rpl_malloc if the replacement function should be used.])
|
||||
fi
|
||||
])
|
||||
## ------------------------------- ##
|
||||
## Check for function prototypes. ##
|
||||
## From Franc,ois Pinard ##
|
||||
## ------------------------------- ##
|
||||
|
||||
# serial 1
|
||||
|
||||
AC_DEFUN(AM_C_PROTOTYPES,
|
||||
[AC_REQUIRE([AM_PROG_CC_STDC])
|
||||
AC_REQUIRE([AC_PROG_CPP])
|
||||
AC_MSG_CHECKING([for function prototypes])
|
||||
if test "$am_cv_prog_cc_stdc" != no; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(PROTOTYPES,1,[Define if compiler has function prototypes])
|
||||
U= ANSI2KNR=
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
U=_ ANSI2KNR=./ansi2knr
|
||||
# Ensure some checks needed by ansi2knr itself.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(string.h)
|
||||
fi
|
||||
AC_SUBST(U)dnl
|
||||
AC_SUBST(ANSI2KNR)dnl
|
||||
])
|
||||
#serial 3
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl Determine whether realloc works when both arguments are 0.
|
||||
dnl If it doesn't, arrange to use the replacement function.
|
||||
dnl
|
||||
|
||||
AC_DEFUN(jm_FUNC_REALLOC,
|
||||
[
|
||||
dnl xmalloc.c requires that this symbol be defined so it doesn't
|
||||
dnl mistakenly use a broken realloc -- as it might if this test were omitted.
|
||||
AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_REALLOC_CHECK, 1,
|
||||
[Define if the realloc check has been performed. ])
|
||||
|
||||
AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc,
|
||||
[AC_TRY_RUN([
|
||||
char *realloc ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
exit (realloc (0, 0) ? 0 : 1);
|
||||
}
|
||||
],
|
||||
jm_cv_func_working_realloc=yes,
|
||||
jm_cv_func_working_realloc=no,
|
||||
dnl When crosscompiling, assume realloc is broken.
|
||||
jm_cv_func_working_realloc=no)
|
||||
])
|
||||
if test $jm_cv_func_working_realloc = no; then
|
||||
AC_SUBST(LIBOBJS)
|
||||
LIBOBJS="$LIBOBJS realloc.$ac_objext"
|
||||
AC_DEFINE_UNQUOTED(realloc, rpl_realloc,
|
||||
[Define to rpl_realloc if the replacement function should be used.])
|
||||
fi
|
||||
])
|
||||
#serial 2
|
||||
|
||||
dnl From Jim Meyering
|
||||
|
||||
dnl Define HAVE_STRUCT_UTIMBUF if `struct utimbuf' is declared --
|
||||
dnl usually in <utime.h>.
|
||||
dnl Some systems have utime.h but don't declare the struct anywhere.
|
||||
|
||||
AC_DEFUN(jm_STRUCT_UTIMBUF,
|
||||
[
|
||||
AC_CHECK_HEADERS(utime.h)
|
||||
AC_REQUIRE([AC_HEADER_TIME])
|
||||
AC_CACHE_CHECK([for struct utimbuf], fu_cv_sys_struct_utimbuf,
|
||||
[AC_TRY_COMPILE(
|
||||
[
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
#ifdef HAVE_UTIME_H
|
||||
# include <utime.h>
|
||||
#endif
|
||||
],
|
||||
[static struct utimbuf x; x.actime = x.modtime;],
|
||||
fu_cv_sys_struct_utimbuf=yes,
|
||||
fu_cv_sys_struct_utimbuf=no)
|
||||
])
|
||||
|
||||
if test $fu_cv_sys_struct_utimbuf = yes; then
|
||||
AC_DEFINE_UNQUOTED(HAVE_STRUCT_UTIMBUF, 1,
|
||||
[Define if struct utimbuf is declared -- usually in <utime.h>.
|
||||
Some systems have utime.h but don't declare the struct anywhere. ])
|
||||
fi
|
||||
])
|
||||
|
||||
15
addext.c
15
addext.c
@ -1,5 +1,5 @@
|
||||
/* addext.c -- add an extension to a file name
|
||||
Copyright (C) 1990, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -23,10 +23,10 @@
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DOS_FILE_NAMES
|
||||
#define HAVE_DOS_FILE_NAMES 0
|
||||
# define HAVE_DOS_FILE_NAMES 0
|
||||
#endif
|
||||
#ifndef HAVE_LONG_FILE_NAMES
|
||||
#define HAVE_LONG_FILE_NAMES 0
|
||||
# define HAVE_LONG_FILE_NAMES 0
|
||||
#endif
|
||||
|
||||
#include <backupfile.h>
|
||||
@ -35,7 +35,7 @@
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#ifndef _POSIX_NAME_MAX
|
||||
#define _POSIX_NAME_MAX 14
|
||||
# define _POSIX_NAME_MAX 14
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -49,14 +49,13 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
char *base_name PARAMS ((char const *));
|
||||
|
||||
/* Append to FILENAME the extension EXT, unless the result would be too long,
|
||||
in which case just append the character E. */
|
||||
|
||||
void
|
||||
addext (filename, ext, e)
|
||||
char *filename;
|
||||
char const *ext;
|
||||
int e;
|
||||
addext (char *filename, char const *ext, int e)
|
||||
{
|
||||
char *s = base_name (filename);
|
||||
size_t slen = strlen (s), extlen = strlen (ext);
|
||||
|
||||
36
ansi2knr.1
Normal file
36
ansi2knr.1
Normal file
@ -0,0 +1,36 @@
|
||||
.TH ANSI2KNR 1 "19 Jan 1996"
|
||||
.SH NAME
|
||||
ansi2knr \- convert ANSI C to Kernighan & Ritchie C
|
||||
.SH SYNOPSIS
|
||||
.I ansi2knr
|
||||
[--varargs] input_file [output_file]
|
||||
.SH DESCRIPTION
|
||||
If no output_file is supplied, output goes to stdout.
|
||||
.br
|
||||
There are no error messages.
|
||||
.sp
|
||||
.I ansi2knr
|
||||
recognizes function definitions by seeing a non-keyword identifier at the left
|
||||
margin, followed by a left parenthesis, with a right parenthesis as the last
|
||||
character on the line, and with a left brace as the first token on the
|
||||
following line (ignoring possible intervening comments). It will recognize a
|
||||
multi-line header provided that no intervening line ends with a left or right
|
||||
brace or a semicolon. These algorithms ignore whitespace and comments, except
|
||||
that the function name must be the first thing on the line.
|
||||
.sp
|
||||
The following constructs will confuse it:
|
||||
.br
|
||||
- Any other construct that starts at the left margin and follows the
|
||||
above syntax (such as a macro or function call).
|
||||
.br
|
||||
- Some macros that tinker with the syntax of the function header.
|
||||
.sp
|
||||
The --varargs switch is obsolete, and is recognized only for
|
||||
backwards compatibility. The present version of
|
||||
.I ansi2knr
|
||||
will always attempt to convert a ... argument to va_alist and va_dcl.
|
||||
.SH AUTHOR
|
||||
L. Peter Deutsch <ghost@aladdin.com> wrote the original ansi2knr and
|
||||
continues to maintain the current version; most of the code in the current
|
||||
version is his work. ansi2knr also includes contributions by Francois
|
||||
Pinard <pinard@iro.umontreal.ca> and Jim Avera <jima@netcom.com>.
|
||||
260
ansi2knr.c
260
ansi2knr.c
@ -1,4 +1,6 @@
|
||||
/* ansi2knr.c */
|
||||
/* Copyright (C) 1989, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved. */
|
||||
|
||||
/*$Id: ansi2knr.c,v 1.14 1999/04/13 14:44:33 meyering Exp $*/
|
||||
/* Convert ANSI C function definitions to K&R ("traditional C") syntax */
|
||||
|
||||
/*
|
||||
@ -11,9 +13,10 @@ License (the "GPL") for full details.
|
||||
Everyone is granted permission to copy, modify and redistribute ansi2knr,
|
||||
but only under the conditions described in the GPL. A copy of this license
|
||||
is supposed to have been given to you along with ansi2knr so you can know
|
||||
your rights and responsibilities. It should be in a file named COPYLEFT.
|
||||
Among other things, the copyright notice and this notice must be preserved
|
||||
on all copies.
|
||||
your rights and responsibilities. It should be in a file named COPYLEFT,
|
||||
or, if there is no file named COPYLEFT, a file named COPYING. Among other
|
||||
things, the copyright notice and this notice must be preserved on all
|
||||
copies.
|
||||
|
||||
We explicitly state here what we believe is already implied by the GPL: if
|
||||
the ansi2knr program is distributed as a separate set of sources and a
|
||||
@ -26,7 +29,10 @@ program under the GPL.
|
||||
|
||||
/*
|
||||
* Usage:
|
||||
ansi2knr input_file [output_file]
|
||||
ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]]
|
||||
* --filename provides the file name for the #line directive in the output,
|
||||
* overriding input_file (if present).
|
||||
* If no input_file is supplied, input is read from stdin.
|
||||
* If no output_file is supplied, output goes to stdout.
|
||||
* There are no error messages.
|
||||
*
|
||||
@ -34,45 +40,71 @@ program under the GPL.
|
||||
* identifier at the left margin, followed by a left parenthesis,
|
||||
* with a right parenthesis as the last character on the line,
|
||||
* and with a left brace as the first token on the following line
|
||||
* (ignoring possible intervening comments).
|
||||
* It will recognize a multi-line header provided that no intervening
|
||||
* line ends with a left or right brace or a semicolon.
|
||||
* (ignoring possible intervening comments), except that a line
|
||||
* consisting of only
|
||||
* identifier1(identifier2)
|
||||
* will not be considered a function definition unless identifier2 is
|
||||
* the word "void", and a line consisting of
|
||||
* identifier1(identifier2, <<arbitrary>>)
|
||||
* will not be considered a function definition.
|
||||
* ansi2knr will recognize a multi-line header provided
|
||||
* that no intervening line ends with a left or right brace or a semicolon.
|
||||
* These algorithms ignore whitespace and comments, except that
|
||||
* the function name must be the first thing on the line.
|
||||
* The following constructs will confuse it:
|
||||
* - Any other construct that starts at the left margin and
|
||||
* follows the above syntax (such as a macro or function call).
|
||||
* - Some macros that tinker with the syntax of the function header.
|
||||
* - Some macros that tinker with the syntax of function headers.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The original and principal author of ansi2knr is L. Peter Deutsch
|
||||
* <ghost@aladdin.com>. Other authors are noted in the change history
|
||||
* that follows (in reverse chronological order):
|
||||
lpd 96-01-21 added code to cope with not HAVE_CONFIG_H and with
|
||||
lpd 1999-04-12 added minor fixes from Pavel Roskin
|
||||
<pavel_roskin@geocities.com> for clean compilation with
|
||||
gcc -W -Wall
|
||||
lpd 1999-03-22 added hack to recognize lines consisting of
|
||||
identifier1(identifier2, xxx) as *not* being procedures
|
||||
lpd 1999-02-03 made indentation of preprocessor commands consistent
|
||||
lpd 1999-01-28 fixed two bugs: a '/' in an argument list caused an
|
||||
endless loop; quoted strings within an argument list
|
||||
confused the parser
|
||||
lpd 1999-01-24 added a check for write errors on the output,
|
||||
suggested by Jim Meyering <meyering@ascend.com>
|
||||
lpd 1998-11-09 added further hack to recognize identifier(void)
|
||||
as being a procedure
|
||||
lpd 1998-10-23 added hack to recognize lines consisting of
|
||||
identifier1(identifier2) as *not* being procedures
|
||||
lpd 1997-12-08 made input_file optional; only closes input and/or
|
||||
output file if not stdin or stdout respectively; prints
|
||||
usage message on stderr rather than stdout; adds
|
||||
--filename switch (changes suggested by
|
||||
<ceder@lysator.liu.se>)
|
||||
lpd 1996-01-21 added code to cope with not HAVE_CONFIG_H and with
|
||||
compilers that don't understand void, as suggested by
|
||||
Tom Lane
|
||||
lpd 96-01-15 changed to require that the first non-comment token
|
||||
lpd 1996-01-15 changed to require that the first non-comment token
|
||||
on the line following a function header be a left brace,
|
||||
to reduce sensitivity to macros, as suggested by Tom Lane
|
||||
<tgl@sss.pgh.pa.us>
|
||||
lpd 95-06-22 removed #ifndefs whose sole purpose was to define
|
||||
lpd 1995-06-22 removed #ifndefs whose sole purpose was to define
|
||||
undefined preprocessor symbols as 0; changed all #ifdefs
|
||||
for configuration symbols to #ifs
|
||||
lpd 95-04-05 changed copyright notice to make it clear that
|
||||
lpd 1995-04-05 changed copyright notice to make it clear that
|
||||
including ansi2knr in a program does not bring the entire
|
||||
program under the GPL
|
||||
lpd 94-12-18 added conditionals for systems where ctype macros
|
||||
lpd 1994-12-18 added conditionals for systems where ctype macros
|
||||
don't handle 8-bit characters properly, suggested by
|
||||
Francois Pinard <pinard@iro.umontreal.ca>;
|
||||
removed --varargs switch (this is now the default)
|
||||
lpd 94-10-10 removed CONFIG_BROKETS conditional
|
||||
lpd 94-07-16 added some conditionals to help GNU `configure',
|
||||
lpd 1994-10-10 removed CONFIG_BROKETS conditional
|
||||
lpd 1994-07-16 added some conditionals to help GNU `configure',
|
||||
suggested by Francois Pinard <pinard@iro.umontreal.ca>;
|
||||
properly erase prototype args in function parameters,
|
||||
contributed by Jim Avera <jima@netcom.com>;
|
||||
correct error in writeblanks (it shouldn't erase EOLs)
|
||||
lpd 89-xx-xx original version
|
||||
lpd 1989-xx-xx original version
|
||||
*/
|
||||
|
||||
/* Most of the conditionals here are to make ansi2knr work with */
|
||||
@ -135,19 +167,24 @@ program under the GPL.
|
||||
|
||||
#endif
|
||||
|
||||
/* Define NULL (for *very* old compilers). */
|
||||
#ifndef NULL
|
||||
# define NULL (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The ctype macros don't always handle 8-bit characters correctly.
|
||||
* Compensate for this here.
|
||||
*/
|
||||
#ifdef isascii
|
||||
# undef HAVE_ISASCII /* just in case */
|
||||
# define HAVE_ISASCII 1
|
||||
# undef HAVE_ISASCII /* just in case */
|
||||
# define HAVE_ISASCII 1
|
||||
#else
|
||||
#endif
|
||||
#if STDC_HEADERS || !HAVE_ISASCII
|
||||
# define is_ascii(c) 1
|
||||
# define is_ascii(c) 1
|
||||
#else
|
||||
# define is_ascii(c) isascii(c)
|
||||
# define is_ascii(c) isascii(c)
|
||||
#endif
|
||||
|
||||
#define is_space(c) (is_ascii(c) && isspace(c))
|
||||
@ -160,6 +197,7 @@ program under the GPL.
|
||||
|
||||
/* Forward references */
|
||||
char *skipspace();
|
||||
char *scanstring();
|
||||
int writeblanks();
|
||||
int test1();
|
||||
int convert1();
|
||||
@ -169,11 +207,17 @@ int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{ FILE *in, *out;
|
||||
{ FILE *in = stdin;
|
||||
FILE *out = stdout;
|
||||
char *filename = 0;
|
||||
char *program_name = argv[0];
|
||||
char *output_name = 0;
|
||||
#define bufsize 5000 /* arbitrary size */
|
||||
char *buf;
|
||||
char *line;
|
||||
char *more;
|
||||
char *usage =
|
||||
"Usage: ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]]\n";
|
||||
/*
|
||||
* In previous versions, ansi2knr recognized a --varargs switch.
|
||||
* If this switch was supplied, ansi2knr would attempt to convert
|
||||
@ -183,44 +227,61 @@ main(argc, argv)
|
||||
* check for this switch for backward compatibility.
|
||||
*/
|
||||
int convert_varargs = 1;
|
||||
int output_error;
|
||||
|
||||
if ( argc > 1 && argv[1][0] == '-' )
|
||||
{ if ( !strcmp(argv[1], "--varargs") )
|
||||
{ convert_varargs = 1;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
else
|
||||
{ fprintf(stderr, "Unrecognized switch: %s\n", argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
while ( argc > 1 && argv[1][0] == '-' ) {
|
||||
if ( !strcmp(argv[1], "--varargs") ) {
|
||||
convert_varargs = 1;
|
||||
argc--;
|
||||
argv++;
|
||||
continue;
|
||||
}
|
||||
if (argc < 2 || argc > 3)
|
||||
if ( !strcmp(argv[1], "--filename") && argc > 2 ) {
|
||||
filename = argv[2];
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
continue;
|
||||
}
|
||||
fprintf(stderr, "%s: Unrecognized switch: %s\n", program_name,
|
||||
argv[1]);
|
||||
fprintf(stderr, usage);
|
||||
exit(1);
|
||||
}
|
||||
switch ( argc )
|
||||
{
|
||||
printf("Usage: ansi2knr input_file [output_file]\n");
|
||||
exit(1);
|
||||
}
|
||||
in = fopen(argv[1], "r");
|
||||
if ( in == NULL )
|
||||
{
|
||||
fprintf(stderr, "Cannot open input file %s\n", argv[1]);
|
||||
default:
|
||||
fprintf(stderr, usage);
|
||||
exit(0);
|
||||
case 3:
|
||||
output_name = argv[2];
|
||||
out = fopen(output_name, "w");
|
||||
if ( out == NULL ) {
|
||||
fprintf(stderr, "%s: Cannot open output file %s\n",
|
||||
program_name, output_name);
|
||||
exit(1);
|
||||
}
|
||||
/* falls through */
|
||||
case 2:
|
||||
in = fopen(argv[1], "r");
|
||||
if ( in == NULL ) {
|
||||
fprintf(stderr, "%s: Cannot open input file %s\n",
|
||||
program_name, argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
if ( filename == 0 )
|
||||
filename = argv[1];
|
||||
/* falls through */
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
if ( filename )
|
||||
fprintf(out, "#line 1 \"%s\"\n", filename);
|
||||
buf = malloc(bufsize);
|
||||
if ( buf == NULL )
|
||||
{
|
||||
fprintf(stderr, "Unable to allocate read buffer!\n");
|
||||
exit(1);
|
||||
}
|
||||
if (argc == 3)
|
||||
{
|
||||
out = fopen(argv[2], "w");
|
||||
if ( out == NULL )
|
||||
{
|
||||
fprintf(stderr, "Cannot open output file %s\n", argv[2]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
out = stdout;
|
||||
}
|
||||
fprintf(out, "#line 1 \"%s\"\n", argv[1]);
|
||||
buf = malloc(bufsize);
|
||||
line = buf;
|
||||
while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
|
||||
{
|
||||
@ -271,12 +332,24 @@ wl: fputs(buf, out);
|
||||
if ( line != buf )
|
||||
fputs(buf, out);
|
||||
free(buf);
|
||||
fclose(out);
|
||||
fclose(in);
|
||||
if ( output_name ) {
|
||||
output_error = ferror(out);
|
||||
output_error |= fclose(out);
|
||||
} else { /* out == stdout */
|
||||
fflush(out);
|
||||
output_error = ferror(out);
|
||||
}
|
||||
if ( output_error ) {
|
||||
fprintf(stderr, "%s: error writing to %s\n", program_name,
|
||||
(output_name ? output_name : "stdout"));
|
||||
exit(1);
|
||||
}
|
||||
if ( in != stdin )
|
||||
fclose(in);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Skip over space and comments, in either direction. */
|
||||
/* Skip over whitespace and comments, in either direction. */
|
||||
char *
|
||||
skipspace(p, dir)
|
||||
register char *p;
|
||||
@ -297,6 +370,17 @@ skipspace(p, dir)
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Scan over a quoted string, in either direction. */
|
||||
char *
|
||||
scanstring(p, dir)
|
||||
register char *p;
|
||||
register int dir;
|
||||
{
|
||||
for (p += dir; ; p += dir)
|
||||
if (*p == '"' && p[-dir] != '\\')
|
||||
return p + dir;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write blanks over part of a string.
|
||||
* Don't overwrite end-of-line characters.
|
||||
@ -365,7 +449,7 @@ test1(buf)
|
||||
};
|
||||
char **key = words;
|
||||
char *kp;
|
||||
int len = endfn - buf;
|
||||
unsigned len = endfn - buf;
|
||||
|
||||
while ( (kp = *key) != 0 )
|
||||
{ if ( strlen(kp) == len && !strncmp(kp, buf, len) )
|
||||
@ -373,6 +457,36 @@ test1(buf)
|
||||
key++;
|
||||
}
|
||||
}
|
||||
{
|
||||
char *id = p;
|
||||
int len;
|
||||
/*
|
||||
* Check for identifier1(identifier2) and not
|
||||
* identifier1(void), or identifier1(identifier2, xxxx).
|
||||
*/
|
||||
|
||||
while ( isidchar(*p) )
|
||||
p++;
|
||||
len = p - id;
|
||||
p = skipspace(p, 1);
|
||||
if (*p == ',' ||
|
||||
(*p == ')' && (len != 4 || strncmp(id, "void", 4)))
|
||||
)
|
||||
return 0; /* not a function */
|
||||
}
|
||||
/*
|
||||
* If the last significant character was a ), we need to count
|
||||
* parentheses, because it might be part of a formal parameter
|
||||
* that is a procedure.
|
||||
*/
|
||||
if (contin > 0) {
|
||||
int level = 0;
|
||||
|
||||
for (p = skipspace(buf, 1); *p; p = skipspace(p + 1, 1))
|
||||
level += (*p == '(' ? 1 : *p == ')' ? -1 : 0);
|
||||
if (level > 0)
|
||||
contin = -1;
|
||||
}
|
||||
return contin;
|
||||
}
|
||||
|
||||
@ -402,7 +516,7 @@ convert1(buf, out, header, convert_varargs)
|
||||
;
|
||||
top: p = endfn;
|
||||
breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
|
||||
if ( breaks == 0 )
|
||||
if ( breaks == NULL )
|
||||
{ /* Couldn't allocate break table, give up */
|
||||
fprintf(stderr, "Unable to allocate break table!\n");
|
||||
fputs(buf, out);
|
||||
@ -414,7 +528,7 @@ top: p = endfn;
|
||||
do
|
||||
{ int level = 0;
|
||||
char *lp = NULL;
|
||||
char *rp;
|
||||
char *rp = NULL;
|
||||
char *end = NULL;
|
||||
|
||||
if ( bp >= btop )
|
||||
@ -441,14 +555,18 @@ top: p = endfn;
|
||||
else rp = p;
|
||||
break;
|
||||
case '/':
|
||||
p = skipspace(p, 1) - 1;
|
||||
if (p[1] == '*')
|
||||
p = skipspace(p, 1) - 1;
|
||||
break;
|
||||
case '"':
|
||||
p = scanstring(p, 1) - 1;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
/* Erase any embedded prototype parameters. */
|
||||
if ( lp )
|
||||
if ( lp && rp )
|
||||
writeblanks(lp + 1, rp);
|
||||
p--; /* back up over terminator */
|
||||
/* Find the name being declared. */
|
||||
@ -464,9 +582,19 @@ top: p = endfn;
|
||||
while ( level )
|
||||
switch ( *--p )
|
||||
{
|
||||
case ']': case ')': level++; break;
|
||||
case '[': case '(': level--; break;
|
||||
case '/': p = skipspace(p, -1) + 1; break;
|
||||
case ']': case ')':
|
||||
level++;
|
||||
break;
|
||||
case '[': case '(':
|
||||
level--;
|
||||
break;
|
||||
case '/':
|
||||
if (p > buf && p[-1] == '*')
|
||||
p = skipspace(p, -1) + 1;
|
||||
break;
|
||||
case '"':
|
||||
p = scanstring(p, -1) + 1;
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
|
||||
292
argmatch.c
292
argmatch.c
@ -1,5 +1,5 @@
|
||||
/* argmatch.c -- find a match for a string in an array
|
||||
Copyright (C) 1990, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1998, 1999 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
|
||||
@ -12,39 +12,86 @@
|
||||
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. */
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu> */
|
||||
/* Written by David MacKenzie <djm@ai.mit.edu>
|
||||
Modified by Akim Demaille <demaille@inf.enst.fr> */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <argmatch.h>
|
||||
#include <quotearg.h>
|
||||
#include "argmatch.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#if HAVE_STRING_H
|
||||
#ifdef STDC_HEADERS
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
/* If ARG is an unambiguous match for an element of the
|
||||
null-terminated array OPTLIST, return the index in OPTLIST
|
||||
of the matched element, else -1 if it does not match any element
|
||||
or -2 if it is ambiguous (is a prefix of more than one element). */
|
||||
#if HAVE_LOCALE_H
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
int
|
||||
argmatch (arg, optlist)
|
||||
const char *arg;
|
||||
const char *const *optlist;
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(Text) gettext (Text)
|
||||
#else
|
||||
# define _(Text) Text
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
#include "quotearg.h"
|
||||
|
||||
/* When reporting an invalid argument, show nonprinting characters
|
||||
by using the quoting style ARGMATCH_QUOTING_STYLE. Do not use
|
||||
literal_quoting_style. */
|
||||
#ifndef ARGMATCH_QUOTING_STYLE
|
||||
# define ARGMATCH_QUOTING_STYLE locale_quoting_style
|
||||
#endif
|
||||
|
||||
/* The following test is to work around the gross typo in
|
||||
systems like Sony NEWS-OS Release 4.0C, whereby EXIT_FAILURE
|
||||
is defined to 0, not 1. */
|
||||
#if !EXIT_FAILURE
|
||||
# undef EXIT_FAILURE
|
||||
# define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
/* Non failing version of argmatch call this function after failing. */
|
||||
#ifndef ARGMATCH_DIE
|
||||
# define ARGMATCH_DIE exit (EXIT_FAILURE)
|
||||
#endif
|
||||
|
||||
#ifdef ARGMATCH_DIE_DECL
|
||||
ARGMATCH_DIE_DECL;
|
||||
#endif
|
||||
|
||||
static void
|
||||
__argmatch_die (void)
|
||||
{
|
||||
int i; /* Temporary index in OPTLIST. */
|
||||
ARGMATCH_DIE;
|
||||
}
|
||||
|
||||
/* Used by XARGMATCH and XARGCASEMATCH. See description in argmatch.h.
|
||||
Default to __argmatch_die, but allow caller to change this at run-time. */
|
||||
argmatch_exit_fn argmatch_die = __argmatch_die;
|
||||
|
||||
|
||||
/* If ARG is an unambiguous match for an element of the
|
||||
null-terminated array ARGLIST, return the index in ARGLIST
|
||||
of the matched element, else -1 if it does not match any element
|
||||
or -2 if it is ambiguous (is a prefix of more than one element).
|
||||
If SENSITIVE, comparison is case sensitive.
|
||||
|
||||
If VALLIST is none null, use it to resolve ambiguities limited to
|
||||
synonyms, i.e., for
|
||||
"yes", "yop" -> 0
|
||||
"no", "nope" -> 1
|
||||
"y" is a valid argument, for `0', and "n" for `1'. */
|
||||
|
||||
static int
|
||||
__argmatch_internal (const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize,
|
||||
int case_sensitive)
|
||||
{
|
||||
int i; /* Temporary index in ARGLIST. */
|
||||
size_t arglen; /* Length of ARG. */
|
||||
int matchind = -1; /* Index of first nonexact match. */
|
||||
int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */
|
||||
@ -52,19 +99,30 @@ argmatch (arg, optlist)
|
||||
arglen = strlen (arg);
|
||||
|
||||
/* Test all elements for either exact match or abbreviated matches. */
|
||||
for (i = 0; optlist[i]; i++)
|
||||
for (i = 0; arglist[i]; i++)
|
||||
{
|
||||
if (!strncmp (optlist[i], arg, arglen))
|
||||
if (case_sensitive
|
||||
? !strncmp (arglist[i], arg, arglen)
|
||||
: !strncasecmp (arglist[i], arg, arglen))
|
||||
{
|
||||
if (strlen (optlist[i]) == arglen)
|
||||
if (strlen (arglist[i]) == arglen)
|
||||
/* Exact match found. */
|
||||
return i;
|
||||
else if (matchind == -1)
|
||||
/* First nonexact match found. */
|
||||
matchind = i;
|
||||
else
|
||||
/* Second nonexact match found. */
|
||||
ambiguous = 1;
|
||||
{
|
||||
/* Second nonexact match found. */
|
||||
if (vallist == NULL
|
||||
|| memcmp (vallist + valsize * matchind,
|
||||
vallist + valsize * i, valsize))
|
||||
{
|
||||
/* There is a real ambiguity, or we could not
|
||||
disambiguate. */
|
||||
ambiguous = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ambiguous)
|
||||
@ -73,18 +131,176 @@ argmatch (arg, optlist)
|
||||
return matchind;
|
||||
}
|
||||
|
||||
/* argmatch - case sensitive version */
|
||||
int
|
||||
argmatch (const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
return __argmatch_internal (arg, arglist, vallist, valsize, 1);
|
||||
}
|
||||
|
||||
/* argcasematch - case insensitive version */
|
||||
int
|
||||
argcasematch (const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
return __argmatch_internal (arg, arglist, vallist, valsize, 0);
|
||||
}
|
||||
|
||||
/* Error reporting for argmatch.
|
||||
KIND is a description of the type of entity that was being matched.
|
||||
CONTEXT is a description of the type of entity that was being matched.
|
||||
VALUE is the invalid value that was given.
|
||||
PROBLEM is the return value from argmatch. */
|
||||
|
||||
void
|
||||
invalid_arg (kind, value, problem)
|
||||
const char *kind;
|
||||
const char *value;
|
||||
int problem;
|
||||
argmatch_invalid (const char *context, const char *value, int problem)
|
||||
{
|
||||
fprintf (stderr,
|
||||
problem == -1 ? "%s: invalid %s %s\n" : "%s: ambiguous %s %s\n",
|
||||
program_name, kind, quotearg (value));
|
||||
char const *format = (problem == -1
|
||||
? _("invalid argument %s for `%s'")
|
||||
: _("ambiguous argument %s for `%s'"));
|
||||
|
||||
error (0, 0, format, quotearg_style (ARGMATCH_QUOTING_STYLE, value), context);
|
||||
}
|
||||
|
||||
/* List the valid arguments for argmatch.
|
||||
ARGLIST is the same as in argmatch.
|
||||
VALLIST is a pointer to an array of values.
|
||||
VALSIZE is the size of the elements of VALLIST */
|
||||
void
|
||||
argmatch_valid (const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
int i;
|
||||
const char *last_val = NULL;
|
||||
|
||||
/* We try to put synonyms on the same line. The assumption is that
|
||||
synonyms follow each other */
|
||||
fprintf (stderr, _("Valid arguments are:"));
|
||||
for (i = 0; arglist[i]; i++)
|
||||
if ((i == 0)
|
||||
|| memcmp (last_val, vallist + valsize * i, valsize))
|
||||
{
|
||||
fprintf (stderr, "\n - `%s'", arglist[i]);
|
||||
last_val = vallist + valsize * i;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, ", `%s'", arglist[i]);
|
||||
}
|
||||
putc ('\n', stderr);
|
||||
}
|
||||
|
||||
/* Never failing versions of the previous functions.
|
||||
|
||||
CONTEXT is the context for which argmatch is called (e.g.,
|
||||
"--version-control", or "$VERSION_CONTROL" etc.). Upon failure,
|
||||
calls the (supposed never to return) function EXIT_FN. */
|
||||
|
||||
int
|
||||
__xargmatch_internal (const char *context,
|
||||
const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize,
|
||||
int case_sensitive,
|
||||
argmatch_exit_fn exit_fn)
|
||||
{
|
||||
int res = __argmatch_internal (arg, arglist,
|
||||
vallist, valsize,
|
||||
case_sensitive);
|
||||
if (res >= 0)
|
||||
/* Success. */
|
||||
return res;
|
||||
|
||||
/* We failed. Explain why. */
|
||||
argmatch_invalid (context, arg, res);
|
||||
argmatch_valid (arglist, vallist, valsize);
|
||||
(*exit_fn) ();
|
||||
|
||||
return -1; /* To please the compilers. */
|
||||
}
|
||||
|
||||
/* Look for VALUE in VALLIST, an array of objects of size VALSIZE and
|
||||
return the first corresponding argument in ARGLIST */
|
||||
const char *
|
||||
argmatch_to_argument (const char *value,
|
||||
const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; arglist[i]; i++)
|
||||
if (!memcmp (value, vallist + valsize * i, valsize))
|
||||
return arglist[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
/*
|
||||
* Based on "getversion.c" by David MacKenzie <djm@gnu.ai.mit.edu>
|
||||
*/
|
||||
char *program_name;
|
||||
extern const char *getenv ();
|
||||
|
||||
/* When to make backup files. */
|
||||
enum backup_type
|
||||
{
|
||||
/* Never make backups. */
|
||||
none,
|
||||
|
||||
/* Make simple backups of every file. */
|
||||
simple,
|
||||
|
||||
/* Make numbered backups of files that already have numbered backups,
|
||||
and simple backups of the others. */
|
||||
numbered_existing,
|
||||
|
||||
/* Make numbered backups of every file. */
|
||||
numbered
|
||||
};
|
||||
|
||||
/* Two tables describing arguments (keys) and their corresponding
|
||||
values */
|
||||
static const char *const backup_args[] =
|
||||
{
|
||||
"no", "none", "off",
|
||||
"simple", "never",
|
||||
"existing", "nil",
|
||||
"numbered", "t",
|
||||
0
|
||||
};
|
||||
|
||||
static const enum backup_type backup_vals[] =
|
||||
{
|
||||
none, none, none,
|
||||
simple, simple,
|
||||
numbered_existing, numbered_existing,
|
||||
numbered, numbered
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc, const char *const *argv)
|
||||
{
|
||||
const char *cp;
|
||||
enum backup_type backup_type = none;
|
||||
|
||||
program_name = (char *) argv[0];
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", program_name);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if ((cp = getenv ("VERSION_CONTROL")))
|
||||
backup_type = XARGCASEMATCH ("$VERSION_CONTROL", cp,
|
||||
backup_args, backup_vals);
|
||||
|
||||
if (argc == 2)
|
||||
backup_type = XARGCASEMATCH (program_name, argv[1],
|
||||
backup_args, backup_vals);
|
||||
|
||||
printf ("The version control is `%s'\n",
|
||||
ARGMATCH_TO_ARGUMENT (backup_type, backup_args, backup_vals));
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
135
argmatch.h
135
argmatch.h
@ -1,12 +1,129 @@
|
||||
/* argmatch.h -- declarations for matching arguments against option lists */
|
||||
/* argmatch.h -- definitions and prototypes for argmatch.c
|
||||
Copyright (C) 1990, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
#if defined __STDC__ || __GNUC__
|
||||
# define __ARGMATCH_P(args) args
|
||||
#else
|
||||
# define __ARGMATCH_P(args) ()
|
||||
#endif
|
||||
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.
|
||||
|
||||
int argmatch __ARGMATCH_P ((const char *, const char * const *));
|
||||
void invalid_arg __ARGMATCH_P ((const char *, const char *, int));
|
||||
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.
|
||||
|
||||
extern char const program_name[];
|
||||
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. */
|
||||
|
||||
/* Written by David MacKenzie <djm@ai.mit.edu>
|
||||
Modified by Akim Demaille <demaille@inf.enst.fr> */
|
||||
|
||||
#ifndef ARGMATCH_H_
|
||||
# define ARGMATCH_H_ 1
|
||||
|
||||
# if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# endif
|
||||
|
||||
# include <sys/types.h>
|
||||
|
||||
# ifndef PARAMS
|
||||
# if PROTOTYPES || (defined (__STDC__) && __STDC__)
|
||||
# define PARAMS(args) args
|
||||
# else
|
||||
# define PARAMS(args) ()
|
||||
# endif /* GCC. */
|
||||
# endif /* Not PARAMS. */
|
||||
|
||||
/* Assert there are as many real arguments as there are values
|
||||
(argument list ends with a NULL guard). There is no execution
|
||||
cost, since it will be statically evalauted to `assert (0)' or
|
||||
`assert (1)'. Unfortunately there is no -Wassert-0. */
|
||||
|
||||
# undef ARRAY_CARDINALITY
|
||||
# define ARRAY_CARDINALITY(Array) (sizeof ((Array)) / sizeof (*(Array)))
|
||||
|
||||
# define ARGMATCH_ASSERT(Arglist, Vallist) \
|
||||
assert (ARRAY_CARDINALITY ((Arglist)) == ARRAY_CARDINALITY ((Vallist)) + 1)
|
||||
|
||||
/* Return the index of the element of ARGLIST (NULL terminated) that
|
||||
matches with ARG. If VALLIST is not NULL, then use it to resolve
|
||||
false ambiguities (i.e., different matches of ARG but corresponding
|
||||
to the same values in VALLIST). */
|
||||
|
||||
int argmatch
|
||||
PARAMS ((const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize));
|
||||
int argcasematch
|
||||
PARAMS ((const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize));
|
||||
|
||||
# define ARGMATCH(Arg, Arglist, Vallist) \
|
||||
argmatch ((Arg), (Arglist), (const char *) (Vallist), sizeof (*(Vallist)))
|
||||
|
||||
# define ARGCASEMATCH(Arg, Arglist, Vallist) \
|
||||
argcasematch ((Arg), (Arglist), (const char *) (Vallist), sizeof (*(Vallist)))
|
||||
|
||||
/* xargmatch calls this function when it fails. This function should not
|
||||
return. By default, this is a function that calls ARGMATCH_DIE which
|
||||
in turn defaults to `exit (EXIT_FAILURE)'. */
|
||||
typedef void (*argmatch_exit_fn) PARAMS ((void));
|
||||
extern argmatch_exit_fn argmatch_die;
|
||||
|
||||
/* Report on stderr why argmatch failed. Report correct values. */
|
||||
|
||||
void argmatch_invalid
|
||||
PARAMS ((const char *context, const char *value, int problem));
|
||||
|
||||
/* Left for compatibility with the old name invalid_arg */
|
||||
|
||||
# define invalid_arg(Context, Value, Problem) \
|
||||
argmatch_invalid ((Context), (Value), (Problem))
|
||||
|
||||
|
||||
|
||||
/* Report on stderr the list of possible arguments. */
|
||||
|
||||
void argmatch_valid
|
||||
PARAMS ((const char *const *arglist,
|
||||
const char *vallist, size_t valsize));
|
||||
|
||||
# define ARGMATCH_VALID(Arglist, Vallist) \
|
||||
argmatch_valid (Arglist, (const char *) Vallist, sizeof (*(Vallist)))
|
||||
|
||||
|
||||
|
||||
/* Same as argmatch, but upon failure, reports a explanation on the
|
||||
failure, and exits using the function EXIT_FN. */
|
||||
|
||||
int __xargmatch_internal
|
||||
PARAMS ((const char *context,
|
||||
const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize,
|
||||
int case_sensitive, argmatch_exit_fn exit_fn));
|
||||
|
||||
/* Programmer friendly interface to __xargmatch_internal. */
|
||||
|
||||
# define XARGMATCH(Context, Arg, Arglist, Vallist) \
|
||||
(Vallist [__xargmatch_internal ((Context), (Arg), (Arglist), \
|
||||
(const char *) (Vallist), \
|
||||
sizeof (*(Vallist)), \
|
||||
1, argmatch_die)])
|
||||
|
||||
# define XARGCASEMATCH(Context, Arg, Arglist, Vallist) \
|
||||
(Vallist [__xargmatch_internal ((Context), (Arg), (Arglist), \
|
||||
(const char *) (Vallist), \
|
||||
sizeof (*(Vallist)), \
|
||||
0, argmatch_die)])
|
||||
|
||||
/* Convert a value into a corresponding argument. */
|
||||
|
||||
const char *argmatch_to_argument
|
||||
PARAMS ((char const *value, const char *const *arglist,
|
||||
const char *vallist, size_t valsize));
|
||||
|
||||
# define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist) \
|
||||
argmatch_to_argument ((char const *) &(Value), (Arglist), \
|
||||
(const char *) (Vallist), sizeof (*(Vallist)))
|
||||
|
||||
#endif /* ARGMATCH_H_ */
|
||||
|
||||
80
backupfile.c
80
backupfile.c
@ -1,5 +1,5 @@
|
||||
/* backupfile.c -- make Emacs style backup file names
|
||||
Copyright (C) 1990,1991,1992,1993,1995,1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1997, 1998, 1999 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
|
||||
@ -64,6 +64,12 @@
|
||||
char *malloc ();
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DECL_GETENV
|
||||
char *getenv ();
|
||||
#endif
|
||||
|
||||
char *base_name PARAMS ((char const *));
|
||||
|
||||
#if HAVE_DIRENT_H || HAVE_NDIR_H || HAVE_SYS_DIR_H || HAVE_SYS_NDIR_H
|
||||
# define HAVE_DIR 1
|
||||
#else
|
||||
@ -74,7 +80,7 @@ char *malloc ();
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#ifndef CHAR_BIT
|
||||
#define CHAR_BIT 8
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
/* Upper bound on the string length of an integer converted to string.
|
||||
302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit;
|
||||
@ -97,15 +103,12 @@ char *malloc ();
|
||||
# define REAL_DIR_ENTRY(dp) 1
|
||||
#endif
|
||||
|
||||
/* Which type of backup file names are generated. */
|
||||
enum backup_type backup_type = none;
|
||||
|
||||
/* The extension added to file names to produce a simple (as opposed
|
||||
to numbered) backup file name. */
|
||||
const char *simple_backup_suffix = ".orig";
|
||||
const char *simple_backup_suffix = "~";
|
||||
|
||||
static int max_backup_version __BACKUPFILE_P ((const char *, const char *));
|
||||
static int version_number __BACKUPFILE_P ((const char *, const char *, size_t));
|
||||
static int max_backup_version PARAMS ((const char *, const char *));
|
||||
static int version_number PARAMS ((const char *, const char *, size_t));
|
||||
|
||||
/* Return the name of the new backup file for file FILE,
|
||||
allocated with malloc. Return 0 if out of memory.
|
||||
@ -113,8 +116,7 @@ static int version_number __BACKUPFILE_P ((const char *, const char *, size_t));
|
||||
Do not call this function if backup_type == none. */
|
||||
|
||||
char *
|
||||
find_backup_file_name (file)
|
||||
const char *file;
|
||||
find_backup_file_name (const char *file, enum backup_type backup_type)
|
||||
{
|
||||
size_t backup_suffix_size_max;
|
||||
size_t file_len = strlen (file);
|
||||
@ -163,9 +165,7 @@ find_backup_file_name (file)
|
||||
*/
|
||||
|
||||
static int
|
||||
max_backup_version (file, dir)
|
||||
const char *file;
|
||||
const char *dir;
|
||||
max_backup_version (const char *file, const char *dir)
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
@ -199,10 +199,7 @@ max_backup_version (file, dir)
|
||||
*/
|
||||
|
||||
static int
|
||||
version_number (base, backup, base_length)
|
||||
const char *base;
|
||||
const char *backup;
|
||||
size_t base_length;
|
||||
version_number (const char *base, const char *backup, size_t base_length)
|
||||
{
|
||||
int version;
|
||||
const char *p;
|
||||
@ -223,30 +220,49 @@ version_number (base, backup, base_length)
|
||||
|
||||
static const char * const backup_args[] =
|
||||
{
|
||||
"never", "simple", "nil", "existing", "t", "numbered", 0
|
||||
/* In a series of synonyms, present the most meaning full first, so
|
||||
that argmatch_valid be more readable. */
|
||||
"none", "off",
|
||||
"simple", "never",
|
||||
"existing", "nil",
|
||||
"numbered", "t",
|
||||
0
|
||||
};
|
||||
|
||||
static const enum backup_type backup_types[] =
|
||||
{
|
||||
simple, simple, numbered_existing, numbered_existing, numbered, numbered
|
||||
none, none,
|
||||
simple, simple,
|
||||
numbered_existing, numbered_existing,
|
||||
numbered, numbered
|
||||
};
|
||||
|
||||
/* Return the type of backup indicated by VERSION.
|
||||
Unique abbreviations are accepted. */
|
||||
/* Return the type of backup specified by VERSION.
|
||||
If VERSION is NULL or the empty string, return numbered_existing.
|
||||
If VERSION is invalid or ambiguous, fail with a diagnostic appropriate
|
||||
for the specified CONTEXT. Unambiguous abbreviations are accepted. */
|
||||
|
||||
enum backup_type
|
||||
get_version (version)
|
||||
const char *version;
|
||||
get_version (const char *context, const char *version)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (version == 0 || *version == 0)
|
||||
return numbered_existing;
|
||||
i = argmatch (version, backup_args);
|
||||
if (i < 0)
|
||||
{
|
||||
invalid_arg ("version control type", version, i);
|
||||
exit (2);
|
||||
}
|
||||
return backup_types[i];
|
||||
else
|
||||
return XARGMATCH (context, version, backup_args, backup_types);
|
||||
}
|
||||
|
||||
|
||||
/* Return the type of backup specified by VERSION.
|
||||
If VERSION is NULL, use the value of the envvar VERSION_CONTROL.
|
||||
If the specified string is invalid or ambiguous, fail with a diagnostic
|
||||
appropriate for the specified CONTEXT.
|
||||
Unambiguous abbreviations are accepted. */
|
||||
|
||||
enum backup_type
|
||||
xget_version (const char *context, const char *version)
|
||||
{
|
||||
if (version && *version)
|
||||
return get_version (context, version);
|
||||
else
|
||||
return get_version ("$VERSION_CONTROL", getenv ("VERSION_CONTROL"));
|
||||
}
|
||||
|
||||
34
backupfile.h
34
backupfile.h
@ -1,5 +1,5 @@
|
||||
/* backupfile.h -- declarations for making Emacs style backup file names
|
||||
Copyright (C) 1990, 1991, 1992, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1992, 1997-1999 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,6 +16,9 @@
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef BACKUPFILE_H_
|
||||
# define BACKUPFILE_H_
|
||||
|
||||
/* When to make backup files. */
|
||||
enum backup_type
|
||||
{
|
||||
@ -33,18 +36,25 @@ enum backup_type
|
||||
numbered
|
||||
};
|
||||
|
||||
extern enum backup_type backup_type;
|
||||
# define VALID_BACKUP_TYPE(Type) \
|
||||
((Type) == none \
|
||||
|| (Type) == simple \
|
||||
|| (Type) == numbered_existing \
|
||||
|| (Type) == numbered)
|
||||
|
||||
extern char const *simple_backup_suffix;
|
||||
|
||||
#ifndef __BACKUPFILE_P
|
||||
# if defined __STDC__ || __GNUC__
|
||||
# define __BACKUPFILE_P(args) args
|
||||
# else
|
||||
# define __BACKUPFILE_P(args) ()
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
char *base_name __BACKUPFILE_P ((char const *));
|
||||
char *find_backup_file_name __BACKUPFILE_P ((char const *));
|
||||
enum backup_type get_version __BACKUPFILE_P ((char const *));
|
||||
void addext __BACKUPFILE_P ((char *, char const *, int));
|
||||
char *find_backup_file_name PARAMS ((char const *, enum backup_type));
|
||||
enum backup_type get_version PARAMS ((char const *context, char const *arg));
|
||||
enum backup_type xget_version PARAMS ((char const *context, char const *arg));
|
||||
void addext PARAMS ((char *, char const *, int));
|
||||
|
||||
#endif /* ! BACKUPFILE_H_ */
|
||||
|
||||
45
basename.c
45
basename.c
@ -1,32 +1,55 @@
|
||||
/* basename.c -- return the last element in a path */
|
||||
/* basename.c -- return the last element in a path
|
||||
Copyright (C) 1990, 1998, 1999 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. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <backupfile.h>
|
||||
|
||||
#ifndef FILESYSTEM_PREFIX_LEN
|
||||
#define FILESYSTEM_PREFIX_LEN(f) 0
|
||||
# define FILESYSTEM_PREFIX_LEN(Filename) 0
|
||||
#endif
|
||||
|
||||
#ifndef ISSLASH
|
||||
#define ISSLASH(c) ((c) == '/')
|
||||
# define ISSLASH(C) ((C) == '/')
|
||||
#endif
|
||||
|
||||
/* In general, we can't use the builtin `basename' function if available,
|
||||
since it has different meanings in different environments.
|
||||
In some environments the builtin `basename' modifies its argument. */
|
||||
In some environments the builtin `basename' modifies its argument.
|
||||
If NAME is all slashes, be sure to return `/'. */
|
||||
|
||||
char *
|
||||
base_name (name)
|
||||
char const *name;
|
||||
base_name (char const *name)
|
||||
{
|
||||
char const *base = name += FILESYSTEM_PREFIX_LEN (name);
|
||||
int all_slashes = 1;
|
||||
char const *p;
|
||||
|
||||
for (; *name; name++)
|
||||
if (ISSLASH (*name))
|
||||
base = name + 1;
|
||||
for (p = name; *p; p++)
|
||||
{
|
||||
if (ISSLASH (*p))
|
||||
base = p + 1;
|
||||
else
|
||||
all_slashes = 0;
|
||||
}
|
||||
|
||||
/* If NAME is all slashes, arrange to return `/'. */
|
||||
if (*base == '\0' && ISSLASH (*name) && all_slashes)
|
||||
--base;
|
||||
|
||||
return (char *) base;
|
||||
}
|
||||
|
||||
9
basename.h
Normal file
9
basename.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
char *base_name PARAMS ((char const *name));
|
||||
46
common.h
46
common.h
@ -1,26 +1,24 @@
|
||||
/* common definitions for `patch' */
|
||||
|
||||
/* $Id: common.h,v 1.19 1998/03/15 14:44:47 eggert Exp $ */
|
||||
/* $Id: common.h,v 1.20 1999/08/30 06:20:08 eggert Exp $ */
|
||||
|
||||
/*
|
||||
Copyright 1986, 1988 Larry Wall
|
||||
Copyright 1990, 1991, 1992, 1993, 1997, 1998 Free Software Foundation, Inc.
|
||||
/* Copyright 1986, 1988 Larry Wall
|
||||
Copyright 1990, 1991-1993, 1997-1998, 1999 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 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.
|
||||
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.
|
||||
*/
|
||||
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. */
|
||||
|
||||
#ifndef DEBUGGING
|
||||
#define DEBUGGING 1
|
||||
@ -34,11 +32,6 @@ If not, write to the Free Software Foundation,
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Enable support for fseeko and ftello on hosts
|
||||
where it is available but is turned off by default.
|
||||
This must be defined before any system file is included. */
|
||||
#define _LARGEFILE_SOURCE 1
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <assert.h>
|
||||
@ -265,9 +258,10 @@ GENERIC_OBJECT *realloc ();
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifndef lseek
|
||||
off_t lseek ();
|
||||
#else
|
||||
# ifndef lseek
|
||||
off_t lseek ();
|
||||
# endif
|
||||
#endif
|
||||
#ifndef SEEK_SET
|
||||
#define SEEK_SET 0
|
||||
@ -281,7 +275,7 @@ off_t lseek ();
|
||||
#ifndef STDERR_FILENO
|
||||
#define STDERR_FILENO 2
|
||||
#endif
|
||||
#if _LFS_LARGEFILE
|
||||
#if HAVE_FSEEKO
|
||||
typedef off_t file_offset;
|
||||
# define file_seek fseeko
|
||||
# define file_tell ftello
|
||||
|
||||
1088
config.guess
vendored
Normal file
1088
config.guess
vendored
Normal file
File diff suppressed because it is too large
Load Diff
78
config.hin
78
config.hin
@ -31,6 +31,9 @@
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
#undef off_t
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef pid_t
|
||||
|
||||
/* Define if the system does not provide POSIX.1 features except
|
||||
with this defined. */
|
||||
#undef _POSIX_1_SOURCE
|
||||
@ -47,37 +50,15 @@
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define if there is a member named d_ino in the struct describing
|
||||
directory headers. */
|
||||
#undef D_INO_IN_DIRENT
|
||||
|
||||
/* Define if you have a working <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define if memchr works. */
|
||||
#undef HAVE_MEMCHR
|
||||
|
||||
/* Define if `struct utimbuf' is declared -- usually in <utime.h>. */
|
||||
#undef HAVE_STRUCT_UTIMBUF
|
||||
|
||||
/* Define to rpl_malloc if the replacement function should be used. */
|
||||
#undef malloc
|
||||
|
||||
/* Define to 1 if ANSI function prototypes are usable. */
|
||||
#undef PROTOTYPES
|
||||
|
||||
/* Define to rpl_realloc if the replacement function should be used. */
|
||||
#undef realloc
|
||||
|
||||
/* Define if you have the DONE_WORKING_MALLOC_CHECK function. */
|
||||
#undef HAVE_DONE_WORKING_MALLOC_CHECK
|
||||
|
||||
/* Define if you have the DONE_WORKING_REALLOC_CHECK function. */
|
||||
#undef HAVE_DONE_WORKING_REALLOC_CHECK
|
||||
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define if you have the _doprintf function. */
|
||||
#undef HAVE__DOPRINTF
|
||||
|
||||
/* Define if you have the fseeko function. */
|
||||
#undef HAVE_FSEEKO
|
||||
|
||||
/* Define if you have the isascii function. */
|
||||
#undef HAVE_ISASCII
|
||||
|
||||
@ -102,6 +83,12 @@
|
||||
/* Define if you have the rename function. */
|
||||
#undef HAVE_RENAME
|
||||
|
||||
/* Define if you have the rmdir function. */
|
||||
#undef HAVE_RMDIR
|
||||
|
||||
/* Define if you have the setmode function. */
|
||||
#undef HAVE_SETMODE
|
||||
|
||||
/* Define if you have the sigaction function. */
|
||||
#undef HAVE_SIGACTION
|
||||
|
||||
@ -143,3 +130,40 @@
|
||||
|
||||
/* Define if you have the <varargs.h> header file. */
|
||||
#undef HAVE_VARARGS_H
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#undef _FILE_OFFSET_BITS
|
||||
|
||||
/* Define to make fseeko etc. visible, on some hosts. */
|
||||
#undef _LARGEFILE_SOURCE
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
#undef _LARGE_FILES
|
||||
|
||||
/* Define if compiler has function prototypes */
|
||||
#undef PROTOTYPES
|
||||
|
||||
/* Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
|
||||
and declares uintmax_t. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define if struct utimbuf is declared -- usually in <utime.h>.
|
||||
Some systems have utime.h but don't declare the struct anywhere. */
|
||||
#undef HAVE_STRUCT_UTIMBUF
|
||||
|
||||
/* Define if the malloc check has been performed. */
|
||||
#undef HAVE_DONE_WORKING_MALLOC_CHECK
|
||||
|
||||
/* Define to rpl_malloc if the replacement function should be used. */
|
||||
#undef malloc
|
||||
|
||||
/* Define if the realloc check has been performed. */
|
||||
#undef HAVE_DONE_WORKING_REALLOC_CHECK
|
||||
|
||||
/* Define to rpl_realloc if the replacement function should be used. */
|
||||
#undef realloc
|
||||
|
||||
/* Define if there is a member named d_ino in the struct describing
|
||||
directory headers. */
|
||||
#undef D_INO_IN_DIRENT
|
||||
|
||||
|
||||
1220
config.sub
vendored
Normal file
1220
config.sub
vendored
Normal file
File diff suppressed because it is too large
Load Diff
119
configure.in
119
configure.in
@ -1,14 +1,15 @@
|
||||
# Configure `patch'.
|
||||
# Copyright 1993, 1997, 1998 Free Software Foundation, Inc.
|
||||
# Copyright 1993, 1997-1998, 1999 Free Software Foundation, Inc.
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.12)
|
||||
AC_INIT(patch.c)
|
||||
AC_CONFIG_HEADER(config.h:config.hin)
|
||||
AC_ARG_PROGRAM
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
PACKAGE=patch
|
||||
VERSION=2.5.3
|
||||
VERSION=2.5.4
|
||||
AC_SUBST(PACKAGE)
|
||||
AC_SUBST(VERSION)
|
||||
|
||||
@ -20,41 +21,12 @@ AC_PROG_MAKE_SET
|
||||
# because <errno.h> reserves symbols starting with `E'.
|
||||
AC_PATH_PROG(ed_PROGRAM, ed, ed)
|
||||
|
||||
# If available, prefer support for large files unless the user specified
|
||||
# one of the CPPFLAGS, LDFLAGS, or LIBS variables.
|
||||
AC_MSG_CHECKING(whether large file support needs explicit enabling)
|
||||
ac_getconfs=''
|
||||
ac_result=yes
|
||||
ac_set=''
|
||||
ac_shellvars='CPPFLAGS LDFLAGS LIBS'
|
||||
for ac_shellvar in $ac_shellvars; do
|
||||
case $ac_shellvar in
|
||||
CPPFLAGS) ac_lfsvar=LFS_CFLAGS ;;
|
||||
*) ac_lfsvar=LFS_$ac_shellvar ;;
|
||||
esac
|
||||
eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
|
||||
(getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
|
||||
ac_getconf=`getconf $ac_lfsvar`
|
||||
ac_getconfs=$ac_getconfs$ac_getconf
|
||||
eval ac_test_$ac_shellvar=\$ac_getconf
|
||||
done
|
||||
case "$ac_result$ac_getconfs" in
|
||||
yes) ac_result=no ;;
|
||||
esac
|
||||
case "$ac_result$ac_set" in
|
||||
yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
|
||||
esac
|
||||
AC_MSG_RESULT($ac_result)
|
||||
case $ac_result in
|
||||
yes)
|
||||
for ac_shellvar in $ac_shellvars; do
|
||||
eval $ac_shellvar=\$ac_test_$ac_shellvar
|
||||
done ;;
|
||||
esac
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
AC_AIX
|
||||
AC_MINIX
|
||||
AC_ISC_POSIX
|
||||
AC_EXEEXT
|
||||
|
||||
AM_C_PROTOTYPES
|
||||
AC_C_CONST
|
||||
@ -62,91 +34,26 @@ AC_C_CONST
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(fcntl.h limits.h string.h unistd.h utime.h varargs.h)
|
||||
|
||||
# Use <inttypes.h> only if it exists,
|
||||
# doesn't clash with <sys/types.h>, and declares intmax_t.
|
||||
AC_MSG_CHECKING(for inttypes.h)
|
||||
AC_CACHE_VAL(patch_cv_header_inttypes_h,
|
||||
[AC_TRY_COMPILE(
|
||||
[#include <sys/types.h>
|
||||
#include <inttypes.h>],
|
||||
[intmax_t i = -1;],
|
||||
patch_cv_header_inttypes_h=yes,
|
||||
patch_cv_header_inttypes_h=no)])
|
||||
AC_MSG_RESULT($patch_cv_header_inttypes_h)
|
||||
if test $patch_cv_header_inttypes_h = yes; then
|
||||
AC_DEFINE(HAVE_INTTYPES_H)
|
||||
fi
|
||||
jm_AC_HEADER_INTTYPES_H
|
||||
|
||||
AC_TYPE_MODE_T
|
||||
AC_TYPE_OFF_T
|
||||
AC_TYPE_PID_T
|
||||
AC_TYPE_SIGNAL
|
||||
AC_TYPE_SIZE_T
|
||||
jm_STRUCT_UTIMBUF
|
||||
|
||||
dnl Some systems have utime.h but don't declare the struct anywhere.
|
||||
AC_MSG_CHECKING(for struct utimbuf)
|
||||
AC_CACHE_VAL(patch_cv_sys_struct_utimbuf,
|
||||
[AC_TRY_COMPILE([#include <sys/types.h>
|
||||
#if HAVE_UTIME_H
|
||||
#include <utime.h>
|
||||
#endif], [static struct utimbuf x; x.actime = x.modtime;],
|
||||
patch_cv_sys_struct_utimbuf=yes,
|
||||
patch_cv_sys_struct_utimbuf=no)])
|
||||
AC_MSG_RESULT($patch_cv_sys_struct_utimbuf)
|
||||
if test $patch_cv_sys_struct_utimbuf = yes; then
|
||||
AC_DEFINE(HAVE_STRUCT_UTIMBUF)
|
||||
fi
|
||||
|
||||
# Check for NetBSD 1.0 bug, where memchr(..., 0) returns nonzero.
|
||||
AC_MSG_CHECKING(for working memchr)
|
||||
AC_CACHE_VAL(ac_cv_func_memchr,
|
||||
[AC_TRY_RUN([#include <string.h>
|
||||
main () { exit (memchr ("", 0, 0) != 0 || memchr ("", 1, 0) != 0); }],
|
||||
ac_cv_func_memchr=yes,
|
||||
ac_cv_func_memchr=no,
|
||||
AC_MSG_WARN([We are cross-compiling so we assume memchr does not work.])
|
||||
ac_cv_func_memchr=no)])dnl
|
||||
AC_MSG_RESULT($ac_cv_func_memchr)
|
||||
if test $ac_cv_func_memchr = yes; then
|
||||
AC_DEFINE(HAVE_MEMCHR)
|
||||
fi
|
||||
|
||||
AC_CHECK_FUNC(getopt_long, , [LIBOBJS="$LIBOBJS getopt1.o getopt.o"])
|
||||
AC_CHECK_FUNC(getopt_long, , [LIBOBJS="$LIBOBJS getopt1\$U.o getopt\$U.o"])
|
||||
AC_SUBST(LIBOBJS)
|
||||
AC_CHECK_FUNCS(_doprintf isascii memcmp mkdir mktemp pathconf raise sigaction sigprocmask sigsetmask strerror)
|
||||
AC_REPLACE_FUNCS(memchr rename)
|
||||
AC_CHECK_FUNCS(_doprintf isascii fseeko memcmp mktemp \
|
||||
pathconf raise setmode sigaction sigprocmask sigsetmask strerror)
|
||||
AC_REPLACE_FUNCS(memchr mkdir rename rmdir)
|
||||
jm_FUNC_MALLOC
|
||||
jm_FUNC_REALLOC
|
||||
AC_FUNC_CLOSEDIR_VOID
|
||||
AC_FUNC_VPRINTF
|
||||
|
||||
AC_SYS_LONG_FILE_NAMES
|
||||
|
||||
AC_MSG_CHECKING([for d_ino member in directory struct])
|
||||
AC_CACHE_VAL(patch_cv_sys_d_ino_in_dirent,
|
||||
[AC_TRY_LINK([
|
||||
#include <sys/types.h>
|
||||
#if HAVE_DIRENT_H
|
||||
# include <dirent.h>
|
||||
#else
|
||||
# define dirent direct
|
||||
# if HAVE_SYS_NDIR_H
|
||||
# include <sys/ndir.h>
|
||||
# endif
|
||||
# ifdef HAVE_SYS_DIR_H
|
||||
# include <sys/dir.h>
|
||||
# endif
|
||||
# ifdef HAVE_NDIR_H
|
||||
# include <ndir.h>
|
||||
# endif
|
||||
#endif
|
||||
],
|
||||
[struct dirent dp; dp.d_ino = 0;],
|
||||
patch_cv_sys_d_ino_in_dirent=yes,
|
||||
patch_cv_sys_d_ino_in_dirent=no)])
|
||||
AC_MSG_RESULT($patch_cv_sys_d_ino_in_dirent)
|
||||
if test $patch_cv_sys_d_ino_in_dirent = yes; then
|
||||
AC_DEFINE(D_INO_IN_DIRENT)
|
||||
fi
|
||||
jm_STRUCT_DIRENT_D_INO
|
||||
|
||||
AC_OUTPUT(Makefile)
|
||||
|
||||
76
error.c
76
error.c
@ -1,29 +1,28 @@
|
||||
/* Error handler for noninteractive utilities
|
||||
Copyright (C) 1990,91,92,93,94,95,96,97 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990,91,92,93,94,95,96,97,98 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
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,
|
||||
The GNU C Library 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.
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library 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. */
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
@ -51,7 +50,7 @@ void exit ();
|
||||
#include "error.h"
|
||||
|
||||
#ifndef _
|
||||
#define _(String) String
|
||||
# define _(String) String
|
||||
#endif
|
||||
|
||||
/* If NULL, error will flush stdout, then print on stderr the program
|
||||
@ -69,26 +68,28 @@ unsigned int error_message_count;
|
||||
#ifdef _LIBC
|
||||
/* In the GNU C library, there is a predefined variable for this. */
|
||||
|
||||
#define program_name program_invocation_name
|
||||
#include <errno.h>
|
||||
# define program_name program_invocation_name
|
||||
# include <errno.h>
|
||||
|
||||
/* In GNU libc we want do not want to use the common name `error' directly.
|
||||
Instead make it a weak alias. */
|
||||
#define error __error
|
||||
#define error_at_line __error_at_line
|
||||
# define error __error
|
||||
# define error_at_line __error_at_line
|
||||
|
||||
#else
|
||||
#else /* not _LIBC */
|
||||
|
||||
/* The calling program should define program_name and set it to the
|
||||
name of the executing program. */
|
||||
extern char *program_name;
|
||||
|
||||
#ifndef HAVE_STRERROR_R
|
||||
# if HAVE_STRERROR
|
||||
# ifndef strerror /* On some systems, strerror is a macro */
|
||||
char *strerror ();
|
||||
# endif
|
||||
# ifdef HAVE_STRERROR_R
|
||||
# define __strerror_r strerror_r
|
||||
# else
|
||||
# if HAVE_STRERROR
|
||||
# ifndef strerror /* On some systems, strerror is a macro */
|
||||
char *strerror ();
|
||||
# endif
|
||||
# else
|
||||
static char *
|
||||
private_strerror (errnum)
|
||||
int errnum;
|
||||
@ -100,10 +101,10 @@ private_strerror (errnum)
|
||||
return _(sys_errlist[errnum]);
|
||||
return _("Unknown system error");
|
||||
}
|
||||
# define strerror private_strerror
|
||||
# endif /* HAVE_STRERROR */
|
||||
#endif /* HAVE_STRERROR_R */
|
||||
#endif /* _LIBC */
|
||||
# define strerror private_strerror
|
||||
# endif /* HAVE_STRERROR */
|
||||
# endif /* HAVE_STRERROR_R */
|
||||
#endif /* not _LIBC */
|
||||
|
||||
/* Print the program name and error message MESSAGE, which is a printf-style
|
||||
format string with optional args.
|
||||
@ -112,7 +113,7 @@ private_strerror (errnum)
|
||||
/* VARARGS */
|
||||
|
||||
void
|
||||
#if defined(VA_START) && __STDC__
|
||||
#if defined VA_START && __STDC__
|
||||
error (int status, int errnum, const char *message, ...)
|
||||
#else
|
||||
error (status, errnum, message, va_alist)
|
||||
@ -151,7 +152,10 @@ error (status, errnum, message, va_alist)
|
||||
{
|
||||
#if defined HAVE_STRERROR_R || defined _LIBC
|
||||
char errbuf[1024];
|
||||
fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf));
|
||||
/* Don't use __strerror_r's return value because on some systems
|
||||
(at least DEC UNIX 4.0[A-D]) strerror_r returns `int'. */
|
||||
__strerror_r (errnum, errbuf, sizeof errbuf);
|
||||
fprintf (stderr, ": %s", errbuf);
|
||||
#else
|
||||
fprintf (stderr, ": %s", strerror (errnum));
|
||||
#endif
|
||||
@ -167,7 +171,7 @@ error (status, errnum, message, va_alist)
|
||||
int error_one_per_line;
|
||||
|
||||
void
|
||||
#if defined(VA_START) && __STDC__
|
||||
#if defined VA_START && __STDC__
|
||||
error_at_line (int status, int errnum, const char *file_name,
|
||||
unsigned int line_number, const char *message, ...)
|
||||
#else
|
||||
@ -239,8 +243,8 @@ error_at_line (status, errnum, file_name, line_number, message, va_alist)
|
||||
|
||||
#ifdef _LIBC
|
||||
/* Make the weak alias. */
|
||||
#undef error
|
||||
#undef error_at_line
|
||||
# undef error
|
||||
# undef error_at_line
|
||||
weak_alias (__error, error)
|
||||
weak_alias (__error_at_line, error_at_line)
|
||||
#endif
|
||||
|
||||
127
getopt.c
127
getopt.c
@ -1,45 +1,42 @@
|
||||
/* Getopt for GNU.
|
||||
NOTE: getopt is now part of the C library, so if you don't know what
|
||||
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
|
||||
"Keep this file name-space clean" means, talk to drepper@gnu.org
|
||||
before changing it!
|
||||
|
||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97
|
||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
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,
|
||||
The GNU C Library 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.
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library 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. */
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
|
||||
Ditto for AIX 3.2 and <stdlib.h>. */
|
||||
#ifndef _NO_PROTO
|
||||
#define _NO_PROTO
|
||||
# define _NO_PROTO
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if !defined (__STDC__) || !__STDC__
|
||||
#if !defined __STDC__ || !__STDC__
|
||||
/* This is a separate conditional since some stdc systems
|
||||
reject `defined (const)'. */
|
||||
#ifndef const
|
||||
#define const
|
||||
#endif
|
||||
# ifndef const
|
||||
# define const
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
@ -53,11 +50,11 @@
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#define GETOPT_INTERFACE_VERSION 2
|
||||
#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2
|
||||
#include <gnu-versions.h>
|
||||
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
|
||||
#define ELIDE_CODE
|
||||
#endif
|
||||
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
|
||||
# include <gnu-versions.h>
|
||||
# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
|
||||
# define ELIDE_CODE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ELIDE_CODE
|
||||
@ -68,26 +65,26 @@
|
||||
#ifdef __GNU_LIBRARY__
|
||||
/* Don't include stdlib.h for non-GNU C libraries because some of them
|
||||
contain conflicting prototypes for getopt. */
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
# include <stdlib.h>
|
||||
# include <unistd.h>
|
||||
#endif /* GNU C library. */
|
||||
|
||||
#ifdef VMS
|
||||
#include <unixlib.h>
|
||||
#if HAVE_STRING_H - 0
|
||||
#include <string.h>
|
||||
#endif
|
||||
# include <unixlib.h>
|
||||
# if HAVE_STRING_H - 0
|
||||
# include <string.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef _
|
||||
/* This is for other GNU distributions with internationalized messages.
|
||||
When compiling libc, the _ macro is predefined. */
|
||||
#ifdef HAVE_LIBINTL_H
|
||||
# include <libintl.h>
|
||||
# define _(msgid) gettext (msgid)
|
||||
#else
|
||||
# define _(msgid) (msgid)
|
||||
#endif
|
||||
# ifdef HAVE_LIBINTL_H
|
||||
# include <libintl.h>
|
||||
# define _(msgid) gettext (msgid)
|
||||
# else
|
||||
# define _(msgid) (msgid)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This version of `getopt' appears to the caller like standard Unix `getopt'
|
||||
@ -197,14 +194,22 @@ static char *posixly_correct;
|
||||
because there are many ways it can cause trouble.
|
||||
On some systems, it contains special magic macros that don't work
|
||||
in GCC. */
|
||||
#include <string.h>
|
||||
#define my_index strchr
|
||||
# include <string.h>
|
||||
# define my_index strchr
|
||||
#else
|
||||
|
||||
# if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
# else
|
||||
# include <strings.h>
|
||||
# endif
|
||||
|
||||
/* Avoid depending on library functions or files
|
||||
whose names are inconsistent. */
|
||||
|
||||
char *getenv ();
|
||||
#ifndef getenv
|
||||
extern char *getenv ();
|
||||
#endif
|
||||
|
||||
static char *
|
||||
my_index (str, chr)
|
||||
@ -225,11 +230,11 @@ my_index (str, chr)
|
||||
#ifdef __GNUC__
|
||||
/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
|
||||
That was relevant to code that was here before. */
|
||||
#if !defined (__STDC__) || !__STDC__
|
||||
# if (!defined __STDC__ || !__STDC__) && !defined strlen
|
||||
/* gcc with -traditional declares the built-in strlen to return int,
|
||||
and has done so at least since version 2.4.5. -- rms. */
|
||||
extern int strlen (const char *);
|
||||
#endif /* not __STDC__ */
|
||||
# endif /* not __STDC__ */
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#endif /* not __GNU_LIBRARY__ */
|
||||
@ -292,7 +297,7 @@ text_set_element (__libc_subinit, store_args_and_env);
|
||||
`first_nonopt' and `last_nonopt' are relocated so that they describe
|
||||
the new indices of the non-options in ARGV after they are moved. */
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#if defined __STDC__ && __STDC__
|
||||
static void exchange (char **);
|
||||
#endif
|
||||
|
||||
@ -378,7 +383,7 @@ exchange (argv)
|
||||
|
||||
/* Initialize the internal data when the first call is made. */
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#if defined __STDC__ && __STDC__
|
||||
static const char *_getopt_initialize (int, char *const *, const char *);
|
||||
#endif
|
||||
static const char *
|
||||
@ -527,11 +532,11 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
from the shell indicating it is not an option. The later information
|
||||
is only used when the used in the GNU libc. */
|
||||
#ifdef _LIBC
|
||||
#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
|
||||
|| (optind < nonoption_flags_len \
|
||||
&& __getopt_nonoption_flags[optind] == '1'))
|
||||
# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
|
||||
|| (optind < nonoption_flags_len \
|
||||
&& __getopt_nonoption_flags[optind] == '1'))
|
||||
#else
|
||||
#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
|
||||
# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
|
||||
#endif
|
||||
|
||||
if (nextchar == NULL || *nextchar == '\0')
|
||||
@ -690,16 +695,18 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
if (argv[optind - 1][1] == '-')
|
||||
/* --option */
|
||||
fprintf (stderr,
|
||||
_("%s: option `--%s' doesn't allow an argument\n"),
|
||||
argv[0], pfound->name);
|
||||
else
|
||||
/* +option or -option */
|
||||
fprintf (stderr,
|
||||
_("%s: option `%c%s' doesn't allow an argument\n"),
|
||||
argv[0], argv[optind - 1][0], pfound->name);
|
||||
{
|
||||
if (argv[optind - 1][1] == '-')
|
||||
/* --option */
|
||||
fprintf (stderr,
|
||||
_("%s: option `--%s' doesn't allow an argument\n"),
|
||||
argv[0], pfound->name);
|
||||
else
|
||||
/* +option or -option */
|
||||
fprintf (stderr,
|
||||
_("%s: option `%c%s' doesn't allow an argument\n"),
|
||||
argv[0], argv[optind - 1][0], pfound->name);
|
||||
}
|
||||
|
||||
nextchar += strlen (nextchar);
|
||||
|
||||
|
||||
108
getopt.h
108
getopt.h
@ -1,26 +1,27 @@
|
||||
/* Declarations for getopt.
|
||||
Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
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,
|
||||
The GNU C Library 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.
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library 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. */
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
#define _GETOPT_H 1
|
||||
|
||||
#ifndef __need_getopt
|
||||
# define _GETOPT_H 1
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -57,6 +58,7 @@ extern int opterr;
|
||||
|
||||
extern int optopt;
|
||||
|
||||
#ifndef __need_getopt
|
||||
/* Describe the long-named options requested by the application.
|
||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
||||
of `struct option' terminated by an element containing a name which is
|
||||
@ -80,11 +82,11 @@ extern int optopt;
|
||||
|
||||
struct option
|
||||
{
|
||||
#if defined (__STDC__) && __STDC__
|
||||
# if defined __STDC__ && __STDC__
|
||||
const char *name;
|
||||
#else
|
||||
# else
|
||||
char *name;
|
||||
#endif
|
||||
# endif
|
||||
/* has_arg can't be an enum because some compilers complain about
|
||||
type mismatches in all the code that assumes it is an int. */
|
||||
int has_arg;
|
||||
@ -94,40 +96,74 @@ struct option
|
||||
|
||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
||||
|
||||
#define no_argument 0
|
||||
#define required_argument 1
|
||||
#define optional_argument 2
|
||||
# define no_argument 0
|
||||
# define required_argument 1
|
||||
# define optional_argument 2
|
||||
#endif /* need getopt */
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#ifdef __GNU_LIBRARY__
|
||||
|
||||
/* Get definitions and prototypes for functions to process the
|
||||
arguments in ARGV (ARGC of them, minus the program name) for
|
||||
options given in OPTS.
|
||||
|
||||
Return the option character from OPTS just read. Return -1 when
|
||||
there are no more options. For unrecognized options, or options
|
||||
missing arguments, `optopt' is set to the option letter, and '?' is
|
||||
returned.
|
||||
|
||||
The OPTS string is a list of characters which are recognized option
|
||||
letters, optionally followed by colons, specifying that that letter
|
||||
takes an argument, to be placed in `optarg'.
|
||||
|
||||
If a letter in OPTS is followed by two colons, its argument is
|
||||
optional. This behavior is specific to the GNU `getopt'.
|
||||
|
||||
The argument `--' causes premature termination of argument
|
||||
scanning, explicitly telling `getopt' that there are no more
|
||||
options.
|
||||
|
||||
If OPTS begins with `--', then non-option arguments are treated as
|
||||
arguments to the option '\0'. This behavior is specific to the GNU
|
||||
`getopt'. */
|
||||
|
||||
#if defined __STDC__ && __STDC__
|
||||
# ifdef __GNU_LIBRARY__
|
||||
/* Many other libraries have conflicting prototypes for getopt, with
|
||||
differences in the consts, in stdlib.h. To avoid compilation
|
||||
errors, only prototype getopt for the GNU C library. */
|
||||
extern int getopt (int argc, char *const *argv, const char *shortopts);
|
||||
#else /* not __GNU_LIBRARY__ */
|
||||
extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
|
||||
# else /* not __GNU_LIBRARY__ */
|
||||
extern int getopt ();
|
||||
#endif /* __GNU_LIBRARY__ */
|
||||
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
extern int getopt_long_only (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
# endif /* __GNU_LIBRARY__ */
|
||||
|
||||
# ifndef __need_getopt
|
||||
extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind);
|
||||
extern int getopt_long_only (int __argc, char *const *__argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind);
|
||||
|
||||
/* Internal only. Users should not call this directly. */
|
||||
extern int _getopt_internal (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct option *longopts, int *longind,
|
||||
int long_only);
|
||||
extern int _getopt_internal (int __argc, char *const *__argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
int __long_only);
|
||||
# endif
|
||||
#else /* not __STDC__ */
|
||||
extern int getopt ();
|
||||
# ifndef __need_getopt
|
||||
extern int getopt_long ();
|
||||
extern int getopt_long_only ();
|
||||
|
||||
extern int _getopt_internal ();
|
||||
# endif
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make sure we later can get all the definitions and declarations. */
|
||||
#undef __need_getopt
|
||||
|
||||
#endif /* getopt.h */
|
||||
|
||||
33
getopt1.c
33
getopt1.c
@ -1,23 +1,22 @@
|
||||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
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,
|
||||
The GNU C Library 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.
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library 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. */
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
@ -25,7 +24,7 @@
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
#if !defined (__STDC__) || !__STDC__
|
||||
#if !defined __STDC__ || !__STDC__
|
||||
/* This is a separate conditional since some stdc systems
|
||||
reject `defined (const)'. */
|
||||
#ifndef const
|
||||
@ -44,7 +43,7 @@
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#define GETOPT_INTERFACE_VERSION 2
|
||||
#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2
|
||||
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
|
||||
#include <gnu-versions.h>
|
||||
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
|
||||
#define ELIDE_CODE
|
||||
|
||||
61
inp.c
61
inp.c
@ -1,26 +1,24 @@
|
||||
/* inputting files to be patched */
|
||||
|
||||
/* $Id: inp.c,v 1.20 1998/03/15 14:44:47 eggert Exp $ */
|
||||
/* $Id: inp.c,v 1.21 1999/08/30 06:20:08 eggert Exp $ */
|
||||
|
||||
/*
|
||||
Copyright 1986, 1988 Larry Wall
|
||||
Copyright 1991, 1992, 1993, 1997, 1998 Free Software Foundation, Inc.
|
||||
/* Copyright 1986, 1988 Larry Wall
|
||||
Copyright 1991, 1992-1993, 1997-1998, 1999 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 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.
|
||||
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.
|
||||
*/
|
||||
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. */
|
||||
|
||||
#define XTERN extern
|
||||
#include <common.h>
|
||||
@ -57,7 +55,7 @@ static void too_many_lines PARAMS ((char const *)) __attribute__((noreturn));
|
||||
/* New patch--prepare to edit another file. */
|
||||
|
||||
void
|
||||
re_input()
|
||||
re_input (void)
|
||||
{
|
||||
if (using_plan_a) {
|
||||
if (i_buffer)
|
||||
@ -83,8 +81,7 @@ re_input()
|
||||
/* Construct the line index, somehow or other. */
|
||||
|
||||
void
|
||||
scan_input(filename)
|
||||
char *filename;
|
||||
scan_input (char *filename)
|
||||
{
|
||||
using_plan_a = ! (debug & 16) && plan_a (filename);
|
||||
if (!using_plan_a)
|
||||
@ -105,8 +102,7 @@ char *filename;
|
||||
/* Report whether a desired revision was found. */
|
||||
|
||||
static void
|
||||
report_revision (found_revision)
|
||||
int found_revision;
|
||||
report_revision (int found_revision)
|
||||
{
|
||||
revision = quotearg (revision);
|
||||
|
||||
@ -135,17 +131,14 @@ report_revision (found_revision)
|
||||
|
||||
|
||||
static void
|
||||
too_many_lines (filename)
|
||||
char const *filename;
|
||||
too_many_lines (char const *filename)
|
||||
{
|
||||
fatal ("File %s has too many lines", quotearg (filename));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
get_input_file (filename, outname)
|
||||
char const *filename;
|
||||
char const *outname;
|
||||
get_input_file (char const *filename, char const *outname)
|
||||
{
|
||||
int elsewhere = strcmp (filename, outname);
|
||||
char const *cs;
|
||||
@ -222,8 +215,7 @@ get_input_file (filename, outname)
|
||||
/* Try keeping everything in memory. */
|
||||
|
||||
static bool
|
||||
plan_a(filename)
|
||||
char const *filename;
|
||||
plan_a (char const *filename)
|
||||
{
|
||||
register char const *s;
|
||||
register char const *lim;
|
||||
@ -328,8 +320,7 @@ plan_a(filename)
|
||||
/* Keep (virtually) nothing in memory. */
|
||||
|
||||
static void
|
||||
plan_b(filename)
|
||||
char const *filename;
|
||||
plan_b (char const *filename)
|
||||
{
|
||||
register FILE *ifp;
|
||||
register int c;
|
||||
@ -431,13 +422,11 @@ plan_b(filename)
|
||||
input_lines = line - 1;
|
||||
}
|
||||
|
||||
/* Fetch a line from the input file. */
|
||||
/* Fetch a line from the input file.
|
||||
WHICHBUF is ignored when the file is in memory. */
|
||||
|
||||
char const *
|
||||
ifetch (line, whichbuf, psize)
|
||||
register LINENUM line;
|
||||
int whichbuf; /* ignored when file in memory */
|
||||
size_t *psize;
|
||||
ifetch (LINENUM line, int whichbuf, size_t *psize)
|
||||
{
|
||||
register char const *q;
|
||||
register char const *p;
|
||||
|
||||
13
install-sh
13
install-sh
@ -1,4 +1,4 @@
|
||||
#! /bin/sh
|
||||
#!/bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
@ -20,8 +20,8 @@
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
#
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
@ -118,8 +118,9 @@ if [ x"$dir_arg" != x ]; then
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
chmodcmd=""
|
||||
else
|
||||
instcmd=mkdir
|
||||
instcmd=$mkdirprog
|
||||
fi
|
||||
else
|
||||
|
||||
@ -162,8 +163,8 @@ dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
|
||||
95
m4/ccstdc.m4
Normal file
95
m4/ccstdc.m4
Normal file
@ -0,0 +1,95 @@
|
||||
# The following is taken from automake 1.4,
|
||||
# except that it prefers the compiler option -Ae to "-Aa -D_HPUX_SOURCE"
|
||||
# because only the former supports 64-bit integral types on HP-UX 10.20.
|
||||
|
||||
## ----------------------------------------- ##
|
||||
## ANSIfy the C compiler whenever possible. ##
|
||||
## From Franc,ois Pinard ##
|
||||
## ----------------------------------------- ##
|
||||
|
||||
# serial 2
|
||||
|
||||
# @defmac AC_PROG_CC_STDC
|
||||
# @maindex PROG_CC_STDC
|
||||
# @ovindex CC
|
||||
# If the C compiler in not in ANSI C mode by default, try to add an option
|
||||
# to output variable @code{CC} to make it so. This macro tries various
|
||||
# options that select ANSI C on some system or another. It considers the
|
||||
# compiler to be in ANSI C mode if it handles function prototypes correctly.
|
||||
#
|
||||
# If you use this macro, you should check after calling it whether the C
|
||||
# compiler has been set to accept ANSI C; if not, the shell variable
|
||||
# @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source
|
||||
# code in ANSI C, you can make an un-ANSIfied copy of it by using the
|
||||
# program @code{ansi2knr}, which comes with Ghostscript.
|
||||
# @end defmac
|
||||
|
||||
AC_DEFUN(AM_PROG_CC_STDC,
|
||||
[AC_REQUIRE([AC_PROG_CC])
|
||||
AC_BEFORE([$0], [AC_C_INLINE])
|
||||
AC_BEFORE([$0], [AC_C_CONST])
|
||||
dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require
|
||||
dnl a magic option to avoid problems with ANSI preprocessor commands
|
||||
dnl like #elif.
|
||||
dnl FIXME: can't do this because then AC_AIX won't work due to a
|
||||
dnl circular dependency.
|
||||
dnl AC_BEFORE([$0], [AC_PROG_CPP])
|
||||
AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
|
||||
AC_CACHE_VAL(am_cv_prog_cc_stdc,
|
||||
[am_cv_prog_cc_stdc=no
|
||||
ac_save_CC="$CC"
|
||||
# Don't try gcc -ansi; that turns off useful extensions and
|
||||
# breaks some systems' header files.
|
||||
# AIX -qlanglvl=ansi
|
||||
# Ultrix and OSF/1 -std1
|
||||
# HP-UX -Aa -D_HPUX_SOURCE
|
||||
# SVR4 -Xc -D__EXTENSIONS__
|
||||
for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
|
||||
do
|
||||
CC="$ac_save_CC $ac_arg"
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
|
||||
struct buf { int x; };
|
||||
FILE * (*rcsopen) (struct buf *, struct stat *, int);
|
||||
static char *e (p, i)
|
||||
char **p;
|
||||
int i;
|
||||
{
|
||||
return p[i];
|
||||
}
|
||||
static char *f (char * (*g) (char **, int), char **p, ...)
|
||||
{
|
||||
char *s;
|
||||
va_list v;
|
||||
va_start (v,p);
|
||||
s = g (p, va_arg (v,int));
|
||||
va_end (v);
|
||||
return s;
|
||||
}
|
||||
int test (int i, double x);
|
||||
struct s1 {int (*f) (int a);};
|
||||
struct s2 {int (*f) (double a);};
|
||||
int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
|
||||
int argc;
|
||||
char **argv;
|
||||
], [
|
||||
return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
|
||||
],
|
||||
[am_cv_prog_cc_stdc="$ac_arg"; break])
|
||||
done
|
||||
CC="$ac_save_CC"
|
||||
])
|
||||
if test -z "$am_cv_prog_cc_stdc"; then
|
||||
AC_MSG_RESULT([none needed])
|
||||
else
|
||||
AC_MSG_RESULT($am_cv_prog_cc_stdc)
|
||||
fi
|
||||
case "x$am_cv_prog_cc_stdc" in
|
||||
x|xno) ;;
|
||||
*) CC="$CC $am_cv_prog_cc_stdc" ;;
|
||||
esac
|
||||
])
|
||||
42
m4/d-ino.m4
Normal file
42
m4/d-ino.m4
Normal file
@ -0,0 +1,42 @@
|
||||
#serial 2
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl
|
||||
dnl Check whether struct dirent has a member named d_ino.
|
||||
dnl
|
||||
|
||||
AC_DEFUN(jm_STRUCT_DIRENT_D_INO,
|
||||
[AC_REQUIRE([AC_HEADER_DIRENT])dnl
|
||||
AC_CACHE_CHECK([for d_ino member in directory struct],
|
||||
jm_cv_struct_dirent_d_ino,
|
||||
[AC_TRY_LINK(dnl
|
||||
[
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_DIRENT_H
|
||||
# include <dirent.h>
|
||||
#else /* not HAVE_DIRENT_H */
|
||||
# define dirent direct
|
||||
# ifdef HAVE_SYS_NDIR_H
|
||||
# include <sys/ndir.h>
|
||||
# endif /* HAVE_SYS_NDIR_H */
|
||||
# ifdef HAVE_SYS_DIR_H
|
||||
# include <sys/dir.h>
|
||||
# endif /* HAVE_SYS_DIR_H */
|
||||
# ifdef HAVE_NDIR_H
|
||||
# include <ndir.h>
|
||||
# endif /* HAVE_NDIR_H */
|
||||
#endif /* HAVE_DIRENT_H */
|
||||
],
|
||||
[struct dirent dp; dp.d_ino = 0;],
|
||||
|
||||
jm_cv_struct_dirent_d_ino=yes,
|
||||
jm_cv_struct_dirent_d_ino=no)
|
||||
]
|
||||
)
|
||||
if test $jm_cv_struct_dirent_d_ino = yes; then
|
||||
AC_DEFINE(D_INO_IN_DIRENT, 1,
|
||||
[Define if there is a member named d_ino in the struct describing
|
||||
directory headers.])
|
||||
fi
|
||||
]
|
||||
)
|
||||
22
m4/inttypes_h.m4
Normal file
22
m4/inttypes_h.m4
Normal file
@ -0,0 +1,22 @@
|
||||
#serial 3
|
||||
|
||||
dnl From Paul Eggert.
|
||||
|
||||
# Define HAVE_INTTYPES_H if <inttypes.h> exists,
|
||||
# doesn't clash with <sys/types.h>, and declares uintmax_t.
|
||||
|
||||
AC_DEFUN(jm_AC_HEADER_INTTYPES_H,
|
||||
[
|
||||
AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
|
||||
[AC_TRY_COMPILE(
|
||||
[#include <sys/types.h>
|
||||
#include <inttypes.h>],
|
||||
[uintmax_t i = (uintmax_t) -1;],
|
||||
jm_ac_cv_header_inttypes_h=yes,
|
||||
jm_ac_cv_header_inttypes_h=no)])
|
||||
if test $jm_ac_cv_header_inttypes_h = yes; then
|
||||
AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
|
||||
[Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
|
||||
and declares uintmax_t. ])
|
||||
fi
|
||||
])
|
||||
115
m4/largefile.m4
Normal file
115
m4/largefile.m4
Normal file
@ -0,0 +1,115 @@
|
||||
#serial 5
|
||||
|
||||
dnl By default, many hosts won't let programs access large files;
|
||||
dnl one must use special compiler options to get large-file access to work.
|
||||
dnl For more details about this brain damage please see:
|
||||
dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
|
||||
|
||||
dnl Written by Paul Eggert <eggert@twinsun.com>.
|
||||
|
||||
dnl Internal subroutine of AC_SYS_LARGEFILE.
|
||||
dnl AC_SYS_LARGEFILE_FLAGS(FLAGSNAME)
|
||||
AC_DEFUN(AC_SYS_LARGEFILE_FLAGS,
|
||||
[AC_CACHE_CHECK([for $1 value to request large file support],
|
||||
ac_cv_sys_largefile_$1,
|
||||
[ac_cv_sys_largefile_$1=`($GETCONF LFS_$1) 2>/dev/null` || {
|
||||
ac_cv_sys_largefile_$1=no
|
||||
ifelse($1, CFLAGS,
|
||||
[case "$host_os" in
|
||||
# IRIX 6.2 and later require cc -n32.
|
||||
changequote(, )dnl
|
||||
irix6.[2-9]* | irix6.1[0-9]* | irix[7-9].* | irix[1-9][0-9]*)
|
||||
changequote([, ])dnl
|
||||
if test "$GCC" != yes; then
|
||||
ac_cv_sys_largefile_CFLAGS=-n32
|
||||
fi
|
||||
ac_save_CC="$CC"
|
||||
CC="$CC $ac_cv_sys_largefile_CFLAGS"
|
||||
AC_TRY_LINK(, , , ac_cv_sys_largefile_CFLAGS=no)
|
||||
CC="$ac_save_CC"
|
||||
esac])
|
||||
}])])
|
||||
|
||||
dnl Internal subroutine of AC_SYS_LARGEFILE.
|
||||
dnl AC_SYS_LARGEFILE_SPACE_APPEND(VAR, VAL)
|
||||
AC_DEFUN(AC_SYS_LARGEFILE_SPACE_APPEND,
|
||||
[case $2 in
|
||||
no) ;;
|
||||
?*)
|
||||
case "[$]$1" in
|
||||
'') $1=$2 ;;
|
||||
*) $1=[$]$1' '$2 ;;
|
||||
esac ;;
|
||||
esac])
|
||||
|
||||
dnl Internal subroutine of AC_SYS_LARGEFILE.
|
||||
dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
|
||||
AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
|
||||
[AC_CACHE_CHECK([for $1], $2,
|
||||
[$2=no
|
||||
changequote(, )dnl
|
||||
$4
|
||||
for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
|
||||
case "$ac_flag" in
|
||||
-D$1)
|
||||
$2=1 ;;
|
||||
-D$1=*)
|
||||
$2=`expr " $ac_flag" : '[^=]*=\(.*\)'` ;;
|
||||
esac
|
||||
done
|
||||
changequote([, ])dnl
|
||||
])
|
||||
if test "[$]$2" != no; then
|
||||
AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
|
||||
fi])
|
||||
|
||||
AC_DEFUN(AC_SYS_LARGEFILE,
|
||||
[AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_ARG_ENABLE(largefile,
|
||||
[ --disable-largefile omit support for large files])
|
||||
if test "$enable_largefile" != no; then
|
||||
AC_CHECK_TOOL(GETCONF, getconf)
|
||||
AC_SYS_LARGEFILE_FLAGS(CFLAGS)
|
||||
AC_SYS_LARGEFILE_FLAGS(LDFLAGS)
|
||||
AC_SYS_LARGEFILE_FLAGS(LIBS)
|
||||
|
||||
for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
|
||||
case "$ac_flag" in
|
||||
no) ;;
|
||||
-D_FILE_OFFSET_BITS=*) ;;
|
||||
-D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;;
|
||||
-D_LARGE_FILES | -D_LARGE_FILES=*) ;;
|
||||
-D?* | -I?*)
|
||||
AC_SYS_LARGEFILE_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;;
|
||||
*)
|
||||
AC_SYS_LARGEFILE_SPACE_APPEND(CFLAGS, "$ac_flag") ;;
|
||||
esac
|
||||
done
|
||||
AC_SYS_LARGEFILE_SPACE_APPEND(LDFLAGS, "$ac_cv_sys_largefile_LDFLAGS")
|
||||
AC_SYS_LARGEFILE_SPACE_APPEND(LIBS, "$ac_cv_sys_largefile_LIBS")
|
||||
AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS,
|
||||
ac_cv_sys_file_offset_bits,
|
||||
[Number of bits in a file offset, on hosts where this is settable.],
|
||||
[case "$host_os" in
|
||||
# HP-UX 10.20 and later
|
||||
hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
|
||||
ac_cv_sys_file_offset_bits=64 ;;
|
||||
esac])
|
||||
AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE,
|
||||
ac_cv_sys_largefile_source,
|
||||
[Define to make fseeko etc. visible, on some hosts.],
|
||||
[case "$host_os" in
|
||||
# HP-UX 10.20 and later
|
||||
hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
|
||||
ac_cv_sys_largefile_source=1 ;;
|
||||
esac])
|
||||
AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES,
|
||||
ac_cv_sys_large_files,
|
||||
[Define for large files, on AIX-style hosts.],
|
||||
[case "$host_os" in
|
||||
# AIX 4.2 and later
|
||||
aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)
|
||||
ac_cv_sys_large_files=1 ;;
|
||||
esac])
|
||||
fi
|
||||
])
|
||||
35
m4/malloc.m4
Normal file
35
m4/malloc.m4
Normal file
@ -0,0 +1,35 @@
|
||||
#serial 3
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl Determine whether malloc accepts 0 as its argument.
|
||||
dnl If it doesn't, arrange to use the replacement function.
|
||||
dnl
|
||||
|
||||
AC_DEFUN(jm_FUNC_MALLOC,
|
||||
[
|
||||
dnl xmalloc.c requires that this symbol be defined so it doesn't
|
||||
dnl mistakenly use a broken malloc -- as it might if this test were omitted.
|
||||
AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_MALLOC_CHECK, 1,
|
||||
[Define if the malloc check has been performed. ])
|
||||
|
||||
AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
|
||||
[AC_TRY_RUN([
|
||||
char *malloc ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
exit (malloc (0) ? 0 : 1);
|
||||
}
|
||||
],
|
||||
jm_cv_func_working_malloc=yes,
|
||||
jm_cv_func_working_malloc=no,
|
||||
dnl When crosscompiling, assume malloc is broken.
|
||||
jm_cv_func_working_malloc=no)
|
||||
])
|
||||
if test $jm_cv_func_working_malloc = no; then
|
||||
AC_SUBST(LIBOBJS)
|
||||
LIBOBJS="$LIBOBJS malloc.$ac_objext"
|
||||
AC_DEFINE_UNQUOTED(malloc, rpl_malloc,
|
||||
[Define to rpl_malloc if the replacement function should be used.])
|
||||
fi
|
||||
])
|
||||
25
m4/protos.m4
Normal file
25
m4/protos.m4
Normal file
@ -0,0 +1,25 @@
|
||||
## ------------------------------- ##
|
||||
## Check for function prototypes. ##
|
||||
## From Franc,ois Pinard ##
|
||||
## ------------------------------- ##
|
||||
|
||||
# serial 1
|
||||
|
||||
AC_DEFUN(AM_C_PROTOTYPES,
|
||||
[AC_REQUIRE([AM_PROG_CC_STDC])
|
||||
AC_REQUIRE([AC_PROG_CPP])
|
||||
AC_MSG_CHECKING([for function prototypes])
|
||||
if test "$am_cv_prog_cc_stdc" != no; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(PROTOTYPES,1,[Define if compiler has function prototypes])
|
||||
U= ANSI2KNR=
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
U=_ ANSI2KNR=./ansi2knr
|
||||
# Ensure some checks needed by ansi2knr itself.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(string.h)
|
||||
fi
|
||||
AC_SUBST(U)dnl
|
||||
AC_SUBST(ANSI2KNR)dnl
|
||||
])
|
||||
35
m4/realloc.m4
Normal file
35
m4/realloc.m4
Normal file
@ -0,0 +1,35 @@
|
||||
#serial 3
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl Determine whether realloc works when both arguments are 0.
|
||||
dnl If it doesn't, arrange to use the replacement function.
|
||||
dnl
|
||||
|
||||
AC_DEFUN(jm_FUNC_REALLOC,
|
||||
[
|
||||
dnl xmalloc.c requires that this symbol be defined so it doesn't
|
||||
dnl mistakenly use a broken realloc -- as it might if this test were omitted.
|
||||
AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_REALLOC_CHECK, 1,
|
||||
[Define if the realloc check has been performed. ])
|
||||
|
||||
AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc,
|
||||
[AC_TRY_RUN([
|
||||
char *realloc ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
exit (realloc (0, 0) ? 0 : 1);
|
||||
}
|
||||
],
|
||||
jm_cv_func_working_realloc=yes,
|
||||
jm_cv_func_working_realloc=no,
|
||||
dnl When crosscompiling, assume realloc is broken.
|
||||
jm_cv_func_working_realloc=no)
|
||||
])
|
||||
if test $jm_cv_func_working_realloc = no; then
|
||||
AC_SUBST(LIBOBJS)
|
||||
LIBOBJS="$LIBOBJS realloc.$ac_objext"
|
||||
AC_DEFINE_UNQUOTED(realloc, rpl_realloc,
|
||||
[Define to rpl_realloc if the replacement function should be used.])
|
||||
fi
|
||||
])
|
||||
40
m4/utimbuf.m4
Normal file
40
m4/utimbuf.m4
Normal file
@ -0,0 +1,40 @@
|
||||
#serial 2
|
||||
|
||||
dnl From Jim Meyering
|
||||
|
||||
dnl Define HAVE_STRUCT_UTIMBUF if `struct utimbuf' is declared --
|
||||
dnl usually in <utime.h>.
|
||||
dnl Some systems have utime.h but don't declare the struct anywhere.
|
||||
|
||||
AC_DEFUN(jm_STRUCT_UTIMBUF,
|
||||
[
|
||||
AC_CHECK_HEADERS(utime.h)
|
||||
AC_REQUIRE([AC_HEADER_TIME])
|
||||
AC_CACHE_CHECK([for struct utimbuf], fu_cv_sys_struct_utimbuf,
|
||||
[AC_TRY_COMPILE(
|
||||
[
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
#ifdef HAVE_UTIME_H
|
||||
# include <utime.h>
|
||||
#endif
|
||||
],
|
||||
[static struct utimbuf x; x.actime = x.modtime;],
|
||||
fu_cv_sys_struct_utimbuf=yes,
|
||||
fu_cv_sys_struct_utimbuf=no)
|
||||
])
|
||||
|
||||
if test $fu_cv_sys_struct_utimbuf = yes; then
|
||||
AC_DEFINE_UNQUOTED(HAVE_STRUCT_UTIMBUF, 1,
|
||||
[Define if struct utimbuf is declared -- usually in <utime.h>.
|
||||
Some systems have utime.h but don't declare the struct anywhere. ])
|
||||
fi
|
||||
])
|
||||
36
maketime.c
36
maketime.c
@ -64,7 +64,7 @@
|
||||
#include <maketime.h>
|
||||
|
||||
char const maket_id[] =
|
||||
"$Id: maketime.c,v 5.16 1997/12/04 07:49:27 eggert Exp $";
|
||||
"$Id: maketime.c,v 5.17 1999/08/29 11:12:37 eggert Exp $";
|
||||
|
||||
static int isleap P ((int));
|
||||
static int month_days P ((struct tm const *));
|
||||
@ -79,8 +79,8 @@ static time_t maketime P ((struct partime const *, time_t));
|
||||
|
||||
/* Quotient and remainder when dividing A by B,
|
||||
truncating towards minus infinity, where B is positive. */
|
||||
#define div(a, b) ((a) / (b) - ((a) % (b) < 0))
|
||||
#define mod(a, b) ((a) % (b) + (b) * ((a) % (b) < 0))
|
||||
#define DIV(a, b) ((a) / (b) - ((a) % (b) < 0))
|
||||
#define MOD(a, b) ((a) % (b) + (b) * ((a) % (b) < 0))
|
||||
|
||||
/* Number of days in 400 consecutive Gregorian years. */
|
||||
#define Y400_DAYS (365 * 400L + 100 - 4 + 1)
|
||||
@ -137,8 +137,8 @@ difftm (a, b)
|
||||
{
|
||||
int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
|
||||
int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
|
||||
int ac = div (ay, 100);
|
||||
int bc = div (by, 100);
|
||||
int ac = DIV (ay, 100);
|
||||
int bc = DIV (by, 100);
|
||||
int difference_in_day_of_year = a->tm_yday - b->tm_yday;
|
||||
int intervening_leap_days = (((ay >> 2) - (by >> 2))
|
||||
- (ac - bc)
|
||||
@ -210,10 +210,10 @@ adjzone (t, seconds)
|
||||
}
|
||||
}
|
||||
if (TM_DEFINED (t->tm_wday))
|
||||
t->tm_wday = mod (t->tm_wday + days, 7);
|
||||
t->tm_hour = mod (t->tm_hour, 24);
|
||||
t->tm_min = mod (t->tm_min, 60);
|
||||
t->tm_sec = (int) mod (sec, 60) + leap_second;
|
||||
t->tm_wday = MOD (t->tm_wday + days, 7);
|
||||
t->tm_hour = MOD (t->tm_hour, 24);
|
||||
t->tm_min = MOD (t->tm_min, 60);
|
||||
t->tm_sec = (int) MOD (sec, 60) + leap_second;
|
||||
}
|
||||
|
||||
/* Convert TM to time_t, using localtime if LOCALZONE and gmtime otherwise.
|
||||
@ -330,7 +330,7 @@ maketime (pt, default_time)
|
||||
{
|
||||
/* Yield a year closest to the default that has the given modulus. */
|
||||
int year0 = tm0->tm_year + TM_YEAR_ORIGIN;
|
||||
int y0 = mod (year0, pt->ymodulus);
|
||||
int y0 = MOD (year0, pt->ymodulus);
|
||||
int d = 2 * (year - y0);
|
||||
year += (((year0 - y0) / pt->ymodulus
|
||||
+ (pt->ymodulus < d ? -1 : d < -pt->ymodulus))
|
||||
@ -391,21 +391,21 @@ maketime (pt, default_time)
|
||||
int hours = tm.tm_hour + pt->tmr.tm_hour;
|
||||
int mins = tm.tm_min + pt->tmr.tm_min;
|
||||
|
||||
int carried_hours = div (mins, 60);
|
||||
int carried_hours = DIV (mins, 60);
|
||||
int hours1 = hours + carried_hours;
|
||||
int carried_days = div (hours1, 24);
|
||||
int carried_days = DIV (hours1, 24);
|
||||
int mdays1 = mdays + carried_days;
|
||||
|
||||
int mon0 = mod (mons, 12);
|
||||
int carried_years0 = div (mons, 12);
|
||||
int mon0 = MOD (mons, 12);
|
||||
int carried_years0 = DIV (mons, 12);
|
||||
int year0 = years + carried_years0;
|
||||
int yday0 = (month_yday[mon0]
|
||||
- (mon0 < 2 || !isleap (year0 + TM_YEAR_ORIGIN)));
|
||||
|
||||
int yday1 = yday0 + mdays1;
|
||||
int carried_years1 = div (yday1, Y400_DAYS) * 400;
|
||||
int carried_years1 = DIV (yday1, Y400_DAYS) * 400;
|
||||
int year1 = year0 + carried_years1;
|
||||
int yday2 = mod (yday1, Y400_DAYS);
|
||||
int yday2 = MOD (yday1, Y400_DAYS);
|
||||
int leap;
|
||||
|
||||
if (overflow_sum_sign (tm.tm_year, pt->tmr.tm_year, years)
|
||||
@ -440,8 +440,8 @@ maketime (pt, default_time)
|
||||
tm.tm_mon = mon;
|
||||
}
|
||||
|
||||
tm.tm_hour = mod (hours1, 24);
|
||||
tm.tm_min = mod (mins, 60);
|
||||
tm.tm_hour = MOD (hours1, 24);
|
||||
tm.tm_min = MOD (mins, 60);
|
||||
|
||||
r = tm2time (&tm, localzone);
|
||||
if (r == -1)
|
||||
|
||||
5
malloc.c
5
malloc.c
@ -1,5 +1,5 @@
|
||||
/* Work around bug on some systems where malloc (0) fails.
|
||||
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -30,8 +30,7 @@ char *malloc ();
|
||||
If N is zero, allocate a 1-byte block. */
|
||||
|
||||
char *
|
||||
rpl_malloc (n)
|
||||
size_t n;
|
||||
rpl_malloc (size_t n)
|
||||
{
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
|
||||
37
memchr.c
37
memchr.c
@ -1,30 +1,30 @@
|
||||
/* Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1993, 1997, 1999 Free Software Foundation, Inc.
|
||||
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
|
||||
with help from Dan Sahlin (dan@sics.se) and
|
||||
commentary by Jim Blandy (jimb@ai.mit.edu);
|
||||
adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
|
||||
and implemented by Roland McGrath (roland@ai.mit.edu).
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
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 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.
|
||||
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. */
|
||||
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. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#undef __ptr_t
|
||||
@ -45,15 +45,14 @@
|
||||
#define LONG_MAX_32_BITS 2147483647
|
||||
|
||||
#ifndef LONG_MAX
|
||||
#define LONG_MAX LONG_MAX_32_BITS
|
||||
# define LONG_MAX LONG_MAX_32_BITS
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#undef memchr
|
||||
|
||||
|
||||
/* Search no more than N bytes of S for C. */
|
||||
|
||||
__ptr_t
|
||||
memchr (s, c, n)
|
||||
const __ptr_t s;
|
||||
|
||||
108
mkdir.c
Normal file
108
mkdir.c
Normal file
@ -0,0 +1,108 @@
|
||||
/* BSD compatible make directory function for System V
|
||||
Copyright (C) 1988, 1990, 1998 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. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#if STAT_MACROS_BROKEN
|
||||
# undef S_ISDIR
|
||||
#endif
|
||||
|
||||
#if !defined(S_ISDIR) && defined(S_IFDIR)
|
||||
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
#ifndef S_IRWXU
|
||||
# define S_IRWXU 0700
|
||||
#endif
|
||||
#ifndef S_IRWXG
|
||||
# define S_IRWXG 0070
|
||||
#endif
|
||||
#ifndef S_IRWXO
|
||||
# define S_IRWXO 0007
|
||||
#endif
|
||||
|
||||
/* mkdir adapted from GNU tar. */
|
||||
|
||||
/* Make directory DPATH, with permission mode DMODE.
|
||||
|
||||
Written by Robert Rother, Mariah Corporation, August 1985
|
||||
(sdcsvax!rmr or rmr@uscd). If you want it, it's yours.
|
||||
|
||||
Severely hacked over by John Gilmore to make a 4.2BSD compatible
|
||||
subroutine. 11Mar86; hoptoad!gnu
|
||||
|
||||
Modified by rmtodd@uokmax 6-28-87 -- when making an already existing dir,
|
||||
subroutine didn't return EEXIST. It does now. */
|
||||
|
||||
int
|
||||
mkdir (const char *dpath, mode_t dmode)
|
||||
{
|
||||
pid_t cpid;
|
||||
mode_t mode;
|
||||
int status;
|
||||
struct stat statbuf;
|
||||
|
||||
if (stat (dpath, &statbuf) == 0)
|
||||
{
|
||||
errno = EEXIST; /* stat worked, so it already exists. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If stat fails for a reason other than non-existence, return error. */
|
||||
if (errno != ENOENT)
|
||||
return -1;
|
||||
|
||||
cpid = fork ();
|
||||
switch (cpid)
|
||||
{
|
||||
case -1: /* Cannot fork. */
|
||||
return -1; /* errno is already set. */
|
||||
|
||||
case 0: /* Child process. */
|
||||
/* Cheap hack to set mode of new directory. Since this child
|
||||
process is going away anyway, we zap its umask.
|
||||
This won't suffice to set SUID, SGID, etc. on this
|
||||
directory, so the parent process calls chmod afterward. */
|
||||
mode = umask (0); /* Get current umask. */
|
||||
/* Set for mkdir. */
|
||||
umask (mode | ((S_IRWXU | S_IRWXG | S_IRWXO) & ~dmode));
|
||||
execl ("/bin/mkdir", "mkdir", dpath, (char *) 0);
|
||||
_exit (1);
|
||||
|
||||
default: /* Parent process. */
|
||||
/* Wait for kid to finish. */
|
||||
while (wait (&status) != cpid)
|
||||
/* Do nothing. */ ;
|
||||
|
||||
if (status)
|
||||
{
|
||||
/* /bin/mkdir failed. */
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
return chmod (dpath, dmode);
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,7 @@
|
||||
# Created: 1993-05-16
|
||||
# Public domain
|
||||
|
||||
# $Id: mkinstalldirs,v 1.10 1996/05/03 07:37:52 friedman Exp $
|
||||
# $Id: mkinstalldirs,v 1.12.2.1 1998/12/26 17:32:14 bje Exp $
|
||||
|
||||
errstatus=0
|
||||
|
||||
@ -22,7 +22,7 @@ do
|
||||
esac
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
echo "mkdir $pathcomp" 1>&2
|
||||
echo "mkdir $pathcomp"
|
||||
|
||||
mkdir "$pathcomp" || lasterr=$?
|
||||
|
||||
|
||||
123
patch.c
123
patch.c
@ -1,26 +1,24 @@
|
||||
/* patch - a program to apply diffs to original files */
|
||||
|
||||
/* $Id: patch.c,v 1.27 1998/03/20 22:42:54 eggert Exp $ */
|
||||
/* $Id: patch.c,v 1.28 1999/08/30 06:20:08 eggert Exp $ */
|
||||
|
||||
/*
|
||||
Copyright 1984, 1985, 1986, 1987, 1988 Larry Wall
|
||||
Copyright 1989, 1990-1993, 1997, 1998 Free Software Foundation, Inc.
|
||||
/* Copyright 1984, 1985-1987, 1988 Larry Wall
|
||||
Copyright 1989, 1990-1993, 1997-1998, 1999 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 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.
|
||||
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.
|
||||
*/
|
||||
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. */
|
||||
|
||||
#define XTERN
|
||||
#include <common.h>
|
||||
@ -79,6 +77,7 @@ static void usage PARAMS ((FILE *, int)) __attribute__((noreturn));
|
||||
static int make_backups;
|
||||
static int backup_if_mismatch;
|
||||
static char const *version_control;
|
||||
static char const *version_control_context;
|
||||
static int remove_empty_files;
|
||||
|
||||
/* TRUE if -R was specified on command line. */
|
||||
@ -115,9 +114,7 @@ char const program_name[] = "patch";
|
||||
int main PARAMS ((int, char **));
|
||||
|
||||
int
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
char const *val;
|
||||
bool somefailed = FALSE;
|
||||
@ -136,7 +133,7 @@ char **argv;
|
||||
|
||||
val = getenv ("QUOTING_STYLE");
|
||||
{
|
||||
int i = val ? argmatch (val, quoting_style_args) : -1;
|
||||
int i = val ? argmatch (val, quoting_style_args, 0, 0) : -1;
|
||||
set_quoting_style ((struct quoting_options *) 0,
|
||||
i < 0 ? shell_quoting_style : (enum quoting_style) i);
|
||||
}
|
||||
@ -151,9 +148,10 @@ char **argv;
|
||||
if (val && *val)
|
||||
simple_backup_suffix = val;
|
||||
|
||||
version_control = getenv ("PATCH_VERSION_CONTROL");
|
||||
if (! version_control)
|
||||
version_control = getenv ("VERSION_CONTROL");
|
||||
if ((version_control = getenv ("PATCH_VERSION_CONTROL")))
|
||||
version_control_context = "$PATCH_VERSION_CONTROL";
|
||||
else if ((version_control = getenv ("VERSION_CONTROL")))
|
||||
version_control_context = "$VERSION_CONTROL";
|
||||
|
||||
/* Cons up the names of the global temporary files.
|
||||
Do this before `cleanup' can possibly be called (e.g. by `pfatal'). */
|
||||
@ -168,7 +166,7 @@ char **argv;
|
||||
get_some_switches();
|
||||
|
||||
if (make_backups | backup_if_mismatch)
|
||||
backup_type = get_version (version_control);
|
||||
backup_type = get_version (version_control_context, version_control);
|
||||
|
||||
init_output (outfile, 0, &outstate);
|
||||
|
||||
@ -290,7 +288,7 @@ char **argv;
|
||||
format_linenum (numbuf, newwhere));
|
||||
}
|
||||
else if (!where
|
||||
|| (where == 1 && pch_says_nonexistent (reverse)
|
||||
|| (where == 1 && pch_says_nonexistent (reverse) == 2
|
||||
&& instat.st_size)) {
|
||||
|
||||
if (where)
|
||||
@ -397,7 +395,7 @@ char **argv;
|
||||
utimbuf.actime = utimbuf.modtime = t;
|
||||
|
||||
if (! force && ! inerrno
|
||||
&& ! pch_says_nonexistent (reverse)
|
||||
&& pch_says_nonexistent (reverse) != 2
|
||||
&& (t = pch_timestamp (reverse)) != (time_t) -1
|
||||
&& t != instat.st_mtime)
|
||||
say ("Not setting time of file %s (time mismatch)\n",
|
||||
@ -461,7 +459,7 @@ char **argv;
|
||||
/* Prepare to find the next patch to do in the patch file. */
|
||||
|
||||
static void
|
||||
reinitialize_almost_everything()
|
||||
reinitialize_almost_everything (void)
|
||||
{
|
||||
re_patch();
|
||||
re_input();
|
||||
@ -601,9 +599,7 @@ static char const *const option_help[] =
|
||||
};
|
||||
|
||||
static void
|
||||
usage (stream, status)
|
||||
FILE *stream;
|
||||
int status;
|
||||
usage (FILE *stream, int status)
|
||||
{
|
||||
char const * const *p;
|
||||
|
||||
@ -626,7 +622,7 @@ usage (stream, status)
|
||||
/* Process switches and filenames. */
|
||||
|
||||
static void
|
||||
get_some_switches()
|
||||
get_some_switches (void)
|
||||
{
|
||||
register int optc;
|
||||
|
||||
@ -731,6 +727,7 @@ get_some_switches()
|
||||
break;
|
||||
case 'V':
|
||||
version_control = optarg;
|
||||
version_control_context = "--version-control or -V option";
|
||||
break;
|
||||
#if DEBUGGING
|
||||
case 'x':
|
||||
@ -775,7 +772,7 @@ get_some_switches()
|
||||
break;
|
||||
case CHAR_MAX + 8:
|
||||
{
|
||||
int i = argmatch (optarg, quoting_style_args);
|
||||
int i = argmatch (optarg, quoting_style_args, 0, 0);
|
||||
if (i < 0)
|
||||
{
|
||||
invalid_arg ("quoting style", optarg, i);
|
||||
@ -812,10 +809,9 @@ get_some_switches()
|
||||
of type ARGTYPE_MSGID by converting it to an integer,
|
||||
returning the result. */
|
||||
static int
|
||||
numeric_string (string, negative_allowed, argtype_msgid)
|
||||
char const *string;
|
||||
int negative_allowed;
|
||||
char const *argtype_msgid;
|
||||
numeric_string (char const *string,
|
||||
int negative_allowed,
|
||||
char const *argtype_msgid)
|
||||
{
|
||||
int value = 0;
|
||||
char const *p = string;
|
||||
@ -849,8 +845,7 @@ numeric_string (string, negative_allowed, argtype_msgid)
|
||||
/* Attempt to find the right place to apply this hunk of patch. */
|
||||
|
||||
static LINENUM
|
||||
locate_hunk(fuzz)
|
||||
LINENUM fuzz;
|
||||
locate_hunk (LINENUM fuzz)
|
||||
{
|
||||
register LINENUM first_guess = pch_first () + last_offset;
|
||||
register LINENUM offset;
|
||||
@ -938,7 +933,7 @@ LINENUM fuzz;
|
||||
/* We did not find the pattern, dump out the hunk so they can handle it. */
|
||||
|
||||
static void
|
||||
abort_hunk()
|
||||
abort_hunk (void)
|
||||
{
|
||||
register LINENUM i;
|
||||
register LINENUM pat_end = pch_end ();
|
||||
@ -996,9 +991,7 @@ abort_hunk()
|
||||
/* We found where to apply it (we hope), so do it. */
|
||||
|
||||
static bool
|
||||
apply_hunk (outstate, where)
|
||||
struct outstate *outstate;
|
||||
LINENUM where;
|
||||
apply_hunk (struct outstate *outstate, LINENUM where)
|
||||
{
|
||||
register LINENUM old = 1;
|
||||
register LINENUM lastline = pch_ptrn_lines ();
|
||||
@ -1159,9 +1152,7 @@ apply_hunk (outstate, where)
|
||||
/* Create an output file. */
|
||||
|
||||
static FILE *
|
||||
create_output_file (name, open_flags)
|
||||
char const *name;
|
||||
int open_flags;
|
||||
create_output_file (char const *name, int open_flags)
|
||||
{
|
||||
int fd = create_file (name, O_WRONLY | binary_transput | open_flags,
|
||||
instat.st_mode);
|
||||
@ -1174,10 +1165,7 @@ create_output_file (name, open_flags)
|
||||
/* Open the new file. */
|
||||
|
||||
static void
|
||||
init_output (name, open_flags, outstate)
|
||||
char const *name;
|
||||
int open_flags;
|
||||
struct outstate *outstate;
|
||||
init_output (char const *name, int open_flags, struct outstate *outstate)
|
||||
{
|
||||
outstate->ofp = name ? create_output_file (name, open_flags) : (FILE *) 0;
|
||||
outstate->after_newline = 1;
|
||||
@ -1187,7 +1175,7 @@ init_output (name, open_flags, outstate)
|
||||
/* Open a file to put hunks we can't locate. */
|
||||
|
||||
static void
|
||||
init_reject ()
|
||||
init_reject (void)
|
||||
{
|
||||
int exclusive = TMPREJNAME_needs_removal ? 0 : O_EXCL;
|
||||
TMPREJNAME_needs_removal = 1;
|
||||
@ -1197,9 +1185,7 @@ init_reject ()
|
||||
/* Copy input file to output, up to wherever hunk is to be applied. */
|
||||
|
||||
static bool
|
||||
copy_till (outstate, lastline)
|
||||
register struct outstate *outstate;
|
||||
register LINENUM lastline;
|
||||
copy_till (register struct outstate *outstate, register LINENUM lastline)
|
||||
{
|
||||
register LINENUM R_last_frozen_line = last_frozen_line;
|
||||
register FILE *fp = outstate->ofp;
|
||||
@ -1230,8 +1216,7 @@ copy_till (outstate, lastline)
|
||||
/* Finish copying the input file to the output file. */
|
||||
|
||||
static bool
|
||||
spew_output (outstate)
|
||||
struct outstate *outstate;
|
||||
spew_output (struct outstate *outstate)
|
||||
{
|
||||
if (debug & 256)
|
||||
{
|
||||
@ -1259,11 +1244,8 @@ spew_output (outstate)
|
||||
/* Does the patch pattern match at line base+offset? */
|
||||
|
||||
static bool
|
||||
patch_match (base, offset, prefix_fuzz, suffix_fuzz)
|
||||
LINENUM base;
|
||||
LINENUM offset;
|
||||
LINENUM prefix_fuzz;
|
||||
LINENUM suffix_fuzz;
|
||||
patch_match (LINENUM base, LINENUM offset,
|
||||
LINENUM prefix_fuzz, LINENUM suffix_fuzz)
|
||||
{
|
||||
register LINENUM pline = 1 + prefix_fuzz;
|
||||
register LINENUM iline;
|
||||
@ -1289,11 +1271,8 @@ LINENUM suffix_fuzz;
|
||||
/* Do two lines match with canonicalized white space? */
|
||||
|
||||
static bool
|
||||
similar (a, alen, b, blen)
|
||||
register char const *a;
|
||||
register size_t alen;
|
||||
register char const *b;
|
||||
register size_t blen;
|
||||
similar (register char const *a, register size_t alen,
|
||||
register char const *b, register size_t blen)
|
||||
{
|
||||
/* Ignore presence or absence of trailing newlines. */
|
||||
alen -= alen && a[alen - 1] == '\n';
|
||||
@ -1333,8 +1312,7 @@ char *mktemp PARAMS ((char *));
|
||||
#endif
|
||||
|
||||
static char const *
|
||||
make_temp (letter)
|
||||
int letter;
|
||||
make_temp (int letter)
|
||||
{
|
||||
char *r;
|
||||
#if HAVE_MKTEMP
|
||||
@ -1358,8 +1336,7 @@ make_temp (letter)
|
||||
/* Fatal exit with cleanup. */
|
||||
|
||||
void
|
||||
fatal_exit (sig)
|
||||
int sig;
|
||||
fatal_exit (int sig)
|
||||
{
|
||||
cleanup ();
|
||||
|
||||
@ -1370,9 +1347,7 @@ fatal_exit (sig)
|
||||
}
|
||||
|
||||
static void
|
||||
remove_if_needed (name, needs_removal)
|
||||
char const *name;
|
||||
int volatile *needs_removal;
|
||||
remove_if_needed (char const *name, int volatile *needs_removal)
|
||||
{
|
||||
if (*needs_removal)
|
||||
{
|
||||
@ -1382,7 +1357,7 @@ remove_if_needed (name, needs_removal)
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup ()
|
||||
cleanup (void)
|
||||
{
|
||||
remove_if_needed (TMPINNAME, &TMPINNAME_needs_removal);
|
||||
remove_if_needed (TMPOUTNAME, &TMPOUTNAME_needs_removal);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
.de Id
|
||||
.ds Dt \\$4
|
||||
..
|
||||
.Id $Id: patch.man,v 1.25 1998/03/17 18:35:38 eggert Exp $
|
||||
.Id $Id: patch.man,v 1.26 1998/03/21 15:48:43 eggert Exp $
|
||||
.ds = \-\^\-
|
||||
.de Sp
|
||||
.if t .sp .3
|
||||
@ -375,7 +375,7 @@ and does not get the file; and if negative,
|
||||
asks the user whether to get the file.
|
||||
The default value of this option is given by the value of the
|
||||
.B PATCH_GET
|
||||
environment variable if it is set; if not, the default value is zero if
|
||||
environment variable if it is set; if not, the default value is zero if
|
||||
.B patch
|
||||
is conforming to \s-1POSIX\s0, negative otherwise.
|
||||
.TP
|
||||
|
||||
1
patchlevel.h
Normal file
1
patchlevel.h
Normal file
@ -0,0 +1 @@
|
||||
#define PATCH_VERSION "2.5.4"
|
||||
@ -7,7 +7,7 @@ To configure `patch' for DJGPP, issue these commands from the
|
||||
To build `patch' in a directory other than where the sources are,
|
||||
add a parameter that specifies the source directory, e.g.:
|
||||
|
||||
e:\gnu\patch-2.3\pc\djgpp\configure e:/gnu/patch-2.3
|
||||
e:\src\patch\pc\djgpp\configure e:/src/patch
|
||||
|
||||
You MUST use forward slashes to specify the source directory.
|
||||
|
||||
|
||||
@ -7,15 +7,18 @@
|
||||
symbols that <sys/config.h> doesn't define correctly. */\
|
||||
#include <sys/config.h>
|
||||
|
||||
s/#undef HAVE_DONE_WORKING_MALLOC_CHECK/#define HAVE_DONE_WORKING_MALLOC_CHECK 1/
|
||||
s/#undef HAVE_DONE_WORKING_REALLOC_CHECK/#define HAVE_DONE_WORKING_REALLOC_CHECK 1/
|
||||
s/#undef HAVE_LONG_FILE_NAMES/#define HAVE_LONG_FILE_NAMES 1/
|
||||
s/#undef HAVE_MEMCMP/#define HAVE_MEMCMP 1/
|
||||
s/#undef HAVE_MKTEMP/#define HAVE_MKTEMP 1/
|
||||
s/#undef HAVE_PATHCONF/#define HAVE_PATHCONF 1/
|
||||
s/#undef HAVE_RAISE/#define HAVE_RAISE 1/
|
||||
s/#undef HAVE_SIGPROCMASK/#define HAVE_SIGPROCMASK 1/
|
||||
s/#undef HAVE_UTIME_H/#define HAVE_UTIME_H 1/
|
||||
s/#undef HAVE_STRUCT_UTIMBUF/#define HAVE_STRUCT_UTIMBUF 1/
|
||||
s/#undef HAVE_UTIME_H/#define HAVE_UTIME_H 1/
|
||||
s/#undef HAVE_VPRINTF/#define HAVE_VPRINTF 1/
|
||||
s/#undef PROTOTYPES/#define PROTOTYPES 1/
|
||||
|
||||
s,#undef.*,/* & */,
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# Edit Makefile.in to produce Makefile for DJGPP v2
|
||||
# $Id: configure.sed,v 1.8 1997/06/18 06:26:43 eggert Exp $
|
||||
# $Id: configure.sed,v 1.9 1998/03/22 20:16:29 eggert Exp $
|
||||
|
||||
1i\
|
||||
# Makefile generated by "configure.bat" for DJGPP v2\
|
||||
@ -20,6 +20,7 @@ s|@LDFLAGS@||g
|
||||
s|@LIBOBJS@|getopt1.o getopt.o chdirsaf.o|g
|
||||
s|@LIBS@||g
|
||||
s|@PACKAGE@|patch|g
|
||||
s|@U@||g
|
||||
/@VERSION@/d
|
||||
|
||||
s|@prefix@|${DJDIR}|g
|
||||
|
||||
136
pch.c
136
pch.c
@ -1,30 +1,29 @@
|
||||
/* reading patches */
|
||||
|
||||
/* $Id: pch.c,v 1.27 1998/03/15 14:44:47 eggert Exp $ */
|
||||
/* $Id: pch.c,v 1.29 1999/08/30 06:20:08 eggert Exp $ */
|
||||
|
||||
/*
|
||||
Copyright 1986, 1987, 1988 Larry Wall
|
||||
Copyright 1990, 1991, 1992, 1993, 1997, 1998 Free Software Foundation, Inc.
|
||||
/* Copyright 1986, 1987, 1988 Larry Wall
|
||||
Copyright 1990, 1991-1993, 1997-1998, 1999 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 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.
|
||||
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.
|
||||
*/
|
||||
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. */
|
||||
|
||||
#define XTERN extern
|
||||
#include <common.h>
|
||||
#include <backupfile.h>
|
||||
#include <basename.h>
|
||||
#include <inp.h>
|
||||
#include <quotearg.h>
|
||||
#include <util.h>
|
||||
@ -37,8 +36,10 @@ If not, write to the Free Software Foundation,
|
||||
/* Patch (diff listing) abstract type. */
|
||||
|
||||
static FILE *pfp; /* patch file pointer */
|
||||
static int p_says_nonexistent[2]; /* [0] for old file, [1] for new;
|
||||
value is 0 for nonempty, 1 for empty, 2 for nonexistent */
|
||||
static int p_says_nonexistent[2]; /* [0] for old file, [1] for new:
|
||||
0 for existent and nonempty,
|
||||
1 for existent and probably (but not necessarily) empty,
|
||||
2 for nonexistent */
|
||||
static int p_rfc934_nesting; /* RFC 934 nesting level */
|
||||
static time_t p_timestamp[2]; /* timestamps in patch headers */
|
||||
static off_t p_filesize; /* size of the patch file */
|
||||
@ -82,7 +83,7 @@ static void skip_to PARAMS ((file_offset, LINENUM));
|
||||
/* Prepare to look for the next patch in the patch file. */
|
||||
|
||||
void
|
||||
re_patch()
|
||||
re_patch (void)
|
||||
{
|
||||
p_first = 0;
|
||||
p_newfirst = 0;
|
||||
@ -97,8 +98,7 @@ re_patch()
|
||||
/* Open the patch file at the beginning of time. */
|
||||
|
||||
void
|
||||
open_patch_file(filename)
|
||||
char const *filename;
|
||||
open_patch_file (char const *filename)
|
||||
{
|
||||
file_offset file_pos = 0;
|
||||
struct stat st;
|
||||
@ -161,7 +161,7 @@ open_patch_file(filename)
|
||||
/* Make sure our dynamically realloced tables are malloced to begin with. */
|
||||
|
||||
void
|
||||
set_hunkmax()
|
||||
set_hunkmax (void)
|
||||
{
|
||||
if (!p_line)
|
||||
p_line = (char **) malloc (hunkmax * sizeof *p_line);
|
||||
@ -174,7 +174,7 @@ set_hunkmax()
|
||||
/* Enlarge the arrays containing the current hunk of patch. */
|
||||
|
||||
static bool
|
||||
grow_hunkmax()
|
||||
grow_hunkmax (void)
|
||||
{
|
||||
hunkmax *= 2;
|
||||
assert (p_line && p_len && p_Char);
|
||||
@ -194,7 +194,7 @@ grow_hunkmax()
|
||||
/* True if the remainder of the patch file contains a diff of some sort. */
|
||||
|
||||
bool
|
||||
there_is_another_patch()
|
||||
there_is_another_patch (void)
|
||||
{
|
||||
if (p_base != 0 && p_base >= p_filesize) {
|
||||
if (verbosity == VERBOSE)
|
||||
@ -284,7 +284,7 @@ there_is_another_patch()
|
||||
/* Determine what kind of diff is in the remaining part of the patch file. */
|
||||
|
||||
static enum diff
|
||||
intuit_diff_type()
|
||||
intuit_diff_type (void)
|
||||
{
|
||||
register file_offset this_line = 0;
|
||||
register file_offset first_command_line = -1;
|
||||
@ -542,6 +542,8 @@ intuit_diff_type()
|
||||
|
||||
if (! posixly_correct)
|
||||
{
|
||||
int is_empty;
|
||||
|
||||
i = best_name (name, stat_errno);
|
||||
|
||||
if (i == NONE && patch_get)
|
||||
@ -583,7 +585,8 @@ intuit_diff_type()
|
||||
}
|
||||
}
|
||||
|
||||
if (p_says_nonexistent[reverse ^ (i == NONE || st[i].st_size == 0)])
|
||||
is_empty = i == NONE || st[i].st_size == 0;
|
||||
if ((! is_empty) < p_says_nonexistent[reverse ^ is_empty])
|
||||
{
|
||||
assert (i0 != NONE);
|
||||
if (ok_to_reverse
|
||||
@ -644,9 +647,7 @@ intuit_diff_type()
|
||||
/* Count the path name components in FILENAME's prefix.
|
||||
If CHECKDIRS is nonzero, count only existing directories. */
|
||||
static int
|
||||
prefix_components (filename, checkdirs)
|
||||
char *filename;
|
||||
int checkdirs;
|
||||
prefix_components (char *filename, int checkdirs)
|
||||
{
|
||||
int count = 0;
|
||||
struct stat stat_buf;
|
||||
@ -676,9 +677,7 @@ prefix_components (filename, checkdirs)
|
||||
Ignore null names, and ignore NAME[i] if IGNORE[i] is nonzero.
|
||||
Return NONE if all names are ignored. */
|
||||
static enum nametype
|
||||
best_name (name, ignore)
|
||||
char *const *name;
|
||||
int const *ignore;
|
||||
best_name (char *const *name, int const *ignore)
|
||||
{
|
||||
enum nametype i;
|
||||
int components[3];
|
||||
@ -724,9 +723,7 @@ best_name (name, ignore)
|
||||
/* Remember where this patch ends so we know where to start up again. */
|
||||
|
||||
static void
|
||||
next_intuit_at(file_pos,file_line)
|
||||
file_offset file_pos;
|
||||
LINENUM file_line;
|
||||
next_intuit_at (file_offset file_pos, LINENUM file_line)
|
||||
{
|
||||
p_base = file_pos;
|
||||
p_bline = file_line;
|
||||
@ -735,9 +732,7 @@ LINENUM file_line;
|
||||
/* Basically a verbose fseek() to the actual diff listing. */
|
||||
|
||||
static void
|
||||
skip_to(file_pos,file_line)
|
||||
file_offset file_pos;
|
||||
LINENUM file_line;
|
||||
skip_to (file_offset file_pos, LINENUM file_line)
|
||||
{
|
||||
register FILE *i = pfp;
|
||||
register FILE *o = stdout;
|
||||
@ -769,7 +764,7 @@ LINENUM file_line;
|
||||
|
||||
/* Make this a function for better debugging. */
|
||||
static void
|
||||
malformed ()
|
||||
malformed (void)
|
||||
{
|
||||
char numbuf[LINENUM_LENGTH_BOUND + 1];
|
||||
fatal ("malformed patch at line %s: %s",
|
||||
@ -780,9 +775,7 @@ malformed ()
|
||||
/* Parse a line number from a string.
|
||||
Return the address of the first char after the number. */
|
||||
static char *
|
||||
scan_linenum (s0, linenum)
|
||||
char *s0;
|
||||
LINENUM *linenum;
|
||||
scan_linenum (char *s0, LINENUM *linenum)
|
||||
{
|
||||
char *s;
|
||||
LINENUM n = 0;
|
||||
@ -812,9 +805,7 @@ scan_linenum (s0, linenum)
|
||||
0 if not; -1 if ran out of memory. */
|
||||
|
||||
int
|
||||
another_hunk (difftype, rev)
|
||||
enum diff difftype;
|
||||
int rev;
|
||||
another_hunk (enum diff difftype, int rev)
|
||||
{
|
||||
register char *s;
|
||||
register LINENUM context = 0;
|
||||
@ -1194,8 +1185,8 @@ another_hunk (difftype, rev)
|
||||
fillsrc++;
|
||||
if (p_end < fillsrc || fillsrc == repl_beginning)
|
||||
{
|
||||
fatal ("replacement text or line numbers mangled in hunk at line %ld",
|
||||
p_hunk_beg);
|
||||
fatal ("replacement text or line numbers mangled in hunk at line %s",
|
||||
format_linenum (numbuf0, p_hunk_beg));
|
||||
}
|
||||
p_line[filldst] = p_line[fillsrc];
|
||||
p_Char[filldst] = p_Char[fillsrc];
|
||||
@ -1506,7 +1497,7 @@ another_hunk (difftype, rev)
|
||||
}
|
||||
|
||||
static size_t
|
||||
get_line ()
|
||||
get_line (void)
|
||||
{
|
||||
return pget_line (p_indent, p_rfc934_nesting, p_strip_trailing_cr);
|
||||
}
|
||||
@ -1521,10 +1512,7 @@ get_line ()
|
||||
Return -1 if we ran out of memory. */
|
||||
|
||||
static size_t
|
||||
pget_line (indent, rfc934_nesting, strip_trailing_cr)
|
||||
int indent;
|
||||
int rfc934_nesting;
|
||||
int strip_trailing_cr;
|
||||
pget_line (int indent, int rfc934_nesting, int strip_trailing_cr)
|
||||
{
|
||||
register FILE *fp = pfp;
|
||||
register int c;
|
||||
@ -1609,7 +1597,7 @@ pget_line (indent, rfc934_nesting, strip_trailing_cr)
|
||||
}
|
||||
|
||||
static bool
|
||||
incomplete_line ()
|
||||
incomplete_line (void)
|
||||
{
|
||||
register FILE *fp = pfp;
|
||||
register int c;
|
||||
@ -1632,7 +1620,7 @@ incomplete_line ()
|
||||
/* Reverse the old and new portions of the current hunk. */
|
||||
|
||||
bool
|
||||
pch_swap()
|
||||
pch_swap (void)
|
||||
{
|
||||
char **tp_line; /* the text of the hunk */
|
||||
size_t *tp_len; /* length of each line */
|
||||
@ -1734,8 +1722,7 @@ pch_swap()
|
||||
Return 1 for empty, 2 for nonexistent. */
|
||||
|
||||
bool
|
||||
pch_says_nonexistent (which)
|
||||
int which;
|
||||
pch_says_nonexistent (int which)
|
||||
{
|
||||
return p_says_nonexistent[which];
|
||||
}
|
||||
@ -1744,8 +1731,7 @@ pch_says_nonexistent (which)
|
||||
or -1 if there was no timestamp or an error in the timestamp. */
|
||||
|
||||
time_t
|
||||
pch_timestamp (which)
|
||||
int which;
|
||||
pch_timestamp (int which)
|
||||
{
|
||||
return p_timestamp[which];
|
||||
}
|
||||
@ -1753,7 +1739,7 @@ pch_timestamp (which)
|
||||
/* Return the specified line position in the old file of the old context. */
|
||||
|
||||
LINENUM
|
||||
pch_first()
|
||||
pch_first (void)
|
||||
{
|
||||
return p_first;
|
||||
}
|
||||
@ -1761,7 +1747,7 @@ pch_first()
|
||||
/* Return the number of lines of old context. */
|
||||
|
||||
LINENUM
|
||||
pch_ptrn_lines()
|
||||
pch_ptrn_lines (void)
|
||||
{
|
||||
return p_ptrn_lines;
|
||||
}
|
||||
@ -1769,7 +1755,7 @@ pch_ptrn_lines()
|
||||
/* Return the probable line position in the new file of the first line. */
|
||||
|
||||
LINENUM
|
||||
pch_newfirst()
|
||||
pch_newfirst (void)
|
||||
{
|
||||
return p_newfirst;
|
||||
}
|
||||
@ -1777,7 +1763,7 @@ pch_newfirst()
|
||||
/* Return the number of lines in the replacement text including context. */
|
||||
|
||||
LINENUM
|
||||
pch_repl_lines()
|
||||
pch_repl_lines (void)
|
||||
{
|
||||
return p_repl_lines;
|
||||
}
|
||||
@ -1785,7 +1771,7 @@ pch_repl_lines()
|
||||
/* Return the number of lines in the whole hunk. */
|
||||
|
||||
LINENUM
|
||||
pch_end()
|
||||
pch_end (void)
|
||||
{
|
||||
return p_end;
|
||||
}
|
||||
@ -1793,7 +1779,7 @@ pch_end()
|
||||
/* Return the number of context lines before the first changed line. */
|
||||
|
||||
LINENUM
|
||||
pch_prefix_context ()
|
||||
pch_prefix_context (void)
|
||||
{
|
||||
return p_prefix_context;
|
||||
}
|
||||
@ -1801,7 +1787,7 @@ pch_prefix_context ()
|
||||
/* Return the number of context lines after the last changed line. */
|
||||
|
||||
LINENUM
|
||||
pch_suffix_context ()
|
||||
pch_suffix_context (void)
|
||||
{
|
||||
return p_suffix_context;
|
||||
}
|
||||
@ -1809,8 +1795,7 @@ pch_suffix_context ()
|
||||
/* Return the length of a particular patch line. */
|
||||
|
||||
size_t
|
||||
pch_line_len(line)
|
||||
LINENUM line;
|
||||
pch_line_len (LINENUM line)
|
||||
{
|
||||
return p_len[line];
|
||||
}
|
||||
@ -1818,8 +1803,7 @@ LINENUM line;
|
||||
/* Return the control character (+, -, *, !, etc) for a patch line. */
|
||||
|
||||
char
|
||||
pch_char(line)
|
||||
LINENUM line;
|
||||
pch_char (LINENUM line)
|
||||
{
|
||||
return p_Char[line];
|
||||
}
|
||||
@ -1827,8 +1811,7 @@ LINENUM line;
|
||||
/* Return a pointer to a particular patch line. */
|
||||
|
||||
char *
|
||||
pfetch(line)
|
||||
LINENUM line;
|
||||
pfetch (LINENUM line)
|
||||
{
|
||||
return p_line[line];
|
||||
}
|
||||
@ -1836,9 +1819,7 @@ LINENUM line;
|
||||
/* Output a patch line. */
|
||||
|
||||
bool
|
||||
pch_write_line (line, file)
|
||||
LINENUM line;
|
||||
FILE *file;
|
||||
pch_write_line (LINENUM line, FILE *file)
|
||||
{
|
||||
bool after_newline = p_line[line][p_len[line] - 1] == '\n';
|
||||
if (! fwrite (p_line[line], sizeof (*p_line[line]), p_len[line], file))
|
||||
@ -1849,7 +1830,7 @@ pch_write_line (line, file)
|
||||
/* Return where in the patch file this hunk began, for error messages. */
|
||||
|
||||
LINENUM
|
||||
pch_hunk_beg()
|
||||
pch_hunk_beg (void)
|
||||
{
|
||||
return p_hunk_beg;
|
||||
}
|
||||
@ -1857,8 +1838,7 @@ pch_hunk_beg()
|
||||
/* Apply an ed script by feeding ed itself. */
|
||||
|
||||
void
|
||||
do_ed_script (ofp)
|
||||
FILE *ofp;
|
||||
do_ed_script (FILE *ofp)
|
||||
{
|
||||
static char const ed_program[] = ed_PROGRAM;
|
||||
|
||||
|
||||
142
quotearg.c
142
quotearg.c
@ -1,5 +1,5 @@
|
||||
/* quotearg.c - quote arguments for output
|
||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -17,6 +17,8 @@
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
/* FIXME: Multibyte characters are not supported yet. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
@ -37,14 +39,21 @@
|
||||
# define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
|
||||
#endif
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(text) gettext (text)
|
||||
#else
|
||||
# define _(text) text
|
||||
#endif
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#ifndef CHAR_BIT
|
||||
#define CHAR_BIT 8
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
#ifndef UCHAR_MAX
|
||||
#define UCHAR_MAX ((unsigned char) -1)
|
||||
# define UCHAR_MAX ((unsigned char) -1)
|
||||
#endif
|
||||
|
||||
#if HAVE_STDLIB_H
|
||||
@ -61,8 +70,8 @@ struct quoting_options
|
||||
{
|
||||
/* Basic quoting style. */
|
||||
enum quoting_style style;
|
||||
|
||||
/* Quote the chararacters indicated by this bit vector even if the
|
||||
|
||||
/* Quote the characters indicated by this bit vector even if the
|
||||
quoting style would not normally require them to be quoted. */
|
||||
int quote_these_too[((UCHAR_MAX + 1) / INT_BITS
|
||||
+ ((UCHAR_MAX + 1) % INT_BITS != 0))];
|
||||
@ -71,7 +80,24 @@ struct quoting_options
|
||||
/* Names of quoting styles. */
|
||||
char const *const quoting_style_args[] =
|
||||
{
|
||||
"literal", "shell", "shell-always", "c", "escape", 0
|
||||
"literal",
|
||||
"shell",
|
||||
"shell-always",
|
||||
"c",
|
||||
"escape",
|
||||
"locale",
|
||||
0
|
||||
};
|
||||
|
||||
/* Correspondences to quoting style names. */
|
||||
enum quoting_style const quoting_style_vals[] =
|
||||
{
|
||||
literal_quoting_style,
|
||||
shell_quoting_style,
|
||||
shell_always_quoting_style,
|
||||
c_quoting_style,
|
||||
escape_quoting_style,
|
||||
locale_quoting_style
|
||||
};
|
||||
|
||||
/* The default quoting options. */
|
||||
@ -119,7 +145,7 @@ set_char_quoting (struct quoting_options *o, char c, int i)
|
||||
*p ^= ((i & 1) ^ r) << shift;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
|
||||
argument ARG (of size ARGSIZE), using O to control quoting.
|
||||
If O is null, use the default.
|
||||
@ -130,16 +156,17 @@ set_char_quoting (struct quoting_options *o, char c, int i)
|
||||
If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */
|
||||
size_t
|
||||
quotearg_buffer (char *buffer, size_t buffersize,
|
||||
char const *arg, size_t argsize,
|
||||
char const *arg, size_t argsize,
|
||||
struct quoting_options const *o)
|
||||
{
|
||||
unsigned char c;
|
||||
size_t i;
|
||||
size_t len;
|
||||
int quote_mark;
|
||||
size_t len = 0;
|
||||
char const *quote_string;
|
||||
size_t quote_string_len;
|
||||
struct quoting_options const *p = o ? o : &default_quoting_options;
|
||||
enum quoting_style quoting_style = p->style;
|
||||
# define STORE(c) \
|
||||
#define STORE(c) \
|
||||
do \
|
||||
{ \
|
||||
if (len < buffersize) \
|
||||
@ -151,18 +178,17 @@ quotearg_buffer (char *buffer, size_t buffersize,
|
||||
switch (quoting_style)
|
||||
{
|
||||
case shell_quoting_style:
|
||||
if (! (argsize == -1 ? arg[0] == '\0' : argsize == 0))
|
||||
if (! (argsize == (size_t) -1 ? arg[0] == '\0' : argsize == 0))
|
||||
{
|
||||
switch (arg[0])
|
||||
{
|
||||
case '#': case '~':
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
len = 0;
|
||||
for (i = 0; ; i++)
|
||||
{
|
||||
if (argsize == -1 ? arg[i] == '\0' : i == argsize)
|
||||
if (argsize == (size_t) -1 ? arg[i] == '\0' : i == argsize)
|
||||
goto done;
|
||||
|
||||
c = arg[i];
|
||||
@ -184,32 +210,40 @@ quotearg_buffer (char *buffer, size_t buffersize,
|
||||
|
||||
STORE (c);
|
||||
}
|
||||
|
||||
needs_quoting:;
|
||||
|
||||
len = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Fall through. */
|
||||
|
||||
case shell_always_quoting_style:
|
||||
quote_mark = '\'';
|
||||
STORE ('\'');
|
||||
quote_string = "'";
|
||||
quote_string_len = 1;
|
||||
break;
|
||||
|
||||
case c_quoting_style:
|
||||
quote_mark = '"';
|
||||
STORE ('"');
|
||||
quote_string = "\"";
|
||||
quote_string_len = 1;
|
||||
break;
|
||||
|
||||
case locale_quoting_style:
|
||||
for (quote_string = _("`"); *quote_string; quote_string++)
|
||||
STORE (*quote_string);
|
||||
quote_string = _("'");
|
||||
quote_string_len = strlen (quote_string);
|
||||
break;
|
||||
|
||||
default:
|
||||
quote_mark = 0;
|
||||
quote_string = 0;
|
||||
quote_string_len = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
len = 0;
|
||||
|
||||
if (quote_mark)
|
||||
STORE (quote_mark);
|
||||
|
||||
for (i = 0; ! (argsize == -1 ? arg[i] == '\0' : i == argsize); i++)
|
||||
for (i = 0; ! (argsize == (size_t) -1 ? arg[i] == '\0' : i == argsize); i++)
|
||||
{
|
||||
c = arg[i];
|
||||
|
||||
@ -230,6 +264,7 @@ quotearg_buffer (char *buffer, size_t buffersize,
|
||||
|
||||
case c_quoting_style:
|
||||
case escape_quoting_style:
|
||||
case locale_quoting_style:
|
||||
switch (c)
|
||||
{
|
||||
case '?': /* Do not generate trigraphs. */
|
||||
@ -242,42 +277,38 @@ quotearg_buffer (char *buffer, size_t buffersize,
|
||||
case '\r': c = 'r'; goto store_escape;
|
||||
case '\t': c = 't'; goto store_escape;
|
||||
case '\v': c = 'v'; goto store_escape;
|
||||
|
||||
case ' ':
|
||||
if (quoting_style == escape_quoting_style)
|
||||
goto store_escape;
|
||||
break;
|
||||
|
||||
case '"':
|
||||
if (quoting_style == c_quoting_style)
|
||||
goto store_escape;
|
||||
break;
|
||||
|
||||
|
||||
case ' ': break;
|
||||
|
||||
default:
|
||||
if (quote_string_len
|
||||
&& strncmp (arg + i, quote_string, quote_string_len) == 0)
|
||||
goto store_escape;
|
||||
if (!ISGRAPH (c))
|
||||
{
|
||||
STORE ('\\');
|
||||
STORE ('0' + (c >> 6));
|
||||
STORE ('0' + ((c >> 3) & 3));
|
||||
c = '0' + (c & 3);
|
||||
STORE ('0' + ((c >> 3) & 7));
|
||||
c = '0' + (c & 7);
|
||||
goto store_c;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (! (p->quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS))))
|
||||
goto store_c;
|
||||
|
||||
|
||||
store_escape:
|
||||
STORE ('\\');
|
||||
}
|
||||
|
||||
|
||||
store_c:
|
||||
STORE (c);
|
||||
}
|
||||
|
||||
if (quote_mark)
|
||||
STORE (quote_mark);
|
||||
if (quote_string)
|
||||
for (; *quote_string; quote_string++)
|
||||
STORE (*quote_string);
|
||||
|
||||
done:
|
||||
if (len < buffersize)
|
||||
@ -289,11 +320,13 @@ quotearg_buffer (char *buffer, size_t buffersize,
|
||||
OPTIONS specifies the quoting options.
|
||||
The returned value points to static storage that can be
|
||||
reused by the next call to this function with the same value of N.
|
||||
N must be nonnegative. */
|
||||
N must be nonnegative. N is deliberately declared with type `int'
|
||||
to allow for future extensions (using negative values). */
|
||||
static char *
|
||||
quotearg_n_options (int n, char const *arg, struct quoting_options *options)
|
||||
quotearg_n_options (int n, char const *arg,
|
||||
struct quoting_options const *options)
|
||||
{
|
||||
static unsigned nslots;
|
||||
static unsigned int nslots;
|
||||
static struct slotvec
|
||||
{
|
||||
size_t size;
|
||||
@ -328,7 +361,7 @@ quotearg_n_options (int n, char const *arg, struct quoting_options *options)
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n (int n, char const *arg)
|
||||
quotearg_n (unsigned int n, char const *arg)
|
||||
{
|
||||
return quotearg_n_options (n, arg, &default_quoting_options);
|
||||
}
|
||||
@ -339,6 +372,21 @@ quotearg (char const *arg)
|
||||
return quotearg_n (0, arg);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n_style (unsigned int n, enum quoting_style s, char const *arg)
|
||||
{
|
||||
struct quoting_options o;
|
||||
o.style = s;
|
||||
memset (o.quote_these_too, 0, sizeof o.quote_these_too);
|
||||
return quotearg_n_options (n, arg, &o);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_style (enum quoting_style s, char const *arg)
|
||||
{
|
||||
return quotearg_n_style (0, s, arg);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_char (char const *arg, char ch)
|
||||
{
|
||||
|
||||
28
quotearg.h
28
quotearg.h
@ -1,5 +1,5 @@
|
||||
/* quotearg.h - quote arguments for output
|
||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999 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
|
||||
@ -24,17 +24,18 @@ enum quoting_style
|
||||
shell_quoting_style, /* --quoting-style=shell */
|
||||
shell_always_quoting_style, /* --quoting-style=shell-always */
|
||||
c_quoting_style, /* --quoting-style=c */
|
||||
escape_quoting_style /* --quoting-style=escape */
|
||||
escape_quoting_style, /* --quoting-style=escape */
|
||||
locale_quoting_style /* --quoting-style=locale */
|
||||
};
|
||||
|
||||
/* For now, --quoting-style=literal is the default, but
|
||||
this is planned to change to --quoting-style=shell in the future. */
|
||||
/* For now, --quoting-style=literal is the default, but this may change. */
|
||||
#ifndef DEFAULT_QUOTING_STYLE
|
||||
#define DEFAULT_QUOTING_STYLE literal_quoting_style
|
||||
# define DEFAULT_QUOTING_STYLE literal_quoting_style
|
||||
#endif
|
||||
|
||||
/* Names of quoting styles. */
|
||||
/* Names of quoting styles and their corresponding values. */
|
||||
extern char const *const quoting_style_args[];
|
||||
extern enum quoting_style const quoting_style_vals[];
|
||||
|
||||
struct quoting_options;
|
||||
|
||||
@ -69,7 +70,7 @@ void set_quoting_style PARAMS ((struct quoting_options *o,
|
||||
0 (the default) and 1 (which means to quote the character even if
|
||||
it would not otherwise be quoted). */
|
||||
int set_char_quoting PARAMS ((struct quoting_options *o, char c, int i));
|
||||
|
||||
|
||||
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
|
||||
argument ARG (of size ARGSIZE), using O to control quoting.
|
||||
If O is null, use the default.
|
||||
@ -87,11 +88,20 @@ size_t quotearg_buffer PARAMS ((char *buffer, size_t buffersize,
|
||||
The returned value points to static storage that can be
|
||||
reused by the next call to this function with the same value of N.
|
||||
N must be nonnegative. */
|
||||
char *quotearg_n PARAMS ((int n, char const *arg));
|
||||
char *quotearg_n PARAMS ((unsigned int n, char const *arg));
|
||||
|
||||
/* Equivalent to quotearg_n (ARG, 0). */
|
||||
/* Equivalent to quotearg_n (0, ARG). */
|
||||
char *quotearg PARAMS ((char const *arg));
|
||||
|
||||
/* Use style S and storage slot N to return a quoted version of the string ARG.
|
||||
This is like quotearg_n (N, ARG), except that it uses S with no other
|
||||
options to specify the quoting method. */
|
||||
char *quotearg_n_style PARAMS ((unsigned int n, enum quoting_style s,
|
||||
char const *arg));
|
||||
|
||||
/* Equivalent to quotearg_n_style (0, S, ARG). */
|
||||
char *quotearg_style PARAMS ((enum quoting_style s, char const *arg));
|
||||
|
||||
/* Like quotearg (ARG), except also quote any instances of CH. */
|
||||
char *quotearg_char PARAMS ((char const *arg, char ch));
|
||||
|
||||
|
||||
19
rename.c
19
rename.c
@ -38,12 +38,9 @@ extern int errno;
|
||||
Return 0 if successful, -1 if not. */
|
||||
|
||||
int
|
||||
rename (from, to)
|
||||
char *from;
|
||||
char *to;
|
||||
rename (char *from, char *to)
|
||||
{
|
||||
struct stat from_stats, to_stats;
|
||||
int pid, status;
|
||||
|
||||
if (stat (from, &from_stats))
|
||||
return -1;
|
||||
@ -76,23 +73,27 @@ rename (from, to)
|
||||
if (S_ISDIR (from_stats.st_mode))
|
||||
{
|
||||
/* Need a setuid root process to link and unlink directories. */
|
||||
pid = fork ();
|
||||
int status;
|
||||
pid_t pid = fork ();
|
||||
switch (pid)
|
||||
{
|
||||
case -1: /* Error. */
|
||||
error (1, errno, "cannot fork");
|
||||
return -1; /* errno already set */
|
||||
|
||||
case 0: /* Child. */
|
||||
execl (MVDIR, "mvdir", from, to, (char *) 0);
|
||||
error (255, errno, "cannot run `%s'", MVDIR);
|
||||
_exit (1);
|
||||
|
||||
default: /* Parent. */
|
||||
while (wait (&status) != pid)
|
||||
/* Do nothing. */ ;
|
||||
|
||||
errno = 0; /* mvdir printed the system error message. */
|
||||
if (status)
|
||||
return -1;
|
||||
{
|
||||
/* MVDIR failed. */
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
87
rmdir.c
Normal file
87
rmdir.c
Normal file
@ -0,0 +1,87 @@
|
||||
/* BSD compatible remove directory function for System V
|
||||
Copyright (C) 1988, 1990 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. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#if STAT_MACROS_BROKEN
|
||||
# undef S_ISDIR
|
||||
#endif
|
||||
|
||||
#if !defined(S_ISDIR) && defined(S_IFDIR)
|
||||
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
/* rmdir adapted from GNU tar. */
|
||||
|
||||
/* Remove directory DPATH.
|
||||
Return 0 if successful, -1 if not. */
|
||||
|
||||
int
|
||||
rmdir (dpath)
|
||||
char *dpath;
|
||||
{
|
||||
pid_t cpid;
|
||||
int status;
|
||||
struct stat statbuf;
|
||||
|
||||
if (stat (dpath, &statbuf) != 0)
|
||||
return -1; /* errno already set */
|
||||
|
||||
if (!S_ISDIR (statbuf.st_mode))
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
cpid = fork ();
|
||||
switch (cpid)
|
||||
{
|
||||
case -1: /* cannot fork */
|
||||
return -1; /* errno already set */
|
||||
|
||||
case 0: /* child process */
|
||||
execl ("/bin/rmdir", "rmdir", dpath, (char *) 0);
|
||||
_exit (1);
|
||||
|
||||
default: /* parent process */
|
||||
|
||||
/* Wait for kid to finish. */
|
||||
|
||||
while (wait (&status) != cpid)
|
||||
/* Do nothing. */ ;
|
||||
|
||||
if (status)
|
||||
{
|
||||
|
||||
/* /bin/rmdir failed. */
|
||||
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
243
util.c
243
util.c
@ -1,30 +1,29 @@
|
||||
/* utility functions for `patch' */
|
||||
|
||||
/* $Id: util.c,v 1.25 1998/03/15 14:44:47 eggert Exp $ */
|
||||
/* $Id: util.c,v 1.27 1999/08/30 06:20:08 eggert Exp $ */
|
||||
|
||||
/*
|
||||
Copyright 1986 Larry Wall
|
||||
Copyright 1992, 1993, 1997, 1998 Free Software Foundation, Inc.
|
||||
/* Copyright 1986 Larry Wall
|
||||
Copyright 1992, 1993, 1997-1998, 1999 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 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.
|
||||
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.
|
||||
*/
|
||||
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. */
|
||||
|
||||
#define XTERN extern
|
||||
#include <common.h>
|
||||
#include <backupfile.h>
|
||||
#include <basename.h>
|
||||
#include <quotearg.h>
|
||||
#include <quotesys.h>
|
||||
#include <version.h>
|
||||
@ -70,20 +69,9 @@ static void makedirs PARAMS ((char *));
|
||||
FROM_NEEDS_REMOVAL must be nonnull if FROM is nonnull.
|
||||
Back up TO if BACKUP is nonzero. */
|
||||
|
||||
#ifdef __STDC__
|
||||
/* If mode_t doesn't promote to itself, we can't use old-style definition. */
|
||||
void
|
||||
move_file (char const *from, int volatile *from_needs_removal,
|
||||
char *to, mode_t mode, int backup)
|
||||
#else
|
||||
void
|
||||
move_file (from, from_needs_removal, to, mode, backup)
|
||||
char const *from;
|
||||
int volatile *from_needs_removal;
|
||||
char *to;
|
||||
mode_t mode;
|
||||
int backup;
|
||||
#endif
|
||||
{
|
||||
struct stat to_st;
|
||||
int to_errno = ! backup ? -1 : stat (to, &to_st) == 0 ? 0 : errno;
|
||||
@ -116,7 +104,7 @@ move_file (from, from_needs_removal, to, mode, backup)
|
||||
}
|
||||
else
|
||||
{
|
||||
bakname = find_backup_file_name (to);
|
||||
bakname = find_backup_file_name (to, backup_type);
|
||||
if (!bakname)
|
||||
memory_fatal ();
|
||||
}
|
||||
@ -213,17 +201,8 @@ move_file (from, from_needs_removal, to, mode, backup)
|
||||
/* Create FILE with OPEN_FLAGS, and with MODE adjusted so that
|
||||
we can read and write the file and that the file is not executable.
|
||||
Return the file descriptor. */
|
||||
#ifdef __STDC__
|
||||
/* If mode_t doesn't promote to itself, we can't use old-style definition. */
|
||||
int
|
||||
create_file (char const *file, int open_flags, mode_t mode)
|
||||
#else
|
||||
int
|
||||
create_file (file, open_flags, mode)
|
||||
char const *file;
|
||||
int open_flags;
|
||||
mode_t mode;
|
||||
#endif
|
||||
{
|
||||
int fd;
|
||||
mode |= S_IRUSR | S_IWUSR;
|
||||
@ -238,18 +217,8 @@ create_file (file, open_flags, mode)
|
||||
|
||||
/* Copy a file. */
|
||||
|
||||
#ifdef __STDC__
|
||||
/* If mode_t doesn't promote to itself, we can't use old-style definition. */
|
||||
void
|
||||
copy_file (char const *from, char const *to, int to_flags, mode_t mode)
|
||||
#else
|
||||
void
|
||||
copy_file (from, to, to_flags, mode)
|
||||
char const *from;
|
||||
char const *to;
|
||||
int to_flags;
|
||||
mode_t mode;
|
||||
#endif
|
||||
{
|
||||
int tofd;
|
||||
int fromfd;
|
||||
@ -296,12 +265,8 @@ static char const CLEARTOOL_CO[] = "cleartool co -unr -nc ";
|
||||
(but set *DIFFBUF to 0 if the diff operation is meaningless).
|
||||
*GETBUF and *DIFFBUF must be freed by the caller. */
|
||||
char const *
|
||||
version_controller (filename, readonly, filestat, getbuf, diffbuf)
|
||||
char const *filename;
|
||||
int readonly;
|
||||
struct stat const *filestat;
|
||||
char **getbuf;
|
||||
char **diffbuf;
|
||||
version_controller (char const *filename, int readonly,
|
||||
struct stat const *filestat, char **getbuf, char **diffbuf)
|
||||
{
|
||||
struct stat cstat;
|
||||
char const *filebase = base_name (filename);
|
||||
@ -409,13 +374,8 @@ version_controller (filename, readonly, filestat, getbuf, diffbuf)
|
||||
Store the resulting file status into *FILESTAT.
|
||||
Return nonzero if successful. */
|
||||
int
|
||||
version_get (filename, cs, exists, readonly, getbuf, filestat)
|
||||
char const *filename;
|
||||
char const *cs;
|
||||
int exists;
|
||||
int readonly;
|
||||
char const *getbuf;
|
||||
struct stat *filestat;
|
||||
version_get (char const *filename, char const *cs, int exists, int readonly,
|
||||
char const *getbuf, struct stat *filestat)
|
||||
{
|
||||
if (patch_get < 0)
|
||||
{
|
||||
@ -448,9 +408,7 @@ version_get (filename, cs, exists, readonly, getbuf, filestat)
|
||||
/* Allocate a unique area for a string. */
|
||||
|
||||
char *
|
||||
savebuf (s, size)
|
||||
register char const *s;
|
||||
register size_t size;
|
||||
savebuf (register char const *s, register size_t size)
|
||||
{
|
||||
register char *rv;
|
||||
|
||||
@ -469,16 +427,13 @@ savebuf (s, size)
|
||||
}
|
||||
|
||||
char *
|
||||
savestr(s)
|
||||
char const *s;
|
||||
savestr (char const *s)
|
||||
{
|
||||
return savebuf (s, strlen (s) + 1);
|
||||
}
|
||||
|
||||
void
|
||||
remove_prefix (p, prefixlen)
|
||||
char *p;
|
||||
size_t prefixlen;
|
||||
remove_prefix (char *p, size_t prefixlen)
|
||||
{
|
||||
char const *s = p + prefixlen;
|
||||
while ((*p++ = *s++))
|
||||
@ -486,9 +441,7 @@ remove_prefix (p, prefixlen)
|
||||
}
|
||||
|
||||
char *
|
||||
format_linenum (numbuf, n)
|
||||
char numbuf[LINENUM_LENGTH_BOUND + 1];
|
||||
LINENUM n;
|
||||
format_linenum (char numbuf[LINENUM_LENGTH_BOUND + 1], LINENUM n)
|
||||
{
|
||||
char *p = numbuf + LINENUM_LENGTH_BOUND;
|
||||
*p = '\0';
|
||||
@ -513,12 +466,8 @@ format_linenum (numbuf, n)
|
||||
|
||||
#if !HAVE_VPRINTF
|
||||
#define vfprintf my_vfprintf
|
||||
static int vfprintf PARAMS ((FILE *, char const *, va_list));
|
||||
static int
|
||||
vfprintf (stream, format, args)
|
||||
FILE *stream;
|
||||
char const *format;
|
||||
va_list args;
|
||||
vfprintf (FILE *stream, char const *format, va_list args)
|
||||
{
|
||||
#if !HAVE_DOPRNT && HAVE__DOPRINTF
|
||||
# define _doprnt _doprintf
|
||||
@ -536,15 +485,8 @@ vfprintf (stream, format, args)
|
||||
|
||||
/* Terminal output, pun intended. */
|
||||
|
||||
#ifdef __STDC__
|
||||
void
|
||||
fatal (char const *format, ...)
|
||||
#else
|
||||
/*VARARGS1*/ void
|
||||
fatal (format, va_alist)
|
||||
char const *format;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list args;
|
||||
fprintf (stderr, "%s: **** ", program_name);
|
||||
@ -557,34 +499,27 @@ fatal (format, va_alist)
|
||||
}
|
||||
|
||||
void
|
||||
memory_fatal ()
|
||||
memory_fatal (void)
|
||||
{
|
||||
fatal ("out of memory");
|
||||
}
|
||||
|
||||
void
|
||||
read_fatal ()
|
||||
read_fatal (void)
|
||||
{
|
||||
pfatal ("read error");
|
||||
}
|
||||
|
||||
void
|
||||
write_fatal ()
|
||||
write_fatal (void)
|
||||
{
|
||||
pfatal ("write error");
|
||||
}
|
||||
|
||||
/* Say something from patch, something from the system, then silence . . . */
|
||||
|
||||
#ifdef __STDC__
|
||||
void
|
||||
pfatal (char const *format, ...)
|
||||
#else
|
||||
/*VARARGS1*/ void
|
||||
pfatal (format, va_alist)
|
||||
char const *format;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
int errnum = errno;
|
||||
va_list args;
|
||||
@ -601,15 +536,8 @@ pfatal (format, va_alist)
|
||||
|
||||
/* Tell the user something. */
|
||||
|
||||
#ifdef __STDC__
|
||||
void
|
||||
say (char const *format, ...)
|
||||
#else
|
||||
/*VARARGS1*/ void
|
||||
say (format, va_alist)
|
||||
char const *format;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list args;
|
||||
vararg_start (args, format);
|
||||
@ -620,15 +548,8 @@ say (format, va_alist)
|
||||
|
||||
/* Get a response from the user, somehow or other. */
|
||||
|
||||
#ifdef __STDC__
|
||||
void
|
||||
ask (char const *format, ...)
|
||||
#else
|
||||
/*VARARGS1*/ void
|
||||
ask (format, va_alist)
|
||||
char const *format;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
static int ttyfd = -2;
|
||||
int r;
|
||||
@ -686,14 +607,8 @@ ask (format, va_alist)
|
||||
|
||||
/* Return nonzero if it OK to reverse a patch. */
|
||||
|
||||
#ifdef __STDC__
|
||||
int
|
||||
ok_to_reverse (char const *format, ...)
|
||||
#else
|
||||
ok_to_reverse (format, va_alist)
|
||||
char const *format;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
int r = 0;
|
||||
|
||||
@ -798,8 +713,7 @@ static sigset_t signals_to_block;
|
||||
#if ! HAVE_SIGACTION
|
||||
static RETSIGTYPE fatal_exit_handler PARAMS ((int)) __attribute__ ((noreturn));
|
||||
static RETSIGTYPE
|
||||
fatal_exit_handler (sig)
|
||||
int sig;
|
||||
fatal_exit_handler (int sig)
|
||||
{
|
||||
signal (sig, SIG_IGN);
|
||||
fatal_exit (sig);
|
||||
@ -807,8 +721,7 @@ fatal_exit_handler (sig)
|
||||
#endif
|
||||
|
||||
void
|
||||
set_signals(reset)
|
||||
int reset;
|
||||
set_signals (int reset)
|
||||
{
|
||||
int i;
|
||||
#if HAVE_SIGACTION
|
||||
@ -861,7 +774,7 @@ int reset;
|
||||
/* How to handle certain events when in a critical region. */
|
||||
|
||||
void
|
||||
ignore_signals()
|
||||
ignore_signals (void)
|
||||
{
|
||||
#if HAVE_SIGPROCMASK || HAVE_SIGSETMASK
|
||||
sigprocmask (SIG_BLOCK, &signals_to_block, &initial_signal_mask);
|
||||
@ -874,8 +787,7 @@ ignore_signals()
|
||||
}
|
||||
|
||||
void
|
||||
exit_with_signal (sig)
|
||||
int sig;
|
||||
exit_with_signal (int sig)
|
||||
{
|
||||
sigset_t s;
|
||||
signal (sig, SIG_DFL);
|
||||
@ -887,8 +799,7 @@ exit_with_signal (sig)
|
||||
}
|
||||
|
||||
int
|
||||
systemic (command)
|
||||
char const *command;
|
||||
systemic (char const *command)
|
||||
{
|
||||
if (debug & 8)
|
||||
say ("+ %s\n", command);
|
||||
@ -896,66 +807,11 @@ systemic (command)
|
||||
return system (command);
|
||||
}
|
||||
|
||||
#if !HAVE_MKDIR
|
||||
/* These mkdir and rmdir substitutes are good enough for `patch';
|
||||
they are not general emulators. */
|
||||
|
||||
static int doprogram PARAMS ((char const *, char const *));
|
||||
static int mkdir PARAMS ((char const *, mode_t));
|
||||
static int rmdir PARAMS ((char const *));
|
||||
|
||||
static int
|
||||
doprogram (program, arg)
|
||||
char const *program;
|
||||
char const *arg;
|
||||
{
|
||||
int result;
|
||||
static char const DISCARD_OUTPUT[] = " 2>/dev/null";
|
||||
size_t program_len = strlen (program);
|
||||
char *cmd = xmalloc (program_len + 1 + quote_system_arg (0, arg)
|
||||
+ sizeof DISCARD_OUTPUT);
|
||||
char *p = cmd;
|
||||
strcpy (p, program);
|
||||
p += program_len;
|
||||
*p++ = ' ';
|
||||
p += quote_system_arg (p, arg);
|
||||
strcpy (p, DISCARD_OUTPUT);
|
||||
result = systemic (cmd);
|
||||
free (cmd);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef __STDC__
|
||||
/* If mode_t doesn't promote to itself, we can't use old-style definition. */
|
||||
static int
|
||||
mkdir (char const *path, mode_t mode)
|
||||
#else
|
||||
static int
|
||||
mkdir (path, mode)
|
||||
char const *path;
|
||||
mode_t mode; /* ignored */
|
||||
#endif
|
||||
{
|
||||
return doprogram ("mkdir", path);
|
||||
}
|
||||
|
||||
static int
|
||||
rmdir (path)
|
||||
char const *path;
|
||||
{
|
||||
int result = doprogram ("rmdir", path);
|
||||
errno = EEXIST;
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Replace '/' with '\0' in FILENAME if it marks a place that
|
||||
needs testing for the existence of directory. Return the address
|
||||
of the last location replaced, or 0 if none were replaced. */
|
||||
static char *replace_slashes PARAMS ((char *));
|
||||
static char *
|
||||
replace_slashes (filename)
|
||||
char *filename;
|
||||
replace_slashes (char *filename)
|
||||
{
|
||||
char *f;
|
||||
char *last_location_replaced = 0;
|
||||
@ -997,8 +853,7 @@ replace_slashes (filename)
|
||||
Ignore the last element of `filename'. */
|
||||
|
||||
static void
|
||||
makedirs (filename)
|
||||
register char *filename;
|
||||
makedirs (register char *filename)
|
||||
{
|
||||
register char *f;
|
||||
register char *flim = replace_slashes (filename);
|
||||
@ -1026,8 +881,7 @@ makedirs (filename)
|
||||
Ignore errors, since the path may contain ".."s, and when there
|
||||
is an EEXIST failure the system may return some other error number. */
|
||||
void
|
||||
removedirs (filename)
|
||||
char *filename;
|
||||
removedirs (char *filename)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
@ -1051,7 +905,7 @@ removedirs (filename)
|
||||
static time_t initial_time;
|
||||
|
||||
void
|
||||
init_time ()
|
||||
init_time (void)
|
||||
{
|
||||
time (&initial_time);
|
||||
}
|
||||
@ -1059,10 +913,7 @@ init_time ()
|
||||
/* Make filenames more reasonable. */
|
||||
|
||||
char *
|
||||
fetchname (at, strip_leading, pstamp)
|
||||
char *at;
|
||||
int strip_leading;
|
||||
time_t *pstamp;
|
||||
fetchname (char *at, int strip_leading, time_t *pstamp)
|
||||
{
|
||||
char *name;
|
||||
register char *t;
|
||||
@ -1117,15 +968,20 @@ time_t *pstamp;
|
||||
if (!*name)
|
||||
return 0;
|
||||
|
||||
/* Ignore the name if it doesn't have enough slashes to strip off,
|
||||
or if it is "/dev/null". */
|
||||
if (0 < sleading || strcmp (at, "/dev/null") == 0)
|
||||
/* If the name is "/dev/null", ignore the name and mark the file
|
||||
as being nonexistent. The name "/dev/null" appears in patches
|
||||
regardless of how NULL_DEVICE is spelled. */
|
||||
if (strcmp (at, "/dev/null") == 0)
|
||||
{
|
||||
if (pstamp)
|
||||
*pstamp = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Ignore the name if it doesn't have enough slashes to strip off. */
|
||||
if (0 < sleading)
|
||||
return 0;
|
||||
|
||||
if (pstamp)
|
||||
*pstamp = stamp;
|
||||
|
||||
@ -1133,10 +989,7 @@ time_t *pstamp;
|
||||
}
|
||||
|
||||
void
|
||||
Fseek (stream, offset, ptrname)
|
||||
FILE *stream;
|
||||
file_offset offset;
|
||||
int ptrname;
|
||||
Fseek (FILE *stream, file_offset offset, int ptrname)
|
||||
{
|
||||
if (file_seek (stream, offset, ptrname) != 0)
|
||||
pfatal ("fseek");
|
||||
|
||||
4
util.h
4
util.h
@ -1,11 +1,13 @@
|
||||
/* utility functions for `patch' */
|
||||
|
||||
/* $Id: util.h,v 1.16 1998/03/15 14:44:47 eggert Exp $ */
|
||||
/* $Id: util.h,v 1.17 1999/08/30 06:20:08 eggert Exp $ */
|
||||
|
||||
/* An upper bound on the print length of a signed decimal line number.
|
||||
Add one for the sign. */
|
||||
#define LINENUM_LENGTH_BOUND (sizeof (LINENUM) * CHAR_BIT / 3 + 1)
|
||||
|
||||
XTERN enum backup_type backup_type;
|
||||
|
||||
int ok_to_reverse PARAMS ((char const *, ...)) __attribute__ ((format (printf, 1, 2)));
|
||||
void ask PARAMS ((char const *, ...)) __attribute__ ((format (printf, 1, 2)));
|
||||
void say PARAMS ((char const *, ...)) __attribute__ ((format (printf, 1, 2)));
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Print the version number. */
|
||||
|
||||
/* $Id: version.c,v 1.6 1998/03/15 14:44:47 eggert Exp $ */
|
||||
/* $Id: version.c,v 1.7 1999/08/30 06:20:08 eggert Exp $ */
|
||||
|
||||
#define XTERN extern
|
||||
#include <common.h>
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
static char const copyright_string[] = "\
|
||||
Copyright 1984-1988 Larry Wall\n\
|
||||
Copyright 1989-1998 Free Software Foundation, Inc.";
|
||||
Copyright 1989-1999 Free Software Foundation, Inc.";
|
||||
|
||||
static char const free_software_msgid[] = "\
|
||||
This program comes with NO WARRANTY, to the extent permitted by law.\n\
|
||||
@ -20,10 +20,10 @@ under the terms of the GNU General Public License.\n\
|
||||
For more information about these matters, see the file named COPYING.";
|
||||
|
||||
static char const authorship_msgid[] = "\
|
||||
written by Larry Wall with lots o' patches by Paul Eggert";
|
||||
written by Larry Wall and Paul Eggert";
|
||||
|
||||
void
|
||||
version()
|
||||
version (void)
|
||||
{
|
||||
printf ("%s %s\n%s\n\n%s\n\n%s\n", program_name, PATCH_VERSION,
|
||||
copyright_string, free_software_msgid, authorship_msgid);
|
||||
|
||||
53
xalloc.h
53
xalloc.h
@ -1,21 +1,52 @@
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
/* xalloc.h -- malloc with out-of-memory checking
|
||||
Copyright (C) 1990-1998, 1999 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 XALLOC_H_
|
||||
# define XALLOC_H_
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Exit value when the requested amount of memory is not available.
|
||||
The caller may set it to some other value. */
|
||||
It is initialized to EXIT_FAILURE, but the caller may set it to
|
||||
some other value. */
|
||||
extern int xalloc_exit_failure;
|
||||
|
||||
/* FIXME: describe */
|
||||
extern char *const xalloc_msg_memory_exhausted;
|
||||
|
||||
/* FIXME: describe */
|
||||
/* If this pointer is non-zero, run the specified function upon each
|
||||
allocation failure. It is initialized to zero. */
|
||||
extern void (*xalloc_fail_func) ();
|
||||
|
||||
/* If XALLOC_FAIL_FUNC is undefined or a function that returns, this
|
||||
message must be non-NULL. It is translated via gettext.
|
||||
The default value is "Memory exhausted". */
|
||||
extern char *const xalloc_msg_memory_exhausted;
|
||||
|
||||
void *xmalloc PARAMS ((size_t n));
|
||||
void *xcalloc PARAMS ((size_t n, size_t s));
|
||||
void *xrealloc PARAMS ((void *p, size_t n));
|
||||
|
||||
# define XMALLOC(Type, N_bytes) ((Type *) xmalloc (sizeof (Type) * (N_bytes)))
|
||||
# define XCALLOC(Type, N_bytes) ((Type *) xcalloc (sizeof (Type), (N_bytes)))
|
||||
# define XREALLOC(Ptr, Type, N_bytes) \
|
||||
((Type *) xrealloc ((void *) (Ptr), sizeof (Type) * (N_bytes)))
|
||||
|
||||
#endif /* !XALLOC_H_ */
|
||||
|
||||
40
xmalloc.c
40
xmalloc.c
@ -1,5 +1,5 @@
|
||||
/* xmalloc.c -- malloc with out of memory checking
|
||||
Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1997, 98, 99 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
|
||||
@ -46,13 +46,6 @@ void free ();
|
||||
# define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
/* Prototypes for functions defined here. */
|
||||
#if defined (__STDC__) && __STDC__
|
||||
void *xmalloc (size_t n);
|
||||
void *xcalloc (size_t n, size_t s);
|
||||
void *xrealloc (void *p, size_t n);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DONE_WORKING_MALLOC_CHECK
|
||||
you must run the autoconf test for a properly working malloc -- see malloc.m4
|
||||
#endif
|
||||
@ -65,31 +58,25 @@ you must run the autoconf test for a properly working realloc -- see realloc.m4
|
||||
The caller may set it to some other value. */
|
||||
int xalloc_exit_failure = EXIT_FAILURE;
|
||||
|
||||
/* FIXME: describe */
|
||||
char *const xalloc_msg_memory_exhausted = N_("Memory exhausted");
|
||||
|
||||
/* FIXME: describe */
|
||||
/* If non NULL, call this function when memory is exhausted. */
|
||||
void (*xalloc_fail_func) () = 0;
|
||||
|
||||
#if __STDC__ && (HAVE_VPRINTF || HAVE_DOPRNT)
|
||||
void error (int, int, const char *, ...);
|
||||
#else
|
||||
void error ();
|
||||
#endif
|
||||
/* If XALLOC_FAIL_FUNC is NULL, or does return, display this message
|
||||
before exiting when memory is exhausted. Goes through gettext. */
|
||||
char *const xalloc_msg_memory_exhausted = N_("Memory exhausted");
|
||||
|
||||
static void
|
||||
xalloc_fail ()
|
||||
xalloc_fail (void)
|
||||
{
|
||||
if (xalloc_fail_func)
|
||||
(*xalloc_fail_func) ();
|
||||
error (xalloc_exit_failure, 0, xalloc_msg_memory_exhausted);
|
||||
error (xalloc_exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted));
|
||||
}
|
||||
|
||||
/* Allocate N bytes of memory dynamically, with error checking. */
|
||||
|
||||
void *
|
||||
xmalloc (n)
|
||||
size_t n;
|
||||
xmalloc (size_t n)
|
||||
{
|
||||
void *p;
|
||||
|
||||
@ -104,9 +91,7 @@ xmalloc (n)
|
||||
If P is NULL, run xmalloc. */
|
||||
|
||||
void *
|
||||
xrealloc (p, n)
|
||||
void *p;
|
||||
size_t n;
|
||||
xrealloc (void *p, size_t n)
|
||||
{
|
||||
p = realloc (p, n);
|
||||
if (p == 0)
|
||||
@ -114,13 +99,10 @@ xrealloc (p, n)
|
||||
return p;
|
||||
}
|
||||
|
||||
#ifdef NOT_USED
|
||||
|
||||
/* Allocate memory for N elements of S bytes, with error checking. */
|
||||
|
||||
void *
|
||||
xcalloc (n, s)
|
||||
size_t n, s;
|
||||
xcalloc (size_t n, size_t s)
|
||||
{
|
||||
void *p;
|
||||
|
||||
@ -129,5 +111,3 @@ xcalloc (n, s)
|
||||
xalloc_fail ();
|
||||
return p;
|
||||
}
|
||||
|
||||
#endif /* NOT_USED */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user