]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldpcli: handle comments in tokenizer
authorVincent Bernat <vincent@bernat.im>
Sat, 18 Oct 2014 07:03:57 +0000 (09:03 +0200)
committerVincent Bernat <vincent@bernat.im>
Sat, 18 Oct 2014 07:05:06 +0000 (09:05 +0200)
This enables us to also ignore end-of-line comments. Completion is a bit
grumpy when done in comments but I doubt anyone would care.

src/client/lldpcli.c
src/client/tokenizer.c

index ef565c7191fc5c2228b9c207ddb77ade44e5fce9..8eeac70ed98c380b2e1f5b3e8b731f000628d58d 100644 (file)
@@ -494,8 +494,7 @@ main(int argc, char *argv[])
                                line = strndup(line, len);
                                if (line[len - 1] == '\n') {
                                        line[len - 1] = '\0';
-                                       if (line[0] != '#')
-                                               parse_and_exec(conn, fmt, line);
+                                       parse_and_exec(conn, fmt, line);
                                }
                                free(line);
                        }
index e751d72995b0b91cda50c8c65d22df1f618cec03..234091f77b4a74c995e037e8f2eb5d63272c71e1 100644 (file)
@@ -44,6 +44,8 @@ tokenize_line(const char *line, int *argc, char ***argv)
        char input[2*strlen(line) + 3]; /* 3 = 2 for '\n ' and 1 for \0 */
        memset(input, 0, 2*strlen(line) + 3);
        for (int pos = 0; line[pos]; pos++) {
+               if (line[pos] == '#' && !escaped && !quote)
+                       break;
                if (!escaped && strchr(escapes, line[pos]))
                        escaped = 1;
                else if (!escaped && strchr(quotes, line[pos]) && !quote) {