handling "Index" column in prn files

This commit is contained in:
Edward Arthur Bingham 2024-06-15 12:49:25 -04:00
parent 36537366f6
commit 5fb34a3741
3 changed files with 193 additions and 173 deletions

View File

@ -39,6 +39,7 @@ void spicestream_construct( SpiceStream *ss, char *filename, char *format, WaveT
spicestream_read_rows, spicestream_destroy );
ss->filename = filename;
ss->format = format;
ss->idxcol = -1;
/* open file */
ss->linebuf = fdbuf_new ( filename, "r", 0);

View File

@ -71,6 +71,7 @@ struct _SpiceStream {
int currow;
/* some more variables for .wav */
int bps; /* bit per sample */
int idxcol; // throw away any index column
};

View File

@ -150,6 +150,16 @@ ascii_process_header(SpiceStream *ss, char *line, VarType ivtype )
return -1;
}
if (app_strcasestr(signam, "index") ) {
ss->idxcol = 0;
// Skip to next token in header
signam = strtok(NULL, " \t\n");
if ( ! signam) {
msg_error(_("line %d: syntax error in header"), fdbuf_get_lineno(ss->linebuf));
return -1;
}
}
if ( ivtype == UNKNOWN) {
if (app_strcasestr(signam, "time") ) {
ivtype = TIME;
@ -202,6 +212,14 @@ int sf_readrow_ascii(SpiceStream *ss)
return -2; /* blank line can indicate end of data */
}
// skip index column
if (ss->idxcol >= 0) {
tok = strtok(NULL, " \t\n");
if ( ! tok) {
return -2; /* blank line can indicate end of data */
}
}
/*
* check to see if it is numeric: ascii format is so loosly defined
* that we might read a load of garbage otherwise.