Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/gnucobol-3.x' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed May 13, 2024
2 parents 87c4fb2 + 1daa393 commit 5ba97ae
Show file tree
Hide file tree
Showing 23 changed files with 558 additions and 338 deletions.
8 changes: 7 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

2024-05-02 Simon Sobisch <[email protected]>

* configure.ac: use pkg-config (with a fallback to ncurses-config) for
getting link / compile information for ncurses/ncursesw; now honoring
NCURSES_CONFIG, NCURSES_LIBS and NCURSES_FLAGS; document XML2_CONFIG

2023-10-17 David Declerck <[email protected]>

* configure.ac: add checks to allow using stdint.h and inttypes.h
Expand Down Expand Up @@ -1579,7 +1585,7 @@
* Version 0.9 released.


Copyright 2002-2023 Free Software Foundation, Inc.
Copyright 2002-2024 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.
7 changes: 6 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NEWS - user visible changes -*- outline -*-

GnuCOBOL 3.3 (planned January 2023)
GnuCOBOL 3.3 (planned ASAP)

work in progress

Expand Down Expand Up @@ -71,6 +71,11 @@ NEWS - user visible changes -*- outline -*-
$b for executable basename, $d for date in YYYYMMDD format, $t for time
in HHMMSS format (before, only $$ was available for pid)

* New build features

** configure now uses pkg-config/ncurses-config to search for ncurses and
honors NCURSES_LIBS and NCURSES_CFLAGS

* Known issues in 3.x

** testsuite:
Expand Down
Empty file modified build_aux/ar-lib
100644 → 100755
Empty file.
26 changes: 22 additions & 4 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@

2024-05-03 Simon Sobisch <[email protected]>

* cobc.c (main): refactored to not need iterating via "iparams"
* flag.def (cb_flag_use_constructor), cobc.c (main), cobc.h,
codegen.c (codegen_internal, output_so_load_version_check):
new flag -fuse-constructor to override possible use of that feature;
internally disabling it for generation of libraries/executable after
first program as we only need that code once, fixing Win32 build errors
and duplication warnings in other environments
* flag.def: don't suppress the help of -fwinmain under Win32
* typeck.c (build_expr_finish): use fallback error position token, fixing
compiler aborts on broken expressions, bugs #933, #938 and #966
* typeck.c: minor refactoring within functions

2024-04-24 Fabrice Le Fessant <[email protected]>

* replace.c: optimize speed and memory usage. For speed, we add two
Expand All @@ -10,7 +24,7 @@
queue of tokens instead of a list.

2024-03-17 Fabrice Le Fessant <[email protected]>
Emilien Lemaire <[email protected]>
Emilien Lemaire <[email protected]>

* parser.y: generate calls to "cob_prof_function_call" in the
parsetree when profiling is unabled, when entering/leaving
Expand All @@ -35,7 +49,7 @@
2024-01-28 Fabrice Le Fessant <[email protected]>

* parser.y: fix SEGFAULT when checking the BY VALUE arguments of a
prototype with ANY LENGTH
prototype with ANY LENGTH

2024-01-25 David Declerck <[email protected]>

Expand Down Expand Up @@ -7293,7 +7307,11 @@

2014-12-11 Ron Norman <[email protected]>

* Fixes so WARNING is given if no DETAIL lines in a report
* Fixes so WARNING is given if no DETAIL lines in a repor

2014-06-17 Ron Norman <[email protected]>

* parser.y, tree.c, codegen.c: Added check to verify PAGE LIMITS of report

2014-06-16 Simon Sobisch <[email protected]>

Expand Down Expand Up @@ -10023,7 +10041,7 @@
dropping some options for now


