gnucobol icon indicating copy to clipboard operation
gnucobol copied to clipboard

Add >>IMP INCLUDE directive

Open engboris opened this issue 1 year ago • 4 comments

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 avatar Apr 25 '24 18:04 engboris

We don't need two lists, but we need to reset the list for each source file specified on the command line to the state from cobc command line.

Therefore either backup the whole list and restore it (similar to cb_source_format) or just use two lists and reset the second before each new source file. I'm ok with both ways but think the two-list approach is easier to handle.

GitMensch avatar Apr 29 '24 13:04 GitMensch

@GitMensch Could you check this? It was almost finished and it was a rather minor change but I wasn't sure about the tests. Thank you!

engboris avatar Jul 25 '24 11:07 engboris

I've rebased this PR and adjusted the "real" test for IMP INCLUDE. There are still open changes (see review notes), but I'm sure @engboris will have a look at those over the next days (or hours)?

GitMensch avatar Jul 25 '24 13:07 GitMensch

:warning: 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 :warning:
cobc/codegen.c 50.00% 1 Missing and 2 partials :warning:
cobc/pplex.l 57.14% 0 Missing and 3 partials :warning:

:exclamation: 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.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Oct 08 '24 16:10 codecov-commenter

@GitMensch friendly ping

engboris avatar Dec 16 '24 09:12 engboris

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, [])

engboris avatar Dec 17 '24 17:12 engboris

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

engboris avatar Dec 17 '24 18:12 engboris

@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!

engboris avatar Dec 17 '24 18:12 engboris

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

GitMensch avatar Dec 17 '24 18:12 GitMensch

What is the status of this PR ? Is it ready to be merged ?

ddeclerck avatar Feb 12 '25 14:02 ddeclerck

What is the status of this PR ? Is it ready to be merged ?

Yes, it should be ready (already marked with "Ready for SVN")

engboris avatar Feb 12 '25 14:02 engboris

What is the status of this PR ? Is it ready to be merged ?

Yes, it should be ready (already marked with "Ready for SVN")

Ah, yeah, I overlooked the "Ready for SVN" tag. So I guess I can merge this to SVN right away, right @GitMensch ?

ddeclerck avatar Feb 12 '25 14:02 ddeclerck

yes, just waits for the commit since two months

GitMensch avatar Feb 12 '25 15:02 GitMensch

Merged in SVN @ 5448.

ddeclerck avatar Feb 12 '25 16:02 ddeclerck