Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add >>IMP INCLUDE directive #143

Open
wants to merge 12 commits into
base: gcos4gnucobol-3.x
Choose a base branch
from

Conversation

engboris
Copy link
Contributor

@engboris engboris commented Apr 25, 2024

Closes #114 and completes FR176 on SourceForge.

A new directive >> IMP INCLUDE FILE_1 ... FILE_n is introduced, allowing to include multiple C headers. Only files with name finishing by .h are allowed.

I'm not sure about that but I marked the feature with /* GnuCOBOL 3.3 extension*/.

@engboris engboris added the enhancement New feature or request label Apr 25, 2024
@engboris engboris requested review from lefessan and GitMensch April 25, 2024 18:00
@engboris engboris force-pushed the engboris-imp-directive branch from b2307d5 to 3936fe9 Compare April 25, 2024 18:04
Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this first take - please copy the tests for --include and adjust those for the directive. In gnbucobol.texi and NEWS add a remark in the --include description, that the directive can be used as an alternative.

cobc/pplex.l Outdated Show resolved Hide resolved
cobc/ppparse.y Outdated Show resolved Hide resolved
cobc/ppparse.y Outdated Show resolved Hide resolved
cobc/pplex.l Outdated Show resolved Hide resolved
@GitMensch
Copy link
Collaborator

GitMensch commented Apr 29, 2024 via email

@engboris engboris force-pushed the engboris-imp-directive branch 4 times, most recently from c035033 to 7bb6097 Compare April 30, 2024 16:07
cobc/pplex.l Outdated Show resolved Hide resolved
cobc/scanner.l Outdated Show resolved Hide resolved
cobc/scanner.l Outdated Show resolved Hide resolved
cobc/codegen.c Outdated Show resolved Hide resolved
cobc/scanner.l Outdated Show resolved Hide resolved
tests/testsuite.src/syn_misc.at Outdated Show resolved Hide resolved
@engboris engboris force-pushed the engboris-imp-directive branch 3 times, most recently from 2ad6625 to 7b94002 Compare May 3, 2024 15:13
Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still some requested changes - but we're on the finish line with this PR

NEWS Outdated Show resolved Hide resolved
cobc/codegen.c Outdated Show resolved Hide resolved
cobc/cobc.c Outdated Show resolved Hide resolved
cobc/ChangeLog Outdated Show resolved Hide resolved
tests/testsuite.src/syn_misc.at Show resolved Hide resolved
tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
@engboris engboris force-pushed the engboris-imp-directive branch from d1abc18 to 67f4382 Compare May 7, 2024 21:19
@engboris engboris requested a review from GitMensch June 12, 2024 13:27
cobc/codegen.c Outdated Show resolved Hide resolved
cobc/scanner.l Outdated Show resolved Hide resolved
tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"approved with minor changes"

@engboris engboris force-pushed the engboris-imp-directive branch from f81defa to 6a16582 Compare June 12, 2024 15:53
Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes to the testcases needed, overal fine

tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
tests/testsuite.src/syn_misc.at Show resolved Hide resolved
cobc/codegen.c Outdated Show resolved Hide resolved
@engboris engboris force-pushed the engboris-imp-directive branch 5 times, most recently from 331e050 to 0df9e5b Compare June 13, 2024 12:37
@engboris engboris closed this Jun 13, 2024
@engboris engboris force-pushed the engboris-imp-directive branch from 0df9e5b to 21b5d51 Compare June 13, 2024 12:42
@ddeclerck ddeclerck reopened this Jun 13, 2024
@engboris engboris force-pushed the engboris-imp-directive branch from a387b82 to 6760a54 Compare June 13, 2024 13:46
@GitMensch GitMensch force-pushed the engboris-imp-directive branch from b47abf8 to 0bf5380 Compare July 25, 2024 13:27
@GitMensch

This comment was marked as resolved.

cobc/ppparse.y Outdated Show resolved Hide resolved
@engboris engboris requested review from GitMensch and removed request for lefessan August 7, 2024 14:50
Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall a good state, we should be able to add the missing pieces and be able to upstream that, soon

cobc/cobc.h Outdated Show resolved Hide resolved
cobc/codegen.c Outdated
Comment on lines 1844 to 1848
if (last != NULL) {
cobc_free (last->text);
cobc_free (last);
}
last = l;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thought was to drop all the explicit cobc_free calls and move this to "parser memory" using cobc_parse_malloc instead for the allocation; then, potentially at ylex_clear_all or clear_local_codegen_vars unset the var...

