mirror of
https://https.git.savannah.gnu.org/git/patch.git
synced 2026-01-27 01:44:34 +00:00
Sync with gnulib
(Imported from RCS by Andreas Gruenbacher)
This commit is contained in:
parent
ae06fb41e2
commit
7a5222a06d
23
ChangeLog
23
ChangeLog
@ -1,8 +1,25 @@
|
||||
2003-07-02 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* pch.c (intuit_diff_type): If a unified-diff header line contains
|
||||
trailing CR, strip CR from each body line. This corrects a bug
|
||||
introduced in the 2003-05-18 patch. Bug reported by Andreas
|
||||
Gruenbacher.
|
||||
|
||||
* mkdir.c, rmdir.c, m4/rmdir.m4: Remove; we no longer
|
||||
need to worry about ancient hosts that lack these functions.
|
||||
|
||||
* addext.c, backupfile.c, backupfile.h, dirname.h, m4/backupfile.m4,
|
||||
m4/onceonly.m4, m4/quote.m4, malloc.c, quote,c, quote.h, realloc.c,
|
||||
strcasecmp.c, xalloc.h, xmalloc.c: Sync with gnulib.
|
||||
* stdbool_.h: Renamed from stdbool.h.in; all uses changed.
|
||||
This renaming is imported from gnulib.
|
||||
* m4/strcase.m4: New file, imported from gnulib.
|
||||
|
||||
* Makefile.in (LIBSRCS): Remove mkdir.c and rmdir.c.
|
||||
(stdbool.h): Put output into temporary file and then rename it;
|
||||
this change is imported from gnulib.
|
||||
(mostlyclean): Clean stdbool.h-t too.
|
||||
(ACINCLUDE_INPUTS): Remove rmdir.m4. Add strcase.m4.
|
||||
* configure.ac (gl_FUNC_RMDIR): Remove.
|
||||
(jm_PREREQ_ADDEXT): Remove; now down by gl_BACKUPFILE.
|
||||
(gl_STRCASE, gl_XALLOC): Add.
|
||||
@ -169,15 +186,15 @@
|
||||
* configure.ac (AC_PROG_CC_STDC): Add.
|
||||
* util.c (vararg_start): Remove. All uses changed to va_start.
|
||||
Always include <stdarg.h>.
|
||||
|
||||
|
||||
* configure.ac (AC_CANONICAL_HOST): Remove.
|
||||
(AC_REPLACE_FUNCS): Add strncasecmp.
|
||||
(AC_CHECK_DECLS): Add mktemp.
|
||||
|
||||
|
||||
* patch.c (main): Remove useless prototype decl.
|
||||
(mktemp): Don't declare if HAVE_DECL_MKTEMP || defined mktemp.
|
||||
(make_temp): Now accepts char, not int.
|
||||
|
||||
|
||||
2002-05-26 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* patch.c (not_defined): Prepend newline. All uses changed.
|
||||
|
||||
17
Makefile.in
17
Makefile.in
@ -61,8 +61,8 @@ CONFIG_STATUS = config.status
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
LIBSRCS = error.c malloc.c memchr.c mkdir.c \
|
||||
realloc.c rmdir.c strcasecmp.c strncasecmp.c
|
||||
LIBSRCS = error.c malloc.c memchr.c \
|
||||
realloc.c strcasecmp.c strncasecmp.c
|
||||
SRCS = $(LIBSRCS) \
|
||||
addext.c argmatch.c backupfile.c \
|
||||
basename.c dirname.c \
|
||||
@ -87,7 +87,7 @@ HDRS = argmatch.h backupfile.h common.h dirname.h \
|
||||
MISC = AUTHORS COPYING ChangeLog INSTALL Makefile.in NEWS README \
|
||||
aclocal.m4 \
|
||||
config.hin configure configure.ac \
|
||||
install-sh mkinstalldirs patch.man stdbool.h.in
|
||||
install-sh mkinstalldirs patch.man stdbool_.h
|
||||
DISTFILES = $(MISC) $(SRCS) $(HDRS)
|
||||
DISTFILES_M4 = $(ACINCLUDE_INPUTS)
|
||||
DISTFILES_PC = pc/chdirsaf.c
|
||||
@ -133,9 +133,9 @@ configure: configure.ac $(srcdir)/aclocal.m4
|
||||
cd $(srcdir) && autoconf
|
||||
config.hin: configure.ac $(srcdir)/aclocal.m4
|
||||
cd $(srcdir) && rm -f config.hin && autoheader
|
||||
stdbool.h: stdbool.h.in
|
||||
sed -e 's/@''HAVE__BOOL''@/@HAVE__BOOL@/g' \
|
||||
<$(srcdir)/stdbool.h.in >stdbool.h
|
||||
stdbool.h: stdbool_.h
|
||||
sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool_.h > stdbool.h-t
|
||||
mv stdbool.h-t stdbool.h
|
||||
|
||||
M4DIR = $(srcdir)/m4
|
||||
ACINCLUDE_INPUTS = \
|
||||
@ -154,9 +154,9 @@ ACINCLUDE_INPUTS = \
|
||||
$(M4DIR)/quote.m4 \
|
||||
$(M4DIR)/quotearg.m4 \
|
||||
$(M4DIR)/realloc.m4 \
|
||||
$(M4DIR)/rmdir.m4 \
|
||||
$(M4DIR)/setmode.m4 \
|
||||
$(M4DIR)/stdbool.m4 \
|
||||
$(M4DIR)/strcase.m4 \
|
||||
$(M4DIR)/unlocked-io.m4 \
|
||||
$(M4DIR)/utimbuf.m4 \
|
||||
$(M4DIR)/xalloc.m4
|
||||
@ -168,7 +168,7 @@ TAGS: $(HDRS) $(SRCS)
|
||||
etags $(HDRS) $(SRCS)
|
||||
|
||||
mostlyclean::
|
||||
rm -f core* *core *.$(OBJEXT) *_.c stdbool.h
|
||||
rm -f core* *core *.$(OBJEXT) *_.c stdbool.h stdbool.h-t
|
||||
|
||||
clean:: mostlyclean
|
||||
rm -f patch$(EXEEXT)
|
||||
@ -206,7 +206,6 @@ error.$(OBJEXT): error.h gettext.h unlocked-io.h
|
||||
getopt.$(OBJEXT) getopt1.$(OBJEXT): getopt.h
|
||||
inp.$(OBJEXT): backupfile.h $(COMMON) inp.h pch.h quotearg.h util.h xalloc.h
|
||||
maketime.$(OBJEXT): maketime.h partime.h
|
||||
mkdir.$(OBJEXT): dirname.h xalloc.h
|
||||
partime.$(OBJEXT): partime.h
|
||||
patch.$(OBJEXT): argmatch.h backupfile.h $(COMMON) getopt.h inp.h \
|
||||
pch.h quotearg.h util.h version.h xalloc.h
|
||||
|
||||
12
addext.c
12
addext.c
@ -31,19 +31,13 @@
|
||||
# define HAVE_LONG_FILE_NAMES 0
|
||||
#endif
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#include <limits.h>
|
||||
#ifndef _POSIX_NAME_MAX
|
||||
# define _POSIX_NAME_MAX 14
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
|
||||
43
backupfile.c
43
backupfile.c
@ -1,6 +1,7 @@
|
||||
/* backupfile.c -- make Emacs style backup file names
|
||||
Copyright (C) 1990,91,92,93,94,95,96,97,98,99,2000, 2001, 2002 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||
1999, 2000, 2001, 2002, 2003 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,13 +25,9 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#if HAVE_DIRENT_H
|
||||
# include <dirent.h>
|
||||
@ -56,23 +53,7 @@
|
||||
# define CLOSEDIR(d) closedir (d)
|
||||
#endif
|
||||
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DECL_GETENV
|
||||
"this configure-time declaration test was not run"
|
||||
#endif
|
||||
#if !HAVE_DECL_GETENV
|
||||
char *getenv ();
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DECL_MALLOC
|
||||
"this configure-time declaration test was not run"
|
||||
#endif
|
||||
#if !HAVE_DECL_MALLOC
|
||||
char *malloc ();
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
#if HAVE_DIRENT_H || HAVE_NDIR_H || HAVE_SYS_DIR_H || HAVE_SYS_NDIR_H
|
||||
# define HAVE_DIR 1
|
||||
@ -80,12 +61,8 @@ char *malloc ();
|
||||
# define HAVE_DIR 0
|
||||
#endif
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
#include <limits.h>
|
||||
|
||||
/* 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;
|
||||
add 1 for integer division truncation; add 1 more for a minus sign. */
|
||||
@ -114,8 +91,8 @@ char *malloc ();
|
||||
to numbered) backup file name. */
|
||||
const char *simple_backup_suffix = "~";
|
||||
|
||||
static int max_backup_version PARAMS ((const char *, const char *));
|
||||
static int version_number PARAMS ((const char *, const char *, size_t));
|
||||
static int max_backup_version (const char *, const char *);
|
||||
static int version_number (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.
|
||||
|
||||
20
backupfile.h
20
backupfile.h
@ -1,5 +1,7 @@
|
||||
/* backupfile.h -- declarations for making Emacs style backup file names
|
||||
Copyright (C) 1990-1992, 1997-1999 Free Software Foundation, Inc.
|
||||
|
||||
Copyright (C) 1990, 1991, 1992, 1997, 1998, 1999, 2003 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
|
||||
@ -44,17 +46,9 @@ enum backup_type
|
||||
|
||||
extern char const *simple_backup_suffix;
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
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));
|
||||
char *find_backup_file_name (char const *, enum backup_type);
|
||||
enum backup_type get_version (char const *context, char const *arg);
|
||||
enum backup_type xget_version (char const *context, char const *arg);
|
||||
void addext (char *, char const *, int);
|
||||
|
||||
#endif /* ! BACKUPFILE_H_ */
|
||||
|
||||
22
dirname.h
22
dirname.h
@ -1,4 +1,6 @@
|
||||
/* Copyright (C) 1998, 2001 Free Software Foundation, Inc.
|
||||
/* Take file names apart into directory and base names.
|
||||
|
||||
Copyright (C) 1998, 2001, 2003 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,13 +19,7 @@
|
||||
#ifndef DIRNAME_H_
|
||||
# define DIRNAME_H_ 1
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
# include <stddef.h>
|
||||
|
||||
# ifndef DIRECTORY_SEPARATOR
|
||||
# define DIRECTORY_SEPARATOR '/'
|
||||
@ -37,11 +33,11 @@
|
||||
# define FILESYSTEM_PREFIX_LEN(Filename) 0
|
||||
# endif
|
||||
|
||||
char *base_name PARAMS ((char const *path));
|
||||
char *dir_name PARAMS ((char const *path));
|
||||
size_t base_len PARAMS ((char const *path));
|
||||
size_t dir_len PARAMS ((char const *path));
|
||||
char *base_name (char const *path);
|
||||
char *dir_name (char const *path);
|
||||
size_t base_len (char const *path);
|
||||
size_t dir_len (char const *path);
|
||||
|
||||
int strip_trailing_slashes PARAMS ((char *path));
|
||||
int strip_trailing_slashes (char *path);
|
||||
|
||||
#endif /* not DIRNAME_H_ */
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# backupfile.m4 serial 1
|
||||
dnl Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
# backupfile.m4 serial 3
|
||||
dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||
dnl This file is free software, distributed under the terms of the GNU
|
||||
dnl General Public License. As a special exception to the GNU General
|
||||
dnl Public License, this file may be distributed as part of a program
|
||||
@ -11,13 +11,11 @@ AC_DEFUN([gl_BACKUPFILE],
|
||||
dnl Prerequisites of lib/backupfile.c.
|
||||
AC_REQUIRE([AC_HEADER_DIRENT])
|
||||
AC_REQUIRE([AC_FUNC_CLOSEDIR_VOID])
|
||||
AC_CHECK_HEADERS_ONCE(limits.h stdlib.h string.h)
|
||||
AC_CHECK_DECLS_ONCE(getenv malloc)
|
||||
jm_CHECK_TYPE_STRUCT_DIRENT_D_INO
|
||||
|
||||
dnl Prerequisites of lib/addext.c.
|
||||
AC_REQUIRE([jm_AC_DOS])
|
||||
AC_SYS_LONG_FILE_NAMES
|
||||
AC_CHECK_HEADERS_ONCE(limits.h string.h unistd.h)
|
||||
AC_REQUIRE([AC_SYS_LONG_FILE_NAMES])
|
||||
AC_CHECK_HEADERS_ONCE(unistd.h)
|
||||
AC_CHECK_FUNCS(pathconf)
|
||||
])
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
# onceonly.m4 serial 3
|
||||
# onceonly.m4 serial 3 (gettext-0.12)
|
||||
dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||
dnl This file is free software, distributed under the terms of the GNU
|
||||
dnl General Public License. As a special exception to the GNU General
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# quote.m4 serial 1
|
||||
dnl Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
# quote.m4 serial 2
|
||||
dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||
dnl This file is free software, distributed under the terms of the GNU
|
||||
dnl General Public License. As a special exception to the GNU General
|
||||
dnl Public License, this file may be distributed as part of a program
|
||||
@ -9,5 +9,5 @@ dnl the same distribution terms as the rest of that program.
|
||||
AC_DEFUN([gl_QUOTE],
|
||||
[
|
||||
dnl Prerequisites of lib/quote.c.
|
||||
AC_CHECK_HEADERS_ONCE(stddef.h)
|
||||
dnl (none)
|
||||
])
|
||||
|
||||
22
m4/rmdir.m4
22
m4/rmdir.m4
@ -1,22 +0,0 @@
|
||||
# rmdir.m4 serial 1
|
||||
dnl Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
dnl This file is free software, distributed under the terms of the GNU
|
||||
dnl General Public License. As a special exception to the GNU General
|
||||
dnl Public License, this file may be distributed as part of a program
|
||||
dnl that contains a configuration script generated by Autoconf, under
|
||||
dnl the same distribution terms as the rest of that program.
|
||||
|
||||
AC_DEFUN([gl_FUNC_RMDIR],
|
||||
[
|
||||
AC_REPLACE_FUNCS(rmdir)
|
||||
if test $ac_cv_func_rmdir = no; then
|
||||
gl_PREREQ_RMDIR
|
||||
fi
|
||||
])
|
||||
|
||||
# Prerequisites of lib/rmdir.c.
|
||||
AC_DEFUN([gl_PREREQ_RMDIR], [
|
||||
AC_REQUIRE([AC_HEADER_STAT])
|
||||
:
|
||||
])
|
||||
|
||||
39
m4/strcase.m4
Normal file
39
m4/strcase.m4
Normal file
@ -0,0 +1,39 @@
|
||||
# strcase.m4 serial 1
|
||||
dnl Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
dnl This file is free software, distributed under the terms of the GNU
|
||||
dnl General Public License. As a special exception to the GNU General
|
||||
dnl Public License, this file may be distributed as part of a program
|
||||
dnl that contains a configuration script generated by Autoconf, under
|
||||
dnl the same distribution terms as the rest of that program.
|
||||
|
||||
AC_DEFUN([gl_STRCASE],
|
||||
[
|
||||
gl_FUNC_STRCASECMP
|
||||
gl_FUNC_STRNCASECMP
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_FUNC_STRCASECMP],
|
||||
[
|
||||
AC_REPLACE_FUNCS(strcasecmp)
|
||||
if test $ac_cv_func_strcasecmp = no; then
|
||||
gl_PREREQ_STRCASECMP
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_FUNC_STRNCASECMP],
|
||||
[
|
||||
AC_REPLACE_FUNCS(strncasecmp)
|
||||
if test $ac_cv_func_strncasecmp = no; then
|
||||
gl_PREREQ_STRNCASECMP
|
||||
fi
|
||||
])
|
||||
|
||||
# Prerequisites of lib/strcasecmp.c.
|
||||
AC_DEFUN([gl_PREREQ_STRCASECMP], [
|
||||
:
|
||||
])
|
||||
|
||||
# Prerequisites of lib/strncasecmp.c.
|
||||
AC_DEFUN([gl_PREREQ_STRNCASECMP], [
|
||||
:
|
||||
])
|
||||
6
malloc.c
6
malloc.c
@ -22,14 +22,12 @@
|
||||
#endif
|
||||
#undef malloc
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
char *malloc ();
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Allocate an N-byte block of memory from the heap.
|
||||
If N is zero, allocate a 1-byte block. */
|
||||
|
||||
char *
|
||||
void *
|
||||
rpl_malloc (size_t n)
|
||||
{
|
||||
if (n == 0)
|
||||
|
||||
76
mkdir.c
76
mkdir.c
@ -1,76 +0,0 @@
|
||||
/* On some systems, mkdir ("foo/", 0700) fails because of the trailing
|
||||
slash. On those systems, this wrapper removes the trailing slash.
|
||||
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* written by Jim Meyering */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Disable the definition of mkdir to rpl_mkdir (from config.h) in this
|
||||
file. Otherwise, we'd get conflicting prototypes for rpl_mkdir on
|
||||
most systems. */
|
||||
#undef mkdir
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "dirname.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
#ifndef HAVE_DECL_FREE
|
||||
"this configure-time declaration test was not run"
|
||||
#endif
|
||||
#if !HAVE_DECL_FREE
|
||||
void free ();
|
||||
#endif
|
||||
|
||||
/* This function is required at least for NetBSD 1.5.2. */
|
||||
|
||||
int
|
||||
rpl_mkdir (char const *dir, mode_t mode)
|
||||
{
|
||||
int ret_val;
|
||||
char *tmp_dir;
|
||||
size_t len = strlen (dir);
|
||||
|
||||
if (len && dir[len - 1] == '/')
|
||||
{
|
||||
tmp_dir = xstrdup (dir);
|
||||
strip_trailing_slashes (tmp_dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_dir = (char *) dir;
|
||||
}
|
||||
|
||||
ret_val = mkdir (tmp_dir, mode);
|
||||
|
||||
if (tmp_dir != dir)
|
||||
free (tmp_dir);
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
4
quote.c
4
quote.c
@ -21,10 +21,6 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STDDEF_H
|
||||
# include <stddef.h> /* For the definition of size_t on windows w/MSVC. */
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include "quotearg.h"
|
||||
#include "quote.h"
|
||||
|
||||
|
||||
16
quote.h
16
quote.h
@ -1,5 +1,7 @@
|
||||
/* quote.h - prototypes for quote.c
|
||||
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2003 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,13 +18,5 @@
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
char const *quote_n PARAMS ((int n, char const *name));
|
||||
char const *quote PARAMS ((char const *name));
|
||||
char const *quote_n (int n, char const *name);
|
||||
char const *quote (char const *name);
|
||||
|
||||
13
realloc.c
13
realloc.c
@ -1,5 +1,5 @@
|
||||
/* Work around bug on some systems where realloc (NULL, 0) fails.
|
||||
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -22,19 +22,14 @@
|
||||
#endif
|
||||
#undef realloc
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
char *malloc ();
|
||||
char *realloc ();
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Change the size of an allocated block of memory P to N bytes,
|
||||
with error checking. If N is zero, change it to 1. If P is NULL,
|
||||
use malloc. */
|
||||
|
||||
char *
|
||||
rpl_realloc (p, n)
|
||||
char *p;
|
||||
size_t n;
|
||||
void *
|
||||
rpl_realloc (void *p, size_t n)
|
||||
{
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
|
||||
87
rmdir.c
87
rmdir.c
@ -1,87 +0,0 @@
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
@ -29,7 +29,7 @@
|
||||
# define LENGTH_LIMIT_EXPR(Expr) 0
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stddef.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
|
||||
|
||||
41
xalloc.h
41
xalloc.h
@ -1,5 +1,7 @@
|
||||
/* xalloc.h -- malloc with out-of-memory checking
|
||||
Copyright (C) 1990-1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||
1999, 2000, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -18,13 +20,7 @@
|
||||
#ifndef XALLOC_H_
|
||||
# define XALLOC_H_
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
# include <stddef.h>
|
||||
|
||||
# ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
|
||||
@ -36,14 +32,9 @@
|
||||
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
|
||||
# endif
|
||||
|
||||
/* Exit value when the requested amount of memory is not available.
|
||||
It is initialized to EXIT_FAILURE, but the caller may set it to
|
||||
some other value. */
|
||||
extern int xalloc_exit_failure;
|
||||
|
||||
/* If this pointer is non-zero, run the specified function upon each
|
||||
allocation failure. It is initialized to zero. */
|
||||
extern void (*xalloc_fail_func) PARAMS ((void));
|
||||
extern void (*xalloc_fail_func) (void);
|
||||
|
||||
/* If XALLOC_FAIL_FUNC is undefined or a function that returns, this
|
||||
message is output. It is translated via gettext.
|
||||
@ -51,20 +42,20 @@ extern void (*xalloc_fail_func) PARAMS ((void));
|
||||
extern char const xalloc_msg_memory_exhausted[];
|
||||
|
||||
/* This function is always triggered when memory is exhausted. It is
|
||||
in charge of honoring the three previous items. This is the
|
||||
in charge of honoring the two previous items. It exits with status
|
||||
exit_failure (defined in exitfail.h). This is the
|
||||
function to call when one wants the program to die because of a
|
||||
memory allocation failure. */
|
||||
extern void xalloc_die PARAMS ((void)) ATTRIBUTE_NORETURN;
|
||||
extern void xalloc_die (void) ATTRIBUTE_NORETURN;
|
||||
|
||||
void *xmalloc PARAMS ((size_t n));
|
||||
void *xcalloc PARAMS ((size_t n, size_t s));
|
||||
void *xrealloc PARAMS ((void *p, size_t n));
|
||||
char *xstrdup PARAMS ((const char *str));
|
||||
void *xmalloc (size_t n);
|
||||
void *xcalloc (size_t n, size_t s);
|
||||
void *xrealloc (void *p, size_t n);
|
||||
char *xstrdup (const char *str);
|
||||
|
||||
# define XMALLOC(Type, N_items) ((Type *) xmalloc (sizeof (Type) * (N_items)))
|
||||
# define XCALLOC(Type, N_items) ((Type *) xcalloc (sizeof (Type), (N_items)))
|
||||
# define XREALLOC(Ptr, Type, N_items) \
|
||||
((Type *) xrealloc ((void *) (Ptr), sizeof (Type) * (N_items)))
|
||||
# define XMALLOC(Type, N_items) xmalloc (sizeof (Type) * (N_items))
|
||||
# define XCALLOC(Type, N_items) xcalloc (sizeof (Type), N_items)
|
||||
# define XREALLOC(Ptr, Type, N_items) xrealloc (Ptr, sizeof (Type) * (N_items))
|
||||
|
||||
/* Declare and alloc memory for VAR of type TYPE. */
|
||||
# define NEW(Type, Var) Type *(Var) = XMALLOC (Type, 1)
|
||||
@ -78,7 +69,7 @@ char *xstrdup PARAMS ((const char *str));
|
||||
|
||||
/* Return a pointer to a malloc'ed copy of the array SRC of NUM elements. */
|
||||
# define CCLONE(Src, Num) \
|
||||
(memcpy (xmalloc (sizeof (*Src) * (Num)), (Src), sizeof (*Src) * (Num)))
|
||||
(memcpy (xmalloc (sizeof *(Src) * (Num)), Src, sizeof *(Src) * (Num)))
|
||||
|
||||
/* Return a malloc'ed copy of SRC. */
|
||||
# define CLONE(Src) CCLONE (Src, 1)
|
||||
|
||||
13
xmalloc.c
13
xmalloc.c
@ -1,5 +1,7 @@
|
||||
/* xmalloc.c -- malloc with out of memory checking
|
||||
Copyright (C) 1990-1999, 2000, 2002 Free Software Foundation, Inc.
|
||||
|
||||
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||
1999, 2000, 2002, 2003 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
|
||||
@ -35,6 +37,7 @@ void free ();
|
||||
#define N_(msgid) msgid
|
||||
|
||||
#include "error.h"
|
||||
#include "exitfail.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
#ifndef EXIT_FAILURE
|
||||
@ -51,12 +54,8 @@ void free ();
|
||||
"you must run the autoconf test for a GNU libc compatible realloc"
|
||||
#endif
|
||||
|
||||
/* Exit value when the requested amount of memory is not available.
|
||||
The caller may set it to some other value. */
|
||||
int xalloc_exit_failure = EXIT_FAILURE;
|
||||
|
||||
/* If non NULL, call this function when memory is exhausted. */
|
||||
void (*xalloc_fail_func) PARAMS ((void)) = 0;
|
||||
void (*xalloc_fail_func) (void) = 0;
|
||||
|
||||
/* If XALLOC_FAIL_FUNC is NULL, or does return, display this message
|
||||
before exiting when memory is exhausted. Goes through gettext. */
|
||||
@ -67,7 +66,7 @@ xalloc_die (void)
|
||||
{
|
||||
if (xalloc_fail_func)
|
||||
(*xalloc_fail_func) ();
|
||||
error (xalloc_exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted));
|
||||
error (exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted));
|
||||
/* The `noreturn' cannot be given to error, since it may return if
|
||||
its first argument is 0. To help compilers understand the
|
||||
xalloc_die does terminate, call exit. */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user