Replacing custom String.toInt() function with a call to atol().

This commit is contained in:
David A. Mellis 2010-12-03 23:12:41 -05:00
parent 4fefe032a5
commit 053ec1b989
3 changed files with 5 additions and 16 deletions

View File

@ -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);

View File

@ -10,6 +10,7 @@
#include "wiring.h"
#ifdef __cplusplus
#include "WCharacter.h"
#include "WString.h"
#include "HardwareSerial.h"

View File

@ -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);
}