[Kst] extragear/graphics/kst/kst/datasources/ascii
George Staikos
staikos at kde.org
Fri Jun 24 21:22:09 CEST 2005
SVN commit 428640 by staikos:
handle INF
M +13 -2 ascii.cpp
--- trunk/extragear/graphics/kst/kst/datasources/ascii/ascii.cpp #428639:428640
@@ -35,8 +35,13 @@
#include <assert.h>
#include <ctype.h>
+#include <math.h>
#include <stdlib.h>
+#ifndef INF
+double INF = 1.0/0.0;
+#endif
+
#define DEFAULT_DELIMITERS "#/c!;"
#define DEFAULT_COLUMN_WIDTH 16
@@ -416,8 +421,11 @@
incol = true;
++i_col;
if (i_col == col) {
- if (isdigit(_tmpBuf[ch]) || _tmpBuf[ch] == '-') {
+ if (isdigit(_tmpBuf[ch]) || _tmpBuf[ch] == '-' || _tmpBuf[ch] == '.') {
v[i] = atof(_tmpBuf + ch);
+ } else if (ch + 2 < bufread && tolower(_tmpBuf[ch]) == 'i' &&
+ tolower(_tmpBuf[ch + 1] == 'n') && tolower(_tmpBuf[ch + 2]) == 'f') {
+ v[i] = INF;
} else {
v[i] = NAN;
}
@@ -447,8 +455,11 @@
incol = true;
++i_col;
if (i_col == col) {
- if (isdigit(_tmpBuf[ch]) || _tmpBuf[ch] == '-') {
+ if (isdigit(_tmpBuf[ch]) || _tmpBuf[ch] == '-' || _tmpBuf[ch] == '.') {
v[i] = atof(_tmpBuf + ch);
+ } else if (ch + 2 < bufread && tolower(_tmpBuf[ch]) == 'i' &&
+ tolower(_tmpBuf[ch + 1] == 'n') && tolower(_tmpBuf[ch + 2]) == 'f') {
+ v[i] = INF;
} else {
v[i] = NAN;
}
More information about the Kst
mailing list