Skip to content

[NSScanner] Fix a bug in the initialization of _NSStringBuffer that makes NSScanner unable to find any number #83

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

Merged
merged 1 commit into from
Dec 8, 2015

Conversation

thii
Copy link
Contributor

@thii thii commented Dec 8, 2015

Copied from commit message:

After writing a simple test case for NSScanner, I found that NSScanner always returns 0 when scanning numbers. The problem is in _NSStringBuffer's init function, curChar was assigned to buffer[0] before buffer gets characters from scanned string. Changing curChar to an optional variable and assign it to buffer[0] after buffer got all characters from scanned string fixed this.

…akes NSScanner unable to find any number.

After writing a simple test case for NSScanner, I found that NSScanner always returns 0 when scanning numbers. The problem is in _NSStringBuffer's init function, `curChar` was assigned to `buffer[0]` before `buffer` gets characters from scanned string. Changing `curChar` to a optional variable and assign it to `buffer[0]` after buffer got all characters from scanned string fixed this.
@jpsim
Copy link
Contributor

jpsim commented Dec 8, 2015

Once this is merged, e1c253f should be reverted since those tests should then pass.

@phausler
Copy link
Contributor

phausler commented Dec 8, 2015

good catch! looks good to me

phausler added a commit that referenced this pull request Dec 8, 2015
[NSScanner] Fix a bug in the initialization of _NSStringBuffer that makes NSScanner unable to find any number
@phausler phausler merged commit 6681af4 into swiftlang:master Dec 8, 2015
@phausler
Copy link
Contributor

phausler commented Dec 8, 2015

for some reason the NSRange one is still failing for me likely we have another bug lurking around

@thii thii deleted the bug-_NSStringBuffer-curChar branch December 8, 2015 22:00
atrick pushed a commit to atrick/swift-corelibs-foundation that referenced this pull request Jan 12, 2021
[swiftpm] Statically link to libSwiftPM
kateinoigakukun pushed a commit to kateinoigakukun/swift-corelibs-foundation that referenced this pull request Apr 29, 2021
Disable swift-driver while investigating several test failures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants