From: Nick Bowler Date: Wed, 10 Mar 2021 01:44:49 +0000 (-0500) Subject: Minor portability improvements. X-Git-Tag: v1.1~9 X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/commitdiff_plain/41d0e2f8f2dc0ec50526ff6e4b8ff12936d1f90e Minor portability improvements. 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. --- diff --git a/common b/common index 1688bad..e218d44 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 1688bad1e5dc89cacf33bc426c92a4abf2bc0647 +Subproject commit e218d4445fa5a2015163cf50d847980ff3240b36 diff --git a/m4/.gitignore b/m4/.gitignore index e43c15a..c87e520 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -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 @@ -36,30 +42,39 @@ /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 diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 index 8d5104d..8b8af8f 100644 --- a/m4/gnulib-cache.m4 +++ b/m4/gnulib-cache.m4 @@ -39,6 +39,7 @@ # --libtool \ # --macro-prefix=gl \ # --no-vc-files \ +# flexmember \ # getopt-gnu \ # gettext-h \ # gitlog-to-changelog \ @@ -46,12 +47,14 @@ # 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 ]) diff --git a/src/error.c b/src/error.c index 3d0a38e..093f56c 100644 --- a/src/error.c +++ b/src/error.c @@ -20,6 +20,7 @@ #include #include #include + #include #include @@ -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. */ diff --git a/src/explain.c b/src/explain.c index 0f6b787..0d9c957 100644 --- a/src/explain.c +++ b/src/explain.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -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); }