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);
85 // printf ("%i %s\n", n_trip, S);
87 if (full_list->sfind (S) == -1) {
88 full_list->add (strdup (S));
89 rctree_iter (S, n_trip);
94 d_virused->foreach (free);
98 void reverse_calltree (char * f_name)
100 assert (f_name == NULL, "Lena 2");
104 tree_echo (0, f_name);
105 d_calltags_file = new EArray;
106 d_calltags_file->from_file ("./call_tags");
107 if (d_calltags_file->get_size () == 0) {
111 rctree_iter (f_name, 0);
113 d_calltags_file->foreach (free);
114 delete d_calltags_file;
118 void tree_echo (int n_trip, char *S)
120 struct d_tag_t * tag;
124 if (! SB_FLGET (SB_FLFNAMES))
127 tags = got_tag_ctags (S);
128 if (! tags || (tags->get_size () == 0))
131 tag = (struct d_tag_t *) tags->get (0);
135 printf ("// %i // %s\t%s", n_trip, S, tag->d_file);
136 if (tags->get_size () > 1)
138 fputc ('\n', stdout);
144 printf ("// %i // %s\n", n_trip, S);
148 * SilentBob call-tree functionality.
151 * òÅËÕÒÓÉ×ÎÏ ÏÂÒÁÂÏÔÁÔØ ÆÕÎËÃÉÉ. ðÏÌÕÞÉÔØ ÆÕÎËÃÉÀ × ÆÁÊÌ ./silent_bob.tmp,
152 * ÐÒÏÐÕÓÔÉÔØ ÞÅÒÅÚ THE_TT, ÒÁÚÂÉÔØ ÎÁ ÏÐÅÒÁÔÏÒÙ. äÌÑ ËÁÖÄÏÇÏ ÏÐÅÒÁÔÏÒÁ
153 * ÓÌÏ×Ï + ÓËÏÂËÁ - ×ÙÚÏ×. éÓËÌÀÞÅÎÉÅ - ÏÂÙÞÎÅ óÉ ÏÐÅÒÁÔÏÒÙ.
157 void call_tree (char * f_name, int n_trip)
159 struct tt_state_t * d_tt_state;
160 struct c_word * d_word;
161 char * d_ptr, *d_out;
168 if (n_trip > d_depth)
172 tree_echo (0, f_name);
173 if (SB_FLGET (SB_FLLINEAR) || SB_FLGET (SB_FLVERBOSE))
174 nogui_tagsdump (f_name, 0);
177 d_virused = new EArray(256);
179 d_tt_state = get_onett_tag (f_name, &d_ptr);
181 if (full_list->get_size () == 0)
182 bug_nosuch_tag (f_name);
189 ch = t_op (&d_ptr, &d_out);
196 ch = t_op (&d_ptr, &d_out);
201 d_words = split_to_words (d_out);
202 assert (d_words == NULL, "Lena 28");
204 for (i = 0; i < d_words->get_size (); i++) {
205 d_word = (struct c_word *) d_words->get (i);
211 if (d_virused->sfind (S) != -1)
214 if (! SB_FLGET (SB_FLLINEAR)) {
215 for (a = 0; a < n_trip; a++)
216 fputc ('\t', stdout);
219 d_virused->add (strdup (S));
220 tree_echo (n_trip, S);
222 if ((SB_FLGET (SB_FLVERBOSE) || SB_FLGET (SB_FLLINEAR)) && !tree_immune (S)) {
223 nogui_tagsdump (S, n_trip);
226 if (full_list->sfind (S) == -1) {
227 full_list->add (strdup (S));
228 if (!tree_immune (S))
229 call_tree (S, n_trip+1);
235 d_words->foreach ((Dfunc_t) free_cword);