Suporta comentários.
[cascardo/declara.git] / lib / token.c
index 50b82de..78a409b 100644 (file)
@@ -53,7 +53,9 @@ static char * token_next(char *line, char **end)
        start = line;
        while (isspace(*start))
                start++;
-       if (*start == '"') {
+       if (*start == '#') {
+               lend = start;
+       } else if (*start == '"') {
                lend = start + 1;
                while (*lend) {
                        cend = *lend;
@@ -86,6 +88,9 @@ char ** tokens_new(char *line)
        int i;
        end = line;
        do {
+               start = token_next(end, &end);
+               if (start == end)
+                       break;
                if (next <= alloc) {
                        char **nargs;
                        alloc += inc;
@@ -101,9 +106,6 @@ char ** tokens_new(char *line)
                                nargs[i] = NULL;
                        args = nargs;
                }
-               start = token_next(end, &end);
-               if (start == end)
-                       break;
                if (*start == '"') {
                        args[next] = token_unescape(start, end - 1);
                } else {