* cfg.mk *skip(defer): Enable sc_program_name. Remove the now-unused variable skip_defer. * find/ftsfind.c: Include "program_name.h". (main): Call set_program_name. * find/find.c: Include "program_name.h". (main): Call set_program_name. * locate/locate.c: Include "program_name.h". (dolocate): Call set_program_name. Remove global variable program_name. * locate/bigram.c: Include "program_name.h". Remove global variable "program_name". (main): Call set_program_name. * locate/frcode.c: Include "program_name.h". (main): Call set_program_name. * xargs/xargs.c (main): Call set_program_name. Include "program_name.h". Remove global variable program_name. * find/finddata.c: Remove global variable program_name. * find/defs.h: No longer need declaration of program_name. * find/util.c: Include "program_name.h".
Signed-off-by: James Youngman <[email protected]> --- ChangeLog | 76 +++++++++++++++++++++++++++++------------------------- cfg.mk | 5 +--- find/defs.h | 2 - find/find.c | 10 ++++--- find/finddata.c | 3 -- find/ftsfind.c | 7 ++++- find/util.c | 1 + locate/bigram.c | 10 ++++--- locate/frcode.c | 8 +++-- locate/locate.c | 11 +++---- xargs/xargs.c | 11 +++++--- 11 files changed, 78 insertions(+), 66 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4659ec1..1ceb300 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,20 +1,26 @@ 2010-04-02 James Youngman <[email protected]> - * build-aux/src-sniff.py (checkers): Avoid false positive with - sc_the_the. - - Avoid false positives for sc_prohibit_atoi_atof. - * find/util.c (set_option_defaults): Avoid false positive with - sc_prohibit_atoi_atof. - (check_nofollow): Likewise. - - * lib/Makefile.am (libfind_a_SOURCES): Add safe-atoi.c and - safe-atoi.h. - - * find/ftsfind.c: We don't use anything from xalloc.h, so don't - #include it. - - * import-gnulib.config (modules): Add maintainer-makefile. + Use set_program_name() to remember the programs' names. + * cfg.mk *skip(defer): Enable sc_program_name. Remove the + now-unused variable skip_defer. + * find/ftsfind.c: Include "program_name.h". + (main): Call set_program_name. + * find/find.c: Include "program_name.h". + (main): Call set_program_name. + * locate/locate.c: Include "program_name.h". + (dolocate): Call set_program_name. + Remove global variable program_name. + * locate/bigram.c: Include "program_name.h". + Remove global variable "program_name". + (main): Call set_program_name. + * locate/frcode.c: Include "program_name.h". + (main): Call set_program_name. + * xargs/xargs.c (main): Call set_program_name. + Include "program_name.h". + Remove global variable program_name. + * find/finddata.c: Remove global variable program_name. + * find/defs.h: No longer need declaration of program_name. + * find/util.c: Include "program_name.h". Use named constants for xargs exit codes. * xargs/xargs.c (child_error): Use EXIT_SUCCESS instead of 0. @@ -131,13 +137,15 @@ * lib/dircallback.c: Likewise. Move safe_atoi out into a separate module. - * find/parser.c: Include "safe-atoi.h". Remove the body of safe_atoi. + * find/parser.c: Include "safe-atoi.h". REmvoe the body of safe_atoi. (parse_group): pass options.err_quoting_style to safe_atoi. (insert_depthspec): Likewise. (parse_user): Likewise. * lib/safe-atoi.h: New file. * lib/safe-atoi.c: New file. Add parameter for quoting style (to avoid an external reference to the "options"struct). + * po/POTFILES.in: Add lib/safe-atoi.c. + * lib/Makefile.am (libfind_a_SOURCES): Add safe-atoi.c and safe-atoi.h. @@ -161,10 +169,6 @@ (main): If process_all_startpoints failed, don't do the cleanup operations because we don't know what subdirectory we're in. - * find/util.c (fd_leak_check_is_enabled): Avoid implicit - pointer-to-int conversion. - * lib/buildcmd.c: #include <stdlib.h> for declaration of free. - Fix some space-followed-by-tab sequences. * NEWS: Change space-tab sequences to just spaces. * build-aux/check-testfiles.sh (main): Likewise @@ -192,15 +196,6 @@ * cfg.mk: New file; configuration file for the maintainer-makefile provided by gnulib. - * import-gnulib.config (modules): Add maintainer-makefile. - - Various coding standard fixes. - * m4/withfts.m4: Quote the first argument of AC_DEFINE. - * configure.ac: Quote the first argument to AC_DEFINE. - * lib/regextype.c: Don't use HAVE_CONFIG_H. - * doc/find-maint.texi: Remove RCS keywords (they were in an - example security vulnerability announcement). - Don't define S_IS*; include <sys/stat.h> instead. * lib/modetype.h: Remove (all it does is define S_IS*). * lib/Makefile.am (EXTRA_DIST): Remove modetype.h. @@ -211,6 +206,22 @@ * find/fstype.c: Likewise. * find/find.c: Likewise. + * find/util.c (fd_leak_check_is_enabled): Avoid implicit + pointer-to-int conversion. + * lib/buildcmd.c: #include <stdlib.h> for declaration of free. + + Various coding standard fixes. + * m4/withfts.m4: Quote the first argument of AC_DEFINE. + * configure.ac: Quote the first argument to AC_DEFINE. + * lib/regextype.c: Don't use HAVE_CONFIG_H. + * doc/find-maint.texi: Remove RCS keywords (they were in an + example security vulnerability announcement). + + Remove useless if conditionals before calls to 'free'. + * lib/nextelem.c (next_element): Remove useless if-before-free. + * lib/buildcmd.c (bc_do_exec): Likewise. + * find/find.c (process_dir): Likewise. + Coding standard fix: "Warning" should be "WARNING". * find/find.c (dirchange_is_fatal): Change "Warning" to "WARNING". * find/ftsfind.c (consider_visiting): Likewise. @@ -222,11 +233,6 @@ (read_line): Change "Warning" to "WARNING". (wait_for_proc): Likewise. - Remove useless if conditionals before calls to 'free'. - * lib/nextelem.c (next_element): Remove useless if-before-free. - * lib/buildcmd.c (bc_do_exec): Likewise. - * find/find.c (process_dir): Likewise. - * import-gnulib.sh (usage): Defeat the simple GPL version check of maint.mk, since it's trying to identify GPL2 licenses. Since the 'rehack' script converts v2 licenses into v3, we get a false @@ -241,7 +247,7 @@ * lib/regexprops.c: Likewise (though the license being changed is the license for the output). - * NEWS: Update copyright years. + * import-gnulib.config (modules): Add maintainer-makefile. 2010-04-01 James Youngman <[email protected]> diff --git a/cfg.mk b/cfg.mk index 46689fb..8b336a3 100644 --- a/cfg.mk +++ b/cfg.mk @@ -22,9 +22,6 @@ skip_too_picky = sc_error_message_period sc_error_message_uppercase \ skip_dunno = sc_immutable_NEWS sc_makefile_at_at_check \ sc_prohibit_quote_without_use sc_prohibit_quotearg_without_use -# Understand, but fix later. -skip_defer = sc_program_name - # False positives I don't have a workaround for yet. # sc_space_tab: several .xo test output files contain this sequence # for testing xargs's handling of white space. @@ -51,5 +48,5 @@ skip_blocked_notours = \ skip_broken_checks = sc_prohibit_strcmp sc_prohibit_stat_st_blocks local-checks-to-skip = \ - $(skip_too_picky) $(skip_dunno) $(false_positives) $(skip_defer) \ + $(skip_too_picky) $(skip_dunno) $(false_positives) \ $(mix_positives) $(skip_blocked_patch) $(skip_blocked_notours) $(skip_broken_checks) diff --git a/find/defs.h b/find/defs.h index 81d3dad..20c7dff 100644 --- a/find/defs.h +++ b/find/defs.h @@ -672,7 +672,5 @@ struct state extern struct state state; extern char const *starting_dir; extern int starting_desc; -extern char *program_name; - #endif diff --git a/find/find.c b/find/find.c index c8084e3..d3a239e 100644 --- a/find/find.c +++ b/find/find.c @@ -51,6 +51,7 @@ #include "xgetcwd.h" #include "error.h" #include "fdleak.h" +#include "progname.h" #ifdef HAVE_LOCALE_H #include <locale.h> @@ -82,9 +83,6 @@ static void process_dir PARAMS((char *pathname, char *name, int pathlen, const s -/* Name this program was run with. */ -extern char *program_name; - /* A file descriptor open to the initial working directory. Doing it this way allows us to work when the i.w.d. has unreadable parents. */ @@ -127,7 +125,11 @@ main (int argc, char **argv) int end_of_leading_options = 0; /* First arg after any -H/-L etc. */ struct predicate *eval_tree; - program_name = argv[0]; + if (argv[0]) + set_program_name (argv[0]); + else + set_program_name ("find"); + state.exit_status = 0; if (fd_leak_check_is_enabled ()) diff --git a/find/finddata.c b/find/finddata.c index 9285301..dc44527 100644 --- a/find/finddata.c +++ b/find/finddata.c @@ -21,9 +21,6 @@ #include "defs.h" -/* Name this program was run with. */ -char *program_name; - struct options options; struct state state; diff --git a/find/ftsfind.c b/find/ftsfind.c index af2d84f..3b56026 100644 --- a/find/ftsfind.c +++ b/find/ftsfind.c @@ -44,6 +44,7 @@ #include <unistd.h> +#include "progname.h" #include "closeout.h" #include "quotearg.h" #include "quote.h" @@ -678,7 +679,11 @@ main (int argc, char **argv) int end_of_leading_options = 0; /* First arg after any -H/-L etc. */ struct predicate *eval_tree; - program_name = argv[0]; + if (argv[0]) + set_program_name (argv[0]); + else + set_program_name ("find"); + state.exit_status = 0; state.execdirs_outstanding = false; state.cwd_dir_fd = AT_FDCWD; diff --git a/find/util.c b/find/util.c index 9294f31..11e8eed 100644 --- a/find/util.c +++ b/find/util.c @@ -31,6 +31,7 @@ #include <errno.h> #include <assert.h> +#include "progname.h" #include "quotearg.h" #include "timespec.h" #include "error.h" diff --git a/locate/bigram.c b/locate/bigram.c index f9e1d2e..7aca021 100644 --- a/locate/bigram.c +++ b/locate/bigram.c @@ -38,11 +38,9 @@ #include <sys/types.h> #include <xalloc.h> +#include "progname.h" #include "closeout.h" -/* The name this program was run with. */ -char *program_name; - /* Return the length of the longest common prefix of strings S1 and S2. */ static int @@ -63,7 +61,11 @@ main (int argc, char **argv) size_t pathsize, oldpathsize; /* Amounts allocated for them. */ int line_len; /* Length of input line. */ - program_name = argv[0]; + if (argv[0]) + set_program_name (argv[0]); + else + set_program_name ("bigram"); + (void) argc; atexit (close_stdout); diff --git a/locate/frcode.c b/locate/frcode.c index 67b5471..85f5619 100644 --- a/locate/frcode.c +++ b/locate/frcode.c @@ -225,9 +225,11 @@ main (int argc, char **argv) int slocate_compat = 0; long slocate_seclevel = 0L; - program_name = argv[0]; - if (!program_name) - program_name = "frcode"; + if (argv[0]) + set_program_name (argv[0]); + else + set_program_name ("frcode"); + atexit (close_stdout); pathsize = oldpathsize = 1026; /* Increased as necessary by getline. */ diff --git a/locate/locate.c b/locate/locate.c index 592f754..84377ac 100644 --- a/locate/locate.c +++ b/locate/locate.c @@ -118,6 +118,7 @@ #endif #include "locatedb.h" +#include "progname.h" #include "xalloc.h" #include "error.h" #include "human.h" @@ -1400,13 +1401,8 @@ search_one_database (int argc, } - - extern char *version_string; -/* The name this program was run with. */ -char *program_name; - static void usage (FILE *stream) { @@ -1583,7 +1579,10 @@ dolocate (int argc, char **argv, int secure_db_fd) int they_chose_db = 0; bool did_stdin = false; /* Set to prevent rereading stdin. */ - program_name = argv[0]; + if (argv[0]) + set_program_name (argv[0]); + else + set_program_name ("locate"); #ifdef HAVE_SETLOCALE setlocale (LC_ALL, ""); diff --git a/xargs/xargs.c b/xargs/xargs.c index a4145c5..4954256 100644 --- a/xargs/xargs.c +++ b/xargs/xargs.c @@ -70,6 +70,8 @@ #endif #include "verify.h" + +#include "progname.h" #include "quotearg.h" #include "findutils-version.h" @@ -114,9 +116,6 @@ void error PARAMS ((int status, int errnum, char *message,...)); extern char *version_string; -/* The name this program was run with. */ -char *program_name; - static FILE *input_stream; /* Buffer for reading arguments from input. */ @@ -385,7 +384,11 @@ main (int argc, char **argv) enum BC_INIT_STATUS bcstatus; enum { XARGS_POSIX_HEADROOM = 2048u }; - program_name = argv[0]; + if (argv[0]) + set_program_name (argv[0]); + else + set_program_name ("xargs"); + parent = getpid (); original_exit_value = EXIT_SUCCESS; -- 1.7.0 _______________________________________________ Findutils-patches mailing list [email protected] http://lists.gnu.org/mailman/listinfo/findutils-patches
