From abac70416024801c7936c6cdada504cdf2f2fe61 Mon Sep 17 00:00:00 2001 From: "Michael J. Chudobiak" Date: Tue, 14 Aug 2012 09:54:59 -0400 Subject: use pcre regex to implement String_is_it_numeric --- string_utils.c | 56 ++++++-------------------------------------------------- 1 file changed, 6 insertions(+), 50 deletions(-) (limited to 'string_utils.c') diff --git a/string_utils.c b/string_utils.c index cbe310f..67ad827 100644 --- a/string_utils.c +++ b/string_utils.c @@ -183,56 +183,12 @@ int String_trim_excess_digits(char *parameter) /*----------------------------------------------------------------------------------------------------------*/ -int String_is_it_numeric(char *parameter) -{ - /* this function takes a parameter like "1e+6" or "on" and determines if it is numeric or not */ - /* it is similar to the Parser_get_unit function */ - - int i; - int j; - int is_number; - - is_number=0; - i=0; - - - if (isdigit(parameter[0]) || parameter[0]=='+' || parameter[0] == '-' || parameter[0] == '.') { - for (i=1; (i < strlen(parameter)) && isdigit(parameter[i]); ++i) {} - - if (i < strlen(parameter)) - if ( parameter[i]=='.' ) - for (++i; (i < strlen(parameter)) && isdigit(parameter[i]); ++i) {} +gboolean String_is_it_numeric(char *parameter) { - /* suck out spaces */ - while ( (i