]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
intl: Improve declaration of 'struct binding'.
authorBruno Haible <bruno@clisp.org>
Fri, 2 Jun 2023 23:25:53 +0000 (01:25 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 2 Jun 2023 23:25:53 +0000 (01:25 +0200)
* autogen.sh (GNULIB_MODULES_LIBINTL): Add flexmember.
* gettext-runtime/intl/gettextP.h (struct binding): Use FLEXIBLE_ARRAY_MEMBER
instead of ZERO.
* gettext-runtime/intl/bindtextdom.c: Include flexmember.h.
(offsetof): Remove fallback definition.
(set_binding_values): Use FLEXNSIZEOF.

autogen.sh
gettext-runtime/intl/bindtextdom.c
gettext-runtime/intl/gettextP.h

index e72f445c401ea284a99baf8f9a8a0b71a5750cf8..44f9ad59e2f8b869a1bd465703e96d7a8a0f0f35 100755 (executable)
@@ -112,6 +112,7 @@ if ! $skip_gnulib; then
     attribute
     bison
     filename
+    flexmember
     havelib
     lib-symbol-visibility
     localcharset
index 62bd418805a56d0dc8ae64b151d10059303131f9..3c64cc193669fdf903b96a407baeb277fbb1e69b 100644 (file)
@@ -1,5 +1,5 @@
 /* Implementation of the bindtextdomain(3) function
-   Copyright (C) 1995-2021 Free Software Foundation, Inc.
+   Copyright (C) 1995-2023 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
 # include "glthread/lock.h"
 #endif
 
-/* Some compilers, like SunOS4 cc, don't have offsetof in <stddef.h>.  */
-#ifndef offsetof
-# define offsetof(type,ident) ((size_t)&(((type*)0)->ident))
-#endif
+#include "flexmember.h"
 
 /* @@ end of prolog @@ */
 
@@ -237,7 +234,9 @@ set_binding_values (const char *domainname,
       /* We have to create a new binding.  */
       size_t len = strlen (domainname) + 1;
       struct binding *new_binding =
-       (struct binding *) malloc (offsetof (struct binding, domainname) + len);
+       (struct binding *)
+       malloc (FLEXNSIZEOF (struct binding, domainname, len));
+
 
       if (__builtin_expect (new_binding == NULL, 0))
        goto failed;
index 9219b3cfe2f273dca1afbd6d9845bbaa19868985..de34a968cd1593504f7d880c04439cd4bcea36b1 100644 (file)
@@ -211,7 +211,7 @@ struct binding
   wchar_t *wdirname;
 #endif
   char *codeset;
-  char domainname[ZERO];
+  char domainname[FLEXIBLE_ARRAY_MEMBER];
 };
 
 /* A counter which is incremented each time some previous translations