Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/gnucobol-3.x' into gcos4gnucob…
Browse files Browse the repository at this point in the history
…ol-3.x
  • Loading branch information
ddeclerck committed Jan 26, 2024
2 parents f059c84 + 12e31f9 commit 824f2a6
Show file tree
Hide file tree
Showing 15 changed files with 241 additions and 63 deletions.
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ NEWS - user visible changes -*- outline -*-
to stop compiliation at first error use -Wfatal-errors
** default value for -fmax-errors was changed from 128 to 20

** New option -fdiagnostics-absolute-paths to print the full path of
a file for diagnostics; this flag can be activated if your editor and
build system do not correctly work together to locate files from
diagnostic output

* More notable changes

** execution times were significantly reduced for the following:
Expand Down
2 changes: 1 addition & 1 deletion build_windows/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@
#define PACKAGE_NAME "GnuCOBOL"

/* Define to the version of this package. */
#define PACKAGE_VERSION "3.2-dev"
#define PACKAGE_VERSION "3.3-dev"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION
Expand Down
15 changes: 15 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

2023-11-29 Fabrice Le Fessant <[email protected]>

* cobc.c (cobc_clean_up): when save-temps specifies a directory,
do not move object files and preprocess files when they were
specified as an explicit target on the command line (-E, -c)

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

BUG #923: generated modules init/clear unused decimal constants
Expand All @@ -22,6 +28,14 @@
* codegen.c (codegen_internal, codegen_finalize): move declaration
of decimal constants from global storage to local storage

2023-10-02 Fabrice Le Fessant <[email protected]>

* error.c (print_error_prefix), flag.def: new flag
-fdiagnostics-absolute-paths to print the full path of
a file for diagnostics; this flag can be activated if
your editor and build system do not correctly work
together to locate files from diagnostic output

2023-09-12 Simon Sobisch <[email protected]>

* codegen.c (literal_list): removed self-reference as tree
Expand All @@ -45,6 +59,7 @@

2023-09-01 Simon Sobisch <[email protected]>

FR #443: error handling for non-cobol "sources"
* pplex.l (ppopen_get_file): test for binary file and directly error out
* cobc.c (cobc_terminate_exit), cobc.h: split cobc_terminate and make
the new function available
Expand Down
8 changes: 6 additions & 2 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,8 @@ clean_up_intermediates (struct filename *fn, const int status)
if (fn->need_preprocess
&& (status
|| cb_compile_level > CB_LEVEL_PREPROCESS
|| (cb_compile_level == CB_LEVEL_PREPROCESS && save_temps))) {
|| (cb_compile_level == CB_LEVEL_PREPROCESS
&& save_temps && !save_temps_dir))) {
cobc_check_action (fn->preprocess);
}
/* CHECKME: we had reports of unexpected intermediate
Expand Down Expand Up @@ -2287,7 +2288,8 @@ cobc_clean_up (const int status)
if (fn->need_assemble
&& (status
|| cb_compile_level > CB_LEVEL_ASSEMBLE
|| (cb_compile_level == CB_LEVEL_ASSEMBLE && save_temps))) {
|| (cb_compile_level == CB_LEVEL_ASSEMBLE
&& save_temps && !save_temps_dir))) {
cobc_check_action (fn->object);
}
clean_up_intermediates (fn, status);
Expand Down Expand Up @@ -3575,6 +3577,8 @@ process_command_line (const int argc, char **argv)
/* -fdiagnostics-plain-output */
cb_diagnostics_show_caret = 0 ;
cb_diagnostics_show_line_numbers = 0;
/* in the future, may also disable urls,
colors, text art, flow paths */
break;

case 'P':
Expand Down
37 changes: 37 additions & 0 deletions cobc/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,20 @@
#include <ctype.h>
#include <errno.h>
#include <stdarg.h>
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif

#include "cobc.h"
#include "tree.h"

#ifdef _WIN32
#if !defined(__BORLANDC__) && !defined(__WATCOMC__) && !defined(__ORANGEC__)
#include <direct.h> // _getcwd
#define getcwd _getcwd
#endif
#endif