Copyright 2001-2023 Free Software Foundation, Inc.
Copyright 2001-2024 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.
94 changes: 51 additions & 43 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2001-2023 Free Software Foundation, Inc.
Copyright (C) 2001-2024 Free Software Foundation, Inc.
Authors:
Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Brian Tiffin,
Expand Down Expand Up @@ -2516,7 +2516,7 @@ static void
cobc_print_version (void)
{
printf ("cobc (%s) %s.%d\n", PACKAGE_NAME, PACKAGE_VERSION, PATCH_LEVEL);
puts ("Copyright (C) 2023 Free Software Foundation, Inc.");
puts ("Copyright (C) 2024 Free Software Foundation, Inc.");
printf (_("License GPLv3+: GNU GPL version 3 or later <%s>"), "https://gnu.org/licenses/gpl.html");
putchar ('\n');
puts (_("This is free software; see the source for copying conditions. There is NO\n"
Expand Down Expand Up @@ -3852,15 +3852,14 @@ process_command_line (const int argc, char **argv)
case CB_FLAG_GETOPT_TTITLE: /* 6 */
/* -fttitle=<title> : Title for listing */
{
size_t i, len;

const size_t len = strlen (cob_optarg);
size_t i;
if (cb_listing_with_title)
cobc_main_free (cb_listing_with_title);
cb_listing_with_title = cobc_main_strdup (cob_optarg);
len = strlen (cb_listing_with_title);
for (i=0; i<len; i++){
if( cb_listing_with_title[i]=='_' )
cb_listing_with_title[i]=' ';
for (i = 0; i < len; i++) {
if (cb_listing_with_title[i] == '_')
cb_listing_with_title[i] = ' ';
}
}
break;
Expand Down Expand Up @@ -3920,8 +3919,7 @@ process_command_line (const int argc, char **argv)
if (strlen (cob_optarg) > (COB_MINI_MAX)) {
cobc_err_exit (COBC_INV_PAR, "--copy");
}
CB_TEXT_LIST_ADD (cb_copy_list,
cobc_strdup (cob_optarg));
CB_TEXT_LIST_ADD (cb_copy_list, cobc_strdup (cob_optarg));
break;

case CB_FLAG_GETOPT_INCLUDE_FILE: /* 19 */
Expand All @@ -3930,8 +3928,7 @@ process_command_line (const int argc, char **argv)
if (strlen (cob_optarg) > (COB_MINI_MAX)) {
cobc_err_exit (COBC_INV_PAR, "--include");
}
CB_TEXT_LIST_ADD (cb_include_file_list,
cobc_strdup (cob_optarg));
CB_TEXT_LIST_ADD (cb_include_file_list, cobc_strdup (cob_optarg));
cb_flag_c_decl_for_static_call = 0;
break;

Expand Down Expand Up @@ -4122,7 +4119,8 @@ process_command_line (const int argc, char **argv)
}

#if 0 /* TODO: */
if (cb_compile_level == CB_LEVEL_PREPROCESS && output_name && strcmp (output_name, COB_DASH) != 0)) {
if (cb_compile_level == CB_LEVEL_PREPROCESS
&& output_name && strcmp (output_name, COB_DASH) != 0)) {
cb_depend_file = output_file;
}
#endif
Expand Down Expand Up @@ -9233,7 +9231,6 @@ int
main (int argc, char **argv)
{
struct filename *fn;
unsigned int iparams;
unsigned int local_level;
int status;
int statuses = 0;
Expand Down Expand Up @@ -9278,8 +9275,9 @@ main (int argc, char **argv)
cb_compile_level = CB_LEVEL_MODULE;
cobc_flag_module = 1;
}
} else if (cb_compile_level != CB_LEVEL_PREPROCESS &&
!cobc_flag_main && !cobc_flag_module && !cobc_flag_library) {
} else
if (cb_compile_level != CB_LEVEL_PREPROCESS
&& !cobc_flag_main && !cobc_flag_module && !cobc_flag_library) {
cobc_flag_module = 1;
}
} else {
Expand All @@ -9302,15 +9300,13 @@ main (int argc, char **argv)

{
struct cb_text_list *l;
for (l = cb_copy_list; l; l=l->next){
const char *filename;
int has_ext;
for (l = cb_copy_list; l; l = l->next) {
const size_t len = strlen (l->text) + 1;
const int has_ext = strchr (l->text, '.') != NULL;
/* note: check for COB_MINI_MAX was done when adding to cb_copy_list */
char name[COB_MINI_BUFF];
int len = strlen (l->text);
memcpy (name, l->text, len+1);
has_ext = (strchr (name, '.') != NULL);
filename = cb_copy_find_file (name, has_ext);
if (!filename){
memcpy (name, l->text, len);
if (cb_copy_find_file (name, has_ext) == NULL) {
cobc_err_exit (_("fatal error: could not find --copy argument %s"), name);
}
}
Expand Down Expand Up @@ -9380,40 +9376,52 @@ main (int argc, char **argv)
}
}

/* resolve runtime name from first file */
if (cobc_flag_run) {
if (file_list->file_is_stdin
&& cb_compile_level == CB_LEVEL_EXECUTABLE) {
run_name = COB_DASH_OUT;
} else {
run_name = file_basename (file_list->source, NULL);
}
run_name = cobc_main_strdup (run_name);
}

/* process all files */
status = 0;
iparams = 0;
local_level = 0;

for (fn = file_list; fn; fn = fn->next) {
iparams++;
if (iparams == 1 && cobc_flag_run) {
if (fn->file_is_stdin
&& cb_compile_level == CB_LEVEL_EXECUTABLE) {
run_name = COB_DASH_OUT;
} else {
run_name = file_basename (fn->source, NULL);
}
run_name = cobc_main_strdup (run_name);
}
if (iparams > 1 && cb_compile_level == CB_LEVEL_EXECUTABLE) {
/* only the first source has the compile_level and main flag set */
local_level = cb_compile_level;
cb_compile_level = CB_LEVEL_ASSEMBLE;
cobc_flag_main = 0;
}
status = process_file (fn, status);
statuses += status;

/* take care for all intermediate files which aren't needed for linking */
clean_up_intermediates (fn, status);

/* first source-only handling */
if (cb_compile_level == CB_LEVEL_EXECUTABLE) {
/* only the first source has the compile_level and main flag set */
local_level = cb_compile_level;
cb_compile_level = CB_LEVEL_ASSEMBLE;
cobc_flag_main = 0;
if (cb_flag_use_constructor == 1) {
/* we only need one check, already generated for first source */
cb_flag_use_constructor = 2;
}
} else
if (cb_compile_level == CB_LEVEL_LIBRARY
&& cb_flag_use_constructor == 1) {
/* we only need one check, already generated for first source */
cb_flag_use_constructor = 2;
}
}

if (cobc_list_file) {
if (cb_listing_file != stdout)
if (cb_listing_file != stdout) {
fclose (cb_listing_file);
else
} else {
fflush (stdout);
}
cb_listing_file = NULL;
}

Expand Down
5 changes: 3 additions & 2 deletions cobc/cobc.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2001-2012, 2014-2022 Free Software Foundation, Inc.
Copyright (C) 2001-2012, 2014-2024 Free Software Foundation, Inc.
Written by Keisuke Nishida, Roger While, Simon Sobisch,
Edward Hart, Ron Norman, Dave Pitts
Expand Down Expand Up @@ -440,7 +440,8 @@ extern int cb_flag_dump;
extern int cb_unix_lf;

extern int cb_flag_main; /* set if "main" requested by -x */
extern int cobc_flag_main; /* set only until first program compiled, for general: use cb_flag_main*/
/* set only until first program compiled, for general: use cb_flag_main */
extern int cobc_flag_main;
extern int cobc_wants_debug;
extern int cb_listing_xref;
extern int cobc_seen_stdin;
Expand Down
49 changes: 26 additions & 23 deletions cobc/codegen.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2003-2023 Free Software Foundation, Inc.
Copyright (C) 2003-2024 Free Software Foundation, Inc.
Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch,
Edward Hart
Expand Down Expand Up @@ -12635,18 +12635,17 @@ output_internal_function (struct cb_program *prog, cb_tree parameter_list)
output_line ("P_initialize:");
output_newline ();

/* Check matching version */
#if !defined (HAVE_ATTRIBUTE_CONSTRUCTOR)
/* Check matching version in program init */
if ( (cb_flag_use_constructor == 0 /* if constructor option disabled */
#ifdef _WIN32
if (prog->flag_main) /* otherwise we generate that in DllMain */
#else
if (!prog->nested_level)
|| prog->flag_main /* or under Win32 (where we can only use DllMain) for executables */
#endif
{
)
/* no use in generating that for nested programs, as the outest program must be started first */
&& !prog->nested_level) {
output_line ("cob_check_version (COB_SOURCE_FILE, COB_PACKAGE_VERSION, COB_PATCH_LEVEL);");
output_newline ();
}
#endif

/* Resolve user functions */
for (clp = func_call_cache; clp; clp = clp->next) {
Expand Down Expand Up @@ -13906,25 +13905,28 @@ codegen_init (struct cb_program *prog, const char *translate_name)
/* Check matching version via constructor attribute / DllMain */
static void output_so_load_version_check (struct cb_program *prog)
{
#if defined (HAVE_ATTRIBUTE_CONSTRUCTOR)
#if defined (_WIN32)
if (prog->flag_main) {
return;
}
output_newline ();
output_line ("#include \"windows.h\"");
output_line ("BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);");
output_line ("BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)");
output_block_open ();
output_line ("if (fdwReason == DLL_PROCESS_ATTACH)");
output_line ("\tcob_check_version (COB_SOURCE_FILE, COB_PACKAGE_VERSION, COB_PATCH_LEVEL);");
output_line ("return TRUE;");
output_block_close ();
output_newline ();
#else
output_newline ();
output_line ("static void gc_module_so_init () __attribute__ ((constructor));");
output_line ("static void gc_module_so_init ()");
output_block_open ();
output_line ("cob_check_version (COB_SOURCE_FILE, COB_PACKAGE_VERSION, COB_PATCH_LEVEL);");
output_block_close ();
output_newline ();
#elif defined (_WIN32)
if (!prog->flag_main) {
output_line ("#include \"windows.h\"");
output_line ("BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);");
output_line ("BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)");
output_block_open ();
output_line ("if (fdwReason == DLL_PROCESS_ATTACH)");
output_line ("\tcob_check_version (COB_SOURCE_FILE, COB_PACKAGE_VERSION, COB_PATCH_LEVEL);");
output_line ("return TRUE;");
output_block_close ();
output_newline ();
}
#endif
}

Expand Down Expand Up @@ -13994,8 +13996,9 @@ codegen_internal (struct cb_program *prog, const int subsequent_call)
if (!subsequent_call) {
output ("/* Functions */");
output_newline ();
output_newline ();
output_so_load_version_check (prog);
if (cb_flag_use_constructor == 1) {
output_so_load_version_check (prog);
}
}

if (prog->prog_type == COB_MODULE_TYPE_FUNCTION) {
Expand Down
Loading

0 comments on commit 5ba97ae

Please sign in to comment.