]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
Add syntax-check rule against OS predef misspellings.
authorBruno Haible <bruno@clisp.org>
Wed, 7 May 2025 08:56:03 +0000 (10:56 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 7 May 2025 08:56:03 +0000 (10:56 +0200)
* Makefile (sc_prohibit_misspelled_os_predefs): New target.
* lib/stat-size.h: Simplify detection of HP-UX.
* lib/mountlist.c: Fix typo in comment.

ChangeLog
Makefile
lib/mountlist.c
lib/stat-size.h

index 6d1e5f8e3d372ed270185940ab7899528ebe8baa..a430ffd406e7eb00162c28b1a27eb682c53aef69 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2025-05-07  Bruno Haible  <bruno@clisp.org>
 
+       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.
 
index 767c6eeb6fbbbf4f3bd7410a0cbdf74fe7729b46..7ed889138a3ebdcc520f18e0419a261dc7f04a8b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -70,6 +70,38 @@ misspelled_compiler_predefs =\
   __GNUC_MAJOR__       \
   __GNUC_MINOR         \
 
+# Cf. <https://github.com/cpredef/predef/blob/master/OperatingSystems.md>
+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; \
index 72bd3f3bb62ec2873a0b4f2159e098a3330eb293..dcff6f831939a3b991abf63e3b4797ff72640a50 100644 (file)
@@ -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;
index 96aba4adad2ba14b96dc9770c9225477c2095fa6..bba083cdf0143aa4f5f0bd62b9ba82b49938daa8 100644 (file)
@@ -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