[Opensrf-commits] r1010 - in branches/new-json2: include/opensrf src/libopensrf

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Jul 6 21:28:47 EDT 2007


Author: miker
Date: 2007-07-06 21:24:43 -0400 (Fri, 06 Jul 2007)
New Revision: 1010

Modified:
   branches/new-json2/include/opensrf/osrf_legacy_json.h
   branches/new-json2/src/libopensrf/osrf_legacy_json.c
Log:
using ctype.h isdigit() instead of home-grown is_number()

Modified: branches/new-json2/include/opensrf/osrf_legacy_json.h
===================================================================
--- branches/new-json2/include/opensrf/osrf_legacy_json.h	2007-07-06 21:08:42 UTC (rev 1009)
+++ branches/new-json2/include/opensrf/osrf_legacy_json.h	2007-07-07 01:24:43 UTC (rev 1010)
@@ -23,6 +23,7 @@
 #define LEGACY_JSON_H
 
 #include <opensrf/osrf_json.h>
+#include <ctype.h>
 
 
 
@@ -75,9 +76,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: branches/new-json2/src/libopensrf/osrf_legacy_json.c
===================================================================
--- branches/new-json2/src/libopensrf/osrf_legacy_json.c	2007-07-06 21:08:42 UTC (rev 1009)
+++ branches/new-json2/src/libopensrf/osrf_legacy_json.c	2007-07-07 01:24:43 UTC (rev 1010)
@@ -124,7 +124,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;
@@ -222,7 +222,7 @@
 
 	while(*index < current_strlen) {
 
-		if(is_number(c)) {
+		if(isdigit(c)) {
 			buffer_add_char(buf, c);
 		}
 
@@ -689,23 +689,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