cwCsv.cpp : _fill_line_buf() now strips trailing white space from the line buffer.
This commit is contained in:
parent
a708d37541
commit
d90b03d810
17
cwCsv.cpp
17
cwCsv.cpp
@ -169,12 +169,29 @@ namespace cw
|
|||||||
{
|
{
|
||||||
rc_t rc;
|
rc_t rc;
|
||||||
|
|
||||||
|
// read the next line
|
||||||
if((rc = getLineAuto( p->fH, &p->lineBuf, &p->lineCharCnt )) != kOkRC )
|
if((rc = getLineAuto( p->fH, &p->lineBuf, &p->lineCharCnt )) != kOkRC )
|
||||||
{
|
{
|
||||||
if( rc != kEofRC )
|
if( rc != kEofRC )
|
||||||
rc = cwLogError(rc,"Line buf alloc failed on line index:%i.",p->curLineIdx);
|
rc = cwLogError(rc,"Line buf alloc failed on line index:%i.",p->curLineIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p->lineCharCnt = textLength(p->lineBuf);
|
||||||
|
|
||||||
|
// trim trailing white space from the line buffer.
|
||||||
|
if( p->lineCharCnt > 0 )
|
||||||
|
{
|
||||||
|
int i = ((int)p->lineCharCnt)-1;
|
||||||
|
|
||||||
|
while( i>=0 && isspace(p->lineBuf[i]) )
|
||||||
|
{
|
||||||
|
p->lineBuf[i] = '\0';
|
||||||
|
--i;
|
||||||
|
p->lineCharCnt -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user