]> git.draconx.ca Git - cdecl99.git/commitdiff
Minor portability improvements.
authorNick Bowler <nbowler@draconx.ca>
Wed, 10 Mar 2021 01:44:49 +0000 (20:44 -0500)
committerNick Bowler <nbowler@draconx.ca>
Wed, 10 Mar 2021 01:44:49 +0000 (20:44 -0500)
Pull in the Gnulib snprintf and flexmember modules to get better
portability improvements related to these C features.

Update dxcommon to get some recent bug fixes.

common
m4/.gitignore
m4/gnulib-cache.m4
src/error.c
src/explain.c

diff --git a/common b/common
index 1688bad1e5dc89cacf33bc426c92a4abf2bc0647..e218d4445fa5a2015163cf50d847980ff3240b36 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 1688bad1e5dc89cacf33bc426c92a4abf2bc0647
+Subproject commit e218d4445fa5a2015163cf50d847980ff3240b36
index e43c15abff1b2643662d5aa025cb7dedf1a1ce67..c87e5200fbb3eff997d93e148704312bd59a29aa 100644 (file)
@@ -1,9 +1,13 @@
 /00gnulib.m4
 /absolute-header.m4
+/alloca.m4
 /codeset.m4
 /errno_h.m4
+/exponentd.m4
 /extensions.m4
 /extern-inline.m4
+/flexmember.m4
+/float_h.m4
 /getdelim.m4
 /getline.m4
 /getopt.m4
@@ -19,7 +23,9 @@
 /inline.m4
 /intl-thread-locale.m4
 /intlmacosx.m4
+/intmax_t.m4
 /inttypes.m4
+/inttypes_h.m4
 /lib-ld.m4
 /lib-link.m4
 /lib-prefix.m4
 /ltsugar.m4
 /ltversion.m4
 /lt~obsolete.m4
+/math_h.m4
 /mbrtowc.m4
 /mbsinit.m4
 /mbstate_t.m4
 /mbswidth.m4
+/memchr.m4
+/mmap-anon.m4
 /multiarch.m4
 /nls.m4
 /nocrash.m4
 /off_t.m4
 /pid_t.m4
 /po.m4
+/printf.m4
 /progtest.m4
 /pthread_rwlock_rdlock.m4
 /readline.m4
 /setlocale_null.m4
+/size_max.m4
+/snprintf.m4
 /ssize_t.m4
 /std-gnu11.m4
 /stdbool.m4
 /stddef_h.m4
 /stdint.m4
+/stdint_h.m4
 /stdio_h.m4
+/string_h.m4
 /sys_types_h.m4
 /threadlib.m4
 /tls.m4
 /unistd_h.m4
+/vasnprintf.m4
 /visibility.m4
 /warn-on-use.m4
 /wchar_h.m4
@@ -67,4 +82,5 @@
 /wctype_h.m4
 /wcwidth.m4
 /wint_t.m4
+/xsize.m4
 /zzgnulib.m4
index 8d5104d59f3ceba93f480773195aa1caf2dcfd9f..8b8af8f4d353e5315d877eb552280cba6e702dca 100644 (file)
@@ -39,6 +39,7 @@
 #  --libtool \
 #  --macro-prefix=gl \
 #  --no-vc-files \
+#  flexmember \
 #  getopt-gnu \
 #  gettext-h \
 #  gitlog-to-changelog \
 #  lock \
 #  mbswidth \
 #  readline \
+#  snprintf \
 #  striconv \
 #  tls
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([])
 gl_MODULES([
+  flexmember
   getopt-gnu
   gettext-h
   gitlog-to-changelog
@@ -59,6 +62,7 @@ gl_MODULES([
   lock
   mbswidth
   readline
+  snprintf
   striconv
   tls
 ])
index 3d0a38e3f83218f739c45f4905ff58c68fa3207f..093f56c5c58e134800998fce8ad05c3e28dfabe3 100644 (file)
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
+
 #include <glthread/lock.h>
 #include <glthread/tls.h>
 
@@ -32,7 +33,7 @@ static gl_tls_key_t tls_key;
 struct err_state {
        struct cdecl_error err;
        size_t nstr;
-       char str[];
+       char str[FLEXIBLE_ARRAY_MEMBER];
 };
 
 /* This error is reserved for extremely dire out-of-memory conditions. */
index 0f6b787afcb135122187322b668eb6f35813aa37..0d9c95740ca03ece599a610c881db74ccdcc540e 100644 (file)
@@ -20,6 +20,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include <inttypes.h>
 #include <stdbool.h>
 #include <assert.h>
 
@@ -80,7 +81,7 @@ explain_array(char *buf, size_t n, struct cdecl_array *a)
                rc = snprintf(buf, n, "%s", a->vla);
                ret += cdecl__advance(&buf, &n, rc);
        } else if (a->length) {
-               rc = snprintf(buf, n, "%ju", a->length);
+               rc = snprintf(buf, n, "%" PRIuMAX, a->length);
                ret += cdecl__advance(&buf, &n, rc);
        }