cwCsv.h/cpp : Fixed off-by-1 bug in _udpate_col_array().
Fixed bug in _get_field_str() where leading white space was not skipped.
This commit is contained in:
parent
95f26398e8
commit
c789d70ce2
@ -74,7 +74,7 @@ namespace cw
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
|
||||
if( col_idx > p->colN )
|
||||
if( col_idx >= p->colN )
|
||||
{
|
||||
rc = cwLogError(kSyntaxErrorRC,"Too many CSV columns on line index:%i",p->curLineIdx);
|
||||
goto errLabel;
|
||||
@ -266,7 +266,9 @@ namespace cw
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
|
||||
// skip leading white space
|
||||
while( isspace(p->lineBuf[ p->colA[colIdx].char_idx ]) && p->lineBuf[ p->colA[colIdx].char_idx ] )
|
||||
p->colA[colIdx].char_idx++;
|
||||
|
||||
fieldStr_Ref = p->lineBuf + p->colA[colIdx].char_idx;
|
||||
|
||||
|
1
cwCsv.h
1
cwCsv.h
@ -10,6 +10,7 @@ namespace cw
|
||||
typedef handle<struct csv_str> handle_t;
|
||||
|
||||
// The first line of the CSV is expected to hold the column titles.
|
||||
// Every column must have a title.
|
||||
// If titlesA and titleN are valid then these will be verified to exist when the CSV file is opened.
|
||||
rc_t create( handle_t& hRef, const char* fname, const char** titleA=nullptr, unsigned titleN=0 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user