diff options
author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2001-11-22 16:22:53 +0000 |
---|---|---|
committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2001-11-22 16:22:53 +0000 |
commit | 570a053255cc39a80060f10cabd6aa94e52e5df3 (patch) | |
tree | df2e331d3253e653c6a9b5bd33f8a6e4e66bca2d /include/expression.c | |
parent | f41a09c7cf368ec8cd0093571033d84df4430efc (diff) | |
download | zabbix-570a053255cc39a80060f10cabd6aa94e52e5df3.tar.gz zabbix-570a053255cc39a80060f10cabd6aa94e52e5df3.tar.xz zabbix-570a053255cc39a80060f10cabd6aa94e52e5df3.zip |
fixed function is_float (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@247 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'include/expression.c')
-rw-r--r-- | include/expression.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/include/expression.c b/include/expression.c index 5ce29735..2d9dc8b1 100644 --- a/include/expression.c +++ b/include/expression.c @@ -17,18 +17,36 @@ int cmp_double(double a,double b) return 1; } +/* + * Return SUCEED if parameter has format X.X or X, where X is [0..9]{1,n} + * */ int is_float(char *c) { int i; + int dot=-1; syslog(LOG_DEBUG, "Starting is_float:%s", c ); - for(i=0;i<=strlen(c);i++) + for(i=0;i<strlen(c);i++) { - if((c[i]=='(')||(c[i]==')')||(c[i]=='{')||(c[i]=='<')||(c[i]=='>')||(c[i]=='=')) + if((c[i]>='0')&&(c[i]<='9')) { - return FAIL; + continue; } + + if((c[i]=='.')&&(dot==-1)) + { + dot=i; + + if((dot!=0)&&(dot!=strlen(c)-1)) + { + continue; + } + } + + syslog(LOG_DEBUG, "It is NOT float" ); + return FAIL; } + syslog(LOG_DEBUG, "It is float" ); return SUCCEED; } |