logological / gpp

GPP, a generic preprocessor
https://logological.org/gpp
GNU Lesser General Public License v3.0
197 stars 31 forks source link

gpp deletes slash from double slash in the output for some reason #46

Closed malcolm061990 closed 4 years ago

malcolm061990 commented 4 years ago

Hi. I have a strange behavior in gpp. The source file is:

# cat macro1.gpp 
exclude_lines: ["^\\s+[\\-`('.|_]"]  # drop asciiart lines

For some reason it deletes one slash from double slash:

# gpp macro1.gpp 
exclude_lines: ["^\s+[\-`('.|_]"]  # drop asciiart lines

Expected behavior is to have two slashes as it is in the source file:

# gpp macro1.gpp 
exclude_lines: ["^\\s+[\\-`('.|_]"]  # drop asciiart lines

In m4 it works good:

# m4 macro1.gpp 
exclude_lines: ["^\\s+[\\-(.|_]"]  # drop asciiart lines

Please, help.

logological commented 4 years ago

I'm about to leave for the day and so can't look into this right away. But could you check if this is perhaps a duplicate of Issue #15? (That is, is this a case of you forgetting that the backslash is used as a quote character by default?)

malcolm061990 commented 4 years ago

I'm about to leave for the day and so can't look into this right away. But could you check if this is perhaps a duplicate of Issue #15? (That is, is this a case of you forgetting that the backslash is used as a quote character by default?)

Thanks for your answer. Checked it but it doesn't work with standard yaml files for Kubernetes. I got this problems: k8s/filebeat.yaml:248: warning: possible comment/string termination problem k8s/filebeat.yaml:265: error: Input ended while scanning a comment/string

Can I delete all quote characters in the default mode in command line using some flag (not in input files)? For example:

gpp -SOME_FLAG_TO_DISABLE_QUOTE_CHARACTERS -D SOME_VAR=SOME_VALUE $file

It's the main purpose for me to use gpp instead of m4 because your syntax looks much better than in m4 :)

logological commented 4 years ago

Per the GPP manual, the default mode is equivalent to the user-defined mode -U "" "" "(" "," ")" "(" ")" "#" "\\" -M "#" "\n" " " " " "\n" "(" ")". The last argument to -U is the quote character, or the empty string if there is no quote character. So to get the behaviour you want, you can run GPP with the flags -U "" "" "(" "," ")" "(" ")" "#" "" -M "#" "\n" " " " " "\n" "(" ")".

I hope this answers your question. If so, you can go ahead and close this issue.

malcolm061990 commented 4 years ago

Thanks!