From 29219e7a301582a6eba9d3efc87dbcc2c2ee97c3 Mon Sep 17 00:00:00 2001 From: miker Date: Sat, 7 Jul 2007 01:24:43 +0000 Subject: [PATCH] using ctype.h isdigit() instead of home-grown is_number() git-svn-id: svn://svn.open-ils.org/OpenSRF/branches/new-json2@1010 9efc2488-bf62-4759-914b-345cdb29e865 --- include/opensrf/osrf_legacy_json.h | 4 +--- src/libopensrf/osrf_legacy_json.c | 21 ++------------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/include/opensrf/osrf_legacy_json.h b/include/opensrf/osrf_legacy_json.h index f394e70..a79fbbe 100644 --- a/include/opensrf/osrf_legacy_json.h +++ b/include/opensrf/osrf_legacy_json.h @@ -23,6 +23,7 @@ GNU General Public License for more details. #define LEGACY_JSON_H #include +#include @@ -75,9 +76,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/libopensrf/osrf_legacy_json.c b/src/libopensrf/osrf_legacy_json.c index be54169..69b9867 100644 --- a/src/libopensrf/osrf_legacy_json.c +++ b/src/libopensrf/osrf_legacy_json.c @@ -124,7 +124,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; @@ -222,7 +222,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); } @@ -689,23 +689,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]; -- 2.11.0