Can you please check if this works?

Note: you currently allocate cb_include_file_list_directive with cobc_parse_strdup - so it is parser allocated already and will automatically be freed - you may only need to drop setting the "last" attribute (or create a separate structure) and the free calls here.

cobc/ppparse.y Outdated Show resolved Hide resolved
cobc/scanner.l Outdated Show resolved Hide resolved
tests/testsuite.src/syn_misc.at Show resolved Hide resolved
@engboris engboris requested a review from GitMensch October 8, 2024 16:05
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 73.07692% with 14 lines in your changes missing coverage. Please review.

Project coverage is 67.80%. Comparing base (2c000f5) to head (1336ded).
Report is 15 commits behind head on gcos4gnucobol-3.x.

Files with missing lines Patch % Lines
cobc/scanner.l 74.19% 3 Missing and 5 partials ⚠️
cobc/codegen.c 50.00% 1 Missing and 2 partials ⚠️
cobc/pplex.l 57.14% 0 Missing and 3 partials ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@                  Coverage Diff                  @@
##           gcos4gnucobol-3.x     #143      +/-   ##
=====================================================
- Coverage              77.56%   67.80%   -9.76%     
=====================================================
  Files                     33       33              
  Lines                  60230    60413     +183     
  Branches               15834    15888      +54     
=====================================================
- Hits                   46717    40966    -5751     
- Misses                 13513    13538      +25     
- Partials                   0     5909    +5909     
Flag Coverage Δ
?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@engboris
Copy link
Contributor Author

@GitMensch friendly ping

Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nearly done, I'm positive that we reach the commit-state tomorrow :-)

Thanks for working on this again!

NEWS Outdated Show resolved Hide resolved
cobc/scanner.l Show resolved Hide resolved
cobc/cobc.h Outdated Show resolved Hide resolved
tests/testsuite.src/syn_misc.at Show resolved Hide resolved
cobc/ChangeLog Outdated Show resolved Hide resolved
cobc/ChangeLog Outdated Show resolved Hide resolved
@engboris
Copy link
Contributor Author

engboris commented Dec 17, 2024

Should be good now. You were right, cobc aborted where compiling several COBOL files within the same command line. I added new checks:

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

AT_DATA([prog.cob], [
       >>IMP INCLUDE "file1.h" file2.h <file3.h> "<file4.h>"
       IDENTIFICATION DIVISION.
       PROGRAM-ID. PROG.
       PROCEDURE DIVISION.
           GOBACK.
])

AT_DATA([prog2.cob], [
       IDENTIFICATION DIVISION.
       PROGRAM-ID. prog.
       PROCEDURE DIVISION.
           GOBACK.
])

AT_CHECK([$COMPILE --save-temps -E -o prog.i prog.cob], [0], [], [])
AT_CHECK([$COMPILE -C prog.cob prog2.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_CHECK([$GREP "#INCLUDE file1.h"   prog.c], [1], ignore, [])
AT_CHECK([$GREP "#INCLUDE file2.h"   prog.c], [1], ignore, [])
AT_CHECK([$GREP "#INCLUDE <file3.h>" prog.c], [1], ignore, [])
AT_CHECK([$GREP "#INCLUDE <file4.h>" prog.c], [1], ignore, [])

Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, good that we ensured to not break something (I've found a lot ways to do so, which is often the reason I consider those checks .... nowadays - it is possible but hard to just deduce that when adding new code in that area for the first time).

Thanks again!

tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
cobc/ChangeLog Outdated Show resolved Hide resolved
@engboris engboris force-pushed the engboris-imp-directive branch from 7d5f5ae to 3efed41 Compare December 17, 2024 18:07
@engboris
Copy link
Contributor Author

I did some mistakes while rebasing and fixing conflicts. I'm trying to fix it now.

@engboris
Copy link
Contributor Author

@GitMensch Could you do a last quick check? I rebased and fixed conflicts but I may have introduced unwanted code although it is unlikely (all the tests are successful). I'm sorry for the inconvenience!

@GitMensch
Copy link
Collaborator

That's fine. [I've just checked the last "Compare", then the additional fix]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Ready for SVN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants