#include "cmt_deps_builder.h"
#include "cmt_system.h"
#include "cmt_use.h"
#include "cmt_include.h"
#include "cmt_symbol.h"
Include dependency graph for cmt_deps_builder.cxx:
Go to the source code of this file.
|
? |
Definition at line 13 of file cmt_deps_builder.cxx. Referenced by at_start_action(), build_deps_stream(), in_char_action(), in_char_comment_action(), in_comment_action(), in_line_action(), in_line_comment_action(), in_string_action(), and in_string_comment_action(). 00014 { 00015 at_start, // beginning of the file 00016 in_line, // along a line 00017 in_string, // inside a quoted string 00018 in_char, // inside a quoted char 00019 in_comment, // inside a multi-line comment 00020 in_string_comment, // inside a quoted string in a comment 00021 in_char_comment, // inside a quoted char in a comment 00022 in_line_comment // inside a single-line comment 00023 }; |
|
? |
Definition at line 97 of file cmt_deps_builder.cxx. References header_file_action(), in_line, and state_def. Referenced by build_deps_stream(). 00105 { 00106 char term = 0; 00107 00108 if (*ptr == '#') 00109 { 00110 ptr++; 00111 while ((*ptr == ' ') || (*ptr == '\t')) ptr++; 00112 if (!strncmp (ptr, "include", 7)) 00113 { 00114 ptr += 7; 00115 00116 while (*ptr == ' ') ptr++; 00117 if (*ptr == '<') 00118 { 00119 term = '>'; 00120 ptr++; 00121 } 00122 else if (*ptr == '"') 00123 { 00124 term = '"'; 00125 ptr++; 00126 } 00127 else 00128 { 00129 state = in_line; 00130 ptr += strlen (ptr); 00131 return (ptr); 00132 } 00133 } 00134 else 00135 { 00136 state = in_line; 00137 ptr += strlen (ptr); 00138 return (ptr); 00139 } 00140 } 00141 else if (!strncmp (ptr, " include", 13)) 00142 { 00143 ptr += 13; 00144 00145 while ((*ptr == ' ') || (*ptr == '\t')) ptr++; 00146 if (*ptr == '\'') 00147 { 00148 term = '\''; 00149 ptr++; 00150 } 00151 else 00152 { 00153 state = in_line; 00154 return (ptr); 00155 } 00156 } 00157 else if (!strncmp (ptr, "\tinclude", 8)) 00158 { 00159 ptr += 8; 00160 00161 while ((*ptr == ' ') || (*ptr == '\t')) ptr++; 00162 if (*ptr == '\'') 00163 { 00164 term = '\''; 00165 ptr++; 00166 } 00167 else 00168 { 00169 state = in_line; 00170 return (ptr); 00171 } 00172 } 00173 else 00174 { 00175 state = in_line; 00176 return (ptr); 00177 } 00178 00179 char* end; 00180 00181 end = strchr (ptr, term); 00182 if (end != 0) 00183 { 00184 *end = 0; 00185 } 00186 00187 const char* header_file = ptr; 00188 00189 header_file_action (header_file, 00190 dir_name, 00191 current_path_index, 00192 include_paths, 00193 substitutions, 00194 all_deps, 00195 deps); 00196 00197 if (end != 0) 00198 { 00199 *end = term; 00200 } 00201 00202 state = in_line; 00203 ptr += strlen (ptr); 00204 00205 return (ptr); 00206 } |
|
? |
Definition at line 498 of file cmt_deps_builder.cxx. References build_deps_stream(), cmt_string::c_str(), CmtSystem::dirname(), CmtSystem::file_separator(), Cmt::get_debug(), cmt_vector< cmt_string >::size(), and CmtSystem::test_file(). Referenced by header_file_action(), and DepsBuilder::run(). 00505 { 00506 int result = -1; 00507 cmt_string new_dir; 00508 00509 if (Cmt::get_debug ()) 00510 { 00511 cout << "CMT> build_deps name=" << name << " dir_name=" << 00512 dir_name << endl; 00513 } 00514 00515 // 00516 // Return 0 when the file is found in the current directory 00517 // 00518 if (CmtSystem::test_file (name)) 00519 { 00520 ifstream input (name.c_str ()); 00521 if (input) 00522 { 00523 CmtSystem::dirname (name, new_dir); 00524 build_deps_stream (input, new_dir, current_path_index, 00525 include_paths, substitutions, 00526 all_deps, deps); 00527 return (0); 00528 } 00529 } 00530 00531 cmt_string full_name; 00532 00533 full_name = dir_name; 00534 full_name += CmtSystem::file_separator (); 00535 full_name += name; 00536 00537 // 00538 // Return 1 when the file is found in the directory of the 00539 // upper level source file 00540 // 00541 if (CmtSystem::test_file (full_name)) 00542 { 00543 ifstream input (full_name.c_str ()); 00544 if (input) 00545 { 00546 CmtSystem::dirname (full_name, new_dir); 00547 build_deps_stream (input, new_dir, current_path_index, 00548 include_paths, substitutions, 00549 all_deps, deps); 00550 return (1); 00551 } 00552 } 00553 00554 int path_index = -1; 00555 00556 // 00557 // Return [path_index + 2] when the include file is found at one of 00558 // the include_paths 00559 // 00560 for (path_index = 0; path_index < include_paths.size (); path_index++) 00561 { 00562 full_name = include_paths[path_index]; 00563 full_name += CmtSystem::file_separator (); 00564 full_name += name; 00565 00566 if (Cmt::get_debug ()) 00567 { 00568 cout << "CMT> build_deps2 full_name=" << full_name << endl; 00569 } 00570 00571 if (CmtSystem::test_file (full_name)) 00572 { 00573 ifstream in (full_name.c_str ()); 00574 if (in) 00575 { 00576 CmtSystem::dirname (full_name, new_dir); 00577 00578 if (Cmt::get_debug ()) 00579 { 00580 cout << "CMT> build_deps3 new_dir=" << new_dir << endl; 00581 } 00582 00583 build_deps_stream (in, 00584 new_dir, 00585 path_index + 2, 00586 include_paths, 00587 substitutions, 00588 all_deps, 00589 deps); 00590 00591 return (path_index + 2); 00592 } 00593 } 00594 } 00595 00596 if (Cmt::get_debug ()) 00597 { 00598 cout << "CMT> build_deps3" << endl; 00599 } 00600 00601 return (-1); 00602 } |
|
? |
Definition at line 426 of file cmt_deps_builder.cxx. References at_start, at_start_action(), Cmt::get_debug(), in_char, in_char_action(), in_char_comment, in_char_comment_action(), in_comment, in_comment_action(), in_line, in_line_action(), in_line_comment, in_string, in_string_action(), in_string_comment, in_string_comment_action(), and state_def. Referenced by build_deps(). 00433 { 00434 if (input) 00435 { 00436 if (Cmt::get_debug ()) 00437 { 00438 cout << "CMT> build_deps_stream dir_name=" << 00439 dir_name << endl; 00440 } 00441 00442 while (!input.eof ()) 00443 { 00444 char line[16384]; 00445 00446 input.getline (line, sizeof (line)); 00447 char* ptr = &line[0]; 00448 state_def state = at_start; 00449 00450 if (Cmt::get_debug ()) 00451 { 00452 cout << "CMT> build_deps_stream2 line=[" << 00453 line << "]" << endl; 00454 } 00455 00456 while (strlen (ptr) > 0) 00457 { 00458 switch (state) 00459 { 00460 case at_start: 00461 ptr = at_start_action (ptr, 00462 state, 00463 dir_name, 00464 current_path_index, 00465 include_paths, 00466 substitutions, 00467 all_deps, 00468 deps); 00469 break; 00470 case in_line: 00471 ptr = in_line_action (ptr, state); 00472 break; 00473 case in_string: 00474 ptr = in_string_action (ptr, state); 00475 break; 00476 case in_char: 00477 ptr = in_char_action (ptr, state); 00478 break; 00479 case in_comment: 00480 ptr = in_comment_action (ptr, state); 00481 break; 00482 case in_string_comment: 00483 ptr = in_string_comment_action (ptr, state); 00484 break; 00485 case in_char_comment: 00486 ptr = in_char_comment_action (ptr, state); 00487 break; 00488 case in_line_comment: 00489 ptr = in_line_action (ptr, state); 00490 break; 00491 } 00492 } 00493 } 00494 } 00495 } |
|
? |
Definition at line 36 of file cmt_deps_builder.cxx. References build_deps(), CmtSystem::file_separator(), cmt_vector< cmt_string >::push_back(), cmt_string::replace(), and cmt_vector< cmt_string >::size(). Referenced by at_start_action(). 00043 { 00044 bool found = false; 00045 00046 for (int i = 0; i < all_deps.size (); i++) 00047 { 00048 if (all_deps[i] == header_file) 00049 { 00050 found = true; 00051 break; 00052 } 00053 } 00054 00055 if (!found) 00056 { 00057 all_deps.push_back (header_file); 00058 00059 int path_index = build_deps (header_file, 00060 dir_name, 00061 current_path_index, 00062 include_paths, 00063 substitutions, 00064 all_deps, 00065 deps); 00066 00067 if (path_index >= 0) 00068 { 00069 cmt_string full_name; 00070 00071 if (path_index == 1) 00072 { 00073 full_name = dir_name; 00074 full_name += CmtSystem::file_separator (); 00075 00076 if (current_path_index >= 2) 00077 { 00078 full_name.replace (include_paths[current_path_index - 2], 00079 substitutions[current_path_index - 2]); 00080 } 00081 } 00082 else if (path_index > 1) 00083 { 00084 full_name = substitutions[path_index - 2]; 00085 full_name += CmtSystem::file_separator (); 00086 } 00087 00088 full_name += header_file; 00089 00090 deps.push_back (full_name); 00091 } 00092 } 00093 } |
|
? |
Definition at line 293 of file cmt_deps_builder.cxx. References in_line, and state_def. Referenced by build_deps_stream(). 00294 { 00295 char* pos = strchr (ptr, '\''); 00296 if (pos == 0) 00297 { 00298 // This string is not finished till the end of the line.. 00299 // we expect it continues to the nex line... 00300 ptr += strlen (ptr); 00301 } 00302 else 00303 { 00304 pos--; 00305 if (*pos == '\\') 00306 { 00307 ptr = pos + 2; 00308 } 00309 else 00310 { 00311 ptr = pos + 2; 00312 state = in_line; 00313 } 00314 } 00315 00316 return (ptr); 00317 } |
|
? |
Definition at line 391 of file cmt_deps_builder.cxx. References in_comment, and state_def. Referenced by build_deps_stream(). 00392 { 00393 char* pos = strchr (ptr, '\''); 00394 if (pos == 0) 00395 { 00396 // This string is not finished till the end of the line.. 00397 // we expect it continues to the nex line... 00398 ptr += strlen (ptr); 00399 } 00400 else 00401 { 00402 pos--; 00403 if (*pos == '\\') 00404 { 00405 ptr = pos + 2; 00406 } 00407 else 00408 { 00409 ptr = pos + 2; 00410 state = in_comment; 00411 } 00412 } 00413 00414 return (ptr); 00415 } |
|
? |
Definition at line 320 of file cmt_deps_builder.cxx. References in_char_comment, in_comment, in_line, in_string_comment, and state_def. Referenced by build_deps_stream(). 00321 { 00322 char* pattern = &ptr[strlen (ptr)]; 00323 char* pos = strchr (ptr, '"'); 00324 if (pos != 0) 00325 { 00326 if (pos < pattern) 00327 { 00328 state = in_string_comment; 00329 pattern = pos; 00330 } 00331 } 00332 pos = strchr (ptr, '\''); 00333 if (pos != 0) 00334 { 00335 if (pos < pattern) 00336 { 00337 state = in_char_comment; 00338 pattern = pos; 00339 } 00340 } 00341 pos = strstr (ptr, "*/"); 00342 if (pos != 0) 00343 { 00344 if (pos < pattern) 00345 { 00346 state = in_line; 00347 pattern = pos + 1; 00348 } 00349 } 00350 00351 if (state == in_comment) 00352 { 00353 ptr += strlen (ptr); 00354 } 00355 else 00356 { 00357 ptr = pattern + 1; 00358 } 00359 00360 return (ptr); 00361 } |
|
? |
Definition at line 209 of file cmt_deps_builder.cxx. References in_char, in_comment, in_line, in_line_comment, in_string, and state_def. Referenced by build_deps_stream(). 00210 { 00211 char* pattern = &ptr[strlen (ptr)]; 00212 00213 char* pos = strchr (ptr, '"'); 00214 if (pos != 0) 00215 { 00216 if (pos < pattern) 00217 { 00218 state = in_string; 00219 pattern = pos; 00220 } 00221 } 00222 00223 pos = strchr (ptr, '\''); 00224 if (pos != 0) 00225 { 00226 if (pos < pattern) 00227 { 00228 state = in_char; 00229 pattern = pos; 00230 } 00231 } 00232 00233 pos = strstr (ptr, "/*"); //*/ 00234 if (pos != 0) 00235 { 00236 if (pos < pattern) 00237 { 00238 state = in_comment; 00239 pattern = pos + 1; 00240 } 00241 } 00242 00243 pos = strstr (ptr, "//"); 00244 if (pos != 0) 00245 { 00246 if (pos < pattern) 00247 { 00248 state = in_line_comment; 00249 pattern = pos + 1; 00250 } 00251 } 00252 00253 if (state != in_line) 00254 { 00255 ptr = pattern + 1; 00256 } 00257 else 00258 { 00259 ptr += strlen (ptr); 00260 } 00261 00262 return (ptr); 00263 } |
|
? |
Definition at line 418 of file cmt_deps_builder.cxx. References state_def. 00419 {
00420 ptr += strlen (ptr);
00421
00422 return (ptr);
00423 }
|
|
? |
Definition at line 266 of file cmt_deps_builder.cxx. References in_line, and state_def. Referenced by build_deps_stream(). 00267 { 00268 char* pos = strchr (ptr, '"'); 00269 if (pos == 0) 00270 { 00271 // This string is not finished till the end of the line.. 00272 // we expect it continues to the nex line... 00273 ptr += strlen (ptr); 00274 } 00275 else 00276 { 00277 pos--; 00278 if (*pos == '\\') 00279 { 00280 ptr = pos + 2; 00281 } 00282 else 00283 { 00284 ptr = pos + 2; 00285 state = in_line; 00286 } 00287 } 00288 00289 return (ptr); 00290 } |
|
? |
Definition at line 364 of file cmt_deps_builder.cxx. References in_comment, and state_def. Referenced by build_deps_stream(). 00365 { 00366 char* pos = strchr (ptr, '"'); 00367 if (pos == 0) 00368 { 00369 // This string is not finished till the end of the line.. 00370 // we expect it continues to the nex line... 00371 ptr += strlen (ptr); 00372 } 00373 else 00374 { 00375 pos--; 00376 if (*pos == '\\') 00377 { 00378 ptr = pos + 2; 00379 } 00380 else 00381 { 00382 ptr = pos + 2; 00383 state = in_comment; 00384 } 00385 } 00386 00387 return (ptr); 00388 } |