From 6b3d60b53a72a491b6792e3bd08c7835297f8f7b Mon Sep 17 00:00:00 2001 From: Anicka Bernathova Date: Tue, 21 Jul 2009 20:25:17 +0200 Subject: [PATCH] allow comments behind # --- lex.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/lex.c b/lex.c index aaf10d0..9512630 100644 --- a/lex.c +++ b/lex.c @@ -77,8 +77,10 @@ parse_err(char* msg, ...) fprintf(stderr, "Line %d: ", line); vfprintf(stderr, msg, args); fputc('\n', stderr); + fprintf(stderr, "Saving the email to default mailbox %s\n", + default_mailbox); va_end(args); - exit(1); + longjmp(env, 1); } char* @@ -133,16 +135,38 @@ is_alpha(int c) (c >= 'A' && c <= 'Z'); } -int -yylex(void) +static int +get_token_start(void) { int c; - - while ((c = getc(conf)) == ' ' || c == '\t' || c =='\n'){ - if (c == '\n') + int want_newline = 0; + + for(;;) { + c = getc(conf); + if (c == EOF) + return c; + if (c == '#') { + want_newline = 1; + continue; + } + if (c == '\n') { line++; + want_newline = 0; + continue; + } + if (c != '\n' && want_newline) + continue; + if (c != ' ' && c != '\t') + return c; } +} + +int +yylex(void) +{ + int c; + c = get_token_start(); if (c == EOF) return 0; -- 2.39.2