]> git.mdlowis.com Git - proto/labwc.git/commitdiff
find-banned: print filename with each unwanted token
authorJohan Malm <jgm323@gmail.com>
Mon, 3 Apr 2023 12:49:35 +0000 (13:49 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Thu, 6 Jul 2023 17:04:55 +0000 (18:04 +0100)
scripts/helper/find-idents.c

index b7b36a84d8dd49feec12fd5111d87b93d886d64f..655aba2825bef24f60a5f4efbe7f41d134fcdc96 100644 (file)
@@ -343,7 +343,7 @@ read_file(const char *filename)
 }
 
 static bool
-grep(struct token *tokens, const char *pattern)
+grep(struct token *tokens, const char *filename, const char *pattern)
 {
        bool found = false;
        unsigned int in_comment = 0;
@@ -362,7 +362,7 @@ grep(struct token *tokens, const char *pattern)
                if (t->kind == TOKEN_IDENTIFIER) {
                        if (!pattern || !strcmp(t->name.buf, pattern)) {
                                found = true;
-                               printf("%d:\t%s\n", t->line, t->name.buf);
+                               printf("%s:%d\t%s\n", filename, t->line, t->name.buf);
                        }
                }
        }
@@ -389,10 +389,10 @@ main(int argc, char **argv)
 
        if (argc == 2) {
                /* Dump all idents */
-               grep(tokens, NULL);
+               grep(tokens, argv[1], NULL);
        } else {
                for (int i = 2; i < argc; ++i) {
-                       found |= grep(tokens, argv[i]);
+                       found |= grep(tokens, argv[1], argv[i]);
                }
        }