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

Incorrect parsing of "+" in labels, titles and possiblely elsewhere #576

Closed
seisman opened this issue Mar 25, 2019 · 4 comments
Closed

Incorrect parsing of "+" in labels, titles and possiblely elsewhere #576

seisman opened this issue Mar 25, 2019 · 4 comments

Comments

@seisman
Copy link
Member

seisman commented Mar 25, 2019

The trailing "+" in labels and title are missing.

gmt basemap -R0/10/0/5 -Jx1c -Bxaf+l"X+" -Byaf+l"Y+" -BWSen+t"Title+" -pdf map

image

@PaulWessel
Copy link
Member

We can do a better job I think. But inside the code there are no quotes - that is only in the shell - so what GMT sees is WSen+tTitle+ and (except for this case) it can be hard to tell what is a modifier and what is part of the text. My usual solution is to scan the entire argument before parsing and if I find sequences of + that are not among the possible modifiers to that option then replace the + with an unprintable character and then replace those back to + after the parsing. Of course, to catch +tTitle+testing we need to remember that +t was already found and allow that second +t as part of the text, but +tTitle+gravity is harder since +g is a valid option. It is getting pretty messy then to check that ravity is not a color, etc.

@PaulWessel
Copy link
Member

The other way to handle this is to escape plus symbols in text: +tTitle+testing which is probably preferable to making people use the octal code for plus: +tTitle\053testing.

@seisman
Copy link
Member Author

seisman commented Mar 25, 2019

It seems there is no easy way to parse "+" correctly. I'm OK with the octal code. Feel free to close this issue.

@PaulWessel
Copy link
Member

I am improving it a bit. The missing + in your example is a bug and is being fixed. Also, I am implementing that any repeat + in a string is not a modifier since you cannot repeat a modifier. So that fixes +tTitle+testing for instance. The +tTitle+gravity actually gives

psbasemap [ERROR]: Colorname ravity not recognized!
psbasemap [ERROR]: Bad +g modifier A

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