2 * (c) Oleg Puchinin 2006
3 * graycardinalster@gmail.com
12 EArray
* d_calltags_file
;
14 inline bool tree_immune (char * m_fname
)
16 return ENV
->immune_list
->sfind (m_fname
) == -1 ? false : true;
20 /* "SilentBob -u" functionality. */
21 void rctree_iter (char * f_name
, int n_trip
)
31 if (n_trip
> ENV
->d_depth
)
35 * 1. Find record in d_calltags_file.
36 * 2. Find _first_ record in d_calltags_file.
38 * 4. Check d_virused list.
39 * 5. If f_name not in ENV->full_list :
40 * 5.1 Add f_name to ENV->full_list.
45 snprintf (m_buf
, 255, "%s\t", f_name
);
48 i
= d_calltags_file
->snfind_fast (m_buf
);
49 d_virused
= new EArray (32);
55 S
= d_calltags_file
->get (i
);
58 } while (! strncmp (S
, m_buf
, len
));
62 S
= d_calltags_file
->get (i
);
63 if (! S
|| strncmp (S
, m_buf
, len
))
66 S
= strstr (S
, "\tby\t");
68 fprintf (ENV
->d_stream_dbg
, "\tBUG (no \"by\") : %s\n",
69 d_calltags_file
->get (i
));
76 if (d_virused
->sfind (S
) != -1)
79 d_virused
->add (strdup (S
));
80 for (a
= 0; a
< n_trip
; a
++)
83 tree_echo (n_trip
, S
);
85 if (ENV
->full_list
->sfind (S
) == -1) {
86 ENV
->full_list
->add (strdup (S
));
87 rctree_iter (S
, n_trip
);
92 d_virused
->foreach (free
);
96 void reverse_calltree (char * f_name
)
98 assert (f_name
== NULL
, "Lena 2");
102 tree_echo (0, f_name
);
103 d_calltags_file
= new EArray
;
104 d_calltags_file
->from_file ("./call_tags");
105 if (d_calltags_file
->get_size () == 0) {
109 rctree_iter (f_name
, 0);
111 d_calltags_file
->foreach (free
);
112 delete d_calltags_file
;
116 void tree_echo (int n_trip
, char *S
)
118 struct d_tag_t
* tag
;
121 if (! SB_FLGET (SB_FLFNAMES
))
124 tags
= got_tag_ctags (S
);
125 if (! tags
|| (tags
->get_size () == 0))
128 tag
= (struct d_tag_t
*) tags
->get (0);
132 printf ("// %i // %s\t%s", n_trip
, S
, tag
->d_file
);
133 if (tags
->get_size () > 1)
135 fputc ('\n', stdout
);
141 printf ("// %i // %s\n", n_trip
, S
);
144 inline void tree_mkpos (int N
)
147 fputc ('\t', stdout
);
150 /* SilentBob call-tree functionality. */
151 void call_tree (char * f_name
, int n_trip
)
153 struct tt_state_t
* d_tt_state
;
154 char * d_ptr
, *d_out
;
157 DArray
* d_vars
; // hash_t **
162 if (n_trip
> ENV
->d_depth
)
166 tree_echo (0, f_name
);
167 if (SB_FLGET (SB_FLLINEAR
) || SB_FLGET (SB_FLVERBOSE
))
168 nogui_tagsdump (f_name
, 0);
171 d_tt_state
= get_onett_tag (f_name
, &d_ptr
);
173 if (ENV
->full_list
->get_size () == 0)
174 bug_nosuch_tag (f_name
);
180 d_virused
= new EArray (256);
181 d_vars
= new DArray (32);
183 ch
= t_op (&d_ptr
, &d_out
);
190 ch
= t_op (&d_ptr
, &d_out
);
195 d_words
= split_to_words (d_out
);
196 assert (d_words
== NULL
, "Lena 28");
198 for (i
= 0; i
< d_words
->get_size (); i
++) {
199 S
= cts ((struct c_word
*) d_words
->get (i
));
204 if (d_virused
->sfind (S
) != -1)
207 if (! SB_FLGET (SB_FLLINEAR
))
210 d_virused
->add (strdup (S
));
211 tree_echo (n_trip
, S
);
213 if ((SB_FLGET (SB_FLVERBOSE
) || SB_FLGET (SB_FLLINEAR
))
214 && !tree_immune (S
)) {
215 nogui_tagsdump (S
, n_trip
);
218 if (ENV
->full_list
->sfind (S
) == -1) {
219 ENV
->full_list
->add (strdup (S
));
220 if (!tree_immune (S
))
221 call_tree (S
, n_trip
+1);
225 d_words
->foreach ((Dfunc_t
) free_cword
);
231 d_vars
->foreach (free
);