Skip to content
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
livecodepanos merged 1 commit into
livecode:develop-9.6from
livecodepanos:bugfix-22868
Jun 30, 2021
Merged

[[ Bug 22868 ]] Ensure format() accepts negative length#7419
livecodepanos merged 1 commit into
livecode:develop-9.6from
livecodepanos:bugfix-22868

Conversation

@livecodepanos

Copy link
Copy Markdown
Contributor

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

@livecodepanos livecodepanos added this to the 9.6.2-rc-1 milestone Aug 20, 2020
Comment thread engine/src/exec-strings.cpp Outdated
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, "");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@runrevmark

Copy link
Copy Markdown
Contributor

@livecode-vulcan review ok 8f062ea

@livecode-vulcan

Copy link
Copy Markdown
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
@livecode-vulcan

Copy link
Copy Markdown
Contributor

😎 test success 8f062ea

  • try-community-armv6-android-sdk26_ndk16r15: success
  • try-community-armv7-android-ndk16r15: success
  • try-community-arm64-android-ndk16r15: success
  • try-community-x86-android-ndk16r15: success
  • try-community-x86_64-android-ndk16r15: success
  • try-community-js-emscripten-sdk1.35: success
  • try-community-universal-ios-iphoneos14.5: success
  • try-community-universal-ios-iphoneos14.4: success
  • try-community-universal-ios-iphonesimulator14.5: success
  • try-community-universal-ios-iphonesimulator14.4: success
  • try-community-universal-mac-macosx10.9: success
  • try-community-x86-linux-debian8: success
  • try-community-x86_64-linux-debian8: success
  • try-community-x86-win32: success
  • try-community-x86_64-win32: success

@livecodepanos livecodepanos merged commit f565947 into livecode:develop-9.6 Jun 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants