aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino
diff options
context:
space:
mode:
authorDavid A. Mellis <d.mellis@arduino.cc>2010-12-03 23:12:41 -0500
committerDavid A. Mellis <d.mellis@arduino.cc>2010-12-03 23:12:41 -0500
commit053ec1b989085e0d59f84ded8641058715701a8b (patch)
tree04bc744b58ddb6fcf71a80bbbf37a5146da43f5e /cores/arduino
parent4fefe032a53667cba2b801d0cc5f021b3d457ddd (diff)
Replacing custom String.toInt() function with a call to atol().
Diffstat (limited to 'cores/arduino')
-rw-r--r--cores/arduino/WCharacter.h7
-rwxr-xr-xcores/arduino/WProgram.h1
-rw-r--r--cores/arduino/WString.cpp13
3 files changed, 5 insertions, 16 deletions
diff --git a/cores/arduino/WCharacter.h b/cores/arduino/WCharacter.h
index 9b3e7fc..79733b5 100644
--- a/cores/arduino/WCharacter.h
+++ b/cores/arduino/WCharacter.h
@@ -20,8 +20,7 @@
#ifndef Character_h
#define Character_h
-
-#include "WProgram.h"
+#include <ctype.h>
// WCharacter.h prototypes
inline boolean isAlphaNumeric(int c) __attribute__((always_inline));
@@ -117,8 +116,8 @@ inline boolean isPunct(int c)
// Checks for white-space characters. For the avr-libc library,
-// these are: space, formfeed (’\f’), newline (’\n’), carriage
-// return (’\r’), horizontal tab (’\t’), and vertical tab (’\v’).
+// these are: space, formfeed ('\f'), newline ('\n'), carriage
+// return ('\r'), horizontal tab ('\t'), and vertical tab ('\v').
inline boolean isSpace(int c)
{
return ( isspace (c) == 0 ? false : true);
diff --git a/cores/arduino/WProgram.h b/cores/arduino/WProgram.h
index 5afecb4..f73e760 100755
--- a/cores/arduino/WProgram.h
+++ b/cores/arduino/WProgram.h
@@ -10,6 +10,7 @@
#include "wiring.h"
#ifdef __cplusplus
+#include "WCharacter.h"
#include "WString.h"
#include "HardwareSerial.h"
diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp
index b13123b..4de9296 100644
--- a/cores/arduino/WString.cpp
+++ b/cores/arduino/WString.cpp
@@ -437,16 +437,5 @@ void String::toCharArray(char *buf, unsigned int bufsize)
long String::toInt() {
- String temp = _buffer;
- long value = 0;
-
- for (unsigned int charPos = 0; charPos < _length; charPos++) {
- int thisChar = temp[charPos];
- if (isdigit(thisChar)) {
- value *= 10;
- value += (thisChar - '0');
- }
- }
-
- return value;
+ return atol(_buffer);
}