Skip to content

Commit

Permalink
Ensure that newlines change the linestate when skipping junk.
Browse files Browse the repository at this point in the history
Sometimes skipline() would skip meaningful characters without
letting skipcomment() look at them.

Reported-By: Christoph Schied <Christoph.Schied@kit.edu>
  • Loading branch information
fanf2 committed Oct 20, 2014
1 parent 41848d1 commit 90ca2ee
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tests/error.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#if FOO != 5
#error
#endif
bar
Empty file added tests/error.experr
Empty file.
2 changes: 2 additions & 0 deletions tests/error.expout
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#error
bar
1 change: 1 addition & 0 deletions tests/error.exprc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
1 change: 1 addition & 0 deletions tests/error.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
unifdef -DFOO=1 error.c
8 changes: 6 additions & 2 deletions unifdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,10 +1132,14 @@ skiphash(void)
static const char *
skipline(const char *cp)
{
const char *pcp;
if (*cp != '\0')
linestate = LS_DIRTY;
while (*cp != '\0')
cp = skipcomment(cp + 1);
while (*cp != '\0') {
cp = skipcomment(pcp = cp);
if (pcp == cp)
cp++;
}
return (cp);
}

Expand Down

0 comments on commit 90ca2ee

Please sign in to comment.