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 printf ("%i %s\n", 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");
104 tree_echo (0, f_name);
106 printf ("%s\n", f_name);
108 d_calltags_file = new EArray;
109 d_calltags_file->from_file ("./call_tags");
110 if (d_calltags_file->get_size () == 0) {
114 rctree_iter (f_name, 0);
116 d_calltags_file->foreach (free);
117 delete d_calltags_file;
122 get_onett_tag (char * f_name, char ** d_tt_buf)
125 tt_state_t * Ret = NULL;
131 d_array.add (f_name);
132 Ret = CNEW (tt_state_t, 1);
134 unlink ("./silent_bob.tmp");
135 tags (&d_array, "./silent_bob.tmp");
137 if (access ("./silent_bob.tmp", R_OK) != 0)
140 Ret->d_file_name = "./silent_bob.tmp";
141 S = THE_TT::do_tt_file (Ret);
147 munmap (Ret->d_file_in, Ret->d_filein_size);
162 void tree_echo (int n_trip, char *S)
164 struct d_tag_t * tag;
168 if (! SB_FLSET (SB_FLFNAMES))
171 tags = got_tag_ctags (S);
172 if (! tags || (tags->get_size () == 0))
175 tag = (struct d_tag_t *) tags->get (0);
179 printf ("// %i // %s\t%s", n_trip, S, tag->d_file);
180 if (tags->get_size () > 1)
182 fputc ('\n', stdout);
188 printf ("// %i // %s\n", n_trip, S);
192 * SilentBob call-tree functionality.
195 * òÅËÕÒÓÉ×ÎÏ ÏÂÒÁÂÏÔÁÔØ ÆÕÎËÃÉÉ. ðÏÌÕÞÉÔØ ÆÕÎËÃÉÀ × ÆÁÊÌ ./silent_bob.tmp,
196 * ÐÒÏÐÕÓÔÉÔØ ÞÅÒÅÚ THE_TT, ÒÁÚÂÉÔØ ÎÁ ÏÐÅÒÁÔÏÒÙ. äÌÑ ËÁÖÄÏÇÏ ÏÐÅÒÁÔÏÒÁ
197 * ÓÌÏ×Ï + ÓËÏÂËÁ - ×ÙÚÏ×. éÓËÌÀÞÅÎÉÅ - ÏÂÙÞÎÅ óÉ ÏÐÅÒÁÔÏÒÙ.
201 void call_tree (char * f_name, int n_trip)
203 struct tt_state_t * d_tt_state;
204 struct c_word * d_word;
205 char * d_ptr, *d_out;
212 if (n_trip > d_depth)
216 tree_echo (0, f_name);
217 if (SB_FLGET (SB_FLLINEAR) || SB_FLGET (SB_FLVERBOSE))
218 nogui_tagsdump (f_name, 0);
221 d_virused = new EArray(256);
223 d_tt_state = get_onett_tag (f_name, &d_ptr);
225 if (full_list->get_size () == 0)
226 bug_nosuch_tag (f_name);
233 ch = t_op (&d_ptr, &d_out);
240 ch = t_op (&d_ptr, &d_out);
245 d_words = split_to_words (d_out);
246 assert (d_words == NULL, "Lena 28");
248 for (i = 0; i < d_words->get_size (); i++) {
249 d_word = (struct c_word *) d_words->get (i);
255 if (d_virused->sfind (S) != -1)
258 if (! SB_FLGET (SB_FLLINEAR)) {
259 for (a = 0; a < n_trip; a++)
260 fputc ('\t', stdout);
263 d_virused->add (strdup (S));
264 tree_echo (n_trip, S);
266 if ((SB_FLGET (SB_FLVERBOSE) || SB_FLGET (SB_FLLINEAR)) && !tree_immune (S)) {
267 nogui_tagsdump (S, n_trip);
270 if (full_list->sfind (S) == -1) {
271 full_list->add (strdup (S));
272 if (!tree_immune (S))
273 call_tree (S, n_trip+1);
279 d_words->foreach ((Dfunc_t) free_cword);