Re: relocatable-lib-lgpl: Don't export symbols from static MSVC .obj files

2023-09-07 Thread Simon Josefsson via Gnulib discussion list
Bruno Haible  writes:

> -#define LIBFOO_DLL_EXPORTED __attribute__((__visibility__("default")))
> -#elif (defined _WIN32 && !defined __CYGWIN__) && BUILDING_SHARED && 
> BUILDING_LIBFOO
> -#define LIBFOO_DLL_EXPORTED __declspec(dllexport)
> -#elif (defined _WIN32 && !defined __CYGWIN__) && BUILDING_SHARED
> -#define LIBFOO_DLL_EXPORTED __declspec(dllimport)
> +# define LIBFOO_DLL_EXPORTED __attribute__((__visibility__("default")))
> +#elif (defined _WIN32 && !defined __CYGWIN__) && @@BUILDING_SHARED@@ && 
> BUILDING_LIBFOO
> +# if defined DLL_EXPORT
> +#  define LIBFOO_DLL_EXPORTED __declspec(dllexport)
> +# else
> +#  define LIBFOO_DLL_EXPORTED
> +# endif
> +#elif (defined _WIN32 && !defined __CYGWIN__) && @@BUILDING_SHARED@@
> +# define LIBFOO_DLL_EXPORTED __declspec(dllimport)

Hi Bruno.  The idea is that this code snippet would go into the public
header file that is installed in /usr/include on people's system, so
using @@BUILDING_SHARED@@ in it does not seem to work.  I think some
other technique or improved documentation is needed here.  I must admit
I'm not sure I understand the entire background here, and just looking
at the end result.

If there is no way in CPP to know if we're building code that will use
libfoo as a shared library (symbols DLL_EXPORT or PIC?) I think it would
be acceptable for the public header file to default to setting things up
for using a shared library, but allow the user to specify a
-DLIBFOO_STATIC_BUILD=1 or similar if she wants to build with a static
libfoo.

/Simon


signature.asc
Description: PGP signature


Re: chown and chgrp won't change on systems without sys_lchown()

2023-09-07 Thread Bruno Haible
Jordi Sanfeliu wrote in
:
> I've detected that chown and chgrp commands will not change the 
> owner/group of a device file (char or block) that doesn't exist on a 
> system that don't has the system call sys_lchown.

On which platform do you see this? I'm asking because
  - on most current portability targets (Linux, macOS, *BSD, AIX, Solaris, 
Cygwin)
the configure test
  checking whether chown dereferences symlinks...
reports 'yes', thus CHOWN_MODIFIES_SYMLINK will not be defined.
That's because lchown is part of POSIX. See

and
.
  - on native Windows symlinks are not handled by gnulib and coreutils
