]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
intl: Pacify pre-C99 compilers
authorDaiki Ueno <ueno@gnu.org>
Tue, 24 May 2016 03:18:07 +0000 (12:18 +0900)
committerDaiki Ueno <ueno@gnu.org>
Wed, 25 May 2016 06:25:27 +0000 (15:25 +0900)
* gettext-runtime/intl/plural-exp.h (HAVE_STRUCT_INITIALIZER): New
macro, based on the check previously in plural-exp.c.  Also add check
for __SUNPRO_C for Solaris Studio C compiler.
(GERMANIC_PLURAL): Define as 'struct expression' not 'const struct
expression' if struct/union initializers are not supported by the
compiler.
* gettext-runtime/intl/plural-exp.c: Use HAVE_STRUCT_INITIALIZER.
Reported by Dagobert Michelsen and investigated by pan7 in:
https://savannah.gnu.org/support/?108743

gettext-runtime/intl/plural-exp.c
gettext-runtime/intl/plural-exp.h

index 7f37e549a622e4aa90374a23097bd5ab8bc577f9..b1445ffdf3e0576fe487fd8c0b035ea3c393538d 100644 (file)
@@ -25,9 +25,7 @@
 
 #include "plural-exp.h"
 
-#if (defined __GNUC__ && !(defined __APPLE_CC_ && __APPLE_CC__ > 1) \
-     && !defined __cplusplus)                                       \
-    || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
+#if HAVE_STRUCT_INITIALIZER
 
 /* These structs are the constant expression for the germanic plural
    form determination.  It represents the expression  "n != 1".  */
index 76b882a2e18238ad2d883b9923d11dff90bd0fd2..6278b954072ea4faf65d6499e67e2473a4bcea35 100644 (file)
@@ -105,10 +105,24 @@ struct parse_args
 # define EXTRACT_PLURAL_EXPRESSION extract_plural_expression
 #endif
 
+#if (defined __GNUC__ && !(defined __APPLE_CC_ && __APPLE_CC__ > 1) \
+     && !defined __cplusplus)                                       \
+    || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)    \
+    || (defined __SUNPRO_C && 0x560 <= __SUNPRO_C                   \
+        && !(defined __STDC__ && __STDC__ == 1))
+# define HAVE_STRUCT_INITIALIZER 1
+#else
+# define HAVE_STRUCT_INITIALIZER 0
+#endif
+
 extern void FREE_EXPRESSION (struct expression *exp)
      internal_function;
 extern int PLURAL_PARSE (struct parse_args *arg);
+#if HAVE_STRUCT_INITIALIZER
 extern const struct expression GERMANIC_PLURAL attribute_hidden;
+#else
+extern struct expression GERMANIC_PLURAL attribute_hidden;
+#endif
 extern void EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
                                       const struct expression **pluralp,
                                       unsigned long int *npluralsp)