diff --git a/cfg.mk b/cfg.mk index 4c2423b5..89b27c52 100644 --- a/cfg.mk +++ b/cfg.mk @@ -84,6 +84,10 @@ exclude_file_name_regexp--sc_prohibit_strncpy = ^(find/print.c|lib/buildcmd.c)$$ # sc_texinfo_acronym: perms.texi from coreutils uses @acronym{GNU}. exclude_file_name_regexp--sc_texinfo_acronym = doc/perm\.texi +# List syntax-check exemptions. +exclude_file_name_regexp--sc_bindtextdomain = \ + ^(locate/frcode|lib/regexprops|lib/test_splitstring)\.c$$ + # sc_prohibit_strcmp is broken because it gives false positives for # cases where neither argument is a string literal. local-checks-to-skip += sc_prohibit_strcmp diff --git a/find/exec.c b/find/exec.c index 9807c74e..13b44925 100644 --- a/find/exec.c +++ b/find/exec.c @@ -30,7 +30,6 @@ #include "cloexec.h" #include "dirname.h" #include "error.h" -#include "gettext.h" #include "save-cwd.h" #include "xalloc.h" @@ -39,13 +38,7 @@ #include "defs.h" #include "die.h" #include "fdleak.h" - -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#endif +#include "system.h" /* Initialize exec->wd_for_exec. diff --git a/find/fstype.c b/find/fstype.c index ec072c7c..578ea8ee 100644 --- a/find/fstype.c +++ b/find/fstype.c @@ -51,19 +51,12 @@ #include "xalloc.h" #include "xstrtol.h" #include "mountlist.h" -#include "gettext.h" /* find headers. */ #include "defs.h" #include "die.h" #include "extendbuf.h" - -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#endif +#include "system.h" static char *file_system_type_uncached (const struct stat *statp, const char *path, diff --git a/find/ftsfind.c b/find/ftsfind.c index 5cebb61f..0e2aca33 100644 --- a/find/ftsfind.c +++ b/find/ftsfind.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -43,7 +42,6 @@ #include "closeout.h" #include "error.h" #include "fts_.h" -#include "gettext.h" #include "progname.h" #include "quotearg.h" #include "save-cwd.h" @@ -55,20 +53,12 @@ #include "dircallback.h" #include "fdleak.h" #include "unused-result.h" +#include "system.h" + #undef STAT_MOUNTPOINTS -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#define textdomain(Domain) -#define bindtextdomain(Package, Directory) -#endif - - /* FTS_TIGHT_CYCLE_CHECK tries to work around Savannah bug #17877 * (but actually using it doesn't fix the bug). */ diff --git a/find/oldfind.c b/find/oldfind.c index 6aa67335..8162aa6d 100644 --- a/find/oldfind.c +++ b/find/oldfind.c @@ -30,7 +30,6 @@ #include #include #include -#include #include /* gnulib headers. */ @@ -40,7 +39,6 @@ #include "dirname.h" #include "error.h" #include "fcntl--.h" -#include "gettext.h" #include "human.h" #include "progname.h" #include "save-cwd.h" @@ -53,6 +51,7 @@ #include "defs.h" #include "die.h" #include "fdleak.h" +#include "system.h" #undef STAT_MOUNTPOINTS @@ -75,16 +74,6 @@ enum # define D_INO(dp) NOT_AN_INODE_NUMBER #endif -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#define textdomain(Domain) -#define bindtextdomain(Package, Directory) -#define ngettext(singular,plural,n) ((1==n) ? singular : plural) -#endif - #ifdef STAT_MOUNTPOINTS static void init_mounted_dev_list (int mandatory); #endif diff --git a/find/parser.c b/find/parser.c index aa88e84c..566dcc67 100644 --- a/find/parser.c +++ b/find/parser.c @@ -35,7 +35,6 @@ #include "error.h" #include "fnmatch.h" #include "fts_.h" -#include "gettext.h" #include "modechange.h" #include "mountlist.h" #include "parse-datetime.h" @@ -66,16 +65,9 @@ #include "die.h" #include "fdleak.h" #include "findutils-version.h" +#include "system.h" - -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#endif - #ifndef HAVE_ENDGRENT #define endgrent () #endif diff --git a/find/pred.c b/find/pred.c index af3bacbc..2014b5ab 100644 --- a/find/pred.c +++ b/find/pred.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -40,7 +39,6 @@ #include "dirname.h" #include "error.h" #include "fnmatch.h" -#include "gettext.h" #include "stat-size.h" #include "stat-time.h" #include "yesno.h" @@ -51,16 +49,10 @@ #include "dircallback.h" #include "listfile.h" #include "printquoted.h" +#include "system.h" -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#endif - #ifdef CLOSEDIR_VOID /* Fake a return value. */ #define CLOSEDIR(d) (closedir (d), 0) diff --git a/find/print.c b/find/print.c index 1271e4de..f27b503e 100644 --- a/find/print.c +++ b/find/print.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -35,7 +34,6 @@ #include "dirname.h" #include "error.h" #include "filemode.h" -#include "gettext.h" #include "human.h" #include "printquoted.h" #include "stat-size.h" @@ -49,12 +47,6 @@ #include "die.h" #include "print.h" -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#endif #if defined STDC_HEADERS # define ISDIGIT(c) isdigit ((unsigned char)c) diff --git a/find/tree.c b/find/tree.c index 4c20b344..5be88f2e 100644 --- a/find/tree.c +++ b/find/tree.c @@ -25,20 +25,12 @@ /* gnulib headers. */ #include "error.h" #include "fnmatch.h" -#include "gettext.h" #include "xalloc.h" /* find headers. */ #include "defs.h" #include "die.h" - -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#endif - +#include "system.h" /* All predicates for each path to process. */ diff --git a/find/util.c b/find/util.c index 09d00ba3..fa338074 100644 --- a/find/util.c +++ b/find/util.c @@ -32,7 +32,6 @@ /* gnulib headers. */ #include "error.h" #include "fdleak.h" -#include "gettext.h" #include "progname.h" #include "quotearg.h" #include "save-cwd.h" @@ -44,14 +43,7 @@ #include "die.h" #include "dircallback.h" #include "bugreports.h" - - -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#endif +#include "system.h" struct debug_option_assoc diff --git a/lib/bugreports.c b/lib/bugreports.c index bdb7e360..e52e9202 100644 --- a/lib/bugreports.c +++ b/lib/bugreports.c @@ -18,14 +18,9 @@ */ #include #include -#include "bugreports.h" -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#endif +#include "bugreports.h" +#include "system.h" int explain_how_to_report_bugs (FILE *f, const char *program_name) diff --git a/lib/buildcmd.c b/lib/buildcmd.c index 290ad6cb..efe6d15c 100644 --- a/lib/buildcmd.c +++ b/lib/buildcmd.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -33,21 +32,13 @@ #include /* gnulib headers. */ -#include "gettext.h" #include "xstrtol.h" /* find headers. */ +#include "system.h" #include "buildcmd.h" #include "die.h" -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#define textdomain(Domain) -#define bindtextdomain(Package, Directory) -#endif /* COMPAT: SYSV version defaults size (and has a max value of) to 470. We try to make it as large as possible. See bc_get_arg_max() below. */ diff --git a/lib/dircallback.c b/lib/dircallback.c index cc12b558..c8a460da 100644 --- a/lib/dircallback.c +++ b/lib/dircallback.c @@ -23,7 +23,6 @@ /* system headers. */ #include -#include #include #include diff --git a/lib/fdleak.c b/lib/fdleak.c index efc0cc4f..38ff8360 100644 --- a/lib/fdleak.c +++ b/lib/fdleak.c @@ -37,19 +37,13 @@ #include "dirent-safer.h" #include "error.h" #include "fcntl--.h" -#include "gettext.h" /* find headers. */ +#include "system.h" #include "extendbuf.h" #include "fdleak.h" #include "safe-atoi.h" -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#endif /* In order to detect FD leaks, we take a snapshot of the open * file descriptors which are not FD_CLOEXEC when the program starts. diff --git a/lib/findutils-version.c b/lib/findutils-version.c index e963277a..fa3593f9 100644 --- a/lib/findutils-version.c +++ b/lib/findutils-version.c @@ -21,18 +21,12 @@ /* system headers would go here if we needed any. */ /* gnulib headers. */ -#include "gettext.h" #include "version-etc.h" /* find headers. */ +#include "system.h" #include "findutils-version.h" -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#endif #ifdef _LIBC /* In the GNU C library, there is a predefined variable for this. */ diff --git a/lib/listfile.c b/lib/listfile.c index 84dbc550..f1c7111c 100644 --- a/lib/listfile.c +++ b/lib/listfile.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -41,9 +40,9 @@ #include "idcache.h" #include "pathmax.h" #include "stat-size.h" -#include "gettext.h" /* find headers. */ +#include "system.h" #include "die.h" #include "listfile.h" @@ -61,12 +60,6 @@ # endif #endif -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#endif static bool print_name (register const char *p, FILE *stream, int literal_control_chars); diff --git a/lib/regextype.c b/lib/regextype.c index e58dbff7..7baec782 100644 --- a/lib/regextype.c +++ b/lib/regextype.c @@ -28,24 +28,16 @@ #include /* gnulib headers. */ -#include "gettext.h" #include "quote.h" #include "regex.h" #include "regextype.h" #include "xalloc.h" /* findutils headers */ +#include "system.h" #include "die.h" -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#endif - - struct tagRegexTypeMap { const char *name; diff --git a/lib/safe-atoi.c b/lib/safe-atoi.c index be261ac9..8e63abb6 100644 --- a/lib/safe-atoi.c +++ b/lib/safe-atoi.c @@ -23,20 +23,13 @@ #include /* gnulib headers. */ -#include "gettext.h" #include "quotearg.h" /* find headers. */ +#include "system.h" #include "die.h" #include "safe-atoi.h" -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#endif - int safe_atoi (const char *s, enum quoting_style style) diff --git a/lib/system.h b/lib/system.h index b261d407..b473cb89 100644 --- a/lib/system.h +++ b/lib/system.h @@ -18,6 +18,21 @@ #if !defined SYSTEM_H # define SYSTEM_H +#include + +/* Take care of NLS matters. */ + +#include "gettext.h" +#if ! ENABLE_NLS +# undef textdomain +# define textdomain(Domainname) /* empty */ +# undef bindtextdomain +# define bindtextdomain(Domainname, Dirname) /* empty */ +#endif + +#define _(msgid) gettext (msgid) +#define N_(msgid) msgid + /* FALLTHROUGH * Since GCC7, the "-Werror=implicit-fallthrough=" option requires * fallthrough cases to be marked as such via: diff --git a/locate/frcode.c b/locate/frcode.c index 71e1ef08..67e70dd3 100644 --- a/locate/frcode.c +++ b/locate/frcode.c @@ -79,26 +79,17 @@ /* gnulib headers. */ #include "closeout.h" #include "error.h" -#include "gettext.h" #include "progname.h" #include "xalloc.h" /* find headers. */ +#include "system.h" #include "bugreports.h" #include "die.h" #include "findutils-version.h" #include "gcc-function-attributes.h" #include "locatedb.h" -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#define textdomain(Domain) -#define bindtextdomain(Package, Directory) -#endif - /* Write out a 16-bit int, high byte first (network byte order). * Return true iff all went well. diff --git a/locate/locate.c b/locate/locate.c index 35593057..a10d86d2 100644 --- a/locate/locate.c +++ b/locate/locate.c @@ -67,7 +67,6 @@ #include #include #include /* for setgroups() */ -#include #include #include #include @@ -82,7 +81,6 @@ /* gnulib headers. */ #include "fnmatch.h" -#include "gettext.h" #include "progname.h" #include "xalloc.h" #include "error.h" @@ -94,6 +92,7 @@ #include "stat-time.h" /* find headers. */ +#include "system.h" #include "bugreports.h" #include "die.h" #include "findutils-version.h" @@ -103,28 +102,6 @@ #include "splitstring.h" -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#define textdomain(Domain) -#define bindtextdomain(Package, Directory) -#define ngettext(singular,plural,n) ((1==n) ? singular : plural) -#endif -#ifdef gettext_noop -# define N_(String) gettext_noop (String) -#else -/* We used to use (String) instead of just String, but apparently ISO C - * doesn't allow this (at least, that's what HP said when someone reported - * this as a compiler bug). This is HP case number 1205608192. See - * also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11250 (which references - * ANSI 3.5.7p14-15). The Intel icc compiler also rejects constructs - * like: static const char buf[] = ("string"); - */ -# define N_(String) String -#endif - /* Warn if a database is older than this. 8 days allows for a weekly update that takes up to a day to perform. */ static unsigned int warn_number_units = 8; diff --git a/locate/word_io.c b/locate/word_io.c index 99aa72ca..1b5225eb 100644 --- a/locate/word_io.c +++ b/locate/word_io.c @@ -28,22 +28,13 @@ /* gnulib headers. */ #include "byteswap.h" #include "error.h" -#include "gettext.h" #include "quotearg.h" /* find headers. */ +#include "system.h" #include "die.h" #include "locatedb.h" -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#define textdomain(Domain) -#define bindtextdomain(Package, Directory) -#endif - enum { WORDBYTES=4 }; diff --git a/xargs/xargs.c b/xargs/xargs.c index e86756de..a0be77ea 100644 --- a/xargs/xargs.c +++ b/xargs/xargs.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -55,7 +54,6 @@ /* gnulib headers. */ #include "closein.h" #include "error.h" -#include "gettext.h" #include "progname.h" #include "quotearg.h" #include "safe-read.h" @@ -70,14 +68,6 @@ #include "gcc-function-attributes.h" #include "system.h" -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#define textdomain(Domain) -#define bindtextdomain(Package, Directory) -#endif #ifndef LONG_MAX #define LONG_MAX (~(1 << (sizeof (long) * 8 - 1)))