- Notifications
You must be signed in to change notification settings - Fork13.3k
String: compatibility with 64 bits scalars#7863
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
9 commits Select commitHold shift + click to select a range
fa09a50 String: compatibility with 64 bits scalars
d-a-v8c4c363 use a single div+mod facility
d-a-v598491f fix host tests
d-a-vfe0b14c remove generic udivmod
d-a-v944e2e8 Merge branch 'master' into StringLL
earlephilhower54bbe23 radix type, test with charconv
d-a-v0ebf7a7 Merge branch 'master' into StringLL
d-a-v5c573cc remove charconv, add comment
d-a-v644ae09 fix corner case
d-a-vFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
NextNext commit
String: compatibility with 64 bits scalars
time_t is now 64 bits. Strig(time_t) was ambiguoustests added
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commitfa09a5079d67931c9f23a22b9caa1a78fbef19d1
There are no files selected for viewing
36 changes: 36 additions & 0 deletionscores/esp8266/WString.cpp
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -98,6 +98,32 @@ String::String(unsigned long value, unsigned char base) { | ||
| *this = buf; | ||
| } | ||
| String::String(long long value) { | ||
| init(); | ||
| char buf[2 + 8 * sizeof(long long)]; | ||
| sprintf(buf, "%lld", value); | ||
| *this = buf; | ||
| } | ||
| String::String(long long value, unsigned char base) { | ||
| init(); | ||
| char buf[2 + 8 * sizeof(long long)]; | ||
| *this = lltoa(value, buf, sizeof(buf), base); | ||
| } | ||
| String::String(unsigned long long value) { | ||
| init(); | ||
| char buf[1 + 8 * sizeof(unsigned long long)]; | ||
| sprintf(buf, "%llu", value); | ||
| *this = buf; | ||
| } | ||
| String::String(unsigned long long value, unsigned char base) { | ||
| init(); | ||
| char buf[1 + 8 * sizeof(unsigned long long)]; | ||
| *this = ulltoa(value, buf, sizeof(buf), base); | ||
| } | ||
| String::String(float value, unsigned char decimalPlaces) { | ||
| init(); | ||
| char buf[33]; | ||
| @@ -313,6 +339,16 @@ unsigned char String::concat(unsigned long num) { | ||
| return concat(buf, strlen(buf)); | ||
| } | ||
| unsigned char String::concat(long long num) { | ||
| char buf[2 + 3 * sizeof(long long)]; | ||
| return concat(buf, sprintf(buf, "%lld", num)); | ||
| } | ||
| unsigned char String::concat(unsigned long long num) { | ||
| char buf[1 + 3 * sizeof(unsigned long long)]; | ||
| return concat(buf, sprintf(buf, "%llu", num)); | ||
| } | ||
d-a-v marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| unsigned char String::concat(float num) { | ||
| char buf[20]; | ||
| char *string = dtostrf(num, 4, 2, buf); | ||
22 changes: 22 additions & 0 deletionscores/esp8266/WString.h
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
2 changes: 1 addition & 1 deletioncores/esp8266/debug.cpp
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
38 changes: 38 additions & 0 deletionscores/esp8266/stdlib_noniso.cpp
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #include "stdlib_noniso.h" | ||
| // fill backwards | ||
| char* ulltoa(unsigned long long val, char* str, size_t slen, uint_fast8_t radix) | ||
| { | ||
| str += --slen; | ||
| *str = 0; | ||
| do | ||
| { | ||
| auto n = val % radix; | ||
| val /= radix; | ||
| *--str = n + ((n > 9) ? ('a' - 10) : '0'); | ||
| } while (--slen && val); | ||
| return val? nullptr: str; | ||
| } | ||
| char* lltoa (long long val, char* str, size_t slen, uint_fast8_t radix) | ||
| { | ||
| bool neg; | ||
| if (val < 0) | ||
| { | ||
| val = -val; | ||
| neg = true; | ||
| } | ||
| else | ||
| { | ||
| neg = false; | ||
| } | ||
| char* ret = ulltoa(val, str, slen, radix); | ||
| if (neg) | ||
| { | ||
| if (ret == str) | ||
| return nullptr; | ||
| *--ret = '-'; | ||
| } | ||
| return ret; | ||
| } |
8 changes: 7 additions & 1 deletioncores/esp8266/stdlib_noniso.h
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
1 change: 1 addition & 0 deletionstests/host/Makefile
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
10 changes: 10 additions & 0 deletionstests/host/core/test_string.cpp
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
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.