summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2009-11-29 11:26:22 +0100
committerJim Meyering <meyering@redhat.com>2009-11-30 16:55:04 +0100
commitc4e8205b988dd2a95a00e188d32f4d6ec1d3f7e7 (patch)
tree3b575ad046e5133ce6c0d7f13ccaf099b2af7aeb /lib
parentb20aababc614594c1db492aefc348273239ef938 (diff)
downloadgrep-c4e8205b988dd2a95a00e188d32f4d6ec1d3f7e7.tar.gz
build: get more lib/* files from gnulib, adjust savedir
* bootstrap.conf (gnulib_modules): Add the following: closeout exclude hard-locale isdir strtoumax. * lib/.gitignore, m4/.gitignore: Update. * lib/closeout.c, lib/closeout.h: Remove. * lib/exclude.c, lib/exclude.h: Remove. * lib/hard-locale.c, lib/hard-locale.h: Remove. * lib/strtoumax.c: Remove. * lib/isdir.c: Remove. * lib/Makefile.am: Remove here, too. * lib/savedir.c: Adapt to new exclude module: s/excluded_filename/excluded_file_name/ and remove 3rd argument.
Diffstat (limited to 'lib')
-rw-r--r--lib/.gitignore73
-rw-r--r--lib/Makefile.am5
-rw-r--r--lib/closeout.c117
-rw-r--r--lib/closeout.h17
-rw-r--r--lib/exclude.c128
-rw-r--r--lib/exclude.h35
-rw-r--r--lib/hard-locale.c59
-rw-r--r--lib/hard-locale.h18
-rw-r--r--lib/isdir.c42
-rw-r--r--lib/savedir.c6
-rw-r--r--lib/strtoumax.c81
11 files changed, 77 insertions, 504 deletions
diff --git a/lib/.gitignore b/lib/.gitignore
index 1052ad79..31262044 100644
--- a/lib/.gitignore
+++ b/lib/.gitignore
@@ -1,28 +1,60 @@
alloca.c
alloca.h
alloca.in.h
+at-func.c
atexit.c
basename-lgpl.c
basename.c
binary-io.h
+bitrotate.h
btowc.c
+chdir-long.c
+chdir-long.h
+chown.c
+close-hook.c
+close-hook.h
+close-stream.c
+close-stream.h
+close.c
+closeout.c
+closeout.h
config.charset
+dirent--.h
+dirent-safer.h
dirent.h
dirent.in.h
+dirfd.c
dirname-lgpl.c
dirname.c
dirname.h
dummy.c
+dup-safer.c
+dup2.c
errno.h
errno.in.h
error.c
error.h
+exclude.c
+exclude.h
exitfail.c
exitfail.h
+fchdir.c
+fchmodat.c
+fchown-stub.c
+fchownat.c
+fclose.c
+fcntl.h
+fcntl.in.h
+fd-safer.c
+fdopendir.c
fnmatch.c
fnmatch.h
fnmatch.in.h
fnmatch_loop.c
+fpending.c
+fpending.h
+fstatat.c
+getcwd.c
getopt.c
getopt.h
getopt.in.h
@@ -31,25 +63,47 @@ getopt_int.h
getpagesize.c
gettext.h
gnulib.mk
+hard-locale.c
+hard-locale.h
+hash.c
+hash.h
intprops.h
inttypes.h
inttypes.in.h
+isdir.c
+lchown.c
localcharset.c
localcharset.h
locale.h
locale.in.h
+lstat.c
malloc.c
+mbchar.c
+mbchar.h
mbrlen.c
mbrtowc.c
+mbscasecmp.c
mbsinit.c
mbsrtowcs-state.c
mbsrtowcs.c
+mbuiter.h
memchr.c
memchr.valgrind
memmove.c
mempcpy.c
+memrchr.c
+mkdir.c
+mkdirat.c
obstack.c
obstack.h
+open.c
+openat-die.c
+openat-priv.h
+openat-proc.c
+openat.c
+openat.h
+opendir-safer.c
+pipe-safer.c
quotearg.c
quotearg.h
realloc.c
@@ -63,15 +117,24 @@ regex.h
regex_internal.c
regex_internal.h
regexec.c
+rmdir.c
+same-inode.h
+save-cwd.c
+save-cwd.h
+stat.c
stdbool.h
stdbool.in.h
stddef.h
stddef.in.h
stdint.h
stdint.in.h
+stdio-write.c
+stdio.h
+stdio.in.h
stdlib.h
stdlib.in.h
stpcpy.c
+strdup.c
streq.h
strerror.c
string.h
@@ -86,21 +149,31 @@ strtol.c
strtoll.c
strtoul.c
strtoull.c
+strtoumax.c
sys
sys_stat.h
sys_stat.in.h
time.h
time.in.h
+unistd--.h
+unistd-safer.h
unistd.h
unistd.in.h
+unitypes.h
+uniwidth.h
+unlink.c
+unlinkat.c
verify.h
wchar.h
wchar.in.h
wcrtomb.c
wctype.h
wctype.in.h
+wcwidth.c
xalloc-die.c
xalloc.h
+xgetcwd.c
+xgetcwd.h
xmalloc.c
xstrndup.c
xstrndup.h
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 603b596f..182c5d84 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -18,11 +18,8 @@
include gnulib.mk
INCLUDES = -I.. -I$(srcdir)
-DEFS = @DEFS@
libgreputils_a_SOURCES += \
- closeout.c exclude.c hard-locale.c isdir.c quotearg.c savedir.c
+ savedir.c savedir.h
libgreputils_a_LIBADD += @LIBOBJS@ @ALLOCA@
-noinst_HEADERS += \
- closeout.h exclude.h hard-locale.h quotearg.h savedir.h
diff --git a/lib/closeout.c b/lib/closeout.c
deleted file mode 100644
index ff93b607..00000000
--- a/lib/closeout.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/* closeout.c - close standard output
- Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <gettext.h>
-#define _(String) gettext(String)
-
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-#ifndef EXIT_FAILURE
-# define EXIT_FAILURE 1
-#endif
-
-#include <stdio.h>
-
-#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
-#include "closeout.h"
-#include "error.h"
-#include "quotearg.h"
-#if 0
-#include "__fpending.h"
-#endif
-
-static int default_exit_status = EXIT_FAILURE;
-static const char *file_name;
-
-/* Set the value to be used for the exit status when close_stdout is called.
- This is useful when it is not convenient to call close_stdout_status,
- e.g., when close_stdout is called via atexit. */
-void
-close_stdout_set_status (int status)
-{
- default_exit_status = status;
-}
-
-/* Set the file name to be reported in the event an error is detected
- by close_stdout_status. */
-void
-close_stdout_set_file_name (const char *file)
-{
- file_name = file;
-}
-
-/* Close standard output, exiting with status STATUS on failure.
- If a program writes *anything* to stdout, that program should `fflush'
- stdout and make sure that it succeeds before exiting. Otherwise,
- suppose that you go to the extreme of checking the return status
- of every function that does an explicit write to stdout. The last
- printf can succeed in writing to the internal stream buffer, and yet
- the fclose(stdout) could still fail (due e.g., to a disk full error)
- when it tries to write out that buffered data. Thus, you would be
- left with an incomplete output file and the offending program would
- exit successfully.
-
- FIXME: note the fflush suggested above is implicit in the fclose
- we actually do below. Consider doing only the fflush and/or using
- setvbuf to inhibit buffering.
-
- Besides, it's wasteful to check the return value from every call
- that writes to stdout -- just let the internal stream state record
- the failure. That's what the ferror test is checking below.
-
- It's important to detect such failures and exit nonzero because many
- tools (most notably `make' and other build-management systems) depend
- on being able to detect failure in other tools via their exit status. */
-
-void
-close_stdout_status (int status)
-{
- int e = ferror (stdout) ? 0 : -1;
-
-#if 0
- if (__fpending (stdout) == 0)
- return;
-#endif
-
- if (fclose (stdout) != 0)
- e = errno;
-
- if (0 < e)
- {
- char const *write_error = _("write error");
- if (file_name)
- error (status, e, "%s: %s", quotearg_colon (file_name), write_error);
- else
- error (status, e, "%s", write_error);
- }
-}
-
-/* Close standard output, exiting with status EXIT_FAILURE on failure. */
-void
-close_stdout (void)
-{
- close_stdout_status (default_exit_status);
-}
diff --git a/lib/closeout.h b/lib/closeout.h
deleted file mode 100644
index 80f24e45..00000000
--- a/lib/closeout.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef CLOSEOUT_H
-# define CLOSEOUT_H 1
-
-# ifndef PARAMS
-# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
-# define PARAMS(Args) Args
-# else
-# define PARAMS(Args) ()
-# endif
-# endif
-
-void close_stdout_set_status PARAMS ((int status));
-void close_stdout_set_file_name PARAMS ((const char *file));
-void close_stdout PARAMS ((void));
-void close_stdout_status PARAMS ((int status));
-
-#endif
diff --git a/lib/exclude.c b/lib/exclude.c
deleted file mode 100644
index 17ff91f9..00000000
--- a/lib/exclude.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/* exclude.c -- exclude file names
- Copyright 1992, 1993, 1994, 1997, 1999, 2000 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING.
- If not, write to the Free Software Foundation,
- 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-/* Written by Paul Eggert <eggert@twinsun.com> */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-#include <exclude.h>
-#include <fnmatch.h>
-#include <stdio.h>
-#include <sys/types.h>
-
-void *xmalloc PARAMS ((size_t));
-void *xrealloc PARAMS ((void *, size_t));
-
-/* Keep track of excluded file name patterns. */
-
-struct exclude
- {
- char const **exclude;
- int exclude_alloc;
- int exclude_count;
- };
-
-struct exclude *
-new_exclude (void)
-{
- struct exclude *ex = (struct exclude *) xmalloc (sizeof (struct exclude));
- ex->exclude_count = 0;
- ex->exclude_alloc = 64;
- ex->exclude = (char const **) xmalloc (ex->exclude_alloc * sizeof (char *));
- return ex;
-}
-
-int
-excluded_filename (struct exclude const *ex, char const *f, int options)
-{
- char const * const *exclude = ex->exclude;
- int exclude_count = ex->exclude_count;
- int i;
-
- for (i = 0; i < exclude_count; i++)
- if (fnmatch (exclude[i], f, options) == 0)
- return 1;
-
- return 0;
-}
-
-void
-add_exclude (struct exclude *ex, char const *pattern)
-{
- if (ex->exclude_alloc <= ex->exclude_count)
- ex->exclude = (char const **) xrealloc (ex->exclude,
- ((ex->exclude_alloc *= 2)
- * sizeof (char *)));
-
- ex->exclude[ex->exclude_count++] = pattern;
-}
-
-int
-add_exclude_file (void (*add_func) PARAMS ((struct exclude *, char const *)),
- struct exclude *ex, char const *filename, char line_end)
-{
- int use_stdin = filename[0] == '-' && !filename[1];
- FILE *in;
- char *buf;
- char *p;
- char const *pattern;
- char const *lim;
- size_t buf_alloc = 1024;
- size_t buf_count = 0;
- int c;
- int e = 0;
-
- if (use_stdin)
- in = stdin;
- else if (! (in = fopen (filename, "r")))
- return -1;
-
- buf = xmalloc (buf_alloc);
-
- while ((c = getc (in)) != EOF)
- {
- buf[buf_count++] = c;
- if (buf_count == buf_alloc)
- buf = xrealloc (buf, buf_alloc *= 2);
- }
-
- buf = xrealloc (buf, buf_count + 1);
-
- if (ferror (in))
- e = errno;
-
- if (!use_stdin && fclose (in) != 0)
- e = errno;
-
- for (pattern = p = buf, lim = buf + buf_count; p <= lim; p++)
- if (p < lim ? *p == line_end : buf < p && p[-1])
- {
- *p = '\0';
- (*add_func) (ex, pattern);
- pattern = p + 1;
- }
-
- errno = e;
- return e ? -1 : 0;
-}
diff --git a/lib/exclude.h b/lib/exclude.h
deleted file mode 100644
index fb2b06be..00000000
--- a/lib/exclude.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* exclude.h -- declarations for excluding file names
- Copyright 1992, 1993, 1994, 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
- the Free Software Foundation; either version 3, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING.
- If not, write to the Free Software Foundation,
- 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-/* Written by Paul Eggert <eggert@twinsun.com> */
-
-#ifndef PARAMS
-# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
-# define PARAMS(Args) Args
-# else
-# define PARAMS(Args) ()
-# endif
-#endif
-
-struct exclude;
-
-struct exclude *new_exclude PARAMS ((void));
-void add_exclude PARAMS ((struct exclude *, char const *));
-int add_exclude_file PARAMS ((void (*) (struct exclude *, char const *),
- struct exclude *, char const *, char));
-int excluded_filename PARAMS ((struct exclude const *, char const *, int));
diff --git a/lib/hard-locale.c b/lib/hard-locale.c
deleted file mode 100644
index eef13f84..00000000
--- a/lib/hard-locale.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* hard-locale.c -- Determine whether a locale is hard.
- Copyright 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 3, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include <config.h>
-#include <alloca.h>
-#include <locale.h>
-#include <string.h>
-
-/* Return nonzero if the current CATEGORY locale is hard, i.e. if you
- can't get away with assuming traditional C or POSIX behavior. */
-int
-hard_locale (int category)
-{
-#if ! (defined ENABLE_NLS && HAVE_SETLOCALE)
- return 0;
-#else
-
- int hard = 1;
- char const *p = setlocale (category, 0);
-
- if (p)
- {
-# if defined __GLIBC__ && __GLIBC__ >= 2
- if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0)
- hard = 0;
-# else
- char *locale = alloca (strlen (p) + 1);
- strcpy (locale, p);
-
- /* Temporarily set the locale to the "C" and "POSIX" locales to
- find their names, so that we can determine whether one or the
- other is the caller's locale. */
- if (((p = setlocale (category, "C")) && strcmp (p, locale) == 0)
- || ((p = setlocale (category, "POSIX")) && strcmp (p, locale) == 0))
- hard = 0;
-
- /* Restore the caller's locale. */
- setlocale (category, locale);
-# endif
- }
-
- return hard;
-
-#endif
-}
diff --git a/lib/hard-locale.h b/lib/hard-locale.h
deleted file mode 100644
index 5b054d9a..00000000
--- a/lib/hard-locale.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef HARD_LOCALE_H_
-# define HARD_LOCALE_H_ 1
-
-# if HAVE_CONFIG_H
-# include <config.h>
-# endif
-
-# ifndef PARAMS
-# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
-# define PARAMS(Args) Args
-# else
-# define PARAMS(Args) ()
-# endif
-# endif
-
-int hard_locale PARAMS ((int));
-
-#endif /* HARD_LOCALE_H_ */
diff --git a/lib/isdir.c b/lib/isdir.c
deleted file mode 100644
index e9ec952b..00000000
--- a/lib/isdir.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* isdir.c -- determine whether a directory exists
- Copyright (C) 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 3, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#if STAT_MACROS_BROKEN
-# undef S_ISDIR
-#endif
-
-#if !defined S_ISDIR && defined S_IFDIR
-# define S_ISDIR(Mode) (((Mode) & S_IFMT) == S_IFDIR)
-#endif
-
-/* If PATH is an existing directory or symbolic link to a directory,
- return nonzero, else 0. */
-
-int
-isdir (const char *path)
-{
- struct stat stats;
-
- return stat (path, &stats) == 0 && S_ISDIR (stats.st_mode);
-}
diff --git a/lib/savedir.c b/lib/savedir.c
index a7e02e8b..0ab41035 100644
--- a/lib/savedir.c
+++ b/lib/savedir.c
@@ -110,10 +110,10 @@ savedir (const char *dir, off_t name_size, struct exclude *included_patterns,
&& !isdir1 (dir, dp->d_name))
{
if (included_patterns
- && !excluded_filename (included_patterns, dp->d_name, 0))
+ && !excluded_file_name (included_patterns, dp->d_name))
continue;
if (excluded_patterns
- && excluded_filename (excluded_patterns, dp->d_name, 0))
+ && excluded_file_name (excluded_patterns, dp->d_name))
continue;
}
@@ -121,7 +121,7 @@ savedir (const char *dir, off_t name_size, struct exclude *included_patterns,
&& isdir1 (dir, dp->d_name) )
{
if (excluded_directory_patterns
- && excluded_filename (excluded_directory_patterns, dp->d_name, 0))
+ && excluded_file_name (excluded_directory_patterns, dp->d_name))
continue;
}
diff --git a/lib/strtoumax.c b/lib/strtoumax.c
deleted file mode 100644
index 7770bcec..00000000
--- a/lib/strtoumax.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* Convert string representation of a number into an uintmax_t value.
- Copyright 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 3, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-/* Written by Paul Eggert. */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-
-#ifndef PARAMS
-# if defined PROTOTYPES || defined __STDC__
-# define PARAMS(Args) Args
-# else
-# define PARAMS(Args) ()
-# endif
-#endif
-
-#ifndef HAVE_DECL_STRTOUL
-"this configure-time declaration test was not run"
-#endif
-#if !HAVE_DECL_STRTOUL
-unsigned long strtoul PARAMS ((char const *, char **, int));
-#endif
-
-#ifndef HAVE_DECL_STRTOULL
-"this configure-time declaration test was not run"
-#endif
-#if !HAVE_DECL_STRTOULL && HAVE_UNSIGNED_LONG_LONG
-unsigned long long strtoull PARAMS ((char const *, char **, int));
-#endif
-
-uintmax_t
-strtoumax (char const *ptr, char **endptr, int base)
-{
-#define USE_IF_EQUIVALENT(function) \
- if (sizeof (uintmax_t) == sizeof function (ptr, endptr, base)) \
- return function (ptr, endptr, base);
-
-#if HAVE_UNSIGNED_LONG_LONG
- USE_IF_EQUIVALENT (strtoull)
-#endif
-
- USE_IF_EQUIVALENT (strtoul)
-
- abort ();
-}
-
-#ifdef TESTING
-# include <stdio.h>
-int
-main ()
-{
- char *p, *endptr;
- printf ("sizeof uintmax_t: %d\n", sizeof (uintmax_t));
- printf ("sizeof strtoull(): %d\n", sizeof strtoull(p, &endptr, 10));
- printf ("sizeof strtoul(): %d\n", sizeof strtoul(p, &endptr, 10));
- exit (0);
-}
-#endif