Skip to content

Commit 26ea318

Browse files
committed
Fix some String error.
1 parent 34e5de5 commit 26ea318

File tree

7 files changed

+258
-171
lines changed

7 files changed

+258
-171
lines changed

cores/arduino/Arduino.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
// AVR stuff, assuming Arduino.h or WProgram.h
3131
// automatically includes it...
3232
#include <avr/pgmspace.h>
33+
#include <avr/dtostrf.h>
3334
//#include <avr/interrupt.h>
3435

3536
#include "binary.h"

cores/arduino/WString.cpp

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

2222
#include "WString.h"
23-
#include "itoa.h"
23+
#include "stdlib_noniso.h"
24+
2425

25-
#ifdef NOTYET /* XXX Marko FIXME! */
2626
#include "avr/dtostrf.h"
27-
#endif
27+
2828

2929
extern "C" {
3030
#include "avr/pgmspace.h"
@@ -114,7 +114,7 @@ String::String(unsigned long value, unsigned char base)
114114
*this = buf;
115115
}
116116

117-
#ifdef NOTYET /* XXX Marko FIXME! */
117+
118118
String::String(float value, unsigned char decimalPlaces)
119119
{
120120
init();
@@ -128,7 +128,7 @@ String::String(double value, unsigned char decimalPlaces)
128128
char buf[33];
129129
*this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf);
130130
}
131-
#endif /* XXX Marko FIXME! */
131+
132132

133133
String::~String()
134134
{
@@ -331,7 +331,7 @@ unsigned char String::concat(unsigned long num)
331331
return concat(buf, strlen(buf));
332332
}
333333

334-
#ifdef NOTYET /* XXX Marko FIXME! */
334+
335335
unsigned char String::concat(float num)
336336
{
337337
char buf[20];
@@ -345,7 +345,7 @@ unsigned char String::concat(double num)
345345
char* string = dtostrf(num, 4, 2, buf);
346346
return concat(string, strlen(string));
347347
}
348-
#endif /* XXX Marko FIXME! */
348+
349349

350350
unsigned char String::concat(const __FlashStringHelper * str)
351351
{
@@ -748,7 +748,7 @@ void String::trim(void)
748748
/* Parsing / Conversion */
749749
/*********************************************/
750750

751-
#ifdef NOTYET /* XXX Marko FIXME! */
751+
752752
long String::toInt(void) const
753753
{
754754
if (buffer) return atol(buffer);
@@ -760,4 +760,4 @@ float String::toFloat(void) const
760760
if (buffer) return float(atof(buffer));
761761
return 0;
762762
}
763-
#endif /* XXX Marko FIXME! */
763+

cores/arduino/avr/dtostrf.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
dtostrf - Emulation for dtostrf function from avr-libc
3+
Copyright (c) 2015 Arduino LLC. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#pragma once
21+
22+
#if !defined(ARDUINO_ARCH_AVR)
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
char *dtostrf(double val, signed char width, unsigned char prec, char *sout);
29+
30+
#ifdef __cplusplus
31+
}
32+
#endif
33+
34+
#endif

cores/arduino/itoa.c

Lines changed: 0 additions & 160 deletions
This file was deleted.

cores/arduino/itoa.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
extern "C"{
2424
#endif // __cplusplus
2525

26-
extern char* ltoa( long value, char *string, int radix ) ;
27-
extern char* ultoa( unsigned long value, char *string, int radix ) ;
26+
extern char* itoa(int value, char *string, int radix);
27+
extern char* ltoa(long value, char *string, int radix);
28+
extern char* utoa(unsigned value, char *string, int radix);
29+
extern char* ultoa(unsigned long value, char *string, int radix);
2830

2931
#ifdef __cplusplus
3032
} // extern "C"

0 commit comments

Comments
 (0)