Skip to content
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

Fixed String(int64_t) #7765

Merged
merged 2 commits into from
Feb 15, 2023

Conversation

mrengineer7777
Copy link
Collaborator

@mrengineer7777 mrengineer7777 commented Jan 27, 2023

Description of Change

Fixed int64_t String support.

Background:
sprintf on esp32 doesn't support "%lld" parameter. It's possible to recompile the underlying libraries to add that option. However this has already been solved in ESP8266 version of WString by replacing sprintf() with itoa/ltoa/lltoa.

This PR does the following:
Fixes integer print issues by replacing sprintf() with itoa/ltoa/lltoa
Moves concat(long long num), concat(unsigned long long num) location (match ESP8266)
Cleans up code formatting (matches ESP8266)

Tests scenarios

Tested on Arduino FeatherESP32 with v2.0.5 and current master.

Related links

Closes #7760

@VojtechBartoska VojtechBartoska added Status: To be implemented Selected for Development Status: In Progress Issue is in progress labels Jan 30, 2023
@SuGlider SuGlider self-assigned this Feb 5, 2023
@SuGlider SuGlider self-requested a review February 5, 2023 19:24
@mrengineer7777 mrengineer7777 force-pushed the WString-Fixes-From-8266 branch 3 times, most recently from 38142dd to c2876d5 Compare February 8, 2023 15:24
@mrengineer7777
Copy link
Collaborator Author

Rebased PR on latest master. Had to undo moved functions, rebase, move again, squash changes and force push.

@mrengineer7777
Copy link
Collaborator Author

I built a test project to verify String integer conversion functionality. https://github.com/mrengineer7777/WStringTEST

Testing against arduino-esp32 v2.0.5:
10:36:31.784 > -------------WString Testing---------------
10:36:31.785 > Constructor Tests
10:36:31.785 > char Expecting a, a, got a, a
10:36:31.785 > int Expecting -12345, 12345, got -12345, 12345
10:36:31.785 > long Expecting -123456, 123456, got -123456, 123456
10:36:31.785 > long Expecting -12345678, 12345678, got ld, 12345678 [FAILED]
10:36:31.785 > Concat Tests
10:36:31.785 > char Expecting a, a, got a, 97 [LEGACY]
10:36:31.785 > int Expecting -12345, 12345, got -12345, 12345
10:36:31.785 > long Expecting -123456, 123456, got -123456, 123456
10:36:31.785 > long long Expecting -12345678, 12345678, got ld, 12345678 [FAILED]
10:36:31.785 > ---Tests completed---

Note the failures on long long.

Testing with proposed PR, including changes to WString from master:
10:48:41.439 > -------------WString Testing---------------
10:48:41.440 > Constructor Tests
10:48:41.440 > char Expecting a, a, got a, a
10:48:41.440 > int Expecting -12345, 12345, got -12345, 12345
10:48:41.440 > long Expecting -123456, 123456, got -123456, 123456
10:48:41.440 > long Expecting -12345678, 12345678, got -12345678, 12345678
10:48:41.440 > Concat Tests
10:48:41.440 > char Expecting a, a, got a, 97 [LEGACY]
10:48:41.440 > int Expecting -12345, 12345, got -12345, 12345
10:48:41.440 > long Expecting -123456, 123456, got -123456, 123456
10:48:41.440 > long long Expecting -12345678, 12345678, got -12345678, 12345678
10:48:41.440 > ---Tests completed---

Note this PR resolves the failure on long long but otherwise does NOT change existing behavior.
Also note that char appears to convert inconsistently (possibly due to cast to int). This PR does not change that.

@mrengineer7777 mrengineer7777 force-pushed the WString-Fixes-From-8266 branch from c2876d5 to 7e26c72 Compare February 8, 2023 17:00
@mrengineer7777 mrengineer7777 marked this pull request as ready for review February 8, 2023 17:02
@mrengineer7777 mrengineer7777 force-pushed the WString-Fixes-From-8266 branch from 7e26c72 to 372544c Compare February 10, 2023 15:10
@mrengineer7777
Copy link
Collaborator Author

@SuGlider Ready for review

WString Fix int64_t

Fixed int64_t String support. Resolves issue espressif#7760.

Background:
sprintf on esp32 doesn't support "%lld" parameter.  It's possible to recompile the underlying libraries to add that option, but I have an easier solution.
This has already been solved in ESP8266 version of WString by replacing sprintf() with itoa/ltoa/lltoa.

This PR does the following:
Fixes integer print issues by replacing sprintf() with itoa/ltoa/lltoa
Moves concat(long long num), concat(unsigned long long num) location (match ESP8266)
Cleans up code formatting (matches ESP8266)
@mrengineer7777 mrengineer7777 force-pushed the WString-Fixes-From-8266 branch from 372544c to da088ef Compare February 14, 2023 16:35
@me-no-dev me-no-dev merged commit 345e3c6 into espressif:master Feb 15, 2023
@mrengineer7777 mrengineer7777 deleted the WString-Fixes-From-8266 branch February 15, 2023 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: In Progress Issue is in progress Status: To be implemented Selected for Development
Projects
None yet
Development

Successfully merging this pull request may close these issues.

String constructor and concat with int64_t results in "ld"
4 participants