Skip to content

Commit

Permalink
BUG: only allow blanks ( not newlines ) after = in meta header
Browse files Browse the repository at this point in the history
Priviously, an empty string was indistinguishable from one which
starts on the next line. This created an ambiguity if the next line
should be a the value or the next field. This patch only allows blanks
(space or tabs) after the seperator charactor.
  • Loading branch information
blowekamp committed Aug 15, 2012
1 parent f44e632 commit 5c7281c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Modules/ThirdParty/MetaIO/src/MetaIO/metaUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ bool MET_SkipToVal(METAIO_STREAM::istream &fp)
c = fp.get();
}

while( !fp.eof() && ( c == MET_SeperatorChar || c == ':' || isspace(c) ) )
while( !fp.eof() && ( c == MET_SeperatorChar || c == ':' || isblank(c) ) )
{
c = fp.get();
}
Expand Down Expand Up @@ -1054,12 +1054,15 @@ bool MET_Read(METAIO_STREAM::istream &fp,
while(!fp.eof())
{
i = 0;

// find the start of name
c = fp.get();
while(!fp.eof() && c != MET_SeperatorChar && c != ':'
&& (c == '\r' || c == '\n' || isspace(c)))
&& isspace(c) )
{
c = fp.get();
}
// save name up to separator or end of line
while(!fp.eof() && c != MET_SeperatorChar && c != ':' && c != '\r' && c != '\n' && i<500)
{
s[i++] = c;
Expand All @@ -1072,8 +1075,9 @@ bool MET_Read(METAIO_STREAM::istream &fp,
fp.putback(c);
s[i] = '\0';

// trim white space on name
i--;
while((s[i] == ' ' || s[i] == '\t') && i>0)
while( isblank(s[i]) && i>0)
{
s[i--] = '\0';
}
Expand Down

0 comments on commit 5c7281c

Please sign in to comment.