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

Use delimiters literally in macro functions #4381

Merged

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Nov 6, 2023

Identify the Bug or Feature request

#4380

Description of the Change

Introduces a StringUtil.split() function that macro functions and others can use to split strings using a literal delimiter.

The following functions were updated to use StringUtil.split() and thus no longer interpret their delimiters as regex:

  • json.toList()
  • json.fromStrProp()
  • execLink()
  • execFunction()
  • selectTokens()
  • deselectTokens()
  • broadcast()
  • exposeFOW()
  • input()

Also removed are the unused JSONMacroFunctionsOld class and the MapTool.addGlobalMessage(String, String, String) method which also had improper uses of String.split().

Possible Drawbacks

Existing macros that depend on the incorrect behaviour will need to be updated.

Documentation Notes

This brings each function in line with its documentation.

Release Notes

  • Fixed macro functions accepting string lists to treat their delimiter parameter literally.

This change is Reviewable

`JSONMacroFunctionsOld` and `MapTool.addGlobalMessage(String, String, String)` are not in use, so have been removed.
These functions had their delimiters interpreted as regex rather than literal strings:
- json.toList() - 2nd parameter
- json.fromStrProp() - 2nd parameter
- execLink() - 4th parameter
- execFunction() - 5th parameter
- selectTokens() - 3rd parameter
- deselectTokens() - 2nd parameter
- broadcast() - 3rd parameter
- exposeFOW() - 3rd parameter
- input() - "DELIMITER=" for lists and radios

This was done by introducing a new `StringUtil.split()` utility method, and changing the implementation of these
functions to use it instead of `String.split()` directly.
@kwvanderlinde kwvanderlinde force-pushed the bugfix/4380-split-delimiters branch from 8364590 to 27dc1c7 Compare November 6, 2023 23:44
@cwisniew cwisniew added this pull request to the merge queue Nov 8, 2023
@cwisniew cwisniew added the bug label Nov 8, 2023
Merged via the queue into RPTools:develop with commit be74653 Nov 8, 2023
4 checks passed
@kwvanderlinde kwvanderlinde deleted the bugfix/4380-split-delimiters branch November 8, 2023 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

2 participants