Skip to content

Improve parsing of modifier text with plus-symbols #577

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

Merged
merged 1 commit into from
Mar 25, 2019
Merged

Conversation

PaulWessel
Copy link
Member

@PaulWessel PaulWessel commented Mar 25, 2019

Since quotes are not passed into GMT, it can be difficult to know if any combination of +letter is a modifier or not. To eliminate as many cases as we can, we run this check before parsing:

  1. For argument to an option that takes modifiers, replace any + symbol that is not followed by one of the allowed modifier letters with ASCII 1.
  2. New: The second time we find a + followed by a valid modifier we know it cannot be a modifer since a modifier can only be given once. So +tTitle+test will now handle the second +t sequence as plain text.
  3. Bug: If a string ended in a plus then it got removed.

With these improvements we are less vulnerable to this problem and a few tests could be simplified and a few actually had text ending in double-pus-symbols to compensate for the loss of the last plus. Ultimately, the only foolproof way to not have a +letter be interpreted as a modifier is to use the octal code for the plus: \053.

Closes #576.

Since quotes are not passed into GMT, it can be difficult to know if any combination of +letter is a modifier or not.  To eliminate as many cases as we can, we do this:
For argument to an option that takes modifiers, replace any + symbol that is not followed by one of the allowed modifier letters with ASCII 1.
New: THe second time we find a + followed by a valid modifier we know it cannot be a modifer since a modifier can only be given once.  So +tTitle+test will now handle the second +t sequence as plain text.
Bug: If a string ended in a plus then it got removed.

With these improvements we are less vulnerable to this problem and a few tests could be simplified and a few actually had text ending in double-pus-symbols to compensate for the loss of the last.  Ultimately, the only foolproof way to not have a +letter be interpreted as a modifier is to use the octal code for the plus: \053.
@PaulWessel PaulWessel requested a review from seisman March 25, 2019 19:54
@PaulWessel PaulWessel merged commit be76d9c into master Mar 25, 2019
@PaulWessel PaulWessel deleted the modparsing branch March 25, 2019 21:20
obaney pushed a commit to obaney/gmt that referenced this pull request Aug 18, 2021
* Remove note on shift_origin added in GenericMappingTools#536
* Remove xfails for put_strings added in GenericMappingTools#520
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.

2 participants