Skip to content

This patch fixes a bug in COPY REPLACING, about spaces surrounding the replacement pseudo-text - #309

Closed
lefessan wants to merge 2 commits into
OCamlPro:gitside-gnucobol-3.xfrom
lefessan:z-2026-08-23-trim-spaces
Closed

This patch fixes a bug in COPY REPLACING, about spaces surrounding the replacement pseudo-text #309
lefessan wants to merge 2 commits into
OCamlPro:gitside-gnucobol-3.xfrom
lefessan:z-2026-08-23-trim-spaces

Conversation

@lefessan

Copy link
Copy Markdown
Member

This patch fixes a bug in COPY REPLACING, when spaces are surrounding the replacement pseudo-text, and should be ignored in the non LEADING/TRAILING case.

@GitMensch

Copy link
Copy Markdown
Collaborator

Sounds good, it just fails all CI because it contains debug output (as noted before we have COB_DEBUG_LOG macros that would be ideally used instead) and SIGSEGVS.

I'll check again once CI passes - or you drop a review-request :-)
If that is expected to take longer, I'd suggest to mark this as a draft.

@lefessan
lefessan force-pushed the z-2026-08-23-trim-spaces branch from 917db7a to 6306453 Compare August 23, 2026 18:09
@lefessan

Copy link
Copy Markdown
Member Author

The Windows CI again, I think it's good otherwise after fixing some other tests.

@lefessan
lefessan requested a review from GitMensch August 23, 2026 19:06
@lefessan
lefessan force-pushed the z-2026-08-23-trim-spaces branch from 6306453 to 651c0d7 Compare August 23, 2026 19:13

@GitMensch GitMensch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for bringing this up.

How did you got to the conclusion of a bug here? Possibly a rule in the standard, I guess.
Does the test code work on IBM/MF/ACU/gcobol?

And: is REPLACE affected as well?
Possibly the listing?

Comment thread cobc/ChangeLog Outdated
Comment thread cobc/ppparse.y Outdated
Comment thread tests/testsuite.src/syn_misc.at Outdated
Comment thread tests/testsuite.src/syn_misc.at Outdated
Comment thread tests/testsuite.src/syn_misc.at
Comment thread tests/testsuite.src/syn_misc.at Outdated
@lefessan

Copy link
Copy Markdown
Member Author

How did you got to the conclusion of a bug here? Possibly a rule in the standard, I guess.

Some customer code triggered it (mainly because it would introduce a space, i.e. X(1) would become an unparsable X (2).

Does the test code work on IBM/MF/ACU/gcobol?

I could only test it on MF, which is consistent with the fact that our customer's code was coming from MF.

@codecov-commenter

codecov-commenter commented Aug 24, 2026

Copy link
Copy Markdown

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

Codecov Report

❌ Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (gitside-gnucobol-3.x@b716a90). Learn more about missing BASE report.

Files with missing lines Patch % Lines
cobc/ppparse.y 88.23% 0 Missing and 2 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@                   Coverage Diff                   @@
##             gitside-gnucobol-3.x     #309   +/-   ##
=======================================================
  Coverage                        ?   67.48%           
=======================================================
  Files                           ?       34           
  Lines                           ?    61566           
  Branches                        ?    16037           
=======================================================
  Hits                            ?    41547           
  Misses                          ?    14067           
  Partials                        ?     5952           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lefessan
lefessan force-pushed the z-2026-08-23-trim-spaces branch 2 times, most recently from c6c91ed to 14f5cbb Compare August 25, 2026 08:25
@lefessan

Copy link
Copy Markdown
Member Author

If the only problem now is the listing, I think we should merge this patch in SVN, keeping only an issue that the listing is broken (in general) with replacements.

@GitMensch GitMensch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I agree that we can put that upstream once we added the listing issue to the known problems (it has its own bug already) and reference that in a comment (references like that also help a lot when fixing things and see bunch of failures and inspecting them directly brings up a note "currently wrong, should be this way, see x").

If possible it would be good to check if those issues are fixed now as well:

All that are not fixed yet can still be included in the testsuite as expected failures with the bug reference... but possibly they are solved / tested already or it is "relative easy" to do so.

Comment thread tests/testsuite.src/syn_misc.at
@GitMensch

Copy link
Copy Markdown
Collaborator

side note: I'd prefer @ddeclerck's #303 to be upstreamed before, but if that isn't the case, then it is how it is

Comment thread tests/testsuite.src/syn_misc.at Outdated
@lefessan

Copy link
Copy Markdown
Member Author

side note: I'd prefer @ddeclerck's #303 to be upstreamed before, but if that isn't the case, then it is how it is

Which part of #303 ? I have merged his changes to build_windows/ and libcob/ into the SVN, and created #310 for changes specific to GIT.

@GitMensch

Copy link
Copy Markdown
Collaborator

I consider the "303 before" part done :-)

