#include <cmt_system.h>
Public Types | |
typedef cmt_vector< cmt_string > | cmt_string_vector |
Static Public Member Functions | |
cmt_string | pwd () |
bool | cd (const cmt_string &dir) |
void | basename (const cmt_string &file_name, cmt_string &result) |
void | basename (const cmt_string &file_name, const cmt_string &suffix, cmt_string &result) |
void | dirname (const cmt_string &file_name, cmt_string &result) |
void | name (const cmt_string &file, cmt_string &result) |
void | get_suffix (const cmt_string &file, cmt_string &result) |
void | get_dot_suffix (const cmt_string &file, cmt_string &result) |
bool | has_prefix (const cmt_string &name) |
bool | absolute_path (const cmt_string &name) |
bool | has_device (const cmt_string &name) |
cmt_string | current_branch () |
bool | test_directory (const cmt_string &name) |
Implementation of the "test -d" equivalent. | |
bool | test_file (const cmt_string &name) |
Implementation of the "test -f" equivalent. | |
bool | compare_files (const cmt_string &name1, const cmt_string &name2) |
Check if the file "name1" is identical to "name2". | |
bool | compare_and_update_files (const cmt_string &name1, const cmt_string &name2) |
Check if the file "name1" is identical to "name2" if they are identical, "name1" will be simply deleted otherwise "name1" will be copied to "name2" and deleted afterwards. | |
int | file_size (const cmt_string &name) |
char | file_separator () |
void | reduce_file_separators (cmt_string &text) |
Transform all / or \ characters in the text into the current file_separator Reduce all multiple file_separator into single ones. | |
char | path_separator () |
char | command_separator () |
const cmt_string & | ev_open () |
const cmt_string & | ev_close () |
bool | create_symlink (const cmt_string &oldname, const cmt_string &newname) |
bool | remove_file (const cmt_string &name) |
bool | remove_directory (const cmt_string &name) |
bool | mkdir (const cmt_string &name) |
void | scan_dir (const cmt_string &dir_name, cmt_string_vector &list) |
void | scan_dir (const cmt_string &dir_name, const cmt_regexp &expression, cmt_string_vector &list) |
cmt_string_vector & | scan_dir (const cmt_string &dir_name) |
const cmt_string & | get_cmt_root () |
void | get_cmt_version (cmt_string &version) |
cmt_string | get_cmt_config () |
cmt_string | get_cmt_site () |
void | get_uname (cmt_string &uname) |
void | get_hosttype (cmt_string &hosttype) |
cmt_string | get_temporary_name () |
cmt_string | get_home_package () |
bool | is_home_package (const cmt_string &name, const cmt_string &version) |
cmt_string | get_user_context_package () |
bool | is_user_context_package (const cmt_string &name, const cmt_string &version) |
cmt_string | get_project_package () |
bool | is_project_package (const cmt_string &name, const cmt_string &version) |
bool | testenv (const cmt_string &name) |
cmt_string | getenv (const cmt_string &name) |
bool | putenv (const cmt_string &name_value) |
void | get_cmt_paths (IProjectFactory &factory, const cmt_string &init_text, const cmt_string &cmt_user_context, const cmt_string &cmt_home) |
int | execute (const cmt_string &command) |
int | execute (const cmt_string &command, cmt_string &output) |
bool | is_package_directory (const cmt_string &name) |
bool | is_version_directory (const cmt_string &name) |
bool | is_version_directory (const cmt_string &name, int &v, int &r, int &p) |
void | split (const cmt_string &text, const cmt_string &separators, cmt_string_vector &strings) |
void | compress_path (const cmt_string &dir, cmt_string &new_dir) |
void | compress_path (cmt_string &dir) |
cmt_string | now () |
cmt_string | user () |
void | get_cvsroot (cmt_string &cvsroot) |
bool | get_home_directory (cmt_string &dir) |
|
|
Definition at line 253 of file cmt_system.cxx. References cmt_string::size(). Referenced by Symbol::action(), DependencyGenerator::build(), Use::build_library_links(), Use::change_path(), CMTPathManager::do_add_cmt_path(), Cmt::do_create(), Cmt::do_remove(), Cmt::do_remove_library_links(), dos_script_prefix(), mkdir(), Use::move_to(), Use::reach_package(), constituents_action_iterator::set(), CmtGenerator::set_full_name(), and Use::show_all().
|
|
Definition at line 142 of file cmt_system.cxx. References basename(), cmt_string::erase(), and cmt_string::find_last_of().
00145 { 00146 basename (file_name, result); 00147 00148 int pos; 00149 00150 pos = result.find_last_of ('.'); 00151 00152 if (pos != cmt_string::npos) 00153 { 00154 result.erase (pos); 00155 } 00156 } |
|
|
|
Definition at line 542 of file cmt_system.cxx. Referenced by SequenceRunner::filter(), and CvsImplementation::really_checkout_package_contents().
00543 { 00544 #ifdef WIN32 00545 return ('&'); 00546 #else 00547 return (';'); 00548 #endif 00549 } |
|
Check if the file "name1" is identical to "name2" if they are identical, "name1" will be simply deleted otherwise "name1" will be copied to "name2" and deleted afterwards.
Definition at line 411 of file cmt_system.cxx. References cmt_string::c_str(), and cmt_string::read(). Referenced by Cmt::do_check_files(), Cmt::install_cleanup_scripts(), Cmt::install_setup_scripts(), Cmt::install_test_cleanup_scripts(), and Cmt::install_test_setup_scripts().
00413 { 00414 struct stat file_stat1; 00415 struct stat file_stat2; 00416 static cmt_string s1; 00417 static cmt_string s2; 00418 int status; 00419 00420 status = stat (name1.c_str (), &file_stat1); 00421 00422 if (status == 0) 00423 { 00424 if ((file_stat1.st_mode & S_IFDIR) != 0) 00425 { 00426 // name1 is a directory. 00427 return (false); 00428 } 00429 } 00430 else 00431 { 00432 // name1 does not exist 00433 return (false); 00434 } 00435 00436 s1.read (name1); 00437 00438 status = stat (name2.c_str (), &file_stat2); 00439 00440 if (status == 0) 00441 { 00442 if ((file_stat2.st_mode & S_IFDIR) != 0) 00443 { 00444 // name2 is a directory 00445 return (false); 00446 } 00447 00448 if (((int) file_stat1.st_size) == ((int) file_stat2.st_size)) 00449 { 00450 s2.read (name2); 00451 if (s1 == s2) 00452 { 00453 unlink (name1); 00454 return (true); 00455 } 00456 } 00457 } 00458 00459 FILE* f = fopen (name2, "wb"); 00460 if (f != NULL) 00461 { 00462 s1.write (f); 00463 fclose (f); 00464 00465 unlink (name1); 00466 00467 return (true); 00468 } 00469 else 00470 { 00471 // 00472 // keep the new file "name1" since it cannot be 00473 // copied to "name2" 00474 // 00475 return (false); 00476 } 00477 } |
|
Check if the file "name1" is identical to "name2".
Definition at line 355 of file cmt_system.cxx. References cmt_string::c_str(), and cmt_string::read(). Referenced by CmtGenerator::check().
00357 { 00358 struct stat file_stat1; 00359 struct stat file_stat2; 00360 int status; 00361 00362 status = stat (name1.c_str (), &file_stat1); 00363 00364 if (status == 0) 00365 { 00366 if ((file_stat1.st_mode & S_IFDIR) != 0) 00367 { 00368 return (false); 00369 } 00370 } 00371 else 00372 { 00373 return (false); 00374 } 00375 00376 status = stat (name2.c_str (), &file_stat2); 00377 00378 if (status == 0) 00379 { 00380 if ((file_stat2.st_mode & S_IFDIR) != 0) 00381 { 00382 return (false); 00383 } 00384 } 00385 else 00386 { 00387 return (false); 00388 } 00389 00390 if (((int) file_stat1.st_size) != ((int) file_stat2.st_size)) 00391 { 00392 return (false); 00393 } 00394 00395 static cmt_string s1; 00396 static cmt_string s2; 00397 00398 s1.read (name1); 00399 s2.read (name2); 00400 00401 return ((s1 == s2)); 00402 } |
|
Definition at line 2041 of file cmt_system.cxx. References basename(), cmt_string::erase(), file_separator(), cmt_string::find(), cmt_string::find_last_of(), cmt_string::replace_all(), cmt_string::size(), and cmt_string::substr().
02042 { 02043 #ifdef WIN32 02044 static const char pattern[] = "\\.."; 02045 static const char fs[] = "\\\\"; 02046 #else 02047 static const char pattern[] = "/.."; 02048 static const char fs[] = "//"; 02049 #endif 02050 02051 if (dir.size () == 0) return; 02052 02053 // 02054 // We first synchronize to using file_separator() in any case. 02055 // 02056 02057 if (file_separator () == '/') 02058 { 02059 dir.replace_all ("\\", file_separator ()); 02060 } 02061 else 02062 { 02063 dir.replace_all ("/", file_separator ()); 02064 } 02065 02066 // Suppress all duplicated file separators 02067 dir.replace_all (fs, file_separator ()); 02068 02069 for (;;) 02070 { 02071 int pos1; 02072 int pos2; 02073 int pos3; 02074 02075 pos1 = dir.find (pattern); 02076 if (pos1 == cmt_string::npos) break; 02077 02078 // 02079 // extract "aaaa/xxxx" from "aaaa/xxxx/../bbbb" 02080 // 02081 cmt_string p = dir.substr (0, pos1); 02082 02083 cmt_string dn; 02084 basename (p, dn); 02085 if (dn == "..") break; 02086 if (dn == ".") break; 02087 if (dn == "") break; 02088 02089 // 02090 // Is "aaaa/xxxx" only made of "xxxx" ? 02091 // 02092 pos2 = p.find_last_of (file_separator ()); 02093 02094 if (pos2 == cmt_string::npos) 02095 { 02096 // the pattern was xxxx/.. 02097 // 02098 // so xxxx is [0:pos1-1] 02099 // 02100 pos3 = p.find ("$"); 02101 if (pos3 == cmt_string::npos) 02102 { 02103 dir.erase (0, pos1 + 3); 02104 } 02105 else 02106 { 02107 break; 02108 } 02109 } 02110 else 02111 { 02112 // 01234567890123456 02113 // aaaa/xxxx/../bbbb 02114 // 2 1 3 02115 // 02116 // erase the "/xxxx/.." pattern 02117 // result will be "aaaa/bbbb" 02118 // 02119 // Here xxxx is [pos2+1:pos1-1] 02120 // 02121 02122 pos3 = p.find (pos2, "$"); 02123 if (pos3 == cmt_string::npos) 02124 { 02125 dir.erase (pos2, pos1 + 3 - pos2); 02126 } 02127 else 02128 { 02129 break; 02130 } 02131 } 02132 } 02133 02134 //if (dir[dir.size () - 1] == file_separator ()) dir.erase (dir.size () - 1); 02135 } |
|
Definition at line 2024 of file cmt_system.cxx. Referenced by DependencyGenerator::build(), DocumentGenerator::build(), LibraryGenerator::build(), Use::change_path(), ProjectFactory::create_project(), CMTPathManager::do_add_cmt_path(), Cmt::do_create(), Cmt::do_remove(), Cmt::filter_dir(), CmtGenerator::filter_path(), Project::find_by_cmtpath(), find_path_entry(), Use::get_cmtpath_and_offset(), and PathScanner::scan_path().
02025 { 02026 new_dir = dir; 02027 02028 compress_path (new_dir); 02029 } |
|
Definition at line 576 of file cmt_system.cxx. References cmt_string::c_str(). Referenced by install_library().
|
|
Definition at line 293 of file cmt_system.cxx. References basename(), and pwd(). Referenced by DependencyGenerator::build(), VSNETGenerator::reset(), MSDEVGenerator::reset(), and CmtGenerator::reset().
00294 { 00295 cmt_string result; 00296 00297 basename (pwd (), result); 00298 00299 return (result); 00300 } |
|
|
Definition at line 564 of file cmt_system.cxx. Referenced by resolve_value_for_macros().
00565 { 00566 #ifdef WIN32 00567 static const cmt_string s = "%"; 00568 #else 00569 static const cmt_string s = "}"; 00570 #endif 00571 00572 return (s); 00573 } |
|
Definition at line 552 of file cmt_system.cxx. Referenced by resolve_value_for_macros().
00553 { 00554 #ifdef WIN32 00555 static const cmt_string s = "%"; 00556 #else 00557 static const cmt_string s = "${"; 00558 #endif 00559 00560 return (s); 00561 } |
|
Definition at line 1525 of file cmt_system.cxx. References cmt_string::c_str().
01526 { 01527 output = ""; 01528 01529 //cout << "CmtSystem::execute2> [" << command << "]" << endl; 01530 01531 FILE* f = popen (command.c_str (), "r"); 01532 01533 if (f != 0) 01534 { 01535 char line[256]; 01536 char* ptr; 01537 01538 while ((ptr = fgets (line, sizeof (line), f)) != NULL) 01539 { 01540 output += ptr; 01541 } 01542 pclose (f); 01543 01544 return (0); 01545 } 01546 01547 return (1); 01548 } |
|
Definition at line 1517 of file cmt_system.cxx. References cmt_string::c_str(). Referenced by DependencyAnalyzer::DependencyAnalyzer(), Cmt::do_broadcast(), Cmt::do_do(), Cmt::do_remove_library_links(), Cmt::do_run(), CvsImplementation::execute(), SequenceRunner::filter(), install_library(), CmtLock::lock(), resolve_value(), resolve_value_for_macros(), DepsBuilder::run(), suppress_OS_delimiters(), and CmtLock::unlock().
01518 { 01519 //cout << "CmtSystem::execute1> [" << command << "]" << endl; 01520 01521 return (system (command.c_str ())); 01522 } |
|
|
Definition at line 480 of file cmt_system.cxx. References cmt_string::c_str().
00481 { 00482 struct stat file_stat; 00483 int status; 00484 00485 status = stat (name.c_str (), &file_stat); 00486 00487 if (status == 0) 00488 { 00489 return ((int) file_stat.st_size); 00490 } 00491 else 00492 { 00493 return (0); 00494 } 00495 } |
|
Definition at line 1001 of file cmt_system.cxx. Referenced by Cmt::configure_config_tag(), Cmt::do_show_system(), getenv(), ArgParser::option_tag(), ArgParser::option_tag_add(), ArgParser::option_tag_remove(), and Cmt::print_context().
01002 { 01003 const char* env = ::getenv ("CMTCONFIG"); 01004 if (env != 0) 01005 { 01006 return (cmt_string (env)); 01007 } 01008 01009 env = ::getenv ("CMTBIN"); 01010 if (env != 0) 01011 { 01012 return (cmt_string (env)); 01013 } 01014 01015 #ifdef WIN32 01016 LONG status; 01017 HKEY key = 0; 01018 01019 status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\CMT", 01020 0, KEY_READ, &key); 01021 if (status == ERROR_SUCCESS) 01022 { 01023 char temp[256]; 01024 DWORD length = sizeof (temp) - 1; 01025 DWORD type; 01026 01027 status = RegQueryValueEx (key, "config", 0, &type, 01028 (LPBYTE) temp, &length); 01029 if (status == ERROR_SUCCESS) 01030 { 01031 cmt_string config (temp); 01032 return (config); 01033 } 01034 } 01035 01036 return ("VisualC"); 01037 #endif 01038 01039 return (""); 01040 01041 } |
|
Definition at line 1400 of file cmt_system.cxx. References CMTPathManager::add_cmt_path(), add_cmt_paths_from_file(), add_cmt_paths_from_text(), file_separator(), get_cmt_root(), get_cmt_version(), get_home_directory(), and CMTPathManager::reset(). Referenced by Cmt::configure_cmt_path().
01404 { 01405 CMTPathManager::reset (); 01406 01407 if (init_text != "") 01408 { 01409 add_cmt_paths_from_text (init_text, "initialization", factory); 01410 } 01411 01412 #ifdef WIN32 01413 LONG status; 01414 HKEY key = 0; 01415 01416 status = RegOpenKeyEx (HKEY_CURRENT_USER, "Software\\CMT\\path", 01417 0, KEY_READ, &key); 01418 if (status == ERROR_SUCCESS) 01419 { 01420 DWORD index = 0; 01421 char name[256]; 01422 char temp[256]; 01423 01424 for (;;) 01425 { 01426 DWORD name_length = sizeof (name) - 1; 01427 DWORD length = sizeof (temp) - 1; 01428 DWORD type; 01429 status = RegEnumValue (key, index, 01430 name, &name_length, 0, &type, 01431 (LPBYTE) temp, &length); 01432 if ((status == ERROR_SUCCESS) || 01433 (status == 234)) 01434 { 01435 const cmt_string path = temp; 01436 CMTPathManager::add_cmt_path (path, "HKEY_CURRENT_USER", factory); 01437 } 01438 01439 if (status == 259) 01440 { 01441 break; 01442 } 01443 01444 index++; 01445 } 01446 } 01447 01448 status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\CMT\\path", 01449 0, KEY_READ, &key); 01450 if (status == ERROR_SUCCESS) 01451 { 01452 DWORD index = 0; 01453 char name[256]; 01454 char temp[256]; 01455 01456 for (;;) 01457 { 01458 DWORD type; 01459 DWORD name_length = sizeof (name) - 1; 01460 DWORD length = sizeof (temp) - 1; 01461 01462 01463 status = RegEnumValue (key, index, 01464 name, &name_length, 0, &type, 01465 (LPBYTE) temp, &length); 01466 if (status != ERROR_NO_MORE_ITEMS) 01467 { 01468 const cmt_string path = temp; 01469 CMTPathManager::add_cmt_path (path, "HKEY_LOCAL_MACHINE", factory); 01470 } 01471 else 01472 { 01473 break; 01474 } 01475 index++; 01476 } 01477 } 01478 01479 #endif 01480 01481 //----------------------------------------- 01482 // look for .cmtrc files : 01483 // first look in ./ 01484 // then in "~/" 01485 // then in ${CMTROOT}/mgr 01486 //----------------------------------------- 01487 cmt_string rc_name; 01488 01489 add_cmt_paths_from_file (".cmtrc", factory); 01490 01491 if (get_home_directory (rc_name)) 01492 { 01493 rc_name += file_separator (); 01494 rc_name += ".cmtrc"; 01495 add_cmt_paths_from_file (rc_name, factory); 01496 } 01497 01498 rc_name = get_cmt_root (); 01499 rc_name += file_separator (); 01500 rc_name += "CMT"; 01501 rc_name += file_separator (); 01502 cmt_string version; 01503 get_cmt_version (version); 01504 rc_name += version; 01505 rc_name += file_separator (); 01506 rc_name += "mgr"; 01507 rc_name += file_separator (); 01508 rc_name += ".cmtrc"; 01509 01510 add_cmt_paths_from_file (rc_name, factory); 01511 01512 CMTPathManager::add_cmt_path (cmt_user_context, "CMTUSERCONTEXT", factory); 01513 CMTPathManager::add_cmt_path (cmt_home, "CMTHOME", factory); 01514 } |
|
Definition at line 922 of file cmt_system.cxx. References dirname(), and cmt_string::replace_all(). Referenced by Cmt::configure_default_path(), and get_cmt_paths().
00923 { 00924 static cmt_string root; 00925 00926 root = ""; 00927 00928 const char* env = ::getenv ("CMTROOT"); 00929 if (env != 0) 00930 { 00931 root = env; 00932 00933 dirname (root, root); 00934 dirname (root, root); 00935 root.replace_all ("\"", ""); 00936 return (root); 00937 } 00938 00939 #ifdef WIN32 00940 LONG status; 00941 HKEY key = 0; 00942 00943 status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\CMT", 00944 0, KEY_READ, &key); 00945 if (status == ERROR_SUCCESS) 00946 { 00947 char temp[256]; 00948 DWORD length = sizeof (temp) - 1; 00949 DWORD type; 00950 00951 status = RegQueryValueEx (key, "root", 0, &type, (LPBYTE) temp, &length); 00952 if (status == ERROR_SUCCESS) 00953 { 00954 root = temp; 00955 return (root); 00956 } 00957 } 00958 #endif 00959 00960 return (root); 00961 } |
|
Definition at line 1044 of file cmt_system.cxx. Referenced by Cmt::configure_site_tag().
01045 { 01046 const char* env = ::getenv ("CMTSITE"); 01047 if (env != 0) 01048 { 01049 return (cmt_string (env)); 01050 } 01051 01052 #ifdef WIN32 01053 LONG status; 01054 HKEY key = 0; 01055 01056 status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\CMT", 01057 0, KEY_READ, &key); 01058 if (status == ERROR_SUCCESS) 01059 { 01060 char temp[256]; 01061 DWORD length = sizeof (temp) - 1; 01062 DWORD type; 01063 01064 status = RegQueryValueEx (key, "site", 0, &type, (LPBYTE) temp, &length); 01065 if (status == ERROR_SUCCESS) 01066 { 01067 cmt_string site (temp); 01068 return (site); 01069 } 01070 } 01071 #endif 01072 01073 return (""); 01074 } |
|
Definition at line 964 of file cmt_system.cxx. References basename(), and cmt_string::replace_all(). Referenced by Cmt::configure_default_path(), and get_cmt_paths().
00965 { 00966 version = ""; 00967 00968 const char* env = ::getenv ("CMTROOT"); 00969 if (env != 0) 00970 { 00971 cmt_string s = env; 00972 basename (s, version); 00973 version.replace_all ("\"", ""); 00974 } 00975 else 00976 { 00977 #ifdef WIN32 00978 LONG status; 00979 HKEY key = 0; 00980 00981 status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\CMT", 00982 0, KEY_READ, &key); 00983 if (status == ERROR_SUCCESS) 00984 { 00985 char temp[256]; 00986 DWORD length = sizeof (temp) - 1; 00987 DWORD type; 00988 00989 status = RegQueryValueEx (key, "version", 0, &type, 00990 (LPBYTE) temp, &length); 00991 if (status == ERROR_SUCCESS) 00992 { 00993 version = temp; 00994 } 00995 } 00996 #endif 00997 } 00998 } |
|
Definition at line 2164 of file cmt_system.cxx. Referenced by CvsImplementation::check_protocol(), CvsImplementation::make_management_files(), and CvsImplementation::retreive_cvs_infos().
02165 { 02166 cvsroot = ""; 02167 02168 const char* env = ::getenv ("CVSROOT"); 02169 if (env != 0) 02170 { 02171 cvsroot = env; 02172 return; 02173 } 02174 02175 #ifdef WIN32 02176 LONG status; 02177 HKEY key = 0; 02178 02179 status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\CMT", 02180 0, KEY_READ, &key); 02181 if (status == ERROR_SUCCESS) 02182 { 02183 char temp[256]; 02184 DWORD length = sizeof (temp) - 1; 02185 DWORD type; 02186 02187 status = RegQueryValueEx (key, "CVSROOT", 0, &type, 02188 (LPBYTE) temp, &length); 02189 if (status == ERROR_SUCCESS) 02190 { 02191 cvsroot = temp; 02192 return; 02193 } 02194 } 02195 #endif 02196 } |
|
Definition at line 225 of file cmt_system.cxx. References file_separator(), cmt_string::find_last_of(), and cmt_string::substr(). Referenced by DependencyFilter::add_source(), Prototyper::begin(), DependencyGenerator::build(), DocumentGenerator::build(), Generator::build_windefs(), CmtGenerator::get_all_files(), DependencyFilter::has_source(), LibraryGenerator::java_file_action(), LibraryGenerator::module_file_action(), and LibraryGenerator::proto_file_action().
00226 { 00227 int pos = file.find_last_of ('.'); 00228 int sep = file.find_last_of (file_separator ()); 00229 00230 if ((pos == cmt_string::npos) || (pos < sep)) 00231 { 00232 result = ""; 00233 } 00234 else 00235 { 00236 file.substr (pos, result); 00237 } 00238 } |
|
Definition at line 2199 of file cmt_system.cxx. Referenced by Cmt::configure_current_dir(), and get_cmt_paths().
02200 { 02201 bool status = false; 02202 02203 #ifdef WIN32 02204 const char* homedrive = ::getenv ("HOMEDRIVE"); 02205 const char* homepath = ::getenv ("HOMEPATH"); 02206 02207 if ((homedrive != 0) && (homepath != 0)) 02208 { 02209 dir = homedrive; 02210 dir += homepath; 02211 status = true; 02212 } 02213 02214 #else 02215 const char* home_env = ::getenv ("HOME"); 02216 if (home_env != 0) 02217 { 02218 dir = home_env; 02219 status = true; 02220 } 02221 #endif 02222 02223 return (status); 02224 } |
|
Definition at line 1134 of file cmt_system.cxx. Referenced by Use::add(), Use::get_cmtpath_and_offset(), Use::reach_package(), and Use::show_all().
01135 { 01136 cmt_string name = "CMTHOME"; 01137 01138 return (name); 01139 } |
|
Definition at line 1110 of file cmt_system.cxx. Referenced by Cmt::configure_hosttype_tag().
01111 { 01112 hosttype = ""; 01113 01114 char* ptr; 01115 01116 ptr = ::getenv ("HOSTTYPE"); 01117 if (ptr != 0) 01118 { 01119 hosttype = ptr; 01120 } 01121 } |
|
Definition at line 1168 of file cmt_system.cxx. Referenced by Use::add(), Use::get_cmtpath_and_offset(), and Use::reach_package().
01169 { 01170 cmt_string name = "PROJECT"; 01171 01172 return (name); 01173 } |
|
Definition at line 209 of file cmt_system.cxx. References file_separator(), cmt_string::find_last_of(), and cmt_string::substr(). Referenced by DependencyFilter::add_source(), DocumentGenerator::analyze_file(), LibraryGenerator::analyze_file(), DependencyGenerator::build(), DocumentGenerator::build(), DependencyFilter::has_source(), and LibraryGenerator::module_file_action().
00210 { 00211 int pos = file.find_last_of ('.'); 00212 int sep = file.find_last_of (file_separator ()); 00213 00214 if ((pos == cmt_string::npos) || (pos < sep)) 00215 { 00216 result = ""; 00217 } 00218 else 00219 { 00220 file.substr (pos + 1, result); 00221 } 00222 } |
|
Definition at line 1124 of file cmt_system.cxx. Referenced by Cmt::do_build_temporary_name(), and CvsImplementation::retreive_cvs_infos().
01125 { 01126 cmt_string name; 01127 01128 name = ::tmpnam (NULL); 01129 01130 return (name); 01131 } |
|
Definition at line 1077 of file cmt_system.cxx. Referenced by Cmt::configure_tags(), and Cmt::configure_uname_tag().
01078 { 01079 #ifdef WIN32 01080 uname = "WIN32"; 01081 #else 01082 01083 uname = ""; 01084 01085 FILE* file; 01086 01087 file = popen ("uname", "r"); 01088 01089 if (file != 0) 01090 { 01091 char line[1024]; 01092 char* ptr; 01093 char* nl; 01094 01095 line[0] = 0; 01096 ptr = fgets (line, sizeof (line), file); 01097 if (ptr != 0) 01098 { 01099 nl = strrchr (ptr, '\n'); 01100 if (nl != 0) *nl = 0; 01101 01102 uname = ptr; 01103 } 01104 pclose (file); 01105 } 01106 #endif 01107 } |
|
Definition at line 1151 of file cmt_system.cxx. Referenced by Use::add(), Use::get_cmtpath_and_offset(), Use::reach_package(), and Use::show_all().
01152 { 01153 cmt_string name = "CMTUSERCONTEXT"; 01154 01155 return (name); 01156 } |
|
|
Definition at line 271 of file cmt_system.cxx. References cmt_string::size(). Referenced by mkdir().
00272 { 00273 #ifdef WIN32 00274 if (name.size () == 0) return (false); 00275 00276 if (name.size () >= 2) 00277 { 00278 if (name[1] == ':') 00279 { 00280 return (true); 00281 } 00282 else if ((name[0] == '\\') && (name[1] == '\\')) 00283 { 00284 return (true); 00285 } 00286 } 00287 #endif 00288 00289 return (false); 00290 } |
|
Definition at line 241 of file cmt_system.cxx. References cmt_string::find().
00242 { 00243 if ((name.find ('/') == cmt_string::npos) && 00244 (name.find ('\\') == cmt_string::npos)) 00245 { 00246 return (false); 00247 } 00248 00249 return (true); 00250 } |
|
Definition at line 1142 of file cmt_system.cxx. Referenced by use_action_iterator::ok().
01144 { 01145 if (name == "CMTHOME") return (true); 01146 01147 return (false); 01148 } |
|
Definition at line 1551 of file cmt_system.cxx. References cmt_string_vector, file_separator(), scan_dir(), cmt_vector< T >::size(), and test_file().
01552 { 01553 cmt_string_vector dirs; 01554 01555 cmt_regexp exp ("^[a-zA-Z.][0-9]+([a-zA-Z.][0-9]+([a-zA-Z.][0-9]+)?)?"); 01556 01557 scan_dir (name, exp, dirs); 01558 01559 cmt_string req; 01560 01561 req = name; 01562 req += file_separator (); 01563 req += "cmt"; 01564 req += file_separator (); 01565 req += "requirements"; 01566 01567 if (test_file (req)) return (true); 01568 01569 if (dirs.size () == 0) 01570 { 01571 return (false); 01572 } 01573 01574 for (int i = 0; i < dirs.size (); i++) 01575 { 01576 const cmt_string& d = dirs[i]; 01577 01578 req = d; 01579 req += file_separator (); 01580 req += "mgr"; 01581 req += file_separator (); 01582 req += "requirements"; 01583 01584 if (test_file (req)) return (true); 01585 01586 req = d; 01587 req += file_separator (); 01588 req += "cmt"; 01589 req += file_separator (); 01590 req += "requirements"; 01591 01592 if (test_file (req)) return (true); 01593 } 01594 01595 return (false); 01596 } |
|
Definition at line 1176 of file cmt_system.cxx. Referenced by use_action_iterator::ok().
01178 { 01179 if (name == "PROJECT") return (true); 01180 01181 return (false); 01182 } |
|
Definition at line 1159 of file cmt_system.cxx. Referenced by use_action_iterator::ok().
01161 { 01162 if (name == "CMTUSERCONTEXT") return (true); 01163 01164 return (false); 01165 } |
|
Definition at line 1609 of file cmt_system.cxx. References cmt_string::c_str(), cmt_string::find(), and cmt_string::size().
01613 { 01614 if ((name == "HEAD") || (name == "head")) 01615 { 01616 v = 0; 01617 r = 0; 01618 p = 0; 01619 01620 return (true); 01621 } 01622 01623 static const cmt_string numbers = "0123456789"; 01624 01625 static const int id_version = 0; 01626 static const int id_release = 1; 01627 static const int id_patch = 2; 01628 01629 cmt_string buffer; 01630 01631 enum 01632 { 01633 starting, 01634 at_key, 01635 at_number 01636 } state; 01637 01638 int id; 01639 int pos; 01640 int value; 01641 01642 v = 0; 01643 r = 0; 01644 p = 0; 01645 01646 // 01647 // version : v-field 01648 // | v-field r-field 01649 // | v-field r-field p-field 01650 // 01651 // v-field : field 01652 // r-field : field 01653 // p-field : field 01654 // 01655 // field : key '*' 01656 // | key number 01657 // 01658 // key : letters 01659 // 01660 01661 state = starting; 01662 id = id_version; 01663 01664 for (pos = 0; pos < name.size (); pos++) 01665 { 01666 char c = name[pos]; 01667 01668 if (c == '*') 01669 { 01670 // A wild card 01671 switch (state) 01672 { 01673 case starting: 01674 // cannot start with a wild card ?? 01675 v = -1; 01676 r = -1; 01677 p = -1; 01678 return (false); 01679 case at_key: 01680 // the numeric field is valued with a wild card 01681 switch (id) 01682 { 01683 case id_version: 01684 v = -1; 01685 case id_release: 01686 r = -1; 01687 case id_patch: 01688 p = -1; 01689 break; 01690 } 01691 return (true); 01692 case at_number: 01693 // question: 01694 // a number followed by a wild-card is considered as: 01695 // 1) a wild card on the number itself (1* comp with 1, 10, 12, 120, etc) 01696 // 2) a wild card on the next fields (1* comp with 1r1, 1-12 etc) 01697 // 01698 01699 // Here we select option 1) 01700 01701 sscanf (buffer.c_str (), "%d", &value); 01702 switch (id) 01703 { 01704 case id_version: 01705 // 01706 // lazy option 1 implies v = -1; 01707 // strict option 1 would imply v = -value; 01708 // option 2 implies v = value; 01709 // 01710 01711 v = -1; 01712 r = -1; 01713 p = -1; 01714 break; 01715 case id_release: 01716 r = value; 01717 p = -1; 01718 break; 01719 case id_patch: 01720 p = value; 01721 break; 01722 } 01723 01724 return (true); 01725 } 01726 } 01727 else if (numbers.find (c) == cmt_string::npos) 01728 { 01729 // A letter 01730 switch (state) 01731 { 01732 case starting: 01733 state = at_key; 01734 break; 01735 case at_key: 01736 // Multiple letter key (is it permitted??) 01737 break; 01738 case at_number: 01739 sscanf (buffer.c_str (), "%d", &value); 01740 switch (id) 01741 { 01742 case id_version: 01743 v = value; 01744 break; 01745 case id_release: 01746 r = value; 01747 break; 01748 case id_patch: 01749 p = value; 01750 break; 01751 } 01752 buffer = ""; 01753 id++; 01754 state = at_key; 01755 break; 01756 } 01757 } 01758 else 01759 { 01760 // a number 01761 switch (state) 01762 { 01763 case starting: 01764 // not starting by a letter (syntax error) 01765 return (false); 01766 case at_key: 01767 // the numeric field for the current id is starting now 01768 buffer += c; 01769 state = at_number; 01770 break; 01771 case at_number: 01772 // continuing the current numeric field 01773 buffer += c; 01774 break; 01775 } 01776 } 01777 } 01778 01779 switch (state) 01780 { 01781 case starting: 01782 // Empty version string 01783 return (false); 01784 case at_key: 01785 // Syntax error (when only letters. Ending letters is not an error) 01786 if (id == id_version) return (false); 01787 else return (true); 01788 case at_number: 01789 sscanf (buffer.c_str (), "%d", &value); 01790 switch (id) 01791 { 01792 case id_version: 01793 v = value; 01794 break; 01795 case id_release: 01796 r = value; 01797 break; 01798 case id_patch: 01799 p = value; 01800 break; 01801 } 01802 id++; 01803 state = at_key; 01804 return (true); 01805 } 01806 01807 return (false); 01808 } |
|
Definition at line 1599 of file cmt_system.cxx. Referenced by compare_versions(), Cmt::configure_current_package(), Cmt::configure_version_tag(), Cmt::do_check_version(), Cmt::do_set_version(), BestFitSelector::operate(), Cmt::reach_current_package(), Use::reach_package(), PathScanner::scan_package(), PathScanner::scan_path(), Use::select_alternate(), and Cmt::set_standard_macros().
01600 { 01601 int v; 01602 int r; 01603 int p; 01604 01605 return (is_version_directory (name, v, r, p)); 01606 } |
|
Definition at line 639 of file cmt_system.cxx. References absolute_path(), cmt_string::c_str(), cmt_string_vector, file_separator(), has_device(), cmt_string::replace_all(), cmt_vector< T >::size(), split(), and test_directory(). Referenced by DependencyGenerator::build(), Project::create(), Cmt::do_build_library_links(), Cmt::do_config(), Cmt::do_create(), SequenceRunner::filter(), CvsImplementation::mkdir(), VSNETGenerator::reset(), MSDEVGenerator::reset(), and CvsImplementation::retreive_cvs_infos().
00640 { 00641 static cmt_string_vector path_vector; 00642 int i; 00643 static cmt_string full_path; 00644 char double_fs[] = " "; 00645 00646 double_fs[0] = file_separator (); 00647 double_fs[1] = file_separator (); 00648 00649 full_path = name; 00650 00651 if (file_separator () == '/') 00652 { 00653 full_path.replace_all ("\\", file_separator ()); 00654 } 00655 else 00656 { 00657 full_path.replace_all ("/", file_separator ()); 00658 } 00659 00660 full_path.replace_all (double_fs, file_separator ()); 00661 00662 split (full_path, file_separator (), path_vector); 00663 00664 full_path = ""; 00665 00666 if (absolute_path (name)) 00667 { 00668 if (!has_device (name)) 00669 { 00670 full_path = file_separator (); 00671 } 00672 } 00673 00674 for (i = 0; i < path_vector.size (); i++) 00675 { 00676 const cmt_string& path = path_vector[i]; 00677 00678 if (i > 0) full_path += file_separator (); 00679 full_path += path; 00680 00681 if (has_device (path)) continue; 00682 00683 if (!test_directory (full_path)) 00684 { 00685 #ifdef WIN32 00686 if (::_mkdir (full_path.c_str ()) != 0) 00687 { 00688 // cerr << "CMT> cannot create directory " << full_path << endl; 00689 return (false); 00690 } 00691 #else 00692 if (::mkdir (full_path.c_str (), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH ) != 0) 00693 { 00694 // cerr << "CMT> cannot create directory " << full_path << endl; 00695 return (false); 00696 } 00697 #endif 00698 } 00699 } 00700 00701 return (true); 00702 } |
|
Definition at line 179 of file cmt_system.cxx. References cmt_string::erase(), and cmt_string::find_last_of(). Referenced by LibraryGenerator::prepare_proto_file().
00180 { 00181 int pos; 00182 00183 result = file_name; 00184 00185 // remove the suffix 00186 00187 pos = result.find_last_of ('.'); 00188 00189 if (pos != cmt_string::npos) 00190 { 00191 result.erase (pos); 00192 } 00193 00194 // remove the directory name 00195 00196 pos = result.find_last_of ('/'); 00197 if (pos == cmt_string::npos) 00198 { 00199 pos = result.find_last_of ('\\'); 00200 } 00201 00202 if (pos != cmt_string::npos) 00203 { 00204 result.erase (0, pos + 1); 00205 } 00206 } |
|
Definition at line 2138 of file cmt_system.cxx. References cmt_string::replace_all(). Referenced by ReadmeGenerator::build(), DocumentGenerator::build(), LibraryGenerator::build(), and CmtLock::lock().
02139 { 02140 cmt_string result; 02141 02142 time_t ltime; 02143 time (<ime); 02144 result = ctime (<ime); 02145 02146 result.replace_all ("\n", ""); 02147 02148 return (result); 02149 } |
|
Definition at line 532 of file cmt_system.cxx. Referenced by PathBuilder::build(), PathBuilder::clean(), ProjectFactory::create_project(), find_path_entry(), and Project::use_action().
00533 { 00534 #ifdef WIN32 00535 return (';'); 00536 #else 00537 return (':'); 00538 #endif 00539 } |
|
Definition at line 1224 of file cmt_system.cxx. References cmt_string::c_str(). Referenced by CvsImplementation::add_cmtpath(), Symbol::all_set(), and cd().
01225 { 01226 int status = ::putenv ((char*) name_value.c_str ()); 01227 01228 if (status == 0) return (true); 01229 else return (false); 01230 } |
|
|
Transform all / or \ characters in the text into the current file_separator Reduce all multiple file_separator into single ones.
Definition at line 511 of file cmt_system.cxx. References file_separator(), cmt_string::find(), and cmt_string::replace_all(). Referenced by CvsImplementation::build_version_directory(), CvsImplementation::do_checkout_phase1(), CmtGenerator::prepare_use_context(), SourceFile::set(), and CmtGenerator::set_full_name().
00512 { 00513 if (file_separator () == '/') 00514 { 00515 text.replace_all ("\\", "/"); 00516 while (text.find ("//") != cmt_string::npos) 00517 { 00518 text.replace_all ("//", "/"); 00519 } 00520 } 00521 else 00522 { 00523 text.replace_all ("/", "\\"); 00524 while (text.find ("\\\\") != cmt_string::npos) 00525 { 00526 text.replace_all ("\\\\", "\\"); 00527 } 00528 } 00529 } |
|
Definition at line 604 of file cmt_system.cxx. References cmt_string_vector, remove_file(), scan_dir(), cmt_vector< T >::size(), and test_directory(). Referenced by Cmt::do_remove(), and CvsImplementation::retreive_cvs_infos().
00605 { 00606 //cerr << "Try to remove directory " << name << endl; 00607 00608 cmt_string_vector files; 00609 00610 scan_dir (name, files); 00611 00612 for (int i = 0; i < files.size (); i++) 00613 { 00614 cmt_string& file = files[i]; 00615 00616 if (test_directory (file)) 00617 { 00618 //cerr << "D=" << file << endl; 00619 if (!remove_directory (file)) return (false); 00620 } 00621 else 00622 { 00623 //cerr << "F=" << file << endl; 00624 if (!remove_file (file)) return (false); 00625 } 00626 } 00627 00628 int status = ::rmdir (name); 00629 if (status != 0) 00630 { 00631 cerr << "#CMT> Cannot remove directory " << name << " errno=" << errno << endl; 00632 return (false); 00633 } 00634 00635 return (true); 00636 } |
|
Definition at line 592 of file cmt_system.cxx. Referenced by CmtInstallAreaMgr::config(), Cmt::do_config(), remove_directory(), and CmtLock::unlock().
00593 { 00594 if (::unlink (name) != 0) 00595 { 00596 cerr << "#CMT> Cannot remove file " << name << endl; 00597 return (false); 00598 } 00599 00600 return (true); 00601 } |
|
Definition at line 912 of file cmt_system.cxx. References cmt_string_vector, and scan_dir().
00913 { 00914 static cmt_string_vector result; 00915 00916 scan_dir (dir_name, result); 00917 00918 return (result); 00919 } |
|
Definition at line 820 of file cmt_system.cxx. References cmt_vector< T >::add(), cmt_vector< T >::clear(), cmt_string_vector, dirname(), file_separator(), cmt_regexp::match(), and test_directory().
00823 { 00824 static cmt_string dir_prefix; 00825 00826 dir_prefix = dir_name; 00827 if (dir_name == "") dir_prefix = "."; 00828 00829 if (!test_directory (dir_prefix)) 00830 { 00831 dirname (dir_prefix, dir_prefix); 00832 } 00833 00834 list.clear (); 00835 00836 #ifdef WIN32 00837 00838 long dir; 00839 struct _finddata_t entry; 00840 00841 static cmt_string search; 00842 00843 search = dir_prefix; 00844 search += file_separator (); 00845 search += "*"; 00846 00847 dir = _findfirst (search.c_str (), &entry); 00848 if (dir > 0) 00849 { 00850 for (;;) 00851 { 00852 if ((entry.name[0] != '.') && 00853 (strcmp ((char*) entry.name, ".") != 0) && 00854 (strcmp ((char*) entry.name, "..") != 0) && 00855 (strncmp ((char*) entry.name, ".nfs", 4) != 0)) 00856 { 00857 const char* name = entry.name; 00858 00859 if (expression.match (name)) 00860 { 00861 cmt_string& name_entry = list.add (); 00862 00863 name_entry = dir_prefix; 00864 name_entry += file_separator (); 00865 name_entry += name; 00866 } 00867 } 00868 00869 int status = _findnext (dir, &entry); 00870 if (status != 0) 00871 { 00872 break; 00873 } 00874 } 00875 _findclose (dir); 00876 } 00877 #else 00878 00879 //cout << "scan_dir> dir=" << dir_name << endl; 00880 00881 DIR* dir = opendir (dir_prefix.c_str ()); 00882 00883 struct dirent* entry; 00884 00885 if (dir != 0) 00886 { 00887 while ((entry = readdir (dir)) != 0) 00888 { 00889 //if (entry->d_name[0] == '.') continue; 00890 if (!strcmp ((char*) entry->d_name, ".")) continue; 00891 if (!strcmp ((char*) entry->d_name, "..")) continue; 00892 if (!strncmp ((char*) entry->d_name, ".nfs", 4)) continue; 00893 00894 const char* name = entry->d_name; 00895 00896 if (!expression.match (name)) continue; 00897 00898 cmt_string& name_entry = list.add (); 00899 00900 name_entry = dir_prefix; 00901 name_entry += file_separator (); 00902 name_entry += name; 00903 } 00904 00905 closedir (dir); 00906 } 00907 #endif 00908 00909 } |
|
Definition at line 705 of file cmt_system.cxx. References cmt_vector< T >::add(), basename(), cmt_string::c_str(), cmt_vector< T >::clear(), cmt_string_vector, dirname(), cmt_string::erase(), file_separator(), cmt_string::find(), cmt_string::size(), and test_directory(). Referenced by CmtInstallAreaMgr::config(), Cmt::do_config(), Cmt::do_remove(), CvsImplementation::find_matching_version(), CmtGenerator::get_all_files(), is_package_directory(), Use::reach_package(), remove_directory(), UseAnalyzer::run(), scan_dir(), PathScanner::scan_package(), and PathScanner::scan_path().
00707 { 00708 static cmt_string dir_prefix; 00709 static cmt_string name_prefix; 00710 00711 dir_prefix = dir_name; 00712 if (dir_name == "") dir_prefix = "."; 00713 00714 if (!test_directory (dir_prefix)) 00715 { 00716 dirname (dir_prefix, dir_prefix); 00717 basename (dir_name, name_prefix); 00718 } 00719 else 00720 { 00721 } 00722 00723 bool need_filter = false; 00724 00725 int wild_card; 00726 00727 wild_card = name_prefix.find ('*'); 00728 if (wild_card != cmt_string::npos) 00729 { 00730 name_prefix.erase (wild_card); 00731 } 00732 00733 if (name_prefix.size () > 0) 00734 { 00735 need_filter = true; 00736 } 00737 00738 list.clear (); 00739 00740 #ifdef WIN32 00741 00742 long dir; 00743 struct _finddata_t entry; 00744 00745 static cmt_string search; 00746 00747 search = dir_prefix; 00748 search += file_separator (); 00749 search += "*"; 00750 00751 dir = _findfirst (search.c_str (), &entry); 00752 if (dir > 0) 00753 { 00754 for (;;) 00755 { 00756 if ((strcmp ((char*) entry.name, ".") != 0) && 00757 (strcmp ((char*) entry.name, "..") != 0) && 00758 (strncmp ((char*) entry.name, ".nfs", 4) != 0)) 00759 { 00760 const char* name = entry.name; 00761 00762 if (!need_filter || 00763 (strncmp (name, name_prefix.c_str (), name_prefix.size ()) == 0)) 00764 { 00765 cmt_string& name_entry = list.add (); 00766 00767 name_entry = dir_prefix; 00768 name_entry += file_separator (); 00769 name_entry += name; 00770 } 00771 } 00772 00773 int status = _findnext (dir, &entry); 00774 if (status != 0) 00775 { 00776 break; 00777 } 00778 } 00779 00780 _findclose (dir); 00781 } 00782 #else 00783 00784 //cout << "scan_dir> dir=" << dir_name << endl; 00785 00786 DIR* dir = opendir (dir_prefix.c_str ()); 00787 00788 struct dirent* entry; 00789 00790 if (dir != 0) 00791 { 00792 while ((entry = readdir (dir)) != 0) 00793 { 00794 //if (entry->d_name[0] == '.') continue; 00795 if (!strcmp ((char*) entry->d_name, ".")) continue; 00796 if (!strcmp ((char*) entry->d_name, "..")) continue; 00797 if (!strncmp ((char*) entry->d_name, ".nfs", 4)) continue; 00798 00799 const char* name = entry->d_name; 00800 00801 if (need_filter && 00802 (strncmp (name, name_prefix.c_str (), name_prefix.size ()) != 0)) continue; 00803 00804 //cout << "scan_dir> name=" << name << endl; 00805 00806 cmt_string& name_entry = list.add (); 00807 00808 name_entry = dir_prefix; 00809 name_entry += file_separator (); 00810 name_entry += name; 00811 } 00812 00813 closedir (dir); 00814 } 00815 #endif 00816 00817 } |
|
Definition at line 1814 of file cmt_system.cxx. References cmt_vector< T >::add(), cmt_string::c_str(), cmt_vector< T >::clear(), cmt_string_vector, and cmt_string::size(). Referenced by Use::action(), Fragment::action(), add_cmt_paths_from_text(), PathBuilder::build(), Use::build_library_links(), CmtLock::check(), PathBuilder::clean(), CmtInstallAreaMgr::config(), ProjectFactory::create_project(), DependencyAnalyzer::DependencyAnalyzer(), Cmt::do_broadcast(), Cmt::do_check_configuration(), SyntaxParser::do_parse_line(), Cmt::do_remove_library_links(), CmtModel::expand(), DependencyAnalyzer::filter(), TriggerAnalyzer::filter(), SequenceRunner::filter(), ProjectPatcher::filter(), ProjectReader::filter(), CmtMountFilterParser::filter(), Prototyper::filter(), Packager::filter(), WinDefAwk::filter(), RecursivePass4::filter(), RecursivePass3::filter(), RecursivePass2::filter(), RecursivePass1::filter(), Cut::filter(), CvsImplementation::filter_list(), find_path_entry(), get_best_form(), CvsImplementation::match_version_request(), mkdir(), ArgParser::option_tag(), ArgParser::option_tag_add(), ArgParser::option_tag_remove(), ArgParser::option_use(), Constituent::parse(), Cmt::parser(), Cmt::print(), CvsImplementation::really_checkout_package_contents(), Cmt::restore_all_tags(), ClientCollector::run(), DepsBuilder::run(), Cmt::set_standard_macros(), StandardMacroBuilder::StandardMacroBuilder(), CmtModel::strict_expand(), CvsImplementation::tags(), and Project::use_action().
01817 { 01818 static char* buffer = 0; 01819 static int allocated = 0; 01820 01821 bool finished = false; 01822 01823 strings.clear (); 01824 01825 if (text.size () == 0) return; 01826 01827 /* 01828 We are going to work in a copy of the text, since 01829 \0 will be inserted right after each found word. 01830 01831 Then the vector of strings is iteratively filled by each found word. 01832 */ 01833 01834 if (buffer == 0) 01835 { 01836 allocated = text.size (); 01837 buffer = (char*) malloc (allocated + 1); 01838 } 01839 else 01840 { 01841 if (text.size () > allocated) 01842 { 01843 allocated = text.size (); 01844 buffer = (char*) realloc (buffer, allocated + 1); 01845 } 01846 } 01847 01848 strcpy (buffer, text.c_str ()); 01849 01850 /* 01851 Algorithm : 01852 01853 We look for words separated by <separators> which may be 01854 o spaces (' ' or '\t') 01855 o other characters such as ':' 01856 01857 A word is a character string not containing any separator. A substring in 01858 this word my be enclosed between quotes (" or ') which permits separator 01859 inclusion within words. 01860 */ 01861 01862 char* current_word = buffer; 01863 01864 while (*current_word != 0) 01865 { 01866 size_t prefix_length; 01867 size_t word_length; 01868 01869 /* 01870 while ((*current_word == ' ') || 01871 (*current_word == '\t')) 01872 { 01873 current_word++; 01874 } 01875 */ 01876 01877 // first skip all starting separators. 01878 01879 prefix_length = strspn (current_word, separators.c_str ()); 01880 if (prefix_length > 0) 01881 { 01882 // Move to the first non-separator character 01883 01884 current_word += prefix_length; 01885 } 01886 01887 /* 01888 Parse the next word. 01889 01890 It may contain enclosures in quote characters or not. 01891 Quotes must be identical on both sides of each enclosure. 01892 */ 01893 01894 char* running_char = current_word; 01895 01896 word_length = 0; 01897 01898 for (;;) 01899 { 01900 size_t unquoted_length; 01901 size_t separator_offset; 01902 01903 for (int p = 0;;) 01904 { 01905 unquoted_length = strcspn (running_char + p, "\"\'") + p; 01906 if ((unquoted_length > 0) && (running_char[unquoted_length-1] == '\\')) 01907 { 01908 p = unquoted_length + 1; 01909 } 01910 else 01911 { 01912 break; 01913 } 01914 } 01915 01916 separator_offset = strcspn (running_char, separators.c_str ()); 01917 01918 if (separator_offset <= unquoted_length) 01919 { 01920 // no quote in this word -> we are finished for this one. 01921 running_char += separator_offset; 01922 break; 01923 } 01924 01925 // We have found a quoted enclosure. Move to it. 01926 01927 running_char += unquoted_length; 01928 01929 char quote = running_char[0]; 01930 01931 // Remove it. 01932 { 01933 char* p = running_char; 01934 while (p[1] != 0) 01935 { 01936 *p = p[1]; 01937 p++; 01938 } 01939 *p = 0; 01940 } 01941 01942 // Look for the next occurence of this quote. 01943 { 01944 char* p = strchr (running_char, quote); 01945 if (p == 0) 01946 { 01947 // Unmatched quote : the rest of the line will be taken as a word... 01948 running_char += strlen (running_char); 01949 finished = true; 01950 break; 01951 } 01952 else 01953 { 01954 running_char = p; 01955 } 01956 } 01957 01958 // Now we remove the ending quote from the word 01959 // (by shifting all remaining characters by one place to the left) 01960 01961 { 01962 char* p = running_char; 01963 while (p[1] != 0) 01964 { 01965 *p = p[1]; 01966 p++; 01967 } 01968 *p = 0; 01969 } 01970 } 01971 01972 word_length = running_char - current_word; 01973 01974 if (current_word[word_length] == 0) 01975 { 01976 finished = true; 01977 } 01978 else 01979 { 01980 current_word[word_length] = 0; 01981 } 01982 01983 /* 01984 if ((t[0] == '"') || 01985 (t[0] == '\'') || 01986 (t[0] == ':')) 01987 { 01988 char* quote; 01989 01990 t++; 01991 quote = strchr (t, sep); 01992 if (quote != 0) *quote = 0; 01993 else finished = true; 01994 } 01995 else 01996 { 01997 int offset; 01998 01999 offset = strcspn (t, " \t:"); 02000 if ((offset < 0) || (t[offset] == 0)) finished = true; 02001 if (!finished) 02002 { 02003 space = t + offset; 02004 *space = 0; 02005 } 02006 } 02007 */ 02008 02009 // Store the current word into the vector of strings 02010 02011 { 02012 cmt_string& s = strings.add (); 02013 s = current_word; 02014 } 02015 02016 if (finished) break; 02017 02018 // Move to the next possible word. 02019 current_word += word_length + 1; 02020 } 02021 } |
|
|
|
Definition at line 1185 of file cmt_system.cxx. Referenced by ApplyPattern::action(), Pattern::action(), ApplyPattern::apply(), Pattern::apply(), Cmt::configure_home(), Cmt::configure_tags(), Cmt::configure_user_context(), Pattern::expand(), CmtModel::expand(), StandardMacroBuilder::fill_for_tag(), cmt_or_node::match(), cmt_and_node::match(), ArgParser::option_tag(), Cmt::restore_all_tags(), Awk::run(), cmt_regexp::set(), and Cmt::set_standard_macros().
01186 { 01187 const char* env = ::getenv (name); 01188 if (env == 0) return (false); 01189 return (true); 01190 } |
|
Definition at line 2152 of file cmt_system.cxx. References getenv(). Referenced by ReadmeGenerator::build(), DocumentGenerator::build(), LibraryGenerator::build(), CmtLock::check(), and CmtLock::lock().
02153 { 02154 #ifdef _WIN32 02155 cmt_string result = getenv ("USERNAME"); 02156 #else 02157 cmt_string result = getenv ("USER"); 02158 #endif 02159 02160 return (result); 02161 } |