(i.e. it's treated like a platforms without symlinks), AFAIK.

Bruno






Re: mbcel module for Gnulib?, incomplete multibyte sequences

2023-09-07 Thread Paul Eggert

On 2023-08-07 00:32, Paul Eggert wrote:

I'll think about naming.


It's been a month and I couldn't think of anything better than to 
shorten the name from mbcel to mcel, so I did that and installed the 
attached patches. These patches shouldn't affect behavior; that is, they 
should only add new functionality.


With luck this should be enough for diffutils to stop using its own 
homegrown variants of Gnulib modules; I plan to look into that next.


I'm not entirely happy with this approach, as it means packages like 
diffutils will need to pass --avoid=mbuiterf etc. to gnulib-tool if the 
packages prefer mcel for everything. If gnulib-tool gave us a way to say 
that mbscasecmp depends on mbuiterf or mbcel (i.e., "or" instead of 
"and") perhaps we could do something better. But the patch should work 
as-is for diffutils, and if we come up with something better for Gnulib 
we can improve diffutils accordingly.


Although these patches update Gnulib's 'exclude' and 'mbscasecmp' 
modules to support mcel-prefer, they don't have similar updates for 
other modules like 'mbsncasecmp' and 'propername' that could also use 
support. Diffutils doesn't use those other modules so I left them alone 
for now; they can be updated later as needed (and by then maybe we'll 
have a better solution for the --avoid problem).From b93de66735cd6f935ee0970f8cb26908d113e09d Mon Sep 17 00:00:00 2001
From: Paul Eggert 
Date: Thu, 7 Sep 2023 14:51:55 -0700
Subject: [PATCH 1/7] mcel: new module

* lib/mcel.c, lib/mcel.h, modules/mcel: New files.
---
 ChangeLog|   5 +
 lib/mcel.c   |   3 +
 lib/mcel.h   | 294 +++
 modules/mcel |  34 ++
 4 files changed, 336 insertions(+)
 create mode 100644 lib/mcel.c
 create mode 100644 lib/mcel.h
 create mode 100644 modules/mcel

diff --git a/ChangeLog b/ChangeLog
index d5fc6c2130..d477347b91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-09-07  Paul Eggert  
+
+	mcel: new module
+	* lib/mcel.c, lib/mcel.h, modules/mcel: New files.
+
 2023-09-07  Bruno Haible  
 
 	Don't use 'throw ()' in C++ 11 or newer.
diff --git a/lib/mcel.c b/lib/mcel.c
new file mode 100644
index 00..3c2ae46290
--- /dev/null
+++ b/lib/mcel.c
@@ -0,0 +1,3 @@
+#include 
+#define MCEL_INLINE _GL_EXTERN_INLINE
+#include "mcel.h"
diff --git a/lib/mcel.h b/lib/mcel.h
new file mode 100644
index 00..400604f8b2
--- /dev/null
+++ b/lib/mcel.h
@@ -0,0 +1,294 @@
+/* Multi-byte characters, Error encodings, and Lengths (MCELs)
+   Copyright 2023 Free Software Foundation, Inc.
+
+   This file is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   This file is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see .  */
+
+/* Written by Paul Eggert.  */
+
+/* The macros in this file implement multi-byte character representation
+   and forward iteration through a multi-byte string.
+   They are simpler and can be faster than the mbiter family.
+   However, they do not support obsolescent encodings like CP864,
+   EBCDIC, Johab, and Shift JIS that glibc also does not support,
+   and it is up to the caller to coalesce encoding-error bytes if desired.
+
+   The mcel_scan function lets code iterate through an array of bytes,
+   supporting character encodings in practical use
+   more simply than using plain mbrtoc32.
+
+   Instead of this single-byte code:
+
+  char *p = ..., *lim = ...;
+  for (; p < lim; p++)
+process (*p);
+
+   You can use this multi-byte code:
+
+  char *p = ..., *lim = ...;
+  for (mcel_t g; p < lim; p += g.len)
+{
+	  g = mcel_scan (p, lim);
+	  process (g);
+	}
+
+   You can select from G using G.ch, G.err, and G.len.
+   G is an encoding error if G.err is nonzero, a character otherwise.
+
+   The mcel_scanz function is similar except it works with a
+   string of unknown but positive length that is terminated with '\0'.
+   Instead of this single-byte code:
+
+  char *p = ...;
+  for (; *p; p++)
+	process (*p);
+
+   You can use this multi-byte code:
+
+  char *p = ...;
+  for (mcel_t g; *p; p += g.len)
+	{
+	  g = mcel_scanz (p);
+	  process (g);
+	}
+
+   mcel_scant (P, TERMINATOR) is like mcel_scanz (P) except the
+   string is terminated by TERMINATOR.  The C standard says that the
+   TERMINATORs '\0', '\r', '\n', '.', '/' are safe, as they cannot be
+   a part (even a trailing byte) of a multi-byte character.
+   In practice TERMINATOR is safe if 0 <= 

Don't use 'throw ()' in C++ 11 or newer

2023-09-07 Thread Bruno Haible
The syntax 'throw ()' is no longer valid in C++ 20, and is deprecated in C++ 17.
See .

Gnulib was partially up-to-date (lib/cdefs.h since 2021-01-05,
m4/gnulib-common.m4 since 2023-09-04). This patch updates the remaining
occurrences.


2023-09-07  Bruno Haible  

Don't use 'throw ()' in C++ 11 or newer.
* lib/stddef.in.h (_GL_ATTRIBUTE_NOTHROW):  Provide fallback definition.
(abort): Declare with _GL_ATTRIBUTE_NOTHROW instead of throw().
* lib/malloc.in.h (rpl_free, free): Likewise.
* lib/stdlib.in.h (free): Likewise.
* lib/string.in.h (rpl_free, free, memchr, memrchr, rawmemchr,
strchrnul, strpbrk, strstr, strcasestr): Likewise.
* lib/wchar.in.h (rpl_free, free): Likewise.
* lib/getopt-cdefs.in.h (__THROW): Define to noexcept(true) for C++ 11
or newer.
* lib/md5.h (__THROW): Likewise.

diff --git a/lib/getopt-cdefs.in.h b/lib/getopt-cdefs.in.h
index e76c78cb21..1a666ebb7b 100644
--- a/lib/getopt-cdefs.in.h
+++ b/lib/getopt-cdefs.in.h
@@ -57,7 +57,11 @@
 
 #ifndef __THROW
 # if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
-#  define __THROW   throw ()
+#  if __cplusplus >= 201103L
+#   define __THROW  noexcept (true)
+#  else
+#   define __THROW  throw ()
+#  endif
 # else
 #  define __THROW
 # endif
diff --git a/lib/malloc.in.h b/lib/malloc.in.h
index bfc749545e..af94064e79 100644
--- a/lib/malloc.in.h
+++ b/lib/malloc.in.h
@@ -95,7 +95,7 @@
   && !(defined __cplusplus && defined GNULIB_NAMESPACE))
 /* We can't do '#define free rpl_free' here.  */
 #  if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
-_GL_EXTERN_C void rpl_free (void *) throw ();
+_GL_EXTERN_C void rpl_free (void *) _GL_ATTRIBUTE_NOTHROW;
 #  else
 _GL_EXTERN_C void rpl_free (void *);
 #  endif
@@ -110,7 +110,7 @@ _GL_EXTERN_C
  void __cdecl free (void *);
 #  else
 #   if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
-_GL_EXTERN_C void free (void *) throw ();
+_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
 #   else
 _GL_EXTERN_C void free (void *);
 #   endif
@@ -125,7 +125,7 @@ _GL_EXTERN_C
  void __cdecl free (void *);
 # else
 #  if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
-_GL_EXTERN_C void free (void *) throw ();
+_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
 #  else
 _GL_EXTERN_C void free (void *);
 #  endif
diff --git a/lib/md5.h b/lib/md5.h
index b298fc4cc3..983f088ba6 100644
--- a/lib/md5.h
+++ b/lib/md5.h
@@ -63,7 +63,11 @@
 
 #ifndef __THROW
 # if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
-#  define __THROW   throw ()
+#  if __cplusplus >= 201103L
+#   define __THROW  noexcept (true)
+#  else
+#   define __THROW  throw ()
+#  endif
 # else
 #  define __THROW
 # endif
diff --git a/lib/stddef.in.h b/lib/stddef.in.h
index bb18198c98..190fd575d8 100644
--- a/lib/stddef.in.h
+++ b/lib/stddef.in.h
@@ -101,11 +101,33 @@ typedef long max_align_t;
 #  ifndef _@GUARD_PREFIX@_STDDEF_H
 #   define _@GUARD_PREFIX@_STDDEF_H
 
-/* This file uses _Noreturn.  */
+/* This file uses _Noreturn, _GL_ATTRIBUTE_NOTHROW.  */
 #if !_GL_CONFIG_H_INCLUDED
  #error "Please include config.h first."
 #endif
 
+/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
+ */
+#ifndef _GL_ATTRIBUTE_NOTHROW
+# if defined __cplusplus
+#  if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4
+#   if __cplusplus >= 201103L
+#define _GL_ATTRIBUTE_NOTHROW noexcept (true)
+#   else
+#define _GL_ATTRIBUTE_NOTHROW throw ()
+#   endif
+#  else
+#   define _GL_ATTRIBUTE_NOTHROW
+#  endif
+# else
+#  if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
+#   define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
+#  else
+#   define _GL_ATTRIBUTE_NOTHROW
+#  endif
+# endif
+#endif
+
 /* Some platforms lack wchar_t.  */
 #if !@HAVE_WCHAR_T@
 # define wchar_t int
@@ -178,7 +200,7 @@ extern
 _Noreturn
 void abort (void)
 #  if defined __cplusplus && (__GLIBC__ >= 2)
-throw ()
+_GL_ATTRIBUTE_NOTHROW
 #  endif
 ;
 #  define unreachable() abort ()
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 10bb811d9e..88dffaba19 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -223,7 +223,7 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
 #   define free rpl_free
 #  endif
 #  if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
-_GL_FUNCDECL_RPL (free, void, (void *ptr) throw ());
+_GL_FUNCDECL_RPL (free, void, (void *ptr) _GL_ATTRIBUTE_NOTHROW);
 #  else
 _GL_FUNCDECL_RPL (free, void, (void *ptr));
 #  endif
diff --git a/lib/string.in.h b/lib/string.in.h
index f7e6f3b18e..d2df319e45 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -156,7 +156,7 @@
   && !(defined __cplusplus && defined GNULIB_NAMESPACE))
 /* We can't do '#define free rpl_free' here.  */
 #  if defined __cplusplus && 

