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

TruncateFile aborts on MSYS/Cygwin #190

Closed
wants to merge 3 commits into from

Conversation

guberathome
Copy link
Contributor

@guberathome guberathome commented Jan 2, 2025

I could not find an obvious way to fix #189.

This patch aborts RESIZE-FILE (for shrinking) on MSYS2/Cygwin instead of silently appending to the existing file.
Which is just a tiny bit better.

If there should be nothing (else) we could do about it, I would advocate documenting the behaviour
(e.g. in README.md),

Hints are welcome.

Output for make test on {Linux, FreeBsd,NetBSD} is now:

cd ../../fth && ../platforms/unix/pforth_standalone -q t_file.fth
Include t_tools.fth
...
  94 passed,    0 failed.
PForth Tests PASSED

... and on MSYS2/Cygwin:

Include t_tools.fth
    include added 1712 bytes,38292 left.
(got=-74, expected=0) INCORRECT RESULT: T{ 37. FID2 @ RESIZE-FILE -> 0 }T
(got=50, expected=37) INCORRECT RESULT: T{ FID2 @ FILE-SIZE -> 37. 0 }T
(got=50, expected=37) INCORRECT RESULT: T{ CBUF BUF 100 FID2 @ READ-FILE -> 37 0 }T
(got=-1, expected=0) INCORRECT RESULT: T{ PAD 38 BUF 38 S= -> FALSE }T
Include t_required_helper1.fth
    include added 0 bytes,37172 left.
Include t_required_helper1.fth
    include added 0 bytes,37172 left.
Include t_required_helper2.fth
    include added 0 bytes,37172 left.
Include t_required_helper2.fth
    include added 0 bytes,37172 left.
  90 passed,    4 failed.
make: *** [Makefile:165: test] Error 40

Copy link
Owner

@philburk philburk left a comment

Choose a reason for hiding this comment

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

Thanks for this PR.
Failing silently was a problem.
This is a step in the right direction.

csrc/stdio/pf_fileio_stdio.c Outdated Show resolved Hide resolved
Co-authored-by: Phil Burk <philburk@mobileer.com>
@guberathome
Copy link
Contributor Author

done, ready to be merged.

@guberathome guberathome marked this pull request as draft January 7, 2025 11:20
@guberathome
Copy link
Contributor Author

alternative solution using Unix-API implemented (separate PR).

@guberathome guberathome closed this Jan 7, 2025
@guberathome guberathome deleted the cygwin-resize-file branch January 7, 2025 11:24
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

Successfully merging this pull request may close these issues.

RESIZE-FILE test fails on MSYS2/Cygwin
2 participants