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

#mode preservelf does not seem to work #56

Open
ptsl opened this issue Feb 18, 2022 · 4 comments
Open

#mode preservelf does not seem to work #56

ptsl opened this issue Feb 18, 2022 · 4 comments

Comments

@ptsl
Copy link

ptsl commented Feb 18, 2022

I have the following test file:

#mode preservelf off
#mode user "$" "$" "{" "}{" "}$" "{" "}" "@" "~"
#mode meta "$" "$\w\n" "{" "}{" "}$\w\n" "{" "}"
$define{macro}{xyzzy}$
$macro$

Depending on the value of preservelf, the gpp outputs:

-with preservelf off-

\n
\n
\n
xyzzy\n

-with preservelf on-

\n
\n
\n
\n
xyzzy\n

I'm not sure if this is a bug or an omission on my side, but I'd like gpp to output only a single line (xyzzy\n).

@logological
Copy link
Owner

On checking the source code, it seems the problem occurs because any invocation of the mode meta-macro assigns the preservelffield to true (gpp.c:2494). I agree that this seems to be a bug, and simply deleting the assignment does result in the expected behaviour for your examples, though it's not yet clear to me whether simply deleting that assignment might introduce further bugs. If any such bugs might be introduced, I suspect that they will affect GPP's handling of C-style strings, since the assignment occurs in that part of the code. Further testing would be appropriate here…

@ptsl
Copy link
Author

ptsl commented Feb 22, 2022

Dear Tristan,

thank you for taking the time to check the issue. This "guerilla" setting of a public flag seems suspect; explicit is better than implicit. Do you think that Mr. Denis Auroux would be willing to comment?

Best regards,
Peter

@logological
Copy link
Owner

Denis hasn't been involved in GPP development for over 15 years and so I'm loath to bother him with this issue. I think it could be solved by writing a few test cases apply the -n option, mode preservelf, and C-style strings in various combinations, and then seeing if the output remains sensible. If you'd like to do so yourself, I'd be glad to check over the tests and the results. Otherwise, I will add this to my own to-do list.

@ptsl
Copy link
Author

ptsl commented Feb 25, 2022

Dear Tristan, I do not dare to write a set of tests, as this was my first encounter with gpp. If you have the capacity, I will appreciate if you do it yourself.

I highly appreciate your work and thank you for the effort you put in gpp.
Peter

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

No branches or pull requests

2 participants