Skip to content

Commit

Permalink
lib/gettext:
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
sf-mensch committed Oct 16, 2022
1 parent 6af1384 commit 5f04ce2
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 33 deletions.
2 changes: 1 addition & 1 deletion cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 13 additions & 14 deletions cobc/codeoptim.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;");
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand Down
9 changes: 8 additions & 1 deletion lib/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

2022-10-16 Simon Sobisch <[email protected]>

* 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 <[email protected]>

* Makefile.am: libtoolized libsupport
Expand Down Expand Up @@ -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.
41 changes: 28 additions & 13 deletions lib/gettext.h
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
/* Convenience header for conditional use of GNU <libintl.h>.
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 <https://www.gnu.org/licenses/>. */

#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 <libintl.h>
Expand Down Expand Up @@ -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
Expand All @@ -156,7 +163,7 @@ pgettext_aux (const char *domain,
return translation;
}

#ifdef __GNUC__
#if defined __GNUC__ || defined __clang__
__inline
#else
#ifdef __cplusplus
Expand All @@ -183,8 +190,16 @@ npgettext_aux (const char *domain,

#include <string.h>

#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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions libcob/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libcob/mlio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5f04ce2

Please sign in to comment.