]> mj.ucw.cz Git - umpf.git/commitdiff
allow comments behind #
authorAnicka Bernathova <anicka@anicka.net>
Tue, 21 Jul 2009 18:25:17 +0000 (20:25 +0200)
committerAnicka Bernathova <anicka@anicka.net>
Tue, 21 Jul 2009 18:25:17 +0000 (20:25 +0200)
lex.c

diff --git a/lex.c b/lex.c
index aaf10d01b71ecd5287850c8946756104548315be..95126304fd350df7669ac399f205f9ed0a46097d 100644 (file)
--- 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;