Line data Source code
1 : /* This file is part of GNU cflow
2 : Copyright (C) 1997, 2005, 2007, 2010 Sergey Poznyakoff
3 :
4 : GNU cflow is free software; you can redistribute it and/or modify
5 : it under the terms of the GNU General Public License as published by
6 : the Free Software Foundation; either version 3 of the License, or
7 : (at your option) any later version.
8 :
9 : GNU cflow is distributed in the hope that it will be useful,
10 : but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : GNU General Public License for more details.
13 :
14 : You should have received a copy of the GNU General Public
15 : License along with GNU cflow; if not, write to the Free Software
16 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 : MA 02110-1301 USA */
18 :
19 : #include <cflow.h>
20 : #include <ctype.h>
21 :
22 : static void
23 780 : print_symbol_type(FILE *outfile, Symbol *sym)
24 : {
25 780 : if (sym->decl)
26 318 : fprintf(outfile, "%s, <%s %d>",
27 : sym->decl,
28 : sym->source,
29 : sym->def_line);
30 : else
31 462 : fprintf(outfile, "<>");
32 780 : }
33 :
34 : static int
35 780 : print_symbol(FILE *outfile, int line, struct output_symbol *s)
36 : {
37 780 : print_level(s->level, s->last);
38 780 : fprintf(outfile, "%s: ", s->sym->name);
39 :
40 780 : if (brief_listing) {
41 780 : if (s->sym->expand_line) {
42 0 : fprintf(outfile, "%d", s->sym->expand_line);
43 0 : return 1;
44 780 : } else if (s->sym->callee)
45 174 : s->sym->expand_line = line;
46 : }
47 780 : print_symbol_type(outfile, s->sym);
48 780 : return 0;
49 : }
50 :
51 : int
52 1601 : posix_output_handler(cflow_output_command cmd,
53 : FILE *outfile, int line,
54 : void *data, void *handler_data)
55 : {
56 1601 : switch (cmd) {
57 : case cflow_output_init:
58 : /* Additional check for consistency */
59 14 : if (emacs_option)
60 0 : error(1, 0, _("--format=posix is not compatible with --emacs"));
61 14 : brief_listing = print_line_numbers = omit_symbol_names_option = 1;
62 14 : break;
63 : case cflow_output_begin:
64 : case cflow_output_end:
65 : case cflow_output_separator:
66 27 : break;
67 : case cflow_output_newline:
68 780 : fprintf(outfile, "\n");
69 780 : break;
70 : case cflow_output_text:
71 0 : fprintf(outfile, "%s", (char*) data);
72 0 : break;
73 : case cflow_output_symbol:
74 780 : return print_symbol(outfile, line, data);
75 : }
76 821 : return 0;
77 : }
|