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

Overlapping source/destination buffers in SUBSTITUTE tests #38

Open
pahihu opened this issue Jan 6, 2023 · 2 comments
Open

Overlapping source/destination buffers in SUBSTITUTE tests #38

pahihu opened this issue Jan 6, 2023 · 2 comments

Comments

@pahihu
Copy link

pahihu commented Jan 6, 2023

In stringtest.fth the following 2 tests use overlapping source and destination buffers
and hence the tests fails:

T{ $" c%mac3%d" 0 3 do-subst show $" czyxwvutd" 1 check-subst -> TRUE }T
T{ $" e%mac2%f" 0 3 do-subst show $" ezyxf" 1 check-subst -> TRUE }T

Thanks,
pahihu

@gerryjackson
Copy link
Owner

Well yes, it is testing for overlapping strings, including the case for SUBSTITUTE ( c-addr1 u1 c-addr2 u2 -- c-addr2 u3 n ) where c-addr1 = caddr2 which is an error and an example of an overlapping string. See line 237 onwards in file stringtest.fth. When I first wrote the test I expected that systems would test for that and return a negative number to indicate an error.

However developers of one system ( I think it was GForth but I might be wrong) said that their system handled overlapping strings correctly and why should they be penalised for providing a better implementation. I thought they had a good point so I wrote the tests which handled various cases for overlapping strings in the tests in lines 299 to 304. The value n returned and substitution is expected to be correct if n >= 0, if a system returns n<0 then the tests pass without the resulting string being checked, see line 271 in the definition of CHECK-SUBST. It looks as if the system you're running the tests on returns n>=0 with an invalid resulting string.

In general standard systems can ignore errors so perhaps I should add some code to check for a system that ignores overlapping strings - I'll have to think about that. In the meantime please comment out the offending tests if failure is causing you a problem.

Thanks for reporting it.
Gerry Jackson
PS I replied to your email directly thinking it would get posted here automatically but it didn't, hence this is a few days late.

@pahihu
Copy link
Author

pahihu commented Jan 13, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants