2 * (c) Oleg Puchinin 2006
3 * graycardinalster@gmail.com
11 EArray
* d_calltags_file
;
14 * "SilentBob -u" functionality.
17 * òÅËÕÒÓÉ×ÎÏ ÉÓËÁÔØ ÚÁÐÉÓÉ × ÆÁÊÌÅ call_tags.
18 * æÕÎËÃÉÑ ×ÙÚÙ×ÁÅÔÓÑ ÔÅÍ, ÞÔÏ ÚÎÁÞÉÔÓÑ × ÚÁÐÉÓÉ ÐÏÓÌÅ "by".
22 void rctree_iter (char * f_name
, int n_trip
)
36 * 1. Find record in d_calltags_file.
37 * 2. Find _first_ record in d_calltags_file.
39 * 4. Check d_virused list.
40 * 5. If f_name not in full_list :
41 * 5.1 Add f_name to full_list.
46 snprintf (m_buf
, 255, "%s\t", f_name
);
49 i
= d_calltags_file
->snfind_fast (m_buf
);
50 d_virused
= new EArray (32);
56 S
= d_calltags_file
->get (i
);
59 } while (! strncmp (S
, m_buf
, len
));
63 S
= d_calltags_file
->get (i
);
64 if (! S
|| strncmp (S
, m_buf
, len
))
67 S
= strstr (S
, "\tby\t");
69 fprintf (d_stream_dbg
, "\tBUG (no \"by\") : %s\n",
70 d_calltags_file
->get (i
));
77 if (d_virused
->sfind (S
) != -1)
80 d_virused
->add (strdup (S
));
81 for (a
= 0; a
< n_trip
; a
++)
84 tree_echo (n_trip
, S
);
86 if (full_list
->sfind (S
) == -1) {
87 full_list
->add (strdup (S
));
88 rctree_iter (S
, n_trip
);
93 d_virused
->foreach (free
);
97 void reverse_calltree (char * f_name
)
99 assert (f_name
== NULL
, "Lena 2");
103 tree_echo (0, f_name
);
104 d_calltags_file
= new EArray
;
105 d_calltags_file
->from_file ("./call_tags");
106 if (d_calltags_file
->get_size () == 0) {
110 rctree_iter (f_name
, 0);
112 d_calltags_file
->foreach (free
);
113 delete d_calltags_file
;
117 void tree_echo (int n_trip
, char *S
)
119 struct d_tag_t
* tag
;
122 if (! SB_FLGET (SB_FLFNAMES
))
125 tags
= got_tag_ctags (S
);
126 if (! tags
|| (tags
->get_size () == 0))
129 tag
= (struct d_tag_t
*) tags
->get (0);
133 printf ("// %i // %s\t%s", n_trip
, S
, tag
->d_file
);
134 if (tags
->get_size () > 1)
136 fputc ('\n', stdout
);
142 printf ("// %i // %s\n", n_trip
, S
);
145 inline void tree_mkpos (int N
)
148 fputc ('\t', stdout
);
152 * SilentBob call-tree functionality.
155 * òÅËÕÒÓÉ×ÎÏ ÏÂÒÁÂÏÔÁÔØ ÆÕÎËÃÉÉ. ðÏÌÕÞÉÔØ ÆÕÎËÃÉÀ × ÆÁÊÌ ./silent_bob.tmp,
156 * ÐÒÏÐÕÓÔÉÔØ ÞÅÒÅÚ THE_TT, ÒÁÚÂÉÔØ ÎÁ ÏÐÅÒÁÔÏÒÙ. äÌÑ ËÁÖÄÏÇÏ ÏÐÅÒÁÔÏÒÁ
157 * ÓÌÏ×Ï + ÓËÏÂËÁ - ×ÙÚÏ×. éÓËÌÀÞÅÎÉÅ - ÏÂÙÞÎÙÅ óÉ ÏÐÅÒÁÔÏÒÙ.
161 void call_tree (char * f_name
, int n_trip
)
163 struct tt_state_t
* d_tt_state
;
164 char * d_ptr
, *d_out
;
167 DArray
* d_vars
; // hash_t **
173 if (n_trip
> d_depth
)
177 tree_echo (0, f_name
);
178 if (SB_FLGET (SB_FLLINEAR
) || SB_FLGET (SB_FLVERBOSE
))
179 nogui_tagsdump (f_name
, 0);
182 d_tt_state
= get_onett_tag (f_name
, &d_ptr
);
184 if (full_list
->get_size () == 0)
185 bug_nosuch_tag (f_name
);
191 d_virused
= new EArray (256);
192 d_vars
= new DArray (32);
194 ch
= t_op (&d_ptr
, &d_out
);
201 ch
= t_op (&d_ptr
, &d_out
);
206 d_words
= split_to_words (d_out
);
207 assert (d_words
== NULL
, "Lena 28");
209 for (i
= 0; i
< d_words
->get_size (); i
++) {
210 S
= cts ((struct c_word
*) d_words
->get (i
));
215 if (d_virused
->sfind (S
) != -1)
218 if (! SB_FLGET (SB_FLLINEAR
))
221 d_virused
->add (strdup (S
));
222 tree_echo (n_trip
, S
);
224 if ((SB_FLGET (SB_FLVERBOSE
) || SB_FLGET (SB_FLLINEAR
))
225 && !tree_immune (S
)) {
226 nogui_tagsdump (S
, n_trip
);
229 if (full_list
->sfind (S
) == -1) {
230 full_list
->add (strdup (S
));
231 if (!tree_immune (S
))
232 call_tree (S
, n_trip
+1);
236 d_words
->foreach ((Dfunc_t
) free_cword
);
242 d_vars
->foreach (free
);