Skip to content
Browse files

scanner: fixed test-case "test_scanner_reach_end_of_template"

when the end of the string is reached stop forwarding.
  • Loading branch information...
1 parent f272060 commit d41d813e13ffcf2f813c7acf1bdfccd48ae73476 @sjaeckel sjaeckel committed Dec 7, 2011
Showing with 10 additions and 4 deletions.
  1. +10 −4 source/scanner.c
View
14 source/scanner.c
@@ -38,10 +38,16 @@ scanner_token get_char(scanner* s)
s->current_col = 0;
++(s->pos);
c = s->thetemplate[s->pos];
- }
- ++s->current_col;
- scanner_token ret = {s->current_row, s->current_col, c };
- ++s->pos;
+ } /* if */
+
+ /* Verify that we stop when the string is terminated */
+ if (c != '\0')
+ {
+ ++s->current_col;
+ ++s->pos;
+ } /* if */
+
+ scanner_token ret = { s->current_row, s->current_col, c };
return ret;
}

0 comments on commit d41d813

Please sign in to comment.
Something went wrong with that request. Please try again.