glib/glib/gnulib
Thomas Haller 5525672a5f build: avoid "-Werror=format-extra-args" warnings in detecting printf for gnulib
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails detection with:

  Running compile:
  Working directory:  /data/src/glib/build/meson-private/tmpoozk2y4b
  Code:

  #include <stdio.h>
  #include <string.h>
  static char buf[100];
  static double zero = 0.0;
  int main ()
  {
    if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0
        || (strcmp (buf, "       inf") != 0
            && strcmp (buf, "  infinity") != 0))
      return 1;
    return 0;
  }

  -----------
  Command line: `cc /data/src/glib/build/meson-private/tmpoozk2y4b/testfile.c -o /data/src/glib/build/meson-private/tmpoozk2y4b/output.exe -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  /data/src/glib/build/meson-private/tmpoozk2y4b/testfile.c: In function 'main':
  /data/src/glib/build/meson-private/tmpoozk2y4b/testfile.c:8:21: error: too many arguments for format [-Werror=format-extra-args]
      8 |   if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0
        |                     ^~~~~~~
  cc1: all warnings being treated as errors
  -----------
  Could not compile test file /data/src/glib/build/meson-private/tmpoozk2y4b/testfile.c: 1

  Checking if "printf supports the zero flag correctly" runs: DID NOT COMPILE
2024-02-07 20:40:59 +01:00
..
gl_cv_cc_double_expbit0 meson: Use meson.can_run_host_binaries() 2022-05-06 13:17:11 +01:00
gl_cv_func_frexp_works meson: Use meson.can_run_host_binaries() 2022-05-06 13:17:11 +01:00
gl_cv_func_frexpl_works build: fix compiler warning in gl_cv_func_frexpl_works meson build check 2024-02-07 14:46:57 +01:00
gl_cv_func_ldexpl_works meson: Use meson.can_run_host_binaries() 2022-05-06 13:17:11 +01:00
gl_cv_func_printf_directive_a build: fix compiler warnings in gnulib printf meson build checks 2024-02-07 14:46:57 +01:00
gl_cv_func_printf_directive_f build: avoid "-Werror=format-extra-args" warnings in detecting printf for gnulib 2024-02-07 20:40:59 +01:00
gl_cv_func_printf_directive_ls meson: Use meson.can_run_host_binaries() 2022-05-06 13:17:11 +01:00
gl_cv_func_printf_enomem meson: Use meson.can_run_host_binaries() 2022-05-06 13:17:11 +01:00
gl_cv_func_printf_flag_grouping meson: Use meson.can_run_host_binaries() 2022-05-06 13:17:11 +01:00
gl_cv_func_printf_flag_leftadjust meson: Use meson.can_run_host_binaries() 2022-05-06 13:17:11 +01:00
gl_cv_func_printf_flag_zero build: avoid "-Werror=format-extra-args" warnings in detecting printf for gnulib 2024-02-07 20:40:59 +01:00
gl_cv_func_printf_infinite meson: Use meson.can_run_host_binaries() 2022-05-06 13:17:11 +01:00
gl_cv_func_printf_infinite_long_double meson: Use meson.can_run_host_binaries() 2022-05-06 13:17:11 +01:00
gl_cv_func_printf_long_double build: avoid "-Werror=format-extra-args" warnings in detecting printf for gnulib 2024-02-07 20:40:59 +01:00
gl_cv_func_printf_precision build: fix compiler warnings in gnulib printf meson build checks 2024-02-07 14:46:57 +01:00
gl_cv_long_double_equals_double glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
gl_extern_inline glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
arg-nonnull.h glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
asnprintf.c glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
c++defs.h glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
float+.h glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
fpucw.h glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
frexp.c glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
frexpl.c build: Improve tests for frexpl() and ldexpl() 2019-04-08 17:50:59 +08:00
g-gnulib.h Normalize C source files to end with exactly one newline 2020-06-10 09:48:02 +01:00
glib-gnulib.patch Add the gnulib adaptation patch 2019-03-13 12:38:42 +00:00
gnulib_math.h.in glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
isinf.c Normalize C source files to end with exactly one newline 2020-06-10 09:48:02 +01:00
isnan.c glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
isnand-nolibm.h glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
isnand.c glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
isnanf-nolibm.h build: Check for more math.h functions in gnulib 2019-04-08 17:50:59 +08:00
isnanf.c build: Check for more math.h functions in gnulib 2019-04-08 17:50:59 +08:00
isnanl-nolibm.h glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
isnanl.c glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
meson.build glib/gnulib/meson: Disable some warnings on clang windows builds 2022-10-31 12:00:53 +01:00
printf-args.c glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
printf-args.h glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
printf-frexp.c glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
printf-frexp.h glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
printf-frexpl.c glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
printf-frexpl.h glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
printf-parse.c glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
printf-parse.h glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
printf.c Normalize C source files to end with exactly one newline 2020-06-10 09:48:02 +01:00
printf.h Normalize C source files to end with exactly one newline 2020-06-10 09:48:02 +01:00
README Update glib/gnulib/README 2019-04-08 17:51:00 +08:00
signbitd.c glib/gnulib: Include gnulib_math.h in place of math.h 2019-04-08 17:51:00 +08:00
signbitf.c glib/gnulib: Include gnulib_math.h in place of math.h 2019-04-08 17:51:00 +08:00
signbitl.c glib/gnulib: Include gnulib_math.h in place of math.h 2019-04-08 17:51:00 +08:00
vasnprintf.c glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
vasnprintf.h glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
verify.h glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00
xsize.c Fixing inlining bug in gnulib/xsize.h 2019-09-17 19:48:56 +02:00
xsize.h glib: update internal gnulib from upstream 2019-03-13 12:38:42 +00:00

The files
 
 asnprintf.c 
 printf-args.c
 printf-args.h
 printf-parse.c
 printf-parse.h
 vasnprintf.c
 vasnprintf.h

are taken from the vasnprintf module of the GNUlib package, which can
be found at: 

 http://www.gnu.org/software/gnulib/

All files have been modified to include g-gnulib.h. 

vasnprintf.c has also been modified to include support for long long 
printing if the system printf doesn't. This code is protected by 
#ifndef HAVE_LONG_LONG_FORMAT.

Code has been added to printf-args.[ch], printf-parse.c and vasnprintf.c
to support printing of __int64 values with the I64 format modifier. This
is protected by #ifdef HAVE_INT64_AND_I64.

The files

 printf.h 
 printf.c
 g-gnulib.h

have been written by me. printf.[hc] contain implementations of the  
remaining functions in the printf family based on vasnprintf. 
g-gnulib.h is included by all source files in order to move all
exported functions to the _g_gnulib namespace, replace malloc by
g_malloc and make sure that snprintf is only used if it implements 
C99 return value semantics. 

Matthias Clasen
November 1, 2003

To update:
* Create an empty directory, put a configure.ac file into it.
* Run gnulib-tool --lgpl=2 --import --lib=libgnu --source-base=lib \
  --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. \
  --no-conditional-dependencies --no-libtool --macro-prefix=gl \
  isnand-nolibm isnanf-nolibm isnanl-nolibm printf-frexpl \
  signbit vasnprintf
* Then pick out the files that are already in glib/gnulib subdirectory
  (the rest of the files are not needed):

asnprintf.c
c++defs.h
float+.h
fpucw.h
gnulib_math.h.in (rename from math.in.h)
isnan.c
isnand.c
isnand-nolibm.h
isnanf.c
isnanf-nolibm.h
isnanl.c
isnanl-nolibm.h
printf-args.c
printf-args.h
printf-frexp.c
printf-frexp.h
printf-frexpl.c
printf-frexpl.h
printf-parse.c
printf-parse.h
signbitd.c
signbitf.c
signbitl.c
vasnprintf.c
vasnprintf.h
verify.h
xsize.h

* Then look at the glib-gnulib.patch and re-introduce custom glib changes
  contained in that patch.
* If gnulib_math.h.in got some new @variables@, these will have to be
  somehow set in meson.build, otherwise meson would warn about them
  at configure stage

LRN
June 06, 2018