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 :
21 : void
22 3163 : print_function_name(Symbol *sym, int has_subtree)
23 : {
24 3163 : fprintf(outfile, "%s", sym->name);
25 3163 : if (sym->arity >= 0)
26 3163 : fprintf(outfile, "()");
27 3163 : if (sym->decl)
28 1721 : fprintf(outfile, " <%s at %s:%d>",
29 : sym->decl,
30 : sym->source,
31 : sym->def_line);
32 3163 : if (sym->active) {
33 29 : fprintf(outfile, " (recursive: see %d)", sym->active-1);
34 3192 : return;
35 : }
36 3134 : if (sym->recursive)
37 56 : fprintf(outfile, " (R)");
38 3134 : if (!print_as_tree && has_subtree)
39 1517 : fprintf(outfile, ":");
40 : }
41 :
42 :
43 : static int
44 3163 : print_symbol(FILE *outfile, int line, struct output_symbol *s)
45 : {
46 6326 : int has_subtree = s->direct ?
47 3163 : s->sym->callee != NULL :
48 0 : s->sym->caller != NULL;
49 :
50 3163 : print_level(s->level, s->last);
51 3163 : print_function_name(s->sym, has_subtree);
52 :
53 3163 : if (brief_listing) {
54 70 : if (s->sym->expand_line) {
55 0 : fprintf(outfile, " [see %d]", s->sym->expand_line);
56 0 : return 1;
57 70 : } else if (s->sym->callee)
58 29 : s->sym->expand_line = line;
59 : }
60 3163 : return 0;
61 : }
62 :
63 : int
64 6349 : gnu_output_handler(cflow_output_command cmd,
65 : FILE *outfile, int line,
66 : void *data, void *handler_data)
67 : {
68 6349 : switch (cmd) {
69 : case cflow_output_begin:
70 5 : if (emacs_option) {
71 1 : fprintf(outfile, ";; This file is generated by %s. -*- cflow -*-",
72 : PACKAGE_STRING);
73 1 : newline();
74 : }
75 5 : break;
76 : case cflow_output_init:
77 : case cflow_output_end:
78 : case cflow_output_separator:
79 17 : break;
80 : case cflow_output_newline:
81 3164 : fprintf(outfile, "\n");
82 3164 : break;
83 : case cflow_output_text:
84 0 : fprintf(outfile, "%s", (char*) data);
85 0 : break;
86 : case cflow_output_symbol:
87 3163 : return print_symbol(outfile, line, data);
88 : }
89 3186 : return 0;
90 : }
|