Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

[21476] Ensure "the extents of tArray" returns empty when keys are not integers - #6636

Merged
livecodepanos merged 5 commits into
livecode:develop-9.0from
livecodepanos:bugfix-21476
Aug 29, 2018
Merged

[21476] Ensure "the extents of tArray" returns empty when keys are not integers#6636
livecodepanos merged 5 commits into
livecode:develop-9.0from
livecodepanos:bugfix-21476

Conversation

@livecodepanos

Copy link
Copy Markdown
Contributor

No description provided.

@livecodepanos livecodepanos added this to the 9.0.2-rc-1 milestone Aug 14, 2018
@runrevmark

Copy link
Copy Markdown
Contributor

@livecodepanos : So this patch isn't quite correct... If you add a test (which we need for this anyway) - then you'll find that:

put 1 into tArray["1"]
put 2 into tArray["1.0"]
put 3 into tArray["1.00"]

Will result in tArray having extents - when they should be empty.

I think we need to MCNumberParseInteger() or similar, which fails if a string is anything other than one matching the pattern 0|[1-9][0-9]* (i.e. no fractional part at all).

Comment thread libfoundation/include/foundation.h Outdated
MC_DLLEXPORT bool MCNumberParseOffsetPartial(MCStringRef p_string, uindex_t offset, uindex_t &r_chars_used, MCNumberRef &r_number);

MC_DLLEXPORT bool MCNumberParseOffset(MCStringRef p_string, uindex_t offset, uindex_t char_count, MCNumberRef &r_number);
MC_DLLEXPORT bool MCNumberParseOffset(MCStringRef p_string, uindex_t offset, uindex_t char_count, bool p_integer_only, MCNumberRef &r_number);

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 there a reason you've added the flag to the public function? We have to be careful changing anything which is MC_DLLEXPORT as it could be bound to by an LCB module.

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.

Currently MCNumberParseOffset is called in MCNumberParse and MCNumberParseInteger, so I added the flag to differentiate between these 2. But I could do so by calling the private __MCNumberParseOffset instead, so I'll change this.

@runrevmark

Copy link
Copy Markdown
Contributor

@livecode-vulcan review ok 7254625

@livecode-vulcan

Copy link
Copy Markdown
Contributor

💙 review by @runrevmark ok 7254625

livecode-vulcan added a commit that referenced this pull request Aug 29, 2018
[21476] Ensure "the extents of tArray" returns empty when keys are not integers
@livecode-vulcan

Copy link
Copy Markdown
Contributor

😎 test success 7254625

  • try-community-armv6-android-sdk26_ndk16r15: success
  • try-community-armv7-android-sdk26_ndk16r15: success
  • try-community-arm64-android-sdk26_ndk16r15: success
  • try-community-x86-android-sdk26_ndk16r15: success
  • try-community-x86_64-android-sdk26_ndk16r15: success
  • try-community-js-emscripten-sdk1.35: success
  • try-community-universal-ios-iphoneos11.4: success
  • try-community-universal-ios-iphonesimulator11.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 a65a200 into livecode:develop-9.0 Aug 29, 2018
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