Re: Add info about recommended warning options

2023-09-07 Thread Bruno Haible
I wrote:
> 2023-09-05  Bruno Haible  
> 
>   Add info about recommended warning options.
>   * HACKING: New section "Warning Options".

Going through the same process with clang: I started with most of the
ca. 900 diagnostic options at
https://releases.llvm.org/16.0.0/tools/clang/docs/DiagnosticsReference.html ,
omitting the redundant ones:

$ WARN_CLANG16=`echo '
-Wall
-Wanon-enum-enum-conversion
-Warc-repeated-use-of-weak
-Warray-bounds-pointer-arithmetic
-Warray-parameter
-Wassign-enum
-Watomic-implicit-seq-cst
-Watomic-properties
-Wbad-function-cast
-Wbinary-literal
-Wbit-int-extension
-Wbitfield-enum-conversion
-Wbitwise-instead-of-logical
-Wbitwise-op-parentheses
-Wbool-operation
-Wc++-compat
-Wc11-extensions
-Wc2x-compat
-Wc2x-extensions
-Wc99-compat
-Wc99-designator
-Wc99-extensions
-Wcalled-once-parameter
-Wcast-align
-Wcast-function-type
-Wcast-function-type-strict
-Wcast-qual
-Wchar-subscripts
-Wcomma
-Wcomment
-Wcompletion-handler
-Wcomplex-component-init
-Wcompound-token-split
-Wconditional-uninitialized
-Wconsumed
-Wconversion
-Wcovered-switch-default
-Wcstring-format-directive
-Wcuda-compat
-Wdate-time
-Wdeclaration-after-statement
-Wdelimited-escape-sequence-extension
-Wdeprecated
-Wdeprecated-dynamic-exception-spec
-Wdeprecated-implementations
-Wdeprecated-this-capture
-Wdeprecated-writable-strings
-Wdirect-ivar-access
-Wdisabled-macro-expansion
-Wdocumentation
-Wdocumentation-deprecated-sync
-Wdocumentation-html
-Wdocumentation-pedantic
-Wdocumentation-unknown-command
-Wdollar-in-identifier-extension
-Wdouble-promotion
-Wduplicate-decl-specifier
-Wduplicate-enum
-Wduplicate-method-arg
-Wduplicate-method-match
-Wdynamic-exception-spec
-Wembedded-directive
-Wempty-init-stmt
-Wempty-translation-unit
-Wenum-compare-conditional
-Wenum-conversion
-Wenum-enum-conversion
-Wenum-float-conversion
-Wexit-time-destructors
-Wexpansion-to-defined
-Wexplicit-ownership-type
-Wextra
-Wextra-semi
-Wextra-semi-stmt
-Wfixed-enum-extension
-Wflexible-array-extensions
-Wfloat-conversion
-Wfloat-equal
-Wfloat-overflow-conversion
-Wfloat-zero-conversion
-Wfor-loop-analysis
-Wformat
-Wformat-non-iso
-Wformat-nonliteral
-Wformat-pedantic
-Wformat-type-confusion
-Wformat=2
-Wfour-char-constants
-Wframe-address
-Wfuse-ld-path
-Wfuture-attribute-extensions
-Wgcc-compat
-Wglobal-constructors
-Wgnu
-Wgnu-anonymous-struct
-Wgnu-auto-type
-Wgnu-case-range
-Wgnu-complex-integer
-Wgnu-compound-literal-initializer
-Wgnu-conditional-omitted-operand
-Wgnu-designator
-Wgnu-empty-initializer
-Wgnu-empty-struct
-Wgnu-flexible-array-initializer
-Wgnu-flexible-array-union-member
-Wgnu-folding-constant
-Wgnu-imaginary-constant
-Wgnu-include-next
-Wgnu-label-as-value
-Wgnu-line-marker
-Wgnu-null-pointer-arithmetic
-Wgnu-offsetof-extensions
-Wgnu-pointer-arith
-Wgnu-redeclared-enum
-Wgnu-statement-expression
-Wgnu-statement-expression-from-macro-expansion
-Wgnu-union-cast
-Wgnu-zero-line-directive
-Wgnu-zero-variadic-macro-arguments
-Wheader-hygiene
-Widiomatic-parentheses
-Wignored-qualifiers
-Wimplicit
-Wimplicit-fallthrough
-Wimplicit-fallthrough-per-function
-Wimplicit-float-conversion
-Wimplicit-function-declaration
-Wimplicit-int
-Wimplicit-int-conversion
-Wimplicit-int-float-conversion
-Wimplicit-retain-self
-Wimport-preprocessor-directive-pedantic
-Wincompatible-function-pointer-types-strict
-Wincomplete-module
-Winconsistent-missing-destructor-override
-Winfinite-recursion
-Wint-in-bool-context
-Winvalid-or-nonexistent-directory
-Winvalid-utf8
-Wkeyword-macro
-Wlanguage-extension-token
-Wlocal-type-template-args
-Wlogical-op-parentheses
-Wlong-long
-Wloop-analysis
-Wmain
-Wmax-tokens
-Wmethod-signatures
-Wmicrosoft
-Wmicrosoft-anon-tag
-Wmicrosoft-charize
-Wmicrosoft-comment-paste
-Wmicrosoft-cpp-macro
-Wmicrosoft-end-of-file
-Wmicrosoft-enum-value
-Wmicrosoft-exception-spec
-Wmicrosoft-fixed-enum
-Wmicrosoft-flexible-array
-Wmicrosoft-redeclare-static
-Wmisleading-indentation
-Wmismatched-tags
-Wmissing-braces
-Wmissing-field-initializers
-Wmissing-method-return-type
-Wmissing-noreturn
-Wmissing-prototypes
-Wmissing-variable-declarations
-Rmodule-build
-Rmodule-import
-Rmodule-include-translation
-Rmodule-lock
-Wmost
-Wmove
-Wnested-anon-types
-Wnewline-eof
-Wnon-gcc
-Wnon-modular-include-in-framework-module

uchar: Fix references to overridden functions with GNULIB_NAMESPACE

2023-09-07 Thread Bruno Haible
clang 16 also produces these warnings:

../gllib/uchar.h:696:10: warning: The symbol ::iswalnum refers to the system 
function. Use gnulib::iswalnum instead. [-Wuser-defined-warnings]
../gllib/uchar.h:711:10: warning: The symbol ::iswalpha refers to the system 
function. Use gnulib::iswalpha instead. [-Wuser-defined-warnings]
../gllib/uchar.h:726:10: warning: The symbol ::iswblank refers to the system 
function. Use gnulib::iswblank instead. [-Wuser-defined-warnings]
../gllib/uchar.h:741:10: warning: The symbol ::iswcntrl refers to the system 
function. Use gnulib::iswcntrl instead. [-Wuser-defined-warnings]
../gllib/uchar.h:756:10: warning: The symbol ::iswdigit refers to the system 
function. Use gnulib::iswdigit instead. [-Wuser-defined-warnings]
../gllib/uchar.h:771:10: warning: The symbol ::iswgraph refers to the system 
function. Use gnulib::iswgraph instead. [-Wuser-defined-warnings]
../gllib/uchar.h:786:10: warning: The symbol ::iswlower refers to the system 
function. Use gnulib::iswlower instead. [-Wuser-defined-warnings]
../gllib/uchar.h:801:10: warning: The symbol ::iswprint refers to the system 
function. Use gnulib::iswprint instead. [-Wuser-defined-warnings]
../gllib/uchar.h:816:10: warning: The symbol ::iswpunct refers to the system 
function. Use gnulib::iswpunct instead. [-Wuser-defined-warnings]
../gllib/uchar.h:831:10: warning: The symbol ::iswspace refers to the system 
function. Use gnulib::iswspace instead. [-Wuser-defined-warnings]
../gllib/uchar.h:846:10: warning: The symbol ::iswupper refers to the system 
function. Use gnulib::iswupper instead. [-Wuser-defined-warnings]
../gllib/uchar.h:861:10: warning: The symbol ::iswxdigit refers to the system 
function. Use gnulib::iswxdigit instead. [-Wuser-defined-warnings]
../gllib/uchar.h:879:10: warning: The symbol ::towlower refers to the system 
function. Use gnulib::towlower instead. [-Wuser-defined-warnings]
../gllib/uchar.h:894:10: warning: The symbol ::towupper refers to the system 
function. Use gnulib::towupper instead. [-Wuser-defined-warnings]
../gllib/uchar.h:912:10: warning: The symbol ::wcwidth refers to the system 
function. Use gnulib::wcwidth instead. [-Wuser-defined-warnings]
../gllib/uchar.h:958:10: warning: The symbol ::wcsnrtombs refers to the system 
function. Use gnulib::wcsnrtombs instead. [-Wuser-defined-warnings]
../gllib/uchar.h:981:10: warning: The symbol ::wcsrtombs refers to the system 
function. Use gnulib::wcsrtombs instead. [-Wuser-defined-warnings]
../gllib/uchar.h:1027:10: warning: The symbol ::wcswidth refers to the system 
function. Use gnulib::wcswidth instead. [-Wuser-defined-warnings]
../gllib/uchar.h:1130:10: warning: The symbol ::mbsnrtowcs refers to the system 
function. Use gnulib::mbsnrtowcs instead. [-Wuser-defined-warnings]
../gllib/uchar.h:1153:10: warning: The symbol ::mbsrtowcs refers to the system 
function. Use gnulib::mbsrtowcs instead. [-Wuser-defined-warnings]
../gllib/uchar.h:1216:10: warning: The symbol ::wctype refers to the system 
function. Use gnulib::wctype instead. [-Wuser-defined-warnings]
../gllib/uchar.h:1239:10: warning: The symbol ::iswctype refers to the system 
function. Use gnulib::iswctype instead. [-Wuser-defined-warnings]
../gllib/uchar.h:1280:10: warning: The symbol ::wctrans refers to the system 
function. Use gnulib::wctrans instead. [-Wuser-defined-warnings]
../gllib/uchar.h:1302:10: warning: The symbol ::towctrans refers to the system 
function. Use gnulib::towctrans instead. [-Wuser-defined-warnings]

The cause is that when, in C++ mode, GNULIB_NAMESPACE is defined, the function
overrides provided by  and  are not named 'rpl_'
but 'GNULIB_NAMESPACE::'. However, the inline functions in uchar.h need
to invoke the overridden, not the system functions. This patch fixes it.


2023-09-07  Bruno Haible  

uchar: Fix references to overridden functions with GNULIB_NAMESPACE.
* lib/uchar.in.h (btoc32, c32isalnum, c32isalpha, c32isblank,
c32iscntrl, c32isdigit, c32isgraph, c32islower, c32isprint, c32ispunct,
c32isspace, c32isupper, c32isxdigit, c32tolower, c32toupper, c32width,
c32snrtombs, c32srtombs, c32swidth, c32tob, mbsnrtoc32s, mbsrtoc32s,
c32_get_type_test, c32_apply_type_test, c32_get_mapping,
c32_apply_mapping): Use GNULIB_NAMESPACE:: prefix to refer to the gnulib
overridden function.
* modules/uchar (Depends-on): Add wctype-h.
(Makefile.am): Substitute GNULIB_BTOWC, GNULIB_ISWDIGIT,
GNULIB_ISWXDIGIT, GNULIB_WCWIDTH, GNULIB_WCSNRTOMBS, GNULIB_WCSRTOMBS,
GNULIB_WCSWIDTH, GNULIB_WCTOB, GNULIB_MBSNRTOWCS, GNULIB_MBSRTOWCS,
GNULIB_WCTYPE, GNULIB_ISWCTYPE, GNULIB_WCTRANS, GNULIB_TOWCTRANS.

diff --git a/lib/uchar.in.h b/lib/uchar.in.h
index 3193340242..1856aec823 100644
--- a/lib/uchar.in.h
+++ b/lib/uchar.in.h
@@ -162,7 +162,11 @@ _GL_BEGIN_C_LINKAGE
 _GL_INLINE _GL_ATTRIBUTE_PURE wint_t
 btoc32 (int c)
 {
-  return btowc (c);
+  return
+#  if @GNULIB_BTOWC@ && 

tests: Fix some clang -Wimplicit-fallthrough warnings

2023-09-07 Thread Bruno Haible
Some clang -Wimplicit-fallthrough warnings are easy to fix:

test-execute-main.c:95:5: warning: unannotated fall-through between switch 
labels [-Wimplicit-fallthrough]
test-sys_file.c:33:5: warning: unannotated fall-through between switch labels 
[-Wimplicit-fallthrough]


2023-09-07  Bruno Haible  

tests: Fix some clang -Wimplicit-fallthrough warnings.
* tests/test-execute-main.c (main): Add 'break' statement.
* tests/test-sys_file.c (main): Likewise.

diff --git a/tests/test-execute-main.c b/tests/test-execute-main.c
index cdbb5bd761..afd6a749bd 100644
--- a/tests/test-execute-main.c
+++ b/tests/test-execute-main.c
@@ -92,6 +92,7 @@ main (int argc, char *argv[])
   for (fd = 3; fd < 20; fd++)
 close (fd);
 }
+  break;
 default:
   break;
 }
diff --git a/tests/test-sys_file.c b/tests/test-sys_file.c
index 347d6d2dd3..dae5fa2d79 100644
--- a/tests/test-sys_file.c
+++ b/tests/test-sys_file.c
@@ -29,9 +29,9 @@ main (void)
 case LOCK_EX:
 case LOCK_NB:
 case LOCK_UN:
-  ;
+  break;
 default:
-  ;
+  break;
 }
   return 0;
 }






unictype/category-none: Fix clang -Wpedantic warning

2023-09-07 Thread Bruno Haible
clang also gives this warning:

unictype/categ_none.c:30:13: warning: initializing 'const void *' with an 
expression of type 'bool (*)(ucs4_t, uint32_t)' (aka 'bool (*)(unsigned int, 
unsigned int)') converts between void pointer and function pointer [-Wpedantic]

The problem is the initializer of a 'union' field that is not the first field.
Fortunately, ISO C designated initializers are nowadays widely usable.


2023-09-07  Bruno Haible  

unictype/category-none: Fix clang -Wpedantic warning.
* lib/unictype/categ_none.c (_UC_CATEGORY_NONE): Use ISO C designated
initializer syntax to initialize the intended field of the union.

diff --git a/lib/unictype/categ_none.c b/lib/unictype/categ_none.c
index 89f4949333..43ae957aa2 100644
--- a/lib/unictype/categ_none.c
+++ b/lib/unictype/categ_none.c
@@ -27,4 +27,4 @@ always_false (ucs4_t uc, uint32_t bitmask)
 }
 
 const uc_general_category_t _UC_CATEGORY_NONE =
-  { 0, 1, { _false } };
+  { 0, 1, { .lookup_fn = _false } };






c-*snprintf: Fix some clang -Wmissing-prototypes warnings

2023-09-07 Thread Bruno Haible
Building a gnulib testdir with clang 16 and many warning options, I get
these warnings:

./vasnprintf.c:2204:1: warning: no previous prototype for function 
'c_vasnprintf' [-Wmissing-prototypes]
c-snprintf.c:41:1: warning: no previous prototype for function 'c_snprintf' 
[-Wmissing-prototypes]
c-vsnprintf.c:43:1: warning: no previous prototype for function 'c_vsnprintf' 
[-Wmissing-prototypes]

Missing prototypes in tests/ are harmless, but in lib/ it's worth looking at
and fixing. Here the problem is that the specification header has not been
included; this is not best practice.


2023-09-07  Bruno Haible  

c-*snprintf: Fix some clang -Wmissing-prototypes warnings.
* lib/c-snprintf.c: Include c-snprintf.h instead of .
* lib/c-vsnprintf.c: Include c-vsnprintf.h instead of .
* lib/c-vasnprintf.c: Include c-vasnprintf.h.

diff --git a/lib/c-snprintf.c b/lib/c-snprintf.c
index 592e0e3cd4..305eb05832 100644
--- a/lib/c-snprintf.c
+++ b/lib/c-snprintf.c
@@ -19,7 +19,7 @@
 #include 
 
 /* Specification.  */
-#include 
+#include "c-snprintf.h"
 
 #include 
 #include 
diff --git a/lib/c-vasnprintf.c b/lib/c-vasnprintf.c
index 745e09cc07..92cde63172 100644
--- a/lib/c-vasnprintf.c
+++ b/lib/c-vasnprintf.c
@@ -16,6 +16,9 @@
 
 #include 
 
+/* Specification.  */
+#include "c-vasnprintf.h"
+
 #include 
 
 #include "printf-parse.h"
diff --git a/lib/c-vsnprintf.c b/lib/c-vsnprintf.c
index ffb975622a..cc63fd62d1 100644
--- a/lib/c-vsnprintf.c
+++ b/lib/c-vsnprintf.c
@@ -21,7 +21,7 @@
 #endif
 
 /* Specification.  */
-#include 
+#include "c-vsnprintf.h"
 
 #include 
 #include