2 * (c) Oleg Puchinin 2006,2007
3 * graycardinalster@gmail.com
14 int callTagsFile (char * fileName
)
16 char * functionName
= NULL
;
18 char * oldName
= NULL
;
20 bool b_inmacro
= false;
24 DArray
* d_words
= NULL
;
27 if (tt
->loadFile (fileName
) < 0) {
41 if ((ptr
[0] == '#') && def_test (ptr
)) {
42 if (macro_name (ptr
, m_name
))
43 functionName
= m_name
;
47 if (! tt
->bracketDepth
) {
48 if (tt
->ch
== '\n' && ptr
[strlen(ptr
) - 1] != '\\') {
50 functionName
= oldName
;
54 if (tt
->wit () == OT::Function
) {
55 functionName
= ww_last_word (tt
->op ());
56 oldName
= functionName
;
59 if (! tt
->bracketDepth
)
62 d_words
= split_to_words (ptr
);
63 for (i
= 0; i
< d_words
->get_size (); i
++) {
64 S
= cts ((c_word
*) d_words
->get (i
));
68 if (functionName
!= NULL
) {
69 printf ("%s\t%s\t%i\t;\tby\t%s\n", S
,
71 tt
->tt
->attachment
[ENV
->t_op_no
].pair_line
+1,
74 printf ("%s\t%s\t%i\n", S
,
76 tt
->tt
->attachment
[ENV
->t_op_no
].pair_line
+1);
80 d_words
->foreach ((Dfunc_t
) free_cword
);
89 int call_tags_multi (EArray
* d_files
)
98 d_files
->strings_to_file (ENV
->tmp_files
);
101 for (i
= 0; i
< ENV
->max_proc
; ++i
) {
102 j
= ENV
->proc_list
->fork ();
104 sprintf (m_buf
, "silent_bob -L %s%i --thread --call-tags", ENV
->tmp_files
, i
);
105 exit (execlp ("sh", "sh", "-c", m_buf
, NULL
));
110 while ((j
= ENV
->proc_list
->wait_all ()) && j
)
113 mk_tags ((char *) "./call_tags", NULL
);
118 /// Точка входа для --call-tags
119 int call_tags (EArray
* d_files
)
124 if (!d_files
|| d_files
->get_size () == 0) {
125 fprintf (stderr
, "No such files.\n");
129 if (! SB_FLGET (SB_FLTHREAD
))
130 unlink (ENV
->tmp_tags
);
132 if (ENV
->max_proc
> 1)
133 return call_tags_multi (d_files
);
135 fd
= open (ENV
->tmp_tags
, O_APPEND
| O_WRONLY
);
137 fd
= open (ENV
->tmp_tags
, O_CREAT
| O_APPEND
| O_WRONLY
, 0666);
143 for (i
= 0; i
< d_files
->get_size (); i
++)
144 callTagsFile (d_files
->get (i
));
148 if (! SB_FLGET (SB_FLTHREAD
)) {
149 mk_tags ((char *) "./call_tags", NULL
);