-
Notifications
You must be signed in to change notification settings - Fork 25
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
Fix for bug #831: COPY REPLACING in listing #92
base: gcos4gnucobol-3.x
Are you sure you want to change the base?
Conversation
Thanks you for working on this. Note that two PRs, one for each change are commonly more easy to review. Let's start with the most easiest one: 863. Please move also the other code fro codegen.c with printf to if((f->report_flag & COB_REPORT_LINE)
&& f->children
&& (f->children->report_flag & COB_REPORT_LINE)) {
printf("Warning: Ignoring nested LINE %s %d\n",
(f->report_flag & COB_REPORT_LINE_PLUS)?"PLUS":"",
f->report_line);
f->report_line = 0;
f->report_flag &= ~COB_REPORT_LINE_PLUS;
f->report_flag &= ~COB_REPORT_LINE;
} Both places can use A PR with those adjustments can be reviewed quickly and would definitely be fine for inclusion into the 3.x branch before the upcoming RC3 (roughly planned for end of the week, maybe a bit earlier). |
cobc/cobc.c
Outdated
@@ -6619,8 +6675,10 @@ print_line (struct list_files *cfile, char *line, int line_num, int in_copy) | |||
struct list_skip *skip; | |||
int do_print; | |||
int on_off; | |||
char pch; |
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.
please leave local defintions in, we try to limit scope where possible
cobc/cobc.c
Outdated
|
||
cmp_line[0] = 0; | ||
bzero (cmp_line, CB_LINE_LENGTH + 2); |
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.
From its manpage:
The bzero() function is deprecated (marked as LEGACY in POSIX.1-2001); use memset(3) in new programs. POSIX.1-2008 removes the specification of bzero().
The best option is to do it before the caller:
char cmp_line[CB_LINE_LENGTH + 2] = { 0 };
cobc/cobc.c
Outdated
make_new_continuation_line (cfile_name, pline, | ||
pline_cnt, line_num); | ||
} | ||
// calculation the len char |
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.
Please use C89 comments here and in other places
- // calculation the len char
+ /* calculation the len char */
cobc/cobc.c
Outdated
@@ -7393,6 +7214,43 @@ cleanup_copybook_reference (struct list_files *cur) | |||
cobc_free (cur); | |||
} | |||
|
|||
static | |||
char *get_word (char *str) |
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.
please move those two after get_next_nonspace
to group those functions
print_line (cfile, pline[i], line_num + i, 0); | ||
pline[i][0] = 0; | ||
} | ||
struct list_files *cur; |
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.
please combine the assignment into this line - nice scoping btw :-)
const int margin_a = cobc_get_margin_a (1); | ||
int cnt_space = 0; | ||
int j = 0; | ||
|
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.
Looks like most of DEBUG_REPLACE
is now out, was this explicit planned?
Did you use that to get an idea where the issue is?
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.
ping @sbelondr
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.
Please split this PR into two ones, as mentioned I think the one for the report stuff # 863 should be quite easy to get through.
We can keep this PR for # 831; so far I did make some minor review comments and get a general overview (not there yet, need to combe back to this later...); I see that the issues we had - marked as AT_XFAIL_IF (true) are solved, as you've mentioned one of the older REPLACE tests now fail, mostly because the replacement is done by starting on the next line instead of the original one. Can you adjust that?
Thank you for the feedback. |
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.
please check the first review parts and consider handling the new cb_partial_replace_when_literal_src
setting (otherwise thi can be included later)
please also fix the non-C89 definition - see the results of the new CI check (in detail here: https://github.com/OCamlPro/gnucobol/actions/runs/5392577360/jobs/9791122631#step:8:125)
I'll the review the result with a local checkout; the diff looks huge (and bigger as it is, while it is still big)
tests/ChangeLog
Outdated
@@ -761,7 +767,7 @@ | |||
* testsuite.src/*.at: Added check for cobc's exit code and stderr | |||
where missing | |||
|
|||
2014-14-04 Philipp B�hme <[email protected]> | |||
2014-14-04 Philipp B�hme <[email protected]> |
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.
somethings broken here, maybe you can revert the line (otherwise I can do it after merging)
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.
I'll take care of that in the next commit
cobc/cobc.c
Outdated
if (!str) { | ||
return NULL; | ||
} | ||
while (str[i] && isspace (str[i])) { |
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.
What about separator commas and separator semicolons?
The old code used isspace ((unsigned char)*bp) || *bp == ',' || *bp == '.' || *bp == ';'
.
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.
I also put that before but when I read the documentation I didn't understand why these characters is understood as a space and this not change the result of the test. I'll try other test for compare old replacing with the new replacing for check the differences
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.
Note: it obviously would be good to have this in the testsuite, too.
In effect the point is that there are multiple "separators" - all "space characters", newline, separator semicolon and separator comma.
The last one is a bit tricky as, depending on DECIMAL-POINT IS COMMA
this may or may not mean that "3,2" has to be separated (=2 "words"/tokens), while "3,a" would always mean two tokens. [note: the listing may "don't care" about that at all or always ignore the comma if DECIMAL-POINT IS COMMA
is in effect].
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.
I think those testcases are missing, right?
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## gcos4gnucobol-3.x #92 +/- ##
=====================================================
+ Coverage 65.19% 65.46% +0.27%
=====================================================
Files 31 32 +1
Lines 58363 58895 +532
Branches 15377 15514 +137
=====================================================
+ Hits 38050 38558 +508
+ Misses 14382 14316 -66
- Partials 5931 6021 +90
... and 2 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@sbelondr: please adjust the testsuite changes - we moved from separate "expected.lst" to "list in stdout", so the changed expectation must be adjusted there (you currently have it just added as new AT_DATA) |
cobc/cobc.c
Outdated
while (line[i]) | ||
{ | ||
/* loop space */ | ||
while (line[i] && isspace (line[i]) && !is_quotes_char (line[i], &simple_quote, &double_quote) && NOT_TOO_LONG (i, start)) { |
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.
We have isspace (line[i])
, so how should be (line[i])
be a quote?
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.
Yes, it's useless. I removed that
@@ -6741,6 +6783,146 @@ print_fixed_line (const int line_num, char pch, char *line) | |||
} | |||
} | |||
|
|||
static int |
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.
Please add a doc comment before the function so it is clear what is checks/changes.
Also: does the code handle an "escaped "" quote like in x""4100"""
?
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.
I added a comment for this function but I didn't understand this format x""4100"".
I think that I'm not handling this but I can't find this in the old code.
Is this "translated" in the code to something else ?
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.
Sorry for this ping @GitMensch, can I have more information on this ?
Hi @GitMensch,
I propose the following fixes for the bugs :
For the bug #863, I just add a loop to check if the variable exist (codegen.c). I added a test in run_reportwriter.at.
For the bug #831 I rewrite partialy the listing mode in the cobc.c file and I add 2 struct in tree.h for manage lines and replacements.
I added a test in the listings.at file (name : Multiple replacement) and I completed two tests (just add the expect.lst file) :
But I didn't pass the huge REPLACE test because I add more space of the default implementation (8 precisely).
I would like to know if the implementation is right for you (I remove backtracking) ?