[PATCH] quotearg: constify get_quoting_style parameters
* lib/quotearg.h (get_quoting_style): Mark parameter as const. * lib/quotearg.c (get_quoting_style): Likewise. --- ChangeLog | 6 ++ lib/quotearg.c | 2 +- lib/quotearg.h | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2b8276f..81c5391 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2015-11-03 P??draig Brady + + quotearg: constify get_quoting_style parameters + * lib/quotearg.h (get_quoting_style): Mark parameter as const. + * lib/quotearg.c (get_quoting_style): Likewise. + 2015-11-02 P??draig Brady quotearg: add support for $'' shell escaping diff --git a/lib/quotearg.c b/lib/quotearg.c index 77896bf..8505081 100644 --- a/lib/quotearg.c +++ b/lib/quotearg.c @@ -120,7 +120,7 @@ clone_quoting_options (struct quoting_options *o) /* Get the value of O's quoting style. If O is null, use the default. */ enum quoting_style -get_quoting_style (struct quoting_options *o) +get_quoting_style (struct quoting_options const *o) { return (o ? o : &default_quoting_options)->style; } diff --git a/lib/quotearg.h b/lib/quotearg.h index 2b7c93c..edee3b5 100644 --- a/lib/quotearg.h +++ b/lib/quotearg.h @@ -278,7 +278,7 @@ struct quoting_options; struct quoting_options *clone_quoting_options (struct quoting_options *o); /* Get the value of O's quoting style. If O is null, use the default. */ -enum quoting_style get_quoting_style (struct quoting_options *o); +enum quoting_style get_quoting_style (struct quoting_options const *o); /* In O (or in the default if O is null), set the value of the quoting style to S. */ -- 2.5.0
Re: [PATCH] intprops: add WRAPV and const flavors for GCC 5
FYI I just noticed this when compiling coreutils with GCC 5.1.1 test-intprops.c: In function 'main': test-intprops.c:199:3: error: string length '5031' is greater than the length '4095' ISO C99 compilers are required to support [-Werror=overlength-strings] CHECK_BINOP (/, DIVIDE, INT_MIN, -1, int, ^ CC test-isatty.o CC test-isblank.o test-intprops.c:202:3: error: string length '4737' is greater than the length '4095' ISO C99 compilers are required to support [-Werror=overlength-strings] CHECK_BINOP (/, DIVIDE, (unsigned int) INT_MIN, -1u, unsigned int, ^ CC test-isnand-nolibm.o In file included from test-intprops.c:28:0: ../lib/intprops.h:357:60: error: suggest parentheses around '-' inside '<<' [-Werror=parentheses] #define INT_LEFT_SHIFT_WRAPV(a, b) _GL_INT_OP_WRAPV (a, b, <<)
Re: [PATCH] Re: stdint.h, C++ and __STDC_LIMIT_MACROS
On 11/03/2015 02:32 AM, Paul Eggert wrote: > Pedro Alves wrote: >> Instead of trying to detect the right types, detect >> good-enough-pre-C++11 stdint.h and in such case make the substitute >> stdint.h just wrap the system's stdint.h with >> __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined. > > Instead, how about just adding the necessary #defines for > __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS to config.h if they are needed to > fix > the bug? Then we can leave stdint.h alone (perhaps not even build stdint.h > at all). The downside could be that config.h's #defines are unconditional, instead of guarded against multiple definition with #ifndef, as they are currently in the replacement stdint.h. I was worried (a bit) that that may break packages that have build systems that pass something like -D__STDC_CONSTANT_MACROS on the command line. But because -DFOO defines FOO as 1, this doesn't error out: echo "#define FOO 1" | g++ -Werror -DFOO -E - Given that config.h defines symbols to 1, I guess that concern is moot. (But that speaks nothing of other compilers gnulib supports, naturally.) I'll update the patch in that direction. Thanks, Pedro Alves
Re: [PATCH] Re: stdint.h, C++ and __STDC_LIMIT_MACROS
On 11/03/2015 02:45 PM, Pedro Alves wrote: > On 11/03/2015 02:32 AM, Paul Eggert wrote: >> Pedro Alves wrote: >>> Instead of trying to detect the right types, detect >>> good-enough-pre-C++11 stdint.h and in such case make the substitute >>> stdint.h just wrap the system's stdint.h with >>> __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined. >> >> Instead, how about just adding the necessary #defines for >> __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS to config.h if they are needed to >> fix >> the bug? Then we can leave stdint.h alone (perhaps not even build stdint.h >> at all). > I'll update the patch in that direction. Here's the updated patch. --- >From e6f4dc6da7d2ef60a5647e4d1bc673572011a463 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 2 Nov 2015 14:52:18 + Subject: [PATCH] stdint: detect good enough pre-C++11 stdint.h in C++ mode When gnulib is configured in C++ mode for a system with a working C99 implementation of stdint.h that predates C++11, gnulib ends up substituing stdint.h anyway. This works on most targets, but on e.g., 64-bit MinGW, it doesn't, as gnulib's substitute assumes LP64, while MinGW is LLP64: ~~~ /* 7.18.1.4. Integer types capable of holding object pointers */ #undef intptr_t #undef uintptr_t typedef long int gl_intptr_t; typedef unsigned long int gl_uintptr_t; #define intptr_t gl_intptr_t #define uintptr_t gl_uintptr_t ~~~ Instead of trying to detect the right types, detect good-enough-pre-C++11 stdint.h and in such case define __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS in config.h. * m4/stdint.m4 (gl_STDINT_H): Always define __STDC_CONSTANT_MACROS / __STDC_LIMIT_MACROS while checking whether the system stdint.h conforms to C99. If it does, check whether it hides symbols behind the __STDC_{CONSTANT|LIMIT}_MACROS macros. Then if it does, define those macros in config.h. --- m4/stdint.m4 | 29 - 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/m4/stdint.m4 b/m4/stdint.m4 index 4011a49..4244c05 100644 --- a/m4/stdint.m4 +++ b/m4/stdint.m4 @@ -1,4 +1,4 @@ -# stdint.m4 serial 43 +# stdint.m4 serial 44 dnl Copyright (C) 2001-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -70,6 +70,8 @@ AC_DEFUN_ONCE([gl_STDINT_H], AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ +#define __STDC_CONSTANT_MACROS 1 +#define __STDC_LIMIT_MACROS 1 #include /* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in . */ #if !(defined WCHAR_MIN && defined WCHAR_MAX) @@ -218,6 +220,8 @@ struct s { AC_RUN_IFELSE([ AC_LANG_PROGRAM([[ #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ +#define __STDC_CONSTANT_MACROS 1 +#define __STDC_LIMIT_MACROS 1 #include ] gl_STDINT_INCLUDES @@ -279,6 +283,29 @@ static const char *macro_values[] = ]) fi if test "$gl_cv_header_working_stdint_h" = yes; then +dnl Now see whether the system works without +dnl __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined. +AC_CACHE_CHECK([whether stdint.h predates C++11], + [gl_cv_header_stdint_predates_cxx11_h], + [gl_cv_header_stdint_predates_cxx11_h=yes + AC_COMPILE_IFELSE([ +AC_LANG_PROGRAM([[ +#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ +#include +] +gl_STDINT_INCLUDES +[ +intmax_t im = INTMAX_MAX; +int32_t i32 = INT32_C (0x7fff); + ]])], + [gl_cv_header_stdint_predates_cxx11_h=no])]) + +if test "$gl_cv_header_stdint_predates_cxx11_h" = yes; then + AC_DEFINE([__STDC_CONSTANT_MACROS], [1], +[Define to 1 if the system predates C++11.]) + AC_DEFINE([__STDC_LIMIT_MACROS], [1], +[Define to 1 if the system predates C++11.]) +fi STDINT_H= else dnl Check for , and for -- 1.9.3
Re: [PATCH] intprops: add WRAPV and const flavors for GCC 5
On Tue, Nov 3, 2015 at 5:26 AM, Pádraig Brady wrote: > FYI I just noticed this when compiling coreutils with GCC 5.1.1 > > test-intprops.c: In function 'main': > test-intprops.c:199:3: error: string length '5031' is greater than the length > '4095' ISO C99 compilers are required to support [-Werror=overlength-strings] >CHECK_BINOP (/, DIVIDE, INT_MIN, -1, int, >^ > CC test-isatty.o > CC test-isblank.o > test-intprops.c:202:3: error: string length '4737' is greater than the length > '4095' ISO C99 compilers are required to support [-Werror=overlength-strings] >CHECK_BINOP (/, DIVIDE, (unsigned int) INT_MIN, -1u, unsigned int, >^ > CC test-isnand-nolibm.o > In file included from test-intprops.c:28:0: > ../lib/intprops.h:357:60: error: suggest parentheses around '-' inside '<<' > [-Werror=parentheses] > #define INT_LEFT_SHIFT_WRAPV(a, b) _GL_INT_OP_WRAPV (a, b, <<) I have fixed the latter with the attached, just-pushed patch: From 24fb386f25ce0800577ac64f2d2303822e9e615c Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 3 Nov 2015 08:32:27 -0800 Subject: [PATCH] intprops: add parentheses for when OP has precedence lower than "-" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lib/intprops.h (_GL_INT_OP_WRAPV_VIA_UNSIGNED): In "a OP b - c", "a OP b" must be parenthesized for when OP is like "<<", which has lower precedence than the following "-". Reported by Pádraig Brady. --- ChangeLog | 7 +++ lib/intprops.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 81c5391..df3829d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2015-11-03 Jim Meyering + + intprops: add parentheses for when OP has precedence lower than "-" + * lib/intprops.h (_GL_INT_OP_WRAPV_VIA_UNSIGNED): In "a OP b - c", + "a OP b" must be parenthesized for when OP is like "<<", which has + lower precedence than the following "-". Reported by Pádraig Brady. + 2015-11-03 Pádraig Brady quotearg: constify get_quoting_style parameters diff --git a/lib/intprops.h b/lib/intprops.h index 4441f1c..b561f14 100644 --- a/lib/intprops.h +++ b/lib/intprops.h @@ -401,7 +401,7 @@ #define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, t) \ ((unsigned t) (a) op (unsigned t) (b) <= TYPE_MAXIMUM (t) \ ? (t) ((unsigned t) (a) op (unsigned t) (b)) \ - : ((t) ((unsigned t) (a) op (unsigned t) (b) - TYPE_MINIMUM (t)) \ + : ((t) (((unsigned t) (a) op (unsigned t) (b)) - TYPE_MINIMUM (t)) \ + TYPE_MINIMUM (t))) /* Calls to the INT__ macros are like their INT_CONST__ -- 2.6.0