maint: move NLS-related macros to a central place

Add definition like in coreutils, thus also silencing GCC on NetBSD 7.1:
  warning: "textdomain" redefined

* lib/system.h: Include <locale.h> and gnulib's "gettext.h" here,
and define the macros textdomain, bindtextdomain, _ and N_.
* find/exe.c: Use it.
* find/fstype.c: Likewise.
* find/ftsfind.c: Likewise.
* find/oldfind.c: Likewise.
* find/parser.c: Likewise.
* find/pred.c: Likewise.
* find/print.c: Likewise.
* find/tree.c: Likewise.
* find/util.c: Likewise.
* lib/bugreports.c: Likewise.
* lib/buildcmd.c: Likewise.
* lib/dircallback.c: Likewise.
* lib/fdleak.c: Likewise.
* lib/findutils-version.c: Likewise.
* lib/listfile.c: Likewise.
* lib/regextype.c: Likewise.
* lib/safe-atoi.c: Likewise.
* locate/frcode.c: Likewise.
* locate/locate.c: Likewise.
* locate/word_io.c: Likewise.
* xargs/xargs.c: Likewise.
* cfg.mk (exclude_file_name_regexp--sc_bindtextdomain): Add exemption
for some non-main sources to pass the syntax-check.
This commit is contained in:
2018-02-02 22:40:42 +01:00
parent 0afb2efada
commit e551cfec0f
23 changed files with 39 additions and 195 deletions

4
cfg.mk
View File

@@ -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

View File

@@ -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 <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
#include "system.h"
/* Initialize exec->wd_for_exec.

View File

@@ -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 <libintl.h>
# 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,

View File

@@ -34,7 +34,6 @@
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <locale.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -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 <libintl.h>
# 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).
*/

View File

@@ -30,7 +30,6 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <locale.h>
#include <sys/stat.h>
/* 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 <libintl.h>
# 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

View File

@@ -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 <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
#ifndef HAVE_ENDGRENT
#define endgrent ()
#endif

View File

@@ -25,7 +25,6 @@
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
#include <locale.h>
#include <math.h>
#include <pwd.h>
#include <selinux/selinux.h>
@@ -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 <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
#ifdef CLOSEDIR_VOID
/* Fake a return value. */
#define CLOSEDIR(d) (closedir (d), 0)

View File

@@ -23,7 +23,6 @@
#include <ctype.h>
#include <errno.h>
#include <grp.h>
#include <locale.h>
#include <math.h>
#include <pwd.h>
#include <stdarg.h>
@@ -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 <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
#if defined STDC_HEADERS
# define ISDIGIT(c) isdigit ((unsigned char)c)

View File

@@ -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 <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
#include "system.h"
/* All predicates for each path to process. */

View File

@@ -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 <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
#include "system.h"
struct debug_option_assoc

View File

@@ -18,14 +18,9 @@
*/
#include <config.h>
#include <stdio.h>
#include "bugreports.h"
#if ENABLE_NLS
# include <libintl.h>
# 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)

View File

@@ -21,7 +21,6 @@
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
@@ -33,21 +32,13 @@
#include <xalloc.h>
/* gnulib headers. */
#include "gettext.h"
#include "xstrtol.h"
/* find headers. */
#include "system.h"
#include "buildcmd.h"
#include "die.h"
#if ENABLE_NLS
# include <libintl.h>
# 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. */

View File

@@ -23,7 +23,6 @@
/* system headers. */
#include <errno.h>
#include <locale.h>
#include <stdarg.h>
#include <sys/stat.h>

View File

@@ -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 <libintl.h>
# 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.

View File

@@ -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 <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
#ifdef _LIBC
/* In the GNU C library, there is a predefined variable for this. */

View File

@@ -22,7 +22,6 @@
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
#include <locale.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -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 <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
static bool print_name (register const char *p, FILE *stream, int literal_control_chars);

View File

@@ -28,24 +28,16 @@
#include <string.h>
/* 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 <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
struct tagRegexTypeMap
{
const char *name;

View File

@@ -23,20 +23,13 @@
#include <stdlib.h>
/* gnulib headers. */
#include "gettext.h"
#include "quotearg.h"
/* find headers. */
#include "system.h"
#include "die.h"
#include "safe-atoi.h"
#if ENABLE_NLS
# include <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
int
safe_atoi (const char *s, enum quoting_style style)

View File

@@ -18,6 +18,21 @@
#if !defined SYSTEM_H
# define SYSTEM_H
#include <locale.h>
/* 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:

View File

@@ -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 <libintl.h>
# 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.

View File

@@ -67,7 +67,6 @@
#include <fcntl.h>
#include <getopt.h>
#include <grp.h> /* for setgroups() */
#include <locale.h>
#include <regex.h>
#include <signal.h>
#include <stdbool.h>
@@ -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 <libintl.h>
# 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;

View File

@@ -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 <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#define textdomain(Domain)
#define bindtextdomain(Package, Directory)
#endif
enum { WORDBYTES=4 };

View File

@@ -41,7 +41,6 @@
#include <getopt.h>
#include <inttypes.h>
#include <limits.h>
#include <locale.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
@@ -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 <libintl.h>
# 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)))