aboutsummaryrefslogtreecommitdiff
path: root/src/gnu.c
blob: e27e006fdd19832064be9f90838dbf5b53813284 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* This file is part of GNU cflow
   Copyright (C) 1997, 2005, 2007, 2010, 2014-2015 Sergey Poznyakoff
 
   GNU cflow is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.
 
   GNU cflow is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */

#include <cflow.h>

void
print_function_name(Symbol *sym, int has_subtree)
{
     fprintf(outfile, "%s", sym->name);
     if (sym->arity >= 0)
	  fprintf(outfile, "()");
     if (sym->decl)
	  fprintf(outfile, " <%s at %s:%d>",
		  sym->decl,
		  sym->source,
		  sym->def_line);
     if (sym->active) {
	  fprintf(outfile, " (recursive: see %d)", sym->active-1);
	  return;
     }
     if (sym->recursive)
	  fprintf(outfile, " (R)");
     if (!print_as_tree && has_subtree)
	  fprintf(outfile, ":");
}


static int
print_symbol(FILE *outfile, int line, struct output_symbol *s)
{
     int has_subtree = s->direct ? 
 	                  s->sym->callee != NULL :
	                  s->sym->caller != NULL;
     
     print_level(s->level, s->last);
     print_function_name(s->sym, has_subtree);
	  
     if (brief_listing) {
	  if (s->sym->expand_line) {
	       fprintf(outfile, " [see %d]", s->sym->expand_line);
	       return 1;
	  } else if (s->sym->callee)
	       s->sym->expand_line = line;
     }
     return 0;
}

int
gnu_output_handler(cflow_output_command cmd,
		   FILE *outfile, int line,
		   void *data, void *handler_data)
{
     switch (cmd) {
     case cflow_output_begin:
	  if (emacs_option) {
	       fprintf(outfile, ";; This file is generated by %s. -*- cflow -*-",
		       PACKAGE_STRING);
	       newline();
	  }
	  break;
     case cflow_output_init:
     case cflow_output_end:
     case cflow_output_separator:
	  break;
     case cflow_output_newline:
	  fprintf(outfile, "\n");
	  break;
     case cflow_output_text:
	  fprintf(outfile, "%s", (char*) data);
	  break;
     case cflow_output_symbol:
	  return print_symbol(outfile, line, data);
     }
     return 0;
}

Return to:

Send suggestions and report system problems to the System administrator.