Skip to content

Commit

Permalink
Several fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
engboris committed Dec 17, 2024
1 parent c77058e commit 781f586
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 30 deletions.
10 changes: 7 additions & 3 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ NEWS - user visible changes -*- outline -*-

* New GnuCOBOL features

** cobc now checks for binary and multi-byte encoded files and early exit
parsing those; the error output for format errors (for example invalid
indicator column) is now limitted to 5 per source file
** the leading space for all internal directives is removed in the lexer.
Source previously processed may need to be ajusted to be processed by
GnuCOBOL 3.3.

** cobc now checks for binary files and early exit parsing those;
the error output for format errors (for example invalid indicator column)
is now limitted to 5 per source file

** support the COLLATING SEQUENCE clause on indexed files
(currently only with the BDB backend)
Expand Down
2 changes: 1 addition & 1 deletion cobc/cobc.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ extern struct cb_text_list *cb_copy_list;
extern struct cb_text_list *cb_include_file_list; /* global */
extern struct cb_text_list *cb_include_file_list_directive; /* temporary */
extern struct cb_text_list *cb_include_list;
extern struct cb_text_list *cb_include_file_list_directive;
extern struct cb_text_list *cb_include_file_list_directive;
extern struct cb_text_list *cb_intrinsic_list;
extern struct cb_text_list *cb_extension_list;
extern struct cb_text_list *cb_static_call_list;
Expand Down
6 changes: 0 additions & 6 deletions cobc/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1834,7 +1834,6 @@ output_gnucobol_defines (const char *formatted_date)

{
struct cb_text_list *l;
struct cb_text_list *last = NULL;
for (l = cb_include_file_list; l; l = l->next) {
if (l->text[0] == '<') {
output_line ("#include %s", l->text);
Expand All @@ -1844,11 +1843,6 @@ output_gnucobol_defines (const char *formatted_date)
}

for (l = cb_include_file_list_directive; l; l = l->next) {
if (last != NULL) {
cobc_free (last->text);
cobc_free (last);
}
last = l;
if (l->text[0] == '<') {
output_line ("#include %s", l->text);
} else {
Expand Down
3 changes: 2 additions & 1 deletion cobc/ppparse.y
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,8 @@ imp_directive:
/* GnuCOBOL 3.3 extension */
INCLUDE
{
ppparse_error (_("Missing argument for IMP INCLUDE directive"));
cb_error (_("invalid %s directive"), "IMP INCLUDE");
yyerrok;
}
| INCLUDE imp_include_sources
{
Expand Down
34 changes: 17 additions & 17 deletions cobc/scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ AREA_A "#AREA_A"\n
cobc_in_area_a = 0;
%}

<*>^[ ]?"#CALLFH".*\n {
<*>^"#CALLFH".*\n {
if (current_program) {
const char *p1;
char *p2;
Expand All @@ -243,37 +243,37 @@ AREA_A "#AREA_A"\n
}


<*>^[ ]?"#DEFLIT".*\n {
<*>^"#DEFLIT".*\n {
scan_define_options (yytext);
}

<*>^[ ]?"#ADDRSV".*\n {
<*>^"#ADDRSV".*\n {
char *word;

copy_word_in_quotes (&word);
add_reserved_word_now (word, NULL);
cobc_free (word);
}

<*>^[ ]?"#ADDSYN-STD".*\n {
<*>^"#ADDSYN-STD".*\n {
add_synonym (1, 0);
}
<*>^[ ]?"#ADDSYN".*\n {
<*>^"#ADDSYN".*\n {
add_synonym (0, 0);
}

<*>^[ ]?"#MAKESYN".*\n {
<*>^"#MAKESYN".*\n {
make_synonym ();
}

<*>^[ ]?"#OVERRIDE-STD".*\n {
<*>^"#OVERRIDE-STD".*\n {
add_synonym (1, 1);
}
<*>^[ ]?"#OVERRIDE".*\n {
<*>^"#OVERRIDE".*\n {
add_synonym (0, 1);
}

<*>^[ ]?"#REMOVE-STD".*\n {
<*>^"#REMOVE-STD".*\n {
char *word;

copy_word_in_quotes (&word);
Expand All @@ -286,27 +286,27 @@ AREA_A "#AREA_A"\n
cobc_free (word);
}

<*>^[ ]?"#REMOVE".*\n {
<*>^"#REMOVE".*\n {
char *word;

copy_word_in_quotes (&word);
remove_reserved_word_now (word);
cobc_free (word);
}

<*>^[ ]?"#REFMOD_ZERO "[0-9]\n {
<*>^"#REFMOD_ZERO "[0-9]\n {
cb_ref_mod_zero_length = (yytext[13] - '0');
}

<*>^[ ]?"#ODOSLIDE "[0-1]\n {
<*>^"#ODOSLIDE "[0-1]\n {
cb_odoslide = (yytext[10] - '0');
}

<*>^[ ]?"#ASSIGN "[0-9]\n {
<*>^"#ASSIGN "[0-9]\n {
cb_assign_type_default = (enum cb_assign_type)(yytext[8] - '0');
}

<*>^[ ]?"#TURN".*\n {
<*>^"#TURN".*\n {
struct cb_turn_list *l;

for (l = cb_turn_list; l && l->line != -1; l = l->next);
Expand All @@ -315,15 +315,15 @@ AREA_A "#AREA_A"\n
}
}

<*>^[ ]?"#AREACHECK"\n {
<*>^"#AREACHECK"\n {
cobc_areacheck = 1;
}

<*>^[ ]?"#NOAREACHECK"\n {
<*>^"#NOAREACHECK"\n {
cobc_areacheck = 0;
}

<*>^[ ]?"#INCLUDE".*/\n {
<*>^"#INCLUDE".*/\n {
cb_include_file_list_directive = scan_list_add (
cb_include_file_list_directive,
yytext + 9
Expand Down
8 changes: 6 additions & 2 deletions tests/testsuite.src/syn_misc.at
Original file line number Diff line number Diff line change
Expand Up @@ -8447,7 +8447,7 @@ AT_DATA([prog2.cob], [
])

AT_CHECK([$COMPILE_ONLY prog2.cob], [1], [],
[prog2.cob:2: error: Missing argument for IMP INCLUDE directive
[prog2.cob:2: error: invalid IMP INCLUDE directive
])

AT_CLEANUP
Expand All @@ -8464,6 +8464,10 @@ AT_DATA([prog.cob], [
GOBACK.
])

AT_CHECK([$COMPILE_ONLY prog.cob], [0], [], [])
AT_CHECK([$COMPILE --save-temps -E -o prog.i prog.cob], [0], [], [])
AT_CHECK([$GREP "#INCLUDE file1.h" prog.i], [0], ignore, [])
AT_CHECK([$GREP "#INCLUDE file2.h" prog.i], [0], ignore, [])
AT_CHECK([$GREP "#INCLUDE <file3.h>" prog.i], [0], ignore, [])
AT_CHECK([$GREP "#INCLUDE <file4.h>" prog.i], [0], ignore, [])

AT_CLEANUP

0 comments on commit 781f586

Please sign in to comment.