From 5f04ce2fe4914d1dde20622efc1f2d37bdfb920e Mon Sep 17 00:00:00 2001 From: sf-mensch Date: Sun, 16 Oct 2022 16:27:24 +0000 Subject: [PATCH] lib/gettext: * gettext.h: updated from GNU gettext 0.21, featuring: * license change from GPL to LGPL * optimizations also enabled for clang * [HAVE_NO_NGETTEXT]: manual addition to support systems that have gettext but not ngettext (which is only used in GnuCOBOL 4+) libcob: * common.c, mlio.c: fixed some compile warnings cobc/codeoptim.c: more optimizations (missed in previous commits) --- cobc/ChangeLog | 2 +- cobc/codeoptim.c | 27 +++++++++++++-------------- lib/ChangeLog | 9 ++++++++- lib/gettext.h | 41 ++++++++++++++++++++++++++++------------- libcob/common.c | 6 +++--- libcob/mlio.c | 2 +- 6 files changed, 54 insertions(+), 33 deletions(-) diff --git a/cobc/ChangeLog b/cobc/ChangeLog index 3bd9e6943..00940214f 100644 --- a/cobc/ChangeLog +++ b/cobc/ChangeLog @@ -964,7 +964,7 @@ COB_CHK_ODO, COB_CHK_REFMOD_MIN, COB_CHK_REFMOD for inline checks of most-used runtime checks - now only passed to libcob in case of actual errors; new entry COB_NOP to replace the cob_nop call (frame switch) - by a simple pointer comparison, which also ensures on all tested + by a simple pointer comparision, which also ensures on all tested compilers that the line is not optimized out, and for those that optimize the check away the old cob_nop call is still done diff --git a/cobc/codeoptim.c b/cobc/codeoptim.c index 89654dfc7..62ab09e7a 100644 --- a/cobc/codeoptim.c +++ b/cobc/codeoptim.c @@ -105,7 +105,7 @@ cob_gen_optim (const enum cb_optim val) output_storage (" cob_field *content, unsigned int is_suppressed,"); output_storage (" cob_ml_tree *children, cob_ml_tree *sibling)"); output_storage ("{"); - output_storage (" tree->name = name;"); + output_storage (" tree->name = name;"); output_storage (" tree->attrs = attrs;"); output_storage (" tree->content = content;"); output_storage (" tree->is_suppressed = is_suppressed;"); @@ -225,13 +225,13 @@ cob_gen_optim (const enum cb_optim val) output_storage ("{"); output_storage (" register const unsigned char *p;"); output_storage (" register int n;"); - output_storage (" register int retval = 0;"); + output_storage (" register int val = 0;"); output_storage (" p = (const unsigned char *)data;"); output_storage (" for (n = 0; n < size; ++n, ++p) {"); - output_storage (" retval *= 10;"); - output_storage (" retval += (*p & 0x0F);"); + output_storage (" val = (val * 10)"); + output_storage (" + (*p & 0x0F);"); output_storage (" }"); - output_storage (" return retval;"); + output_storage (" return val;"); output_storage ("}"); return; @@ -241,18 +241,17 @@ cob_gen_optim (const enum cb_optim val) output_storage ("{"); output_storage (" register const unsigned char *p;"); output_storage (" register int n;"); - output_storage (" register int retval = 0;"); + output_storage (" register int val = 0;"); output_storage (" p = (const unsigned char *)data;"); output_storage (" for (n = 0; n < size; ++n, ++p) {"); - output_storage (" retval *= 10;"); - output_storage (" if ((*p & 0x40) && (n + 1) == size) {"); - output_storage (" retval += (*p & 0x0F);"); - output_storage (" retval = -retval;"); - output_storage (" } else {"); - output_storage (" retval += (*p & 0x0F);"); - output_storage (" }"); + output_storage (" val = (val * 10)"); + output_storage (" + (*p & 0x0F);"); output_storage (" }"); - output_storage (" return retval;"); + output_storage (" p--;"); + output_storage (" if (*p & 0x40) {"); + output_storage (" return -val;"); + output_storage (" }"); + output_storage (" return val;"); output_storage ("}"); return; diff --git a/lib/ChangeLog b/lib/ChangeLog index 5162ce341..72ae79455 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,4 +1,11 @@ +2022-10-16 Simon Sobisch + + * gettext.h: updated from GNU gettext 0.21, + featuring license change from GPL to LGPL an optimizations for clang + * gettext.h [HAVE_NO_NGETTEXT]: manual addition to support systems that + have gettext but not ngettext (which is only used in GnuCOBOL 4+) + 2020-09-30 Simon Sobisch * Makefile.am: libtoolized libsupport @@ -45,7 +52,7 @@ * getopt.c, getopt.h, getopt1.c: Extracted from glibc-2.2.5. -Copyright 2002-2012, 2017 Free Software Foundation, Inc. +Copyright 2002-2012, 2017, 2020, 2022 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted provided the copyright notice and this notice are preserved. diff --git a/lib/gettext.h b/lib/gettext.h index 117090149..0ea18eff7 100644 --- a/lib/gettext.h +++ b/lib/gettext.h @@ -1,25 +1,32 @@ /* Convenience header for conditional use of GNU . - Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2016 Free Software + Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2020 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ #ifndef _LIBGETTEXT_H #define _LIBGETTEXT_H 1 -/* NLS can be disabled through the configure --disable-nls option. */ -#if ENABLE_NLS + +/* NLS can be disabled through the configure --disable-nls option + or through "#define ENABLE NLS 0" before including this file. */ +#if defined ENABLE_NLS && ENABLE_NLS + +#if defined HAVE_NO_NGETTEXT /* GnuCOBOL addition */ +#define dcngettext(domain,msgid,msgid_pl,n,category) \ + dcgettext (domain, msgid, category); n = 1 +#endif /* Get declarations of GNU message catalog functions. */ # include @@ -137,7 +144,7 @@ #define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) -#ifdef __GNUC__ +#if defined __GNUC__ || defined __clang__ __inline #else #ifdef __cplusplus @@ -156,7 +163,7 @@ pgettext_aux (const char *domain, return translation; } -#ifdef __GNUC__ +#if defined __GNUC__ || defined __clang__ __inline #else #ifdef __cplusplus @@ -183,8 +190,16 @@ npgettext_aux (const char *domain, #include -#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ - /* || __STDC_VERSION__ >= 199901L */ ) +/* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported. + This relates to the -Wvla and -Wvla-larger-than warnings, enabled in + the default GCC many warnings set. This allows programs to disable use + of VLAs, which may be unintended, or may be awkward to support portably, + or may have security implications due to non-deterministic stack usage. */ + +#if (!defined GNULIB_NO_VLA \ + && (((__GNUC__ >= 3 || defined __clang__) && !defined __STRICT_ANSI__) \ + /* || (__STDC_VERSION__ == 199901L && !defined __HP_cc) + || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ )) # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1 #else # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0 @@ -199,7 +214,7 @@ npgettext_aux (const char *domain, #define dpgettext_expr(Domainname, Msgctxt, Msgid) \ dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) -#ifdef __GNUC__ +#if defined __GNUC__ || defined __clang__ __inline #else #ifdef __cplusplus @@ -246,7 +261,7 @@ dcpgettext_expr (const char *domain, #define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) -#ifdef __GNUC__ +#if defined __GNUC__ || defined __clang__ __inline #else #ifdef __cplusplus diff --git a/libcob/common.c b/libcob/common.c index 381ae2a44..abaf5c909 100644 --- a/libcob/common.c +++ b/libcob/common.c @@ -464,7 +464,7 @@ static struct config_tbl gc_conf[] = { {"COB_SEQ_CONCAT_NAME","seq_concat_name","0",NULL,GRP_FILE,ENV_BOOL,SETPOS(cob_concat_name)}, {"COB_SEQ_CONCAT_SEP","seq_concat_sep","+",NULL,GRP_FILE,ENV_CHAR,SETPOS(cob_concat_sep),1}, {"COB_SORT_CHUNK", "sort_chunk", "256K", NULL, GRP_FILE, ENV_SIZE, SETPOS (cob_sort_chunk), (128 * 1024), (16 * 1024 * 1024)}, - {"COB_SORT_MEMORY", "sort_memory", "128M", NULL, GRP_FILE, ENV_SIZE, SETPOS (cob_sort_memory), (1024*1024), 4294967294 /* max. guaranteed - 1 */}, + {"COB_SORT_MEMORY", "sort_memory", "128M", NULL, GRP_FILE, ENV_SIZE, SETPOS (cob_sort_memory), (1024*1024), 4294967294UL /* max. guaranteed - 1 */}, {"COB_SYNC", "sync", "0", syncopts, GRP_FILE, ENV_BOOL, SETPOS (cob_do_sync)}, #ifdef WITH_DB {"DB_HOME", "db_home", NULL, NULL, GRP_FILE, ENV_FILE, SETPOS (bdb_home)}, @@ -7134,7 +7134,7 @@ set_config_val (char *value, int pos) } else { /* use max. guaranteed value for unsigned long to raise a warning as max value is limit to one less */ - numval = 4294967295; + numval = 4294967295UL; } ptr++; break; @@ -7144,7 +7144,7 @@ set_config_val (char *value, int pos) } else { /* use max. guaranteed value for unsigned long to raise a warning as max value is limit to one less */ - numval = 4294967295; + numval = 4294967295UL; } ptr++; break; diff --git a/libcob/mlio.c b/libcob/mlio.c index 2d3981207..e88c80341 100644 --- a/libcob/mlio.c +++ b/libcob/mlio.c @@ -1106,7 +1106,7 @@ int cob_xml_parse (cob_field *in, cob_field *encoding, cob_field *validation, } } - /* user user-initiated exception condition (-1) /*/ + /* user user-initiated exception condition (-1) */ if (xml_code == -1) { /* xml code stays with one */ xml_free_parse_memory (state);