This repository was archived by the owner on Aug 31, 2021. It is now read-only.
[[ Bug 22868 ]] Ensure format() accepts negative length#7419
Merged
Conversation
runrevmark
reviewed
Aug 25, 2020
| if (!t_is_negative) | ||
| t_success = MCStringAppendFormat(*t_result, "%0*s%@", width - t_range . length, "", *t_string); | ||
| else | ||
| t_success = MCStringAppendFormat(*t_result, "%@%0*s", *t_string, width - t_range . length, ""); |
Contributor
There was a problem hiding this comment.
Is this definitely the LC6 behavior? i.e. if 0 padding is specified, and -ve (i.e. left alignment in width) then 0's appear after the number (thus changing the number printed...).
Contributor
Author
There was a problem hiding this comment.
Indeed, in the case of 0 padding this will not match the LC 6 behavior. I have just pushed an update to fix this use-case too:
LC 6: put 6 into n1;put format ("%-05s", n1) --> 6
LC 7+: put 6 into n1;put format ("%-05s", n1) --> 00006
this patch: put 6 into n1;put format ("%-05s", n1) --> 6
This patch ensures the format() fuction recognizes a negative format length. In this case, it appends spaces to the string, matching the LC 6.x behavior.
26d07b1 to
8f062ea
Compare
runrevmark
approved these changes
Jun 30, 2021
Contributor
|
@livecode-vulcan review ok 8f062ea |
Contributor
|
💙 review by @runrevmark ok 8f062ea |
livecode-vulcan
added a commit
that referenced
this pull request
Jun 30, 2021
[[ Bug 22868 ]] Ensure format() accepts negative length This patch ensures the format() fuction recognizes a negative format length. In this case, it appends spaces to the string, matching the LC 6.x behavior. Fixes https://quality.livecode.com/show_bug.cgi?id=22868
Contributor
|
😎 test success 8f062ea
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch ensures the format() fuction recognizes a negative format length. In this case, it appends spaces to the string, matching the LC 6.x behavior.
Fixes https://quality.livecode.com/show_bug.cgi?id=22868