-
Notifications
You must be signed in to change notification settings - Fork 24
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
base: gcos4gnucobol-3.x
Are you sure you want to change the base?
Add >>IMP INCLUDE directive #143
Conversation
b2307d5
to
3936fe9
Compare
There was a problem hiding this 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.
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.
|
c035033
to
7bb6097
Compare
2ad6625
to
7b94002
Compare
There was a problem hiding this 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
d1abc18
to
67f4382
Compare
There was a problem hiding this 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"
f81defa
to
6a16582
Compare
There was a problem hiding this 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
331e050
to
0df9e5b
Compare
0df9e5b
to
21b5d51
Compare
a387b82
to
6760a54
Compare
@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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code changes requested for @engboris - I'll adjust the used_binaries.at, so please don't force-push
cobc/codegen.c
Outdated
if (last != NULL) { | ||
cobc_free (last->text); | ||
cobc_free (last); | ||
} | ||
last = l; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently the memory was allocated with cobc_malloc
and would need to be always freed, and that must also be done when there is no codegen (preprocess/syntaxy-check only) so must be done outside of codegen.
I think the parse_ memory functions would be more reasonable and drop the need to execute the free, also removing the need to keep the "last" element here; the only thing missing then is to initialize cb_include_file_list_directive
at the right place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, I should free those variables outside/independently of codegen but still after the running of codegen? Maybe after ylex_clear_all ()
in cobc.c
and add a parse_clear_all ()
function or something like that?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may only need to drop setting the "last" attribute (or create a separate structure) and the free calls here.
Looks like it works with that with no leak from valgrind. I didn't unset any variable (tell me if it is necessary).
b47abf8
to
0bf5380
Compare
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this 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/codegen.c
Outdated
if (last != NULL) { | ||
cobc_free (last->text); | ||
cobc_free (last); | ||
} | ||
last = l; |
There was a problem hiding this comment.
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.
Codecov ReportAttention: Patch coverage is
❗ 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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*/
.