enum cb_error_kind {
CB_KIND_ERROR,
CB_KIND_WARNING,
Expand All @@ -57,13 +67,40 @@ static void
print_error_prefix (const char *file, int line, const char *prefix)
{
if (file) {
char *absfile = NULL ;
if (cb_diagnostics_absolute_paths
&& strcmp (file, COB_DASH) != 0
&& file[0] != '/'
&& file[0] != '\\'
&& file[1] != ':'){
int filelen = strlen (file);
int dirlen = 256;
char *cwd ;
absfile = cobc_malloc( dirlen + 1 + filelen + 1 );
cwd = getcwd (absfile, dirlen);
if (cwd != NULL ){
#ifdef HAVE_SYS_STAT_H
struct stat st;
#endif
dirlen = strlen (cwd);
absfile[dirlen] = '/';
memcpy (absfile+dirlen+1, file, filelen+1);
#ifdef HAVE_SYS_STAT_H
if (!stat (absfile,&st))
#endif
{
file = absfile;
}
}
}
if (line <= 0) {
fprintf (stderr, "%s: ", file);
} else if (cb_msg_style == CB_MSG_STYLE_MSC) {
fprintf (stderr, "%s(%d): ", file, line);
} else {
fprintf (stderr, "%s:%d: ", file, line);
}
if (absfile) cobc_free (absfile);
}
if (prefix) {
fprintf (stderr, "%s", prefix);
Expand Down
3 changes: 3 additions & 0 deletions cobc/flag.def
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,6 @@ CB_FLAG_ON (cb_diagnostics_show_caret, 1, "diagnostics-show-caret",

CB_FLAG_ON (cb_diagnostics_show_line_numbers, 1, "diagnostics-show-line-numbers",
_(" -fno-diagnostics-show-line-numbers\tsuppress display of line numbers in diagnostics"))

CB_FLAG (cb_diagnostics_absolute_paths, 1, "diagnostics-absolute-paths",
_(" -fdiagnostics-absolute-paths\tprint absolute paths in diagnostics"))
10 changes: 5 additions & 5 deletions cobc/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -5998,14 +5998,16 @@ cb_build_binary_op (cb_tree x, const enum cb_binary_op_op op, cb_tree y)
&& !(CB_FIELD_PTR (x)->usage == CB_USAGE_COMP_5
|| CB_FIELD_PTR (x)->usage == CB_USAGE_COMP_X)) {
cb_error_x (CB_TREE(current_statement),
_("%s should be COMP-X/COMP-5 for logical operator"), CB_FIELD_PTR (x)->name);
_("%s should be COMP-X/COMP-5 for logical operator"),
CB_FIELD_PTR (x)->name);
return cb_error_node;
}
if ((CB_REF_OR_FIELD_P (y))
&& !(CB_FIELD_PTR (y)->usage == CB_USAGE_COMP_5
|| CB_FIELD_PTR (y)->usage == CB_USAGE_COMP_X)) {
cb_error_x (CB_TREE(current_statement),
_("%s should be COMP-X/COMP-5 for logical operator"), CB_FIELD_PTR (y)->name);
_("%s should be COMP-X/COMP-5 for logical operator"),
CB_FIELD_PTR (y)->name);
return cb_error_node;
}
if (cb_constant_folding
Expand Down Expand Up @@ -6382,9 +6384,7 @@ cb_build_binary_op (cb_tree x, const enum cb_binary_op_op op, cb_tree y)
cb_tree
cb_build_binary_list (cb_tree l, const int op)
{
cb_tree e;

e = CB_VALUE (l);
cb_tree e = CB_VALUE (l);
for (l = CB_CHAIN (l); l; l = CB_CHAIN (l)) {
e = cb_build_binary_op (e, op, CB_VALUE (l));
}
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ AC_CACHE_SAVE

# Checks for header files.
dnl entries only used from external includes -> likely no need to check here
dnl AC_CHECK_HEADERS([stdint.h whcar.h malloc.h])
dnl AC_CHECK_HEADERS([whcar.h malloc.h])
# mandatory:
AC_CHECK_HEADERS([sys/types.h signal.h stddef.h], [],
[AC_MSG_ERROR([mandatory header could not be found or included])])
Expand Down
30 changes: 30 additions & 0 deletions doc/gnucobol.texi
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ Compiler options
* Build target:: Build target
* Source format:: Source format
* Warning options:: Warning options
* Diagnostics options:: Diagnostics options
* Configuration options:: Configuration options
* Listing options:: Listing options
* Debug switches:: Debug switches
Expand Down Expand Up @@ -281,6 +282,7 @@ A complete list of options can be displayed by using the option @option{--help}.
* Build target:: Build target
* Source format:: Source format
* Warning options:: Warning options
* Diagnostics options:: Diagnostics options
* Configuration options:: Configuration options
* Listing options:: Listing options
* Debug switches:: Debug switches
Expand Down Expand Up @@ -651,6 +653,34 @@ Warn if statements are likely unreachable. This is @emph{not} set with @option{-
Enable warnings that don't have an own warning flag.
@end table

@node Diagnostics options
@subsection Diagnostics options

The compiler provides some options to tune the way errors and warnings
(diagnostics) are displayed to the user.

@table @code

@item -fdiagnostics-absolute-paths
Print absolute paths in diagnostics. This option can be useful if your editor is not able
to correctly locate relative paths in your project.

@item -fdiagnostics-plain-output
Make diagnostic output as plain as possible.

@item -fno-diagnostics-show-option
Suppress output of option that directly controls the diagnostic, on which
warnings should be displayed.

@item -fno-diagnostics-show-caret
Do not display source context on warning/error diagnostic. By default, diagnostics
contain an excerpt with two lines before and after the location.

@item -fno-diagnostics-show-line-numbers
Suppress display of line numbers in the source context in diagnostics

@end table

@node Configuration options
@subsection Configuration options

Expand Down
16 changes: 13 additions & 3 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@
2023-12-14 David Declerck <[email protected]>

* common.c (cob_terminate_routines, cob_call_with_exception_check):
add a mechanism to postpone unloading of modules when using longjmp,
as this is not safe on Windows (its implementation of longjmp
performs stack-unwinding)
add a mechanism to postpone unloading of modules when using longjmp,
as this is not safe on Windows (its implementation of longjmp
performs stack-unwinding)

2023-11-29 Fabrice Le Fessant <[email protected]>

* common.c (cob_get_strerror), coblocal.h: export as utility function
* common.c (cob_expand_env_string): fix potention buffer overflow

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

* common.h: use stdint.h and inttypes.h when available to
define cob_s64_t, cob_u64_t and the various CB_FMT_ macros

2023-10-04 Simon Sobisch <[email protected]>

* fileio.c (lineseq_write, lineseq_rewrite): fix bug #918 partial broken
COB_LS_VALIDATE by incrementing pointer outside of macro IS_BAD_CHAR

2023-09-15 Simon Sobisch <[email protected]>

Fixing Bug #914 CLOSE LOCK abends program on OPEN
Expand Down
1 change: 1 addition & 0 deletions libcob/coblocal.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ COB_HIDDEN int cob_check_env_true (char*);
COB_HIDDEN int cob_check_env_false (char*);
COB_HIDDEN const char *cob_get_last_exception_name (void);
COB_HIDDEN void cob_parameter_check (const char *, const int);
COB_HIDDEN char* cob_get_strerror (void);

enum cob_case_modifier {
CCM_NONE,
Expand Down
9 changes: 5 additions & 4 deletions libcob/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ cob_get_source_line ()
}

/* reentrant version of strerror */
static char *
char *
cob_get_strerror (void)
{
size_t size;
Expand Down Expand Up @@ -7802,9 +7802,10 @@ cob_expand_env_string (char *strval)
}
}
if (penv != NULL) {
if ((strlen (penv) + j) > (envlen - 128)) {
env = cob_realloc (env, envlen, strlen (penv) + 256);
envlen = strlen (penv) + 256;
size_t copy_len = strlen (penv);
if (copy_len + j + 128 > envlen) {
env = cob_realloc (env, envlen, j + copy_len + 256);
envlen = j + copy_len + 256;
}
j += sprintf (&env[j], "%s", penv);
penv = NULL;
Expand Down
39 changes: 20 additions & 19 deletions libcob/screenio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3105,27 +3105,26 @@ extract_line_and_col_vals (cob_field *line, cob_field *column,
*sline = 0;
*scolumn = 0;
return;
}
if (line->size < 4) {
/* this is used when only a LINE clause is specified,
not an AT clause */
cobol_line = cob_get_int (line);
cobol_col = 1;
} else {
if (line->size < 4) {
/* this is used when only a LINE clause is specified,
not an AT clause */
cobol_line = cob_get_int (line);
cobol_col = 1;
} else {
/* common case: line actually contains both the
line and field numbers */
int ret = get_line_and_col_from_field
(line, &cobol_line, &cobol_col);
/* LCOV_EXCL_START */
if (unlikely (ret == 1)) {
#if 0 /* Throw an exception? EC-SCREEN-IMP-LINE-VAR-LENGTH? */
cob_set_exception (COB_EC_SCREEN_IMP);
/* common case: line actually contains both the
line and field numbers */
int ret = get_line_and_col_from_field
(line, &cobol_line, &cobol_col);
/* LCOV_EXCL_START */
if (unlikely (ret == 1)) {
#if 0 /* Throw an exception? EC-SCREEN-IMP-LINE-VAR-LENGTH? */
cob_set_exception (COB_EC_SCREEN_IMP);
#else
cob_fatal_error (COB_FERROR_CODEGEN);
cob_fatal_error (COB_FERROR_CODEGEN);
#endif
}
/* LCOV_EXCL_STOP */
}
/* LCOV_EXCL_STOP */
}
} else {
get_line_column (line, column, &cobol_line, &cobol_col);
Expand Down Expand Up @@ -4188,7 +4187,7 @@ cob_display_field (cob_field *f, const cob_flags_t fattr, const char *parms, ...

if (parms && *parms) {
va_list args;
const char *p = parms;
const char *p = parms;

va_start (args, parms);
for (;;) {
Expand Down Expand Up @@ -4828,10 +4827,12 @@ cob_sys_get_char (unsigned char *fld)
return -1;
}
}
return 0;
#else
/* this function is only valid for extended screenio! */
COB_UNUSED (fld);
return -2;
#endif
return 0;
}

/* set CurSoR position on screen,
Expand Down
Loading

0 comments on commit 824f2a6

Please sign in to comment.