From: miker Date: Fri, 6 Jul 2007 00:20:44 +0000 (+0000) Subject: moved from custom is_number() to standared ctype.h isdigit() X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d9540988ba22a88a67813344f265826ca6b00db4;p=working%2FOpenSRF.git moved from custom is_number() to standared ctype.h isdigit() git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1001 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/include/objson/json_parser.h b/include/objson/json_parser.h index ede5d91..a1f785b 100644 --- a/include/objson/json_parser.h +++ b/include/objson/json_parser.h @@ -23,6 +23,7 @@ GNU General Public License for more details. #define JSON_PARSER_H #include +#include #include #include @@ -77,9 +78,6 @@ int json_eat_comment(char* string, unsigned long* index, char** class_hint, int /* prints a useful error message to stderr. always returns -1 */ int json_handle_error(char* string, unsigned long* index, char* err_msg); -/* returns true if c is 0-9 */ -int is_number(char c); - int json_parse_json_null(char* string, unsigned long* index, jsonObject* obj, int current_strlen); diff --git a/src/objson/json_parser.c b/src/objson/json_parser.c index bf4eb27..18cd2a8 100644 --- a/src/objson/json_parser.c +++ b/src/objson/json_parser.c @@ -127,7 +127,7 @@ int _json_parse_string(char* string, unsigned long* index, jsonObject* obj, int break; default: - if(is_number(c) || c == '.' || c == '-') { /* are we a number? */ + if(isdigit(c) || c == '.' || c == '-') { /* are we a number? */ status = json_parse_json_number(string, index, obj, current_strlen); if(status) return status; break; @@ -225,7 +225,7 @@ int json_parse_json_number(char* string, unsigned long* index, jsonObject* obj, while(*index < current_strlen) { - if(is_number(c)) { + if(isdigit(c)) { buffer_add_char(buf, c); } @@ -692,23 +692,6 @@ int json_eat_comment(char* string, unsigned long* index, char** buffer, int pars return 0; } -int is_number(char c) { - switch(c) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return 1; - } - return 0; -} - int json_handle_error(char* string, unsigned long* index, char* err_msg) { char buf[60];