From: Bruno Haible Date: Wed, 7 May 2025 08:56:03 +0000 (+0200) Subject: Add syntax-check rule against OS predef misspellings. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b641c8975caec7b3cc4612e417f11b3848eb374;p=thirdparty%2Fgnulib.git Add syntax-check rule against OS predef misspellings. * Makefile (sc_prohibit_misspelled_os_predefs): New target. * lib/stat-size.h: Simplify detection of HP-UX. * lib/mountlist.c: Fix typo in comment. --- diff --git a/ChangeLog b/ChangeLog index 6d1e5f8e3d..a430ffd406 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2025-05-07 Bruno Haible + Add syntax-check rule against OS predef misspellings. + * Makefile (sc_prohibit_misspelled_os_predefs): New target. + * lib/stat-size.h: Simplify detection of HP-UX. + * lib/mountlist.c: Fix typo in comment. + Add syntax-check rule against compiler predef misspellings. * Makefile (sc_prohibit_misspelled_compiler_predefs): New target. diff --git a/Makefile b/Makefile index 767c6eeb6f..7ed889138a 100644 --- a/Makefile +++ b/Makefile @@ -70,6 +70,38 @@ misspelled_compiler_predefs =\ __GNUC_MAJOR__ \ __GNUC_MINOR \ +# Cf. +sc_prohibit_misspelled_os_predefs: + if test -d .git; then \ + git ls-files m4 lib tests \ + | xargs grep -Ew '($(misspelled_os_predefs_or))' \ + && { printf '*** %s\n' 'misspelled predefs' 1>&2; exit 1; } \ + || : \ + else :; fi +misspelled_os_predefs_or = $(shell echo $(misspelled_os_predefs) | tr -s ' ' '|') +misspelled_os_predefs = \ + __AIX__ \ + __FreeBSD \ + __NetBSD \ + __OpenBSD \ + __CYGWIN \ + __CYGWIN32__ \ + __MINGW__ \ + __WIN32__ \ + __WIN64__ \ + __GNU__ \ + __HAIKU \ + __hpux__ \ + __IRIX__ \ + __sgi__ \ + __linux \ + __minix__ \ + __sun__ \ + __unix \ + __unix__ \ + __ZOS__ \ + __zOS__ \ + sc_prohibit_augmenting_PATH_via_TESTS_ENVIRONMENT: if test -d .git; then \ url=https://lists.gnu.org/r/bug-gnulib/2010-09/msg00064.html; \ diff --git a/lib/mountlist.c b/lib/mountlist.c index 72bd3f3bb6..dcff6f8319 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -568,7 +568,7 @@ read_file_system_list (bool need_fs_type) goto free_then_fail; } else /* fallback to /proc/self/mounts (/etc/mtab). */ -# endif /* __linux __ || __ANDROID__ */ +# endif /* __linux__ || __ANDROID__ */ { struct mntent *mnt; char const *table = MOUNTED; diff --git a/lib/stat-size.h b/lib/stat-size.h index 96aba4adad..bba083cdf0 100644 --- a/lib/stat-size.h +++ b/lib/stat-size.h @@ -68,7 +68,7 @@ # define STP_BLKSIZE(st) ((0 < (st)->st_blksize \ && (st)->st_blksize <= (size_t) -1 / 8 + 1) \ ? (st)->st_blksize : DEV_BSIZE) -# if defined hpux || defined __hpux__ || defined __hpux +# if defined __hpux /* HP-UX counts st_blocks in 1024-byte units. This loses when mixing HP-UX and BSD file systems with NFS. */ # define ST_NBLOCKSIZE 1024