[Opensrf-commits] r1001 - in trunk: include/objson src/objson

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jul 5 20:24:40 EDT 2007


Author: miker
Date: 2007-07-05 20:20:44 -0400 (Thu, 05 Jul 2007)
New Revision: 1001

Modified:
   trunk/include/objson/json_parser.h
   trunk/src/objson/json_parser.c
Log:
moved from custom is_number() to standared ctype.h isdigit()

Modified: trunk/include/objson/json_parser.h
===================================================================
--- trunk/include/objson/json_parser.h	2007-07-05 20:45:36 UTC (rev 1000)
+++ trunk/include/objson/json_parser.h	2007-07-06 00:20:44 UTC (rev 1001)
@@ -23,6 +23,7 @@
 #define JSON_PARSER_H
 
 #include <stdio.h>
+#include <ctype.h>
 #include <objson/object.h>
 #include <opensrf/utils.h>
 
@@ -77,9 +78,6 @@
 /* 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);
 
 

Modified: trunk/src/objson/json_parser.c
===================================================================
--- trunk/src/objson/json_parser.c	2007-07-05 20:45:36 UTC (rev 1000)
+++ trunk/src/objson/json_parser.c	2007-07-06 00:20:44 UTC (rev 1001)
@@ -127,7 +127,7 @@
 			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 @@
 
 	while(*index < current_strlen) {
 
-		if(is_number(c)) {
+		if(isdigit(c)) {
 			buffer_add_char(buf, c);
 		}
 
@@ -692,23 +692,6 @@
 	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];



More information about the opensrf-commits mailing list