From ead3f08671156412dc4c44bcf73da7e3829d0a22 Mon Sep 17 00:00:00 2001 From: "zik.saleeba" Date: Fri, 19 Dec 2008 04:24:55 +0000 Subject: [PATCH] Updated hello.c to current syntax. Fixed a bug in string constant handling. git-svn-id: http://picoc.googlecode.com/svn/trunk@11 21eae674-98b7-11dd-bd71-f92a316d2d60 --- hello.c | 1 + lex.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hello.c b/hello.c index 0cf55b8..2a80574 100644 --- a/hello.c +++ b/hello.c @@ -3,3 +3,4 @@ int main() printf("Hello world\n"); } +main(); diff --git a/lex.c b/lex.c index 0192c83..a9a63a4 100644 --- a/lex.c +++ b/lex.c @@ -90,17 +90,18 @@ enum LexToken LexGetStringConstant(struct LexState *Lexer) { int Escape = FALSE; - Lexer->Pos++; Lexer->Value.String.Str = Lexer->Pos; - while (Lexer->Pos != Lexer->End && !Escape && *Lexer->Pos != '"') + while (Lexer->Pos != Lexer->End && (*Lexer->Pos != '"' || Escape)) { if (Escape) Escape = FALSE; else if (*Lexer->Pos == '\\') Escape = TRUE; + + Lexer->Pos++; } Lexer->Value.String.Len = Lexer->Pos - Lexer->Value.String.Str; - if (*Lexer->Pos != '"') + if (*Lexer->Pos == '"') Lexer->Pos++; return TokenStringConstant;