#577 closed defect (fixed)
psVectorsReadFromFile parsing of multiple columns
| Reported by: | Paul Price | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | mathtypes | Version: | 0.8.0 |
| Severity: | critical | Keywords: | |
| Cc: |
Description
Parsing of multiple columns does not work correctly: it would not parse the
simple file:
# Non-linearity correction lookup table
# Col 1: Input value
# Col 2: Corrected value
0 0
100 1
200 2
...
It fails with the (rather unenlightening) error message:
2005:11:03 22:47:32Z|mithrandir |E|psVectorsReadFromFile
(psLookupTable.c:553)
Parsing text file failed.
I traced this down to the logic in the various parse functions. The parse
function use functions like strtol() to convert the string to a number. The
parse function checks the value of the 'end' character after strtol, assuming
this should be '\0'. But in the case that there are multiple columns, the end
character after reading the first number will not be '\0', but will be whitespace.
The fix is to change the lines that read:
if(*end != '\0') {
to:
if(*end != '\0' && !isspace(*end)) {
Change History (8)
comment:1 by , 21 years ago
| Owner: | changed from to |
|---|
comment:2 by , 21 years ago
comment:3 by , 20 years ago
I don't know that much about this function yet and wasn't planning on investing
too much time in it unless necessary. Thus, I have made the requested changes,
however, I'm not sure as to their "effectiveness". I will put the revised code
in CVS and leave this bug as open until the fixes can be verified. The "\t" did
not work appropriately which doesn't surprise me too much. As a quick fix, I
replaced it with " " (4 spaces) but I have to assume this will not fix the
problem. Consequently, if you could give it another run with whatever tests you
were using, and let me know what issues still exist, I will look into it
shortly. Thanks.
comment:4 by , 20 years ago
Four spaces is not the same as a tab. That string needs to be " \t" (i.e., a
space followed by '\t', so that getToken will find either a space or a tab.
comment:5 by , 20 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
ok. my bad... changed it to " \t" and now it works. looked like "\t" before.

An additional bug is that it will not read tab-delimited columns. The fix is to
add the '\t' to the below lines:
\t",&parseStatus)) &&
\t",&parseStatus)) ) {