mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
Test: fixing itoa implementation and clean-up of tests and test Makefile (#8531)
* Test: fixing itoa implementation, clean-up of tests and test runner Update itoa to be the same as newlib, fixing edgecase of abs(INT_MIN) Update WString.cpp:toString() integer conversions to use noniso funcs Remove legacy gcc versions from Makefile and allow overrides Don't fallback to c11 and c++11, source cannot support that * CXX and CC are make predefined values, assuming ?= does not work (?)
This commit is contained in:
@ -65,29 +65,24 @@ char* itoa(int value, char* result, int base)
|
||||
*result = 0;
|
||||
return result;
|
||||
}
|
||||
if (base != 10)
|
||||
|
||||
unsigned uvalue;
|
||||
char* out = result;
|
||||
|
||||
// after this point we convert the value to unsigned and go to the utoa
|
||||
// only base10 gets minus sign in the front, adhering to the newlib implementation
|
||||
if ((base == 10) && (value < 0))
|
||||
{
|
||||
return utoa((unsigned)value, result, base);
|
||||
*result++ = '-';
|
||||
uvalue = (unsigned)-value;
|
||||
}
|
||||
else
|
||||
{
|
||||
uvalue = (unsigned)value;
|
||||
}
|
||||
|
||||
char* out = result;
|
||||
int quotient = abs(value);
|
||||
|
||||
do
|
||||
{
|
||||
const int tmp = quotient / base;
|
||||
*out = "0123456789abcdef"[quotient - (tmp * base)];
|
||||
++out;
|
||||
quotient = tmp;
|
||||
} while (quotient);
|
||||
|
||||
// Apply negative sign
|
||||
if (value < 0)
|
||||
*out++ = '-';
|
||||
|
||||
reverse(result, out);
|
||||
*out = 0;
|
||||
return result;
|
||||
utoa(uvalue, result, base);
|
||||
return out;
|
||||
}
|
||||
|
||||
int atoi(const char* s)
|
||||
|
Reference in New Issue
Block a user