-
Notifications
You must be signed in to change notification settings - Fork 169
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
Improve fault-tolerance of Modelica.Utilities.Strings.substring w.r.t. index arguments and remove undocumented case with endIndex=-999 #3503
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea overall.
However,
- startIndex=0 is illegal, but not "negative" I would use the phrase "non-positive"
- I'm unsure if we totally should ignore messages for endIndex>length. Using startIndex=2 endIndex=9999999 (or a symbol for the latter) seems like a simple way to skip the first character.
a51a0ec
to
fcedc53
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good. Although I see some unrelated changes (I assume due to merging).
123d562
to
089d51d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with the idea of making this function more tolerant.
I agree with @HansOlsson that you should replace "negative" with "non-positive" or "less than one" in the warning when startIndex < 1
@sjoelund is on holiday |
* Do not assert on incorrect arguments of substring, but try to correct them and raise a warning instead. * substring was also improved to return an empty string, in case endIndex is less than startIndex.
089d51d
to
8626c64
Compare
That should be the case already. |
I missed the feature of Modelica.Utilities.Strings.substring to return an empty string. This is why I started this PR.