diff options
author | Robert Bragg <robert@linux.intel.com> | 2012-04-09 19:58:47 +0100 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2012-04-10 18:45:04 +0100 |
commit | c5b8027bf7444f2f56634259c78bd339076b3de5 (patch) | |
tree | 802749d4c802f8ccb2047c090dbe16a2611ac546 | |
parent | 20bddde7766f75df9e6ba1c5f1fec97adfacea0a (diff) | |
download | cogl-c5b8027bf7444f2f56634259c78bd339076b3de5.tar.gz |
sparse: Adds tool to dump gtk-doc comments
This adds a minimal tool that performs preprocessing on input files and
then dump all comments that start with "/**\n" with NULL separators to
stdout for easy processing by some other tool.
-rw-r--r-- | deps/sparse/dump-gtk-doc.c | 45 | ||||
-rw-r--r-- | deps/sparse/lib.c | 17 | ||||
-rw-r--r-- | deps/sparse/lib.h | 1 |
3 files changed, 62 insertions, 1 deletions
diff --git a/deps/sparse/dump-gtk-doc.c b/deps/sparse/dump-gtk-doc.c new file mode 100644 index 00000000..99e38ac1 --- /dev/null +++ b/deps/sparse/dump-gtk-doc.c @@ -0,0 +1,45 @@ +/* + * Example test program that just uses the tokenization and + * preprocessing phases, and prints out the results. + * + * Copyright (C) 2003 Transmeta Corp. + * 2003 Linus Torvalds + * + * Licensed under the Open Software License version 1.1 + */ +#include <stdarg.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <ctype.h> +#include <unistd.h> +#include <fcntl.h> + +#include "lib.h" +#include "token.h" +#include "allocate.h" + +int main(int argc, char **argv) +{ + struct string_list *filelist = NULL; + char *file; + + keep_comment_tokens = 1; + sparse_initialize(argc, argv, &filelist); + FOR_EACH_PTR_NOTAG(filelist, file) { + struct token *token = tokenize_keep_tokens(file); + for (token = preprocess(token); + !eof_token(token); + token = token->next) + { + if (token_type(token) == TOKEN_COMMENT) { + const char *comment = token->comment->data; + if (strncmp (comment, "/**\n", 4) == 0) + printf("%s\n%c", token->comment->data, '\0'); + + } + } + clear_token_alloc(); + } END_FOR_EACH_PTR_NOTAG(file); + return 0; +} diff --git a/deps/sparse/lib.c b/deps/sparse/lib.c index fdf1a3c5..5acdeab9 100644 --- a/deps/sparse/lib.c +++ b/deps/sparse/lib.c @@ -862,7 +862,7 @@ static struct symbol_list *sparse_tokenstream(struct token *token) return translation_unit_used_list; } -static struct symbol_list *sparse_file(const char *filename) +static struct token *tokenize_file(const char *filename) { int fd; struct token *token; @@ -879,6 +879,13 @@ static struct symbol_list *sparse_file(const char *filename) token = tokenize(filename, fd, NULL, includepath); close(fd); + return token; +} + +static struct symbol_list *sparse_file(const char *filename) +{ + struct token *token; + token = tokenize_file(filename); return sparse_tokenstream(token); } @@ -967,6 +974,14 @@ struct symbol_list * sparse_keep_tokens(char *filename) return res; } +struct token * tokenize_keep_tokens(char *filename) +{ + /* Clear previous symbol list */ + translation_unit_used_list = NULL; + + new_file_scope(); + return tokenize_file(filename); +} struct symbol_list * __sparse(char *filename) { diff --git a/deps/sparse/lib.h b/deps/sparse/lib.h index 1e48574c..fb5863ad 100644 --- a/deps/sparse/lib.h +++ b/deps/sparse/lib.h @@ -127,6 +127,7 @@ extern struct symbol_list *sparse_initialize(int argc, char **argv, struct strin extern struct symbol_list *__sparse(char *filename); extern struct symbol_list *sparse_keep_tokens(char *filename); extern struct symbol_list *sparse(char *filename); +struct token * tokenize_keep_tokens(char *filename); static inline int symbol_list_size(struct symbol_list *list) { |