Skip to content

Commit 59faa71

Browse files
authored
Merge pull request #21 from dmadison/upstream-1.8.7
Merge upstream tag '1.8.7'
2 parents 796f5d2 + 41c2f4d commit 59faa71

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

cores/arduino/WString.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
*/
2121

2222
#include "WString.h"
23+
#include <float.h>
24+
25+
/*********************************************/
26+
/* Static Member Initialisation */
27+
/*********************************************/
28+
29+
size_t const String::FLT_MAX_DECIMAL_PLACES = DECIMAL_DIG;
30+
size_t const String::DBL_MAX_DECIMAL_PLACES = DECIMAL_DIG;
2331

2432
/*********************************************/
2533
/* Constructors */
@@ -107,15 +115,19 @@ String::String(unsigned long value, unsigned char base)
107115

108116
String::String(float value, unsigned char decimalPlaces)
109117
{
118+
static size_t const FLOAT_BUF_SIZE = (FLT_MAX_10_EXP + 1) + FLT_MAX_DECIMAL_PLACES + 1 /* '-' */ + 1 /* '.' */ + 1 /* '\0' */;
110119
init();
111-
char buf[33];
120+
char buf[FLOAT_BUF_SIZE];
121+
decimalPlaces = decimalPlaces < FLT_MAX_DECIMAL_PLACES ? decimalPlaces : FLT_MAX_DECIMAL_PLACES;
112122
*this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf);
113123
}
114124

115125
String::String(double value, unsigned char decimalPlaces)
116126
{
127+
static size_t const DOUBLE_BUF_SIZE = (DBL_MAX_10_EXP + 1) + DBL_MAX_DECIMAL_PLACES + 1 /* '-' */ + 1 /* '.' */ + 1 /* '\0' */;
117128
init();
118-
char buf[33];
129+
char buf[DOUBLE_BUF_SIZE];
130+
decimalPlaces = decimalPlaces < DBL_MAX_DECIMAL_PLACES ? decimalPlaces : DBL_MAX_DECIMAL_PLACES;
119131
*this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf);
120132
}
121133

cores/arduino/WString.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class String
5050
typedef void (String::*StringIfHelperType)() const;
5151
void StringIfHelper() const {}
5252

53+
static size_t const FLT_MAX_DECIMAL_PLACES;
54+
static size_t const DBL_MAX_DECIMAL_PLACES;
55+
5356
public:
5457
// constructors
5558
// creates a copy of the initial value.

libraries/Wire/examples/i2c_scanner/i2c_scanner.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// can be found in many places.
77
// For example on the Arduino.cc forum.
88
// The original author is not known.
9-
// Version 2, Juni 2012, Using Arduino 1.0.1
9+
// Version 2, June 2012, Using Arduino 1.0.1
1010
// Adapted to be as simple as possible by Arduino.cc user Krodal
1111
// Version 3, Feb 26 2013
1212
// V3 by louarnold

platform.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# https://arduino.github.io/arduino-cli/latest/platform-specification/
77

88
name=XInput AVR Boards
9-
version=1.0.5
9+
version=1.0.6
1010

1111
# AVR compile variables
1212
# ---------------------

0 commit comments

Comments
 (0)