Comment thread cobc/ChangeLog Outdated
Comment thread cobc/ppparse.y Outdated
@lefessan
lefessan force-pushed the z-2026-08-23-trim-spaces branch 3 times, most recently from 1b62759 to 869c5e1 Compare August 26, 2026 10:55
replacement pseudo-text should be ignored in the non LEADING/TRAILING
case.
@lefessan
lefessan force-pushed the z-2026-08-23-trim-spaces branch from 869c5e1 to 559e586 Compare August 26, 2026 10:58
@lefessan

Copy link
Copy Markdown
Member Author
* crash when replacing by nothing (regression from your PR) https://sourceforge.net/p/gnucobol/bugs/1071/ - the analysis and fix is done, the commit including a testcase is likely missing

Fixed in this PR.

* REPLACE statement inside COPY does not work correct https://sourceforge.net/p/gnucobol/bugs/722/ - _should_ be solved with your changes in 3.2

* COPY REPLACING isn't working when replacing with a star https://sourceforge.net/p/gnucobol/bugs/736/ - edge case _possibly_ solved in 3.2

* COPY/REPLACE issues https://sourceforge.net/p/gnucobol/bugs/927/ - could be already solved in 3.x since a while

I think we can close all of them, the first one is similar to 831, and the other ones are, for me, not bugs.

@GitMensch GitMensch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

... yay, I've seem to have missed clicking "Submit" some hours ago, so here we go, mostly with a request on the testing

Comment thread cobc/ChangeLog Outdated
Comment thread cobc/ChangeLog
Comment thread tests/testsuite.src/syn_misc.at Outdated
Comment thread tests/testsuite.src/syn_misc.at Outdated
Comment thread tests/testsuite.src/syn_misc.at Outdated
STOP RUN.
])
AT_DATA([fab.cob], [>>SOURCE IS FREE
>>DEFINE 1aa AS 2

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I guess you wanted to check if replace also worked in the directive - I don't know if they should - but that isn't tested yet, to do so you need to do anything with the define also in the program (with the changed/unchanged name)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Actually, this file comes from the issue on the bug tracker, I just took the files that were submitted and created a test case with them (only fob.cob was created because it was not in the issue)

PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shouldn't that test (and therefore also the keywords) include REPLACE as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I haven't tried to create a perfect test case, just the one that was in the issue...

Comment thread cobc/ChangeLog Outdated
@lefessan

Copy link
Copy Markdown
Member Author

If it's ok with you, I am going to merge this PR as is, to prevent it from stalling.

@GitMensch GitMensch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

OK to send upstream, while I'd prefer this testcase to be reinspected - we can set the upstream issue(s) to pending for that while leaving a note that the bug itself is fixed with that commit.

Co-authored-by: Simon Sobisch <simonsobisch@web.de>
@lefessan
lefessan force-pushed the z-2026-08-23-trim-spaces branch from 54cfa57 to e8cb017 Compare August 27, 2026 12:16
@lefessan

Copy link
Copy Markdown
Member Author

I updated the test to check also REPLACE and remove useless directives.

@lefessan

Copy link
Copy Markdown
Member Author

Merged in SVN

@lefessan lefessan closed this Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants