Skip to content

Commit

Permalink
Merge SVN 3993
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Jun 11, 2024
1 parent d212c67 commit a8a2f6a
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 44 deletions.
7 changes: 7 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,13 @@
* error.c (cb_note_x): fixed late return that lead to listing issues and
memory leak

2020-11-28 Simon Sobisch <[email protected]>

* cobc.c: fixed bad memory access for cobc -v -version
* scanner.l: fixed bad memory access for "missing terminator"
* tree.c, parser.y, field.c: last missing adjustments for cb_warn_opt_val
* codegen.c, error.c, pplex.l, typeck.c: fixed some minor coding issues

2020-11-27 Simon Sobisch <[email protected]>

* cobc.c (process_command_line): early processing for -g and optimization
Expand Down
2 changes: 1 addition & 1 deletion cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2929,7 +2929,7 @@ process_command_line (const int argc, char **argv)
snprintf (cobc_buffer, cobc_buffer_size, "%s -v", cobc_cc);
}
#endif
cobc_buffer[cobc_buffer_size] = 0;
cobc_buffer[cobc_buffer_size - 1] = 0;
process (cobc_buffer);
cobc_free (cobc_buffer);
cobc_buffer = NULL;
Expand Down
18 changes: 9 additions & 9 deletions cobc/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -10815,26 +10815,26 @@ output_report_define_lines (int top, struct cb_report *r, struct cb_field *f, in
char fname[128];

if (f == NULL)
return;
return;
n = f->sister;
c = f->children;
if (n
&& n->storage != CB_STORAGE_REPORT)
&& n->storage != CB_STORAGE_REPORT)
n = NULL;
if (n
&& n->report != r)
&& n->report != r)
n = NULL;
if (c
&& c->storage != CB_STORAGE_REPORT)
&& c->storage != CB_STORAGE_REPORT)
c = NULL;
if (n
&& (n->report_flag & COB_REPORT_LINE)) {
&& (n->report_flag & COB_REPORT_LINE)) {
output_report_define_lines(top, r, n, 0);
}
if (c
&& (c->report_flag & COB_REPORT_LINE)) {
&& (c->report_flag & COB_REPORT_LINE)) {
if (c->flag_occurs
&& !chk_field_variable_size (c)) {
&& !chk_field_variable_size (c)) {
int x;
for (x = 1; x <= c->occurs_max; x++) {
c->report_flag &= ~COB_REPORT_LINE_EMITTED;
Expand Down Expand Up @@ -10891,8 +10891,8 @@ output_report_define_lines (int top, struct cb_report *r, struct cb_field *f, in
output_local("SourceId:%d ",f->report_source_id);
}
if ((f->report_flag & COB_REPORT_LINE)
&& f->children
&& (f->children->report_flag & COB_REPORT_LINE)) {
&& f->children
&& (f->children->report_flag & COB_REPORT_LINE)) {
printf("Warning: Ignoring nested LINE %s %d\n",
(f->report_flag & COB_REPORT_LINE_PLUS)?"PLUS":"",
f->report_line);
Expand Down
4 changes: 2 additions & 2 deletions cobc/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,9 @@ cb_error_always (const char *fmt, ...)
enum cb_warn_val
cb_error (const char *fmt, ...)
{
enum cb_warn_val ret;
const enum cb_warn_opt opt = cb_warn_ignored_error;
const enum cb_warn_val pref = cb_warn_opt_val[opt];
enum cb_warn_val ret = pref;
va_list ap;

cobc_in_repository = 0;
Expand All @@ -410,11 +410,11 @@ cb_error (const char *fmt, ...)
va_start (ap, fmt);
if (!ignore_error) {
print_error (NULL, 0, _("error: "), fmt, ap, NULL);
ret = COBC_WARN_AS_ERROR;
} else if (pref == COBC_WARN_AS_ERROR) {
print_error (NULL, 0, _("error: "), fmt, ap, warning_option_text (opt, pref));
} else {
print_error (NULL, 0, _("warning: "), fmt, ap, warning_option_text (opt, pref));
ret = COBC_WARN_AS_ERROR;
}
va_end (ap);

Expand Down
2 changes: 1 addition & 1 deletion cobc/field.c
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,7 @@ validate_elem_value (const struct cb_field * const f)
}

/* ISO+IEC+1989-2002: 13.16.42.2-10 */
if (cb_warn_ignored_initial_val) {
if (cb_warn_opt_val[cb_warn_ignored_initial_val] != COBC_WARN_DISABLED) {
for (p = f; p; p = p->parent) {
if (p->flag_external) {
cb_warning_x (cb_warn_ignored_initial_val, x,
Expand Down
1 change: 0 additions & 1 deletion cobc/pplex.l
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,6 @@ ppcopy (const char *name, const char *lib, struct cb_replace_list *replace_list)
/* check for library-name with directory-name via environment
(as emulation of specifying a library-name via JCL) */
if (*lib >= 'A' && *lib <= 'Z') {
const char* lib_env;
char envname[COB_MINI_BUFF];

snprintf (envname, (size_t)COB_MINI_MAX, "COB_COPY_LIB_%s", lib);
Expand Down
32 changes: 17 additions & 15 deletions cobc/scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -210,20 +210,22 @@ static void make_synonym (void);
%}

<*>^[ ]?"#CALLFH".*\n {
const char *p1;
char *p2;
if (current_program->extfh) {
cobc_parse_free ((void *)current_program->extfh);
current_program->extfh = NULL;
}
p1 = strchr (yytext, '"');
if (p1) {
++p1;
p2 = strrchr (p1, '"');
if (p2) {
*p2 = 0;
if (strcmp (p1, "EXTFH")) {
current_program->extfh = cobc_parse_strdup (p1);
if (current_program) {
const char *p1;
char *p2;
if (current_program->extfh) {
cobc_parse_free ((void *)current_program->extfh);
current_program->extfh = NULL;
}
p1 = strchr (yytext, '"');
if (p1) {
++p1;
p2 = strrchr (p1, '"');
if (p2) {
*p2 = 0;
if (strcmp (p1, "EXTFH")) {
current_program->extfh = cobc_parse_strdup (p1);
}
}
}
}
Expand Down Expand Up @@ -1362,7 +1364,7 @@ read_literal (const char mark, const char *type)
) {
snprintf (err_msg, COB_MINI_MAX,
_("missing terminating %c character"), mark);
plex_buff[cb_lit_length] = 0; /* ensure valid C-string for error message */
plex_buff[cb_lit_length - 0] = 0; /* ensure valid C-string for error message */
error_literal ("", plex_buff);
}

Expand Down
2 changes: 1 addition & 1 deletion cobc/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -6970,7 +6970,7 @@ warn_if_no_definition_seen_for_prototype (const struct cb_prototype *proto)
return;
}

if (cb_warn_prototypes) {
if (cb_warn_opt_val[cb_warn_ignored_initial_val] != COBC_WARN_DISABLED) {
if (strcmp (proto->name, proto->ext_name) == 0) {
/*
Warn if no definition seen for element with prototype-
Expand Down
19 changes: 10 additions & 9 deletions cobc/typeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -7863,11 +7863,9 @@ cb_emit_call (cb_tree prog, cb_tree par_using, cb_tree returning,
continue;
}
if (CB_PURPOSE_INT (l) == CB_CALL_BY_REFERENCE) {
if (cb_warn_call_params) {
if (f->level != 01 && f->level != 77) {
cb_warning_x (cb_warn_call_params, x,
_("'%s' is not a 01 or 77 level item"), CB_NAME (x));
}
if (f->level != 01 && f->level != 77) {
cb_warning_x (cb_warn_call_params, x,
_("'%s' is not a 01 or 77 level item"), CB_NAME (x));
}
check_list = cb_list_add (check_list, x);
} else if (f->flag_any_length) {
Expand Down Expand Up @@ -9216,15 +9214,18 @@ cb_emit_initialize (cb_tree vars, cb_tree fillinit, cb_tree value,
def_init = (def != NULL);
for (l = vars; l; l = CB_CHAIN (l)) {
x = CB_VALUE (l);
if (!(CB_REFERENCE_P (x) && CB_FIELD_P (CB_REFERENCE (x)->value)) &&
!CB_FIELD_P (x)) {
if (CB_VALID_TREE (x)
&& ( CB_FIELD_P (x)
|| (CB_REFERENCE_P (x) && CB_FIELD_P (CB_REFERENCE (x)->value)))) {
/* as expected */
} else {
cb_error_x (CB_TREE (current_statement), _("invalid INITIALIZE statement"));
return;
}

f = CB_FIELD_PTR (x);
odo_level = 0;
while(f->children)
while (f->children)
f = f->children;
for (p = f; p; p = p->parent) {
if (p->depending) {
Expand Down Expand Up @@ -13110,7 +13111,7 @@ validate_pointer_clause (cb_tree pointer, cb_tree pointee)
struct cb_field *pointer_field = CB_FIELD_PTR (pointer);

if (pointer_field->children) {
cb_error_x (pointer, _("'%s' is not an elementary item"),
cb_error_x (pointee, _("'%s' is not an elementary item"),
CB_NAME (pointer));
return;
}
Expand Down
5 changes: 5 additions & 0 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,11 @@
* call.c, common.c, fileio.c, intrinsic.c, mlio.c, strings.c:
reduced scope of some variables

2020-11-28 Simon Sobisch <[email protected]>

* common.c (cob_check_version): restored compat option for GC 2.x pre 2.2
* fileio.c, screenio.c, strings.c, termio.c: fixed some minor coding issues

2020-11-27 Simon Sobisch <[email protected]>

* common.c, common.h: added externalized cob_nop to have a portable way to
Expand Down
6 changes: 3 additions & 3 deletions libcob/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1597,10 +1597,10 @@ looks_absolute (char *src)
{
/* no file path adjustment if filename is absolute
because it begins with a slash (or win-disk-drive) */
if (file_open_name[0] == '/'
|| file_open_name[0] == SLASH_CHAR
if (src[0] == '/'
|| src[0] == SLASH_CHAR
#if WIN32
|| file_open_name[1] == ':'
|| src[1] == ':'
#endif
) {
return 1;
Expand Down
5 changes: 3 additions & 2 deletions libcob/termio.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ setup_varname_with_indices (char *buffer, cob_u32_t *subscript,
} else {
size_t len = strlen (name);
memcpy (buffer, name, len + 1);
buffer[len] = 0;
return len;
}
}
Expand Down Expand Up @@ -780,7 +781,7 @@ cob_dump_field (const int level, const char *name,

/* copy over indexes to local array and calculate size offset */
if (indexes != 0) {
unsigned int size;
size_t size;
va_start (ap, indexes);
for (cob_idx = 1; cob_idx <= indexes; cob_idx++) {
int c_subscript = va_arg (ap, int);
Expand All @@ -802,7 +803,7 @@ cob_dump_field (const int level, const char *name,
/* copy field pointer to allow access to its data pointer and size
and for the actual dump also its attributes */
memcpy (f, f_addr, sizeof (cob_field));

if (calc_dump_index != 0) {
calc_dump_index--;
}
Expand Down

0 comments on commit a8a2f6a

Please sign in to comment.