Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
engboris committed May 7, 2024
1 parent 7b94002 commit d1abc18
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 31 deletions.
4 changes: 2 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ NEWS - user visible changes -*- outline -*-
calls to externals. The files are put into quotes, unless they start by
'<'. Quoted files are expected to have absolute paths, as the C compiler
is called in a temp directory instead of the project directory.
The directive >>IMP INCLUDE "FILE.h" or >>IMP INCLUDE <FILE.h> can be used
as an alternative to this compiler option.
The directive >>IMP INCLUDE "file.h", >>IMP INCLUDE "<file.h>" or
>>IMP INCLUDE file.h can be used as an alternative to this compiler option.

** output of unlimited errors may be requested by -fmax-errors=0,
to stop compiliation at first error use -Wfatal-errors
Expand Down
3 changes: 2 additions & 1 deletion cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

2024-04-25 Boris Eng <[email protected]>

* cobc.h, pplex.l, ppparse.y: new >>IMP INCLUDE directive to include
* cobc.h, cobc.c, codegen.c, pplex.l, ppparse.y, scanner.l:
new >>IMP INCLUDE directive to include
multiple header files in the C generated code. Has the same behavior as the
--include compiler option.

Expand Down
1 change: 0 additions & 1 deletion cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ const char *cb_storage_file_name = NULL;
const char *cb_call_extfh = NULL;
struct cb_text_list *cb_copy_list = NULL;
struct cb_text_list *cb_include_file_list = NULL;
struct cb_text_list *cb_include_file_list_directive = NULL;
struct cb_text_list *cb_include_list = NULL;
struct cb_text_list *cb_depend_list = NULL;
struct cb_text_list *cb_intrinsic_list = NULL;
Expand Down
29 changes: 12 additions & 17 deletions cobc/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1830,33 +1830,28 @@ output_gnucobol_defines (const char *formatted_date)
output_line ("#define COB_MODULE_TIME\t\t%d", i);

{
struct cb_text_list *l = cb_include_file_list;
struct cb_text_list *ld = cb_include_file_list_directive;
struct cb_text_list *next;
for (;l;l=l->next) {
struct cb_text_list *l;
for (l = cb_include_file_list; l; l = l->next) {
if (l->text[0] == '<') {
output_line ("#include %s", l->text);
} else {
output_line ("#include \"%s\"", l->text);
}
}
while (ld) {
if (ld->text[0] == '<') {
output_line ("#include %s", ld->text);

l = cb_include_file_list_directive;
while (l) {
struct cb_text_list *last = l;
if (l->text[0] == '<') {
output_line ("#include %s", l->text);
} else {
output_line ("#include \"%s\"", ld->text);
}
next = ld->next;
if (ld != NULL) {
cobc_free (ld);
cobc_free (ld->text);
ld = NULL;
output_line ("#include \"%s\"", l->text);
}
ld = next;
l = l->next;
cobc_free (last->text);
cobc_free (last);
}
cb_include_file_list_directive = NULL;
}

}

/* CALL cache */
Expand Down
2 changes: 2 additions & 0 deletions cobc/scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ static size_t pic2_size;
static unsigned int inside_bracket = 0;
static char err_msg[COB_MINI_BUFF];

struct cb_text_list *cb_include_file_list_directive = NULL;

/* Function declarations */
static void read_literal (const char, const enum cb_literal_type);
static int scan_x (const char *, const char *);
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite.src/syn_misc.at
Original file line number Diff line number Diff line change
Expand Up @@ -8385,6 +8385,7 @@ prog.cob:18: error: ANY LENGTH items may only be BY REFERENCE formal parameters

AT_CLEANUP


AT_SETUP([IMP INCLUDE directive])
AT_KEYWORDS([IMP INCLUDE])

Expand Down Expand Up @@ -8420,6 +8421,7 @@ AT_CHECK([$COMPILE_ONLY -fformat=free prog.cob], [0], [], [])

AT_CLEANUP


AT_SETUP([IMP INCLUDE directive multiple files])
AT_KEYWORDS([IMP INCLUDE])

Expand Down
11 changes: 1 addition & 10 deletions tests/testsuite.src/used_binaries.at
Original file line number Diff line number Diff line change
Expand Up @@ -1140,22 +1140,13 @@ AT_CHECK([$COMPILE_MODULE -Wno-unfinished --copy "f.copy" -fstatic-call prog2.co

AT_CLEANUP


AT_SETUP([check include header file with directive])
#AT_KEYWORDS([imp include])

AT_DATA([file.h], [
COB_EXT_IMPORT void f (char *, long);
])
AT_DATA([prog.cob], [
>> IMP INCLUDE "file.h"
IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
PROCEDURE DIVISION.
CALL "f" USING "Hello".
])

AT_CHECK([$COBC -m -I . -fstatic-call prog.cob], [1], [], [ignore])

AT_DATA([prog2.cob], [
>> IMP INCLUDE "file.h"
IDENTIFICATION DIVISION.
Expand Down

0 comments on commit d1abc18

Please sign in to comment.