- Timestamp:
- Dec 4, 2013, 10:57:15 AM (10 years ago)
- Location:
- CMT/HEAD
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/ChangeLog
r655 r656 1 2013-12-03 <rybkin@lal.in2p3.fr> 515 2 3 * source/cmt_symbol.h: In class SymbolValueList function print, class 4 Symbol functions all_print, print introduce optional argument of type 5 ostream reference, in class Symbol, declare static functions std_env_vars, 6 set_path_strip 7 * source/cmt_symbol.cxx: In class PathBuilder, introduce and implement 8 functions filter_path_value, get/set_path_strip, constructor with 9 path_strip argument and member m_path_strip to indicate whether to strip 10 paths of non-existent directories, in unnamed namespace, introduce cache 11 of command outputs for use in functions resolve_value, 12 resolve_value_for_macros, suppress_OS_delimiters, in class Symbol function 13 create, create PathBuilder instance with configured value of path_strip, 14 in class Symbol, implement static functions std_env_vars, set_path_strip, 15 control access to environment in functions resolve_value, class Symbol 16 functions all_set, get_env_value, class SetBuilder function build, class 17 PathBuilder function build, systematically use class PathBuilder function 18 filter_path_value in class Symbol functions all_set, check_all_paths, 19 print, in class PathBuilder function build, in class SymbolValueList 20 function print, modify helper function find_path_entry so as not to access 21 file system and return index of entry found, in class PathBuilder function 22 build, make use of signature to enhance implementation of path_append / 23 prepend commands, drop redundant cleaning of repeating path separators, in 24 class SymbolValueList function print, implement enhanced cached 25 requirements file generation, i.e., resolve sets for macros if possible, 26 resolve paths fully if possible, so as to strip path of non-existent 27 directories, implement use of argument of type ostream reference 28 * source/cmt_use.cxx: In class Use function fill_standard_macros, generate 29 CONFIG macros, if CONFIG environment variables are relevant, in setup 30 Requirements mode 31 * source/cmt_error.cxx: Cosmetic modifications to error messages 32 * source/cmt_commands.h: In class ArgParser, declare functions 33 option_with(out)_projects, option(_no)_path_strip 34 * source/cmt_commands.cxx: In class ArgParser, implement introduced 35 functions 36 * source/cmt.h: In class CmtContext, introduce member m_use_projects to 37 indicate whether to parse project files, member m_env_access to indicate 38 whether symbols values can be taken from environment, member m_print_mode 39 to hold corresponding value from class ArgParser instance, member 40 m_path_strip to indicate whether to strip paths of non-existent 41 directories, in class Cmt functions print, print_context introduce optional 42 argument of type ostream reference, declare and implement inline functions 43 get/set_env_access, get/set_print_mode, get_path_strip 44 * source/cmt_parser.cxx: In class Cmt function configure_cmt_path, do not 45 create projects if m_use_projects is false, in function do_broadcast, set 46 cmtpath for all uses so as to fill in templates correctly, in function 47 do_check_configuration, do not run class Symbol function check_all_paths 48 for setup unless in Requirements mode (since paths checks are done in class 49 Symbol function print), in function do_setup, implement procedure of cached 50 requirements file generation, i.e., do not access environment to set 51 symbols values and, by default, strip paths of non-existent directories if 52 possible, in function guess_current_project, return if projects are not 53 used, do not change m_autoconfigure_cmtpath value, in functions print, 54 print_context, implement use of argument of type ostream reference, in 55 function print_context, in Requirements mode, generate CONFIG sets if 56 CONFIG environment variables are relevant, in function 57 use_special_requirements, handle case when projects are not used 58 * mgr/requirements: Associate CMTr25 tag with HEAD, append CMT to PATH as 59 in CMT setup scripts 60 1 61 2013-11-13 <rybkin@lal.in2p3.fr> 514 2 62 … … 41 101 system tags handling to make all initially known tags available while 42 102 reading project files, implement get_tags_remove function, in parser 43 function initialise static xCmtContext instance at very beginning103 function initialise static CmtContext instance at very beginning 44 104 * source/cmt.h: In class Cmt, declare get_tags_remove function 45 105 -
CMT/HEAD/mgr/requirements
r628 r656 6 6 tag CMTr16 CMTr14 7 7 tag CMTr18 CMTr16 8 tag CMTr0 CMTr 188 tag CMTr0 CMTr25 9 9 10 10 # … … 125 125 WIN32 "CMT\v" 126 126 127 path_ prependPATH "${CMTROOT}/${CMTBIN}" \127 path_append PATH "${CMTROOT}/${CMTBIN}" \ 128 128 WIN32 "%CMTROOT%\%CMTBIN%" 129 129 -
CMT/HEAD/source/cmt.h
r654 r656 35 35 cmt_string m_cmt_version; 36 36 bool m_use_cmt; 37 bool m_use_projects; 37 38 38 39 cmt_string m_current_dir; … … 74 75 75 76 bool m_autoconfigure_cmtpath; 77 78 bool m_env_access; 79 PrintMode m_print_mode; 80 bool m_path_strip; 76 81 77 82 private: … … 271 276 static int parser (const cmt_string& command_line); 272 277 static int parser (int argc, char* argv[]); 273 static void print (PrintMode mode); 278 static void print (PrintMode mode, ostream& out = cout); 279 //static void print (PrintMode mode); 274 280 static void print_clean (PrintMode mode); 275 static void print_context (Use& use, PrintMode mode, const cmt_string& tag); 281 static void print_context (Use& use, PrintMode mode, const cmt_string& tag, ostream& out = cout); 282 //static void print_context (Use& use, PrintMode mode, const cmt_string& tag); 276 283 static void print_macros (PrintMode mode, const cmt_string& pattern = "", 277 284 ostream& out = cout); … … 302 309 cmt_string& result); 303 310 311 static inline const bool& get_env_access (); 312 static inline void set_env_access (const bool& access); 313 static inline const PrintMode& get_print_mode (); 314 static inline void set_print_mode (const PrintMode& mode); 315 static inline const bool& get_path_strip (); 316 304 317 private: 305 318 static CmtContext& m_cmt_context; … … 425 438 } 426 439 440 inline const bool& Cmt::get_env_access () 441 { 442 return m_cmt_context.m_env_access; 443 } 444 445 inline void Cmt::set_env_access (const bool& access) 446 { 447 m_cmt_context.m_env_access = access; 448 } 449 450 inline const PrintMode& Cmt::get_print_mode () 451 { 452 return m_cmt_context.m_print_mode; 453 } 454 455 inline void Cmt::set_print_mode (const PrintMode& mode) 456 { 457 m_cmt_context.m_print_mode = mode; 458 } 459 460 inline const bool& Cmt::get_path_strip () 461 { 462 return m_cmt_context.m_path_strip; 463 } 427 464 //---------------------------------------------------------- 428 465 -
CMT/HEAD/source/cmt_commands.cxx
r652 r656 256 256 pv.push_back (&ArgParser::option_no_cleanup); i++; 257 257 258 parsers.add ("-no_path_s", i); 259 parsers.add ("-no_path_st", i); 260 parsers.add ("-no_path_str", i); 261 parsers.add ("-no_path_stri", i); 262 parsers.add ("-no_path_strip", i); 263 pv.push_back (&ArgParser::option_no_path_strip); i++; 264 258 265 parsers.add ("-pac", i); 259 266 parsers.add ("-pack", i); … … 263 270 parsers.add ("-path", i); 264 271 pv.push_back (&ArgParser::option_path); i++; 272 273 parsers.add ("-path_s", i); 274 parsers.add ("-path_st", i); 275 parsers.add ("-path_str", i); 276 parsers.add ("-path_stri", i); 277 parsers.add ("-path_strip", i); 278 pv.push_back (&ArgParser::option_path_strip); i++; 265 279 266 280 parsers.add ("-pr", i); … … 346 360 parsers.add ("-without_cmt", i); 347 361 pv.push_back (&ArgParser::option_without_cmt); i++; 362 363 parsers.add ("-with_p", i); 364 parsers.add ("-with_pr", i); 365 parsers.add ("-with_pro", i); 366 parsers.add ("-with_proj", i); 367 parsers.add ("-with_proje", i); 368 parsers.add ("-with_projec", i); 369 parsers.add ("-with_project", i); 370 parsers.add ("-with_projects", i); 371 pv.push_back (&ArgParser::option_with_projects); i++; 372 373 parsers.add ("-without_p", i); 374 parsers.add ("-without_pr", i); 375 parsers.add ("-without_pro", i); 376 parsers.add ("-without_proj", i); 377 parsers.add ("-without_proje", i); 378 parsers.add ("-without_projec", i); 379 parsers.add ("-without_project", i); 380 parsers.add ("-without_projects", i); 381 pv.push_back (&ArgParser::option_without_projects); i++; 348 382 349 383 parsers.add ("-warn", i); … … 2022 2056 } 2023 2057 2058 void ArgParser::option_no_path_strip () 2059 { 2060 cmt.m_path_strip = false; 2061 if (!Cmt::add_cmt_flag ("-no_path_strip")) 2062 CmtMessage::error ("Cannot add flag `-no_path_strip'"); 2063 } 2064 2065 void ArgParser::option_path_strip () 2066 { 2067 cmt.m_path_strip = true; 2068 if (!Cmt::add_cmt_flag ("-path_strip")) 2069 CmtMessage::error ("Cannot add flag `-path_strip'"); 2070 } 2071 2024 2072 void ArgParser::option_tag () 2025 2073 { … … 2323 2371 if (!Cmt::add_cmt_flag ("-without_cmt")) 2324 2372 CmtMessage::error ("Cannot add flag `-without_cmt'"); 2373 } 2374 2375 void ArgParser::option_with_projects () 2376 { 2377 cmt.m_use_projects = true; 2378 if (!Cmt::add_cmt_flag ("-with_projects")) 2379 CmtMessage::error ("Cannot add flag `-with_projects'"); 2380 } 2381 2382 void ArgParser::option_without_projects () 2383 { 2384 cmt.m_use_projects = false; 2385 if (!Cmt::add_cmt_flag ("-without_projects")) 2386 CmtMessage::error ("Cannot add flag `-without_projects'"); 2325 2387 } 2326 2388 -
CMT/HEAD/source/cmt_commands.h
r561 r656 83 83 void option_with_cmt (); 84 84 void option_without_cmt (); 85 void option_with_projects (); 86 void option_without_projects (); 85 87 void option_with_version_directory (); 86 88 void option_without_version_directory (); 87 89 void option_no_cleanup (); 90 void option_no_path_strip (); 91 void option_path_strip (); 88 92 void option_private (); 89 93 void option_public (); -
CMT/HEAD/source/cmt_error.cxx
r598 r656 18 18 { 19 19 error_names.add() = "ok"; 20 error_names.add() = " Warning";20 error_names.add() = "warning"; 21 21 error_names.add() = "symbol not found"; 22 22 error_names.add() = "pattern not found"; … … 159 159 160 160 result = get_error_name (e.get_code ()); 161 result += " 161 result += ": "; 162 162 result += e.get_text (); 163 163 -
CMT/HEAD/source/cmt_parser.cxx
r655 r656 68 68 m_cmt_version = ""; 69 69 m_use_cmt = true; 70 m_use_projects = true; 70 71 71 72 m_current_dir = ""; … … 109 110 110 111 m_autoconfigure_cmtpath = false; 112 113 m_env_access = true; 114 m_print_mode = Csh; 115 m_path_strip = false; 111 116 } 112 117 //---------------------------------------------------------- … … 627 632 Me.m_autoconfigure_cmtpath = true; 628 633 configure_cmt_path (0); 629 Me.m_autoconfigure_cmtpath = false;634 // Me.m_autoconfigure_cmtpath = false; 630 635 631 636 Me.m_quiet = save_quiet; … … 710 715 { 711 716 if (!Me.m_autoconfigure_cmtpath) return; 717 718 if (!m_cmt_context.m_use_projects) return; 712 719 713 720 cmt_string s; … … 2115 2122 ok = selected; 2116 2123 } 2124 else if (up) 2125 cmtpath = up->get_cmtpath (); 2117 2126 2118 2127 if (ok) … … 3170 3179 } 3171 3180 3172 Symbol::check_all_paths (); 3181 if (action_setup != get_action () || 3182 Requirements == ap.mode) 3183 // PathBuilder::filter_path_value is called 3184 // for each path in Symbol::print 3185 Symbol::check_all_paths (); 3173 3186 3174 3187 env = CmtSystem::getenv ("CMTSITE"); … … 4569 4582 break; 4570 4583 case Requirements : 4584 /* 4571 4585 CmtSystem::cmt_string_vector flags; 4572 4586 get_cmt_flags (flags); 4573 4587 cout << "\n# CMTFLAGS: -without_cmt"; 4588 cout << " -without_projects" ; 4574 4589 for (int i = 0; i < flags.size (); i++) 4575 4590 { … … 4578 4593 else if (flags[i] == "-with_cmt") 4579 4594 cout << " -without_cmt"; 4595 else if (flags[i] == "-without_projects") 4596 cout << " -with_projects"; 4597 else if (flags[i] == "-with_projects") 4598 cout << " -without_projects"; 4580 4599 else 4581 4600 cout << " " << flags[i]; 4582 4601 } 4583 4602 cout << endl; 4603 */ 4584 4604 break; 4585 } 4586 print (ap.mode); 4605 default: 4606 break; 4607 } 4608 4609 ostringstream os; 4610 ostringstream oh; 4611 bool reset (false); 4612 CmtSystem::cmt_string_vector flags; 4613 cmt_string path_strip_flag; 4614 bool path_strip (false); 4615 4616 bool strip_saved (get_path_strip ()); 4617 bool access_saved (Cmt::get_env_access ()); 4618 4619 switch (ap.mode) 4620 { 4621 case Requirements : 4622 4623 get_cmt_flags (flags); 4624 for (int i = 0; i < flags.size (); i++) 4625 { 4626 if (flags[i] == "-no_path_strip") 4627 path_strip_flag = "-no_path_strip"; 4628 else if (flags[i] == "-path_strip") 4629 path_strip_flag = "-path_strip"; 4630 } 4631 if (path_strip_flag != "-no_path_strip" && 4632 !get_path_strip ()) 4633 reset = Symbol::set_path_strip (true); 4634 4635 if (get_path_strip () || reset) 4636 path_strip = true; 4637 else 4638 path_strip = false; 4639 4640 Cmt::set_env_access (false); 4641 4642 print (ap.mode, os); 4643 4644 if (CmtError::get_last_error_code () == CmtError::warning && 4645 (get_path_strip () || reset)) 4646 { 4647 reset = Symbol::set_path_strip (false); 4648 if (reset) 4649 { 4650 path_strip = false; 4651 4652 CmtError::print (); 4653 CmtError::clear (); 4654 4655 if (Cmt::get_debug ()) 4656 { 4657 cerr << "|Cmt::do_setup> Failure with:\n" << os.str () 4658 << "|Cmt::do_setup> Trying again." << endl; 4659 } 4660 4661 // Try again 4662 os.str (""); 4663 print (ap.mode, os); 4664 } 4665 } 4666 4667 if (reset) Symbol::set_path_strip (strip_saved); 4668 Cmt::set_env_access (access_saved); 4669 4670 //get_cmt_flags (flags); 4671 oh << "\n# CMTFLAGS:" 4672 " -without_cmt" 4673 " -without_projects" 4674 //" -path_strip" 4675 ; 4676 for (int i = 0; i < flags.size (); i++) 4677 { 4678 if (flags[i] == "-without_cmt") 4679 oh << " -with_cmt"; 4680 else if (flags[i] == "-with_cmt") 4681 oh << " -without_cmt"; 4682 else if (flags[i] == "-without_projects") 4683 oh << " -with_projects"; 4684 else if (flags[i] == "-with_projects") 4685 oh << " -without_projects"; 4686 /* 4687 else if (flags[i] == "-no_path_strip") 4688 oh << " -path_strip"; 4689 else if (flags[i] == "-path_strip") 4690 oh << " -no_path_strip"; 4691 */ 4692 else if (flags[i] == "-no_path_strip" || 4693 flags[i] == "-path_strip") 4694 continue; 4695 else 4696 oh << " " << flags[i]; 4697 } 4698 //if (reset) oh << " -path_strip"; 4699 if (path_strip) 4700 oh << " -no_path_strip"; 4701 else 4702 oh << " -path_strip"; 4703 oh << endl; 4704 4705 cout << oh.str (); 4706 cout << os.str (); 4707 4708 break; 4709 4710 default: 4711 4712 print (ap.mode); 4713 4714 break; 4715 } 4716 4587 4717 switch (ap.mode) 4588 4718 { … … 5680 5810 void Cmt::guess_current_project () 5681 5811 { 5812 if (!m_cmt_context.m_use_projects) return; 5813 5682 5814 Log; 5683 5815 … … 5782 5914 // Use& use = Use::current(); 5783 5915 5916 bool autoconfigure_cmtpath_saved (Me.m_autoconfigure_cmtpath); 5917 Me.m_autoconfigure_cmtpath = false; 5784 5918 bool save_quiet = Me.m_quiet; 5785 5919 Me.m_quiet = true; … … 5788 5922 5789 5923 Me.m_quiet = save_quiet; 5790 5791 Me.m_autoconfigure_cmtpath = true;5924 Me.m_autoconfigure_cmtpath = autoconfigure_cmtpath_saved; 5925 // Me.m_autoconfigure_cmtpath = true; 5792 5926 5793 5927 // CmtSystem::cd (Me.m_current_dir); … … 6797 6931 6798 6932 parse_arguments (ap); 6933 // Copy ap.mode into cmt_context member/instance 6934 set_print_mode (ap.mode); 6799 6935 6800 6936 // configure (); … … 7741 7877 * joined with semi-colons to form one shell command. 7742 7878 */ 7743 void Cmt::print (PrintMode mode )7879 void Cmt::print (PrintMode mode, ostream& out) 7744 7880 { 7745 7881 Use::UsePtrVector& Uses = Use::get_ordered_uses (); … … 7805 7941 if (tag != 0) 7806 7942 { 7807 tag->show (true, cout, "apply_tag ");7943 tag->show (true, out, "apply_tag "); 7808 7944 } 7809 7945 } … … 7826 7962 if (use.m_hidden) continue; 7827 7963 7828 print_context (use, mode, tag );7829 } 7830 } 7831 7832 print_context (Use::current (), mode, tag );7964 print_context (use, mode, tag, out); 7965 } 7966 } 7967 7968 print_context (Use::current (), mode, tag, out); 7833 7969 7834 7970 if (Me.m_debug) … … 7837 7973 } 7838 7974 7839 Symbol::all_print (mode );7975 Symbol::all_print (mode, out); 7840 7976 // Script::all_print (mode); 7841 7977 … … 7850 7986 break; 7851 7987 default : 7852 cout << endl;7988 out << endl; 7853 7989 break; 7854 7990 } … … 7956 8092 7957 8093 //---------------------------------------------------------- 7958 void Cmt::print_context (Use& use, PrintMode mode, const cmt_string& tag )8094 void Cmt::print_context (Use& use, PrintMode mode, const cmt_string& tag, ostream& out) 7959 8095 { 7960 8096 if (use.get_package_name () == "cmt_standalone") return; … … 7988 8124 if (do_root) 7989 8125 { 7990 cout << "setenv " << prefix << "ROOT \"" <<8126 out << "setenv " << prefix << "ROOT \"" << 7991 8127 use.get_full_path () << "\"" << endl; 7992 8128 } … … 7994 8130 if (use.get_package_name () == "CMT") 7995 8131 { 7996 cout << "setenv CMTCONFIG " << system << endl;8132 out << "setenv CMTCONFIG " << system << endl; 7997 8133 } 7998 8134 else … … 8000 8136 if (do_config) 8001 8137 { 8002 cout << "setenv " << prefix << "CONFIG \"" << tag << "\"" << endl;8138 out << "setenv " << prefix << "CONFIG \"" << tag << "\"" << endl; 8003 8139 } 8004 8140 } … … 8008 8144 if (do_root) 8009 8145 { 8010 cout << prefix << "ROOT=\"" <<8146 out << prefix << "ROOT=\"" << 8011 8147 use.get_full_path () << "\"; export " << 8012 8148 prefix << "ROOT" << endl; … … 8015 8151 if (use.get_package_name () == "CMT") 8016 8152 { 8017 cout << "CMTCONFIG=" << system << "; export CMTCONFIG" << endl;8153 out << "CMTCONFIG=" << system << "; export CMTCONFIG" << endl; 8018 8154 } 8019 8155 else … … 8021 8157 if (do_config) 8022 8158 { 8023 cout << prefix << "CONFIG=\"" <<8159 out << prefix << "CONFIG=\"" << 8024 8160 tag << "\"; export " << 8025 8161 prefix << "CONFIG" << endl; … … 8031 8167 if (do_root) 8032 8168 { 8033 cout << "set " << prefix << "ROOT=" <<8169 out << "set " << prefix << "ROOT=" << 8034 8170 CmtSystem::quote (use.get_full_path (), " \t") << endl; 8035 8171 } … … 8037 8173 if (use.get_package_name () == "CMT") 8038 8174 { 8039 cout << "set CMTCONFIG=" << system << endl;8175 out << "set CMTCONFIG=" << system << endl; 8040 8176 } 8041 8177 else … … 8043 8179 if (do_config) 8044 8180 { 8045 cout << "set " << prefix << "CONFIG=" << CmtSystem::quote (tag, " \t") << endl;8181 out << "set " << prefix << "CONFIG=" << CmtSystem::quote (tag, " \t") << endl; 8046 8182 } 8047 8183 } … … 8051 8187 if (do_root) 8052 8188 { 8053 cout << "<variable><name>" << prefix << "ROOT</name>"8054 8189 out << "<variable><name>" << prefix << "ROOT</name>" 8190 << "<value>" << use.get_full_path () << "</value></variable>"; 8055 8191 } 8056 8192 8057 8193 if (use.get_package_name () == "CMT") 8058 8194 { 8059 cout << "<variable><name>CMTCONFIG</name>"8060 8195 out << "<variable><name>CMTCONFIG</name>" 8196 << "<value>" << system << "</value></variable>"; 8061 8197 } 8062 8198 else … … 8064 8200 if (do_config) 8065 8201 { 8066 cout << "<variable><name>" << prefix << "CONFIG</name>"8067 8202 out << "<variable><name>" << prefix << "CONFIG</name>" 8203 << "<value>" << tag << "</value></variable>"; 8068 8204 } 8069 8205 } … … 8074 8210 use.get_package_name () != "CMT") 8075 8211 { 8076 cout << "set " << use.prefix << "ROOT " <<8212 out << "set " << use.prefix << "ROOT " << 8077 8213 CmtSystem::quote (use.get_full_path (), " \t") << endl; 8078 8214 … … 8093 8229 if (use.get_package_name () == "CMT") 8094 8230 { 8095 cout << "set CMTCONFIG " << system << endl;8231 out << "set CMTCONFIG " << system << endl; 8096 8232 } 8097 8233 else … … 8099 8235 if (do_config) 8100 8236 { 8101 cout << "set " << use.prefix << "CONFIG " << CmtSystem::quote (tag, " \t") << endl; 8237 out << "set " << use.prefix << "CONFIG " << CmtSystem::quote (tag, " \t") << endl; 8238 8239 cmt_string name (use.prefix + "CONFIG"); 8240 Symbol* symbol = Symbol::find (name); 8241 if (symbol != 0) 8242 { 8243 symbol->printed = true; 8244 } 8245 if (symbol == 0 || symbol->type != Symbol::SymbolMacro) 8246 { 8247 CmtMessage::warning 8248 (CmtError::get_error_name (CmtError::symbol_not_found) 8249 + ": macro " + name); 8250 } 8102 8251 } 8103 8252 } … … 10333 10482 if (0 == Ordered.size ()) 10334 10483 { 10335 CmtError::set(CmtError::configuration_error, 10336 "No ordered project: " + use->get_info ()); 10337 return; 10484 if (m_cmt_context.m_use_projects) 10485 { 10486 CmtError::set(CmtError::configuration_error, 10487 "No such ordered project: " + use->get_info ()); 10488 return; 10489 } 10490 else 10491 { 10492 use->change_path (path); 10493 } 10338 10494 } 10339 if (name == CmtSystem::get_home_package ()) 10340 use->change_path (path, Ordered[Ordered.size () - 1]); 10341 else if (name == CmtSystem::get_user_context_package ()) 10342 use->change_path (path, Ordered[0]); 10495 else 10496 { 10497 if (name == CmtSystem::get_home_package ()) 10498 use->change_path (path, Ordered[Ordered.size () - 1]); 10499 else if (name == CmtSystem::get_user_context_package ()) 10500 use->change_path (path, Ordered[0]); 10501 } 10343 10502 } 10344 10503 else … … 10370 10529 { 10371 10530 const cmt_string& s = v[i]; 10372 if (s == "") continue;10531 if (s.size () == 0) continue; 10373 10532 10374 10533 if (result.size () != 0) result += separator; 10375 10534 //if (i > 0) result += separator; 10376 result += v[i];10535 result += s; 10377 10536 } 10378 10537 } -
CMT/HEAD/source/cmt_symbol.cxx
r652 r656 15 15 #include "cmt_database.h" 16 16 #include "cmt_log.h" 17 #include "cmt_error.h" 17 18 18 19 // Global inhibitor of any display … … 42 43 const cmt_string clean (const Symbol& symbol, 43 44 const cmt_string& tag_name = ""); 45 46 void filter_path_value (const Symbol& symbol, 47 cmt_string& value, 48 const cmt_string& tag_name = "") const; 49 void filter_path_value (const Symbol& symbol, 50 CmtSystem::cmt_string_vector& value, 51 const cmt_string& tag_name = "") const; 52 inline const bool& get_path_strip () const; 53 inline void set_path_strip (const bool& path_strip); 54 55 PathBuilder (); 56 PathBuilder (bool path_strip); 57 58 private: 59 bool m_path_strip; 44 60 }; 45 61 //------------------------------------------------------------- … … 248 264 } 249 265 266 // 267 // Global cache 268 // 269 namespace 270 { 271 cmt_vmap <cmt_string, cmt_string> cmdoutputs; 272 } 250 273 /** 251 274 … … 285 308 int start = 0; 286 309 310 // static cmt_vmap <cmt_string, cmt_string> cmdoutputs; 311 287 312 for (;;) 288 313 { … … 337 362 // to be applied. The output of the command is then substituted 338 363 364 Symbol::all_set (); 365 339 366 cmt_string result; 340 341 Symbol::all_set (); 342 CmtSystem::execute (command, result); 343 344 /* 345 int pos; 346 pos = result.find ('\n'); 347 if (pos != cmt_string::npos) result.erase (pos); 348 pos = result.find ('\r'); 349 if (pos != cmt_string::npos) result.erase (pos); 350 */ 351 process_cmd_output (result); 352 353 if (Cmt::get_debug ()) 354 { 355 cout << "resolve_value: Executing [" << command << "] to expand a symbol value =>[" 356 << result << "]" << endl; 357 } 358 367 const cmt_string * presult; 368 if (!(presult = cmdoutputs.find (command))) 369 { 370 CmtSystem::execute (command, result); 371 372 process_cmd_output (result); 373 cmdoutputs.add (command, result); 374 if (Cmt::get_debug ()) 375 { 376 cout << "resolve_value: Executing [" << command << "] to expand a symbol value =>[" 377 << result << "]" << endl; 378 } 379 } 380 else 381 { 382 result = *presult; 383 if (Cmt::get_debug ()) 384 { 385 cout << "resolve_value: Found in cache [" << command << "] to expand a symbol value =>[" 386 << result << "]" << endl; 387 } 388 } 389 359 390 text.replace_all (pattern, result); 360 391 … … 378 409 else 379 410 { 411 if (Cmt::get_env_access () || 412 Symbol::std_env_vars ().has (symbol_name)) 413 { 380 414 // Symbol not found. Look for env. variable 381 415 cmt_string value = CmtSystem::getenv (symbol_name); 382 383 416 // When the env. variable is not defined, the replacement is empty 384 417 // thus all $(xxx) ${xxx} %xxx% patterns are always filtered away. 385 418 text.replace_all (pattern, value); 386 419 420 if (Cmt::get_debug ()) 421 { 422 cerr << "resolve_value: getenv (" << symbol_name 423 << ") => " << value << endl; 424 } 387 425 // The substitution will restart from the same place 388 426 // allowing for recursive replacements 389 427 start = begin; 428 } 429 else 430 { 431 if (Cmt::get_debug ()) 432 { 433 cerr << "resolve_value: getenv (" << symbol_name 434 << ") denied" << endl; 435 } 436 CmtError::set (CmtError::warning, 437 "getenv (" + symbol_name + ") denied"); 438 return; 439 } 390 440 } 391 441 } … … 484 534 // to be applied. The output of the command is substituted 485 535 536 Symbol::all_set (); 537 486 538 cmt_string result; 487 488 Symbol::all_set (); 489 CmtSystem::execute (command, result); 490 491 /* 492 int pos; 493 pos = result.find ('\n'); 494 if (pos != cmt_string::npos) result.erase (pos); 495 pos = result.find ('\r'); 496 if (pos != cmt_string::npos) result.erase (pos); 497 */ 498 process_cmd_output (result); 499 500 if (Cmt::get_debug ()) 501 { 502 cout << " Executing [" << command << "] to expand a macro value =>[" 503 << result << "]" << endl; 504 } 505 539 const cmt_string * presult; 540 if (!(presult = cmdoutputs.find (command))) 541 { 542 CmtSystem::execute (command, result); 543 544 process_cmd_output (result); 545 cmdoutputs.add (command, result); 546 if (Cmt::get_debug ()) 547 { 548 cout << "resolve_value_for_macros: Executing [" << command << "] to expand a symbol value =>[" 549 << result << "]" << endl; 550 } 551 } 552 else 553 { 554 result = *presult; 555 if (Cmt::get_debug ()) 556 { 557 cout << "resolve_value_for_macros: Found in cache [" << command << "] to expand a symbol value =>[" 558 << result << "]" << endl; 559 } 560 } 561 506 562 text.replace_all (pattern, result); 507 563 … … 621 677 // to be applied. The output of the command is substituted 622 678 679 Symbol::all_set (); 680 623 681 cmt_string result; 624 625 Symbol::all_set (); 626 CmtSystem::execute (command, result); 627 628 /* 629 int pos; 630 pos = result.find ('\n'); 631 if (pos != cmt_string::npos) result.erase (pos); 632 pos = result.find ('\r'); 633 if (pos != cmt_string::npos) result.erase (pos); 634 */ 635 process_cmd_output (result); 636 637 if (Cmt::get_debug ()) 638 { 639 cout << " Executing [" << command << "] to expand a macro value =>[" 640 << result << "]" << endl; 641 } 642 682 const cmt_string * presult; 683 if (!(presult = cmdoutputs.find (command))) 684 { 685 CmtSystem::execute (command, result); 686 687 process_cmd_output (result); 688 cmdoutputs.add (command, result); 689 if (Cmt::get_debug ()) 690 { 691 cout << "suppress_OS_delimiters: Executing [" << command << "] to expand a symbol value =>[" 692 << result << "]" << endl; 693 } 694 } 695 else 696 { 697 result = *presult; 698 if (Cmt::get_debug ()) 699 { 700 cout << "suppress_OS_delimiters: Found in cache [" << command << "] to expand a symbol value =>[" 701 << result << "]" << endl; 702 } 703 } 704 643 705 text.replace_all (pattern, result); 644 706 … … 692 754 { 693 755 static SetBuilder Set; 694 static PathBuilder Path; 756 static PathBuilder Path (Cmt::get_path_strip ()); 757 //static PathBuilder Path; 695 758 static MacroBuilder Macro; 696 759 static ScriptBuilder Script; … … 913 976 } 914 977 978 //------------------------------------------------------------- 979 Symbol::SymbolMap& Symbol::std_env_vars () 980 { 981 static SymbolMap env_vars; 982 static Symbol std_sym; 983 static bool initialized (false); 984 if (!initialized) 985 { 986 env_vars.add ("SITEROOT", std_sym); 987 env_vars.add ("CMTCONFIG", std_sym); 988 env_vars.add ("CMTBIN", std_sym); 989 env_vars.add ("CMTPATH", std_sym); 990 env_vars.add ("CMTHEADVERSION", std_sym); 991 env_vars.add ("CMTPROJECTPATH", std_sym); 992 env_vars.add ("CMTSITE", std_sym); 993 env_vars.add ("CMTEXTRATAGS", std_sym); 994 env_vars.add ("CMTSTRUCTURINGSTYLE", std_sym); 995 env_vars.add ("CMTHOME", std_sym); 996 env_vars.add ("CMTUSERCONTEXT", std_sym); 997 initialized = true; 998 } 999 return env_vars; 1000 } 1001 915 1002 /** 916 1003 Filter out faulty items of a path-like symbol value … … 1168 1255 1169 1256 //------------------------------------------------------------- 1257 bool Symbol::set_path_strip (const bool& path_strip) 1258 { 1259 // searching for a path symbol 1260 for (int number = 0; number < Symbol::symbol_number (); number++) 1261 { 1262 Symbol& symbol = Symbol::symbol (number); 1263 1264 if (symbol.type == Symbol::SymbolPath) 1265 { 1266 static_cast<PathBuilder*> (symbol.builder)->set_path_strip (path_strip); 1267 return true; 1268 } 1269 } 1270 1271 return false; 1272 } 1273 1274 //------------------------------------------------------------- 1170 1275 int Symbol::is_selected (const cmt_string& name) 1171 1276 { … … 1422 1527 cmt_string value; 1423 1528 1529 if (Cmt::get_env_access ()) 1530 { 1424 1531 for (number = 0; number < Symbol::symbol_number (); number++) 1425 1532 { … … 1433 1540 Symbol::expand (value); 1434 1541 1542 if (Cmt::get_debug ()) 1543 { 1544 cerr << "Symbol::all_set (set)> " << symbol.name << " = " << value << endl; 1545 } 1546 1435 1547 CmtSystem::putenv (symbol.name, value); 1436 1548 } 1549 } 1437 1550 } 1438 1551 … … 1500 1613 } 1501 1614 1615 static PathBuilder* pb (0); 1616 1617 if (Cmt::get_env_access ()) 1618 { 1502 1619 for (number = 0; number < Symbol::symbol_number (); number++) 1503 1620 { … … 1510 1627 { 1511 1628 Symbol::expand (value); 1512 filter_path_value (symbol.name, value); 1629 if (!pb) 1630 pb = static_cast<PathBuilder*> (symbol.builder); 1631 pb->filter_path_value (symbol, value); 1632 //filter_path_value (symbol.name, value); 1513 1633 1514 1634 #ifdef WIN32 … … 1518 1638 if (Cmt::get_debug ()) 1519 1639 { 1520 cerr << "Symbol::all_set -2> " << symbol.name << " = " << value << endl;1640 cerr << "Symbol::all_set (path)> " << symbol.name << " = " << value << endl; 1521 1641 } 1522 1642 … … 1524 1644 } 1525 1645 } 1646 } 1526 1647 1527 1648 running = false; … … 1529 1650 1530 1651 //------------------------------------------------------------- 1531 void Symbol::all_print (PrintMode mode) 1652 void Symbol::all_print (PrintMode mode, ostream& out) 1653 //void Symbol::all_print (PrintMode mode) 1532 1654 { 1533 1655 static SymbolVector& Symbols = symbols (); … … 1550 1672 (symbol.type == SymbolMacro)) 1551 1673 { 1552 if (symbol.print_macro (mode ))1674 if (symbol.print_macro (mode, out)) 1553 1675 { 1554 1676 // cout << endl; … … 1567 1689 (symbol.type == SymbolPath)) 1568 1690 { 1569 if (symbol.print (mode ))1691 if (symbol.print (mode, out)) 1570 1692 { 1571 1693 if (mode == Bat) 1572 1694 { 1573 cout << endl;1695 out << endl; 1574 1696 } 1575 1697 else if (mode == Xml) … … 1579 1701 else 1580 1702 { 1581 cout << endl;1703 out << endl; 1582 1704 } 1583 1705 } … … 1593 1715 static SymbolVector& Symbols = symbols (); 1594 1716 1717 static PathBuilder* pb (0); 1718 1595 1719 int number; 1596 1720 … … 1608 1732 expand (temp); 1609 1733 1610 Symbol::filter_path_value (symbol.name, temp); 1734 if (!pb) 1735 pb = static_cast<PathBuilder*> (symbol.builder); 1736 pb->filter_path_value (symbol, temp); 1737 //Symbol::filter_path_value (symbol.name, temp); 1611 1738 } 1612 1739 } … … 1762 1889 1763 1890 //------------------------------------------------------------- 1764 int Symbol::print (PrintMode mode) 1765 { 1891 int Symbol::print (PrintMode mode, ostream& out) 1892 { 1893 static PathBuilder* pb (0); 1894 1766 1895 int result = 0; 1767 1896 … … 1772 1901 { 1773 1902 expand (temp); 1774 Symbol::filter_path_value (name, temp); 1903 //Symbol::filter_path_value (name, temp); 1904 if (!pb) 1905 pb = static_cast<PathBuilder*> (builder); 1906 pb->filter_path_value (*this, temp); 1775 1907 } 1776 1908 … … 1785 1917 { 1786 1918 case Csh : 1787 if (empty) cout << "unsetenv " << _name;1788 else cout << "setenv " << _name << " \"" << temp << "\"";1789 //else cout << "setenv " << name << " " << CmtSystem::quote (temp, " \t");1919 if (empty) out << "unsetenv " << _name; 1920 else out << "setenv " << _name << " \"" << temp << "\""; 1921 //else out << "setenv " << name << " " << CmtSystem::quote (temp, " \t"); 1790 1922 1791 1923 result = 1; 1792 1924 break; 1793 1925 case Sh : 1794 if (empty) cout << "[ -z ${" << _name << "+CMT} ] || unset " << _name;1795 // if (empty) cout << "unset " << _name;1796 else cout << _name << "=\"" << temp << "\"; export " << _name;1797 //else cout << name << "=" << CmtSystem::quote (temp, " \t") << "; export " << name;1926 if (empty) out << "[ -z ${" << _name << "+CMT} ] || unset " << _name; 1927 // if (empty) out << "unset " << _name; 1928 else out << _name << "=\"" << temp << "\"; export " << _name; 1929 //else out << name << "=" << CmtSystem::quote (temp, " \t") << "; export " << name; 1798 1930 1799 1931 result = 1; … … 1801 1933 case Bat : 1802 1934 temp.replace_all ("/", "\\"); 1803 cout << "set " << _name << "=" << CmtSystem::quote (temp, " \t");1804 // cout << "set " << name << "=" << temp;1935 out << "set " << _name << "=" << CmtSystem::quote (temp, " \t"); 1936 //out << "set " << name << "=" << temp; 1805 1937 result = 1; 1806 1938 break; 1807 1939 case Xml : 1808 cout << "<variable><name>" << _name << "</name>"1940 out << "<variable><name>" << _name << "</name>" 1809 1941 << "<value>" << temp << "</value></variable>"; 1810 1942 result = 1; … … 1816 1948 { 1817 1949 case Csh : 1818 cout << "alias " << name <<1950 out << "alias " << name << 1819 1951 " \"" << temp << "\""; 1820 1952 //CmtSystem::quote (temp, " \t"); … … 1822 1954 break; 1823 1955 case Sh : 1824 cout << "alias " << name <<1956 out << "alias " << name << 1825 1957 "=\"" << temp << "\""; 1826 1958 //"=" << CmtSystem::quote (temp, " \t"); … … 1828 1960 break; 1829 1961 case Bat : 1830 cout << "set " << name <<1962 out << "set " << name << 1831 1963 "=" << CmtSystem::quote (temp, " \t"); 1832 1964 //"=" << temp; … … 1834 1966 break; 1835 1967 case Xml : 1836 cout << "<alias><name>" << name << "</name>"1968 out << "<alias><name>" << name << "</name>" 1837 1969 << "<value>" << temp << "</value></alias>"; 1838 1970 result = 1; … … 1852 1984 { 1853 1985 case Csh : 1854 cout << "if ( -f " << CmtSystem::quote (name, " \t") << ".csh ) then" << endl;1855 cout << " source " << CmtSystem::quote (name, " \t") << ".csh" << endl;1856 cout <<1986 out << "if ( -f " << CmtSystem::quote (name, " \t") << ".csh ) then" << endl; 1987 out << " source " << CmtSystem::quote (name, " \t") << ".csh" << endl; 1988 out << 1857 1989 "if ( $status != 0 ) then\n" 1858 1990 " set cmtsetupstatus=1\n" 1859 1991 "endif\n"; 1860 cout << "endif" << endl;1992 out << "endif" << endl; 1861 1993 result = 1; 1862 1994 break; 1863 1995 case Sh : 1864 cout << "if test -f " << CmtSystem::quote (name, " \t") << ".sh; then" << endl;1865 cout << " . " << CmtSystem::quote (name, " \t") << ".sh" << endl;1866 cout <<1996 out << "if test -f " << CmtSystem::quote (name, " \t") << ".sh; then" << endl; 1997 out << " . " << CmtSystem::quote (name, " \t") << ".sh" << endl; 1998 out << 1867 1999 "if test $? != 0; then\n" 1868 2000 " cmtsetupstatus=1\n" 1869 2001 "fi\n"; 1870 cout << "fi" << endl;2002 out << "fi" << endl; 1871 2003 result = 1; 1872 2004 break; 1873 2005 case Bat : 1874 cout << "call " << CmtSystem::quote (name, " \t");2006 out << "call " << CmtSystem::quote (name, " \t"); 1875 2007 result = 1; 1876 2008 break; 1877 2009 case Xml : 1878 cout << "<script>" << name << "</script>";2010 out << "<script>" << name << "</script>"; 1879 2011 result = 1; 1880 2012 break; … … 2124 2256 SymbolValue& value = value_list.values[selected]; 2125 2257 2126 result += value_list.print (symbol, value, first_definition );2258 result += value_list.print (symbol, value, first_definition, out); 2127 2259 } 2128 2260 … … 2202 2334 else if (temp == "") 2203 2335 { 2204 temp = CmtSystem::getenv (symbol.name); 2336 if (Cmt::get_env_access () || 2337 Symbol::std_env_vars ().has (symbol.name)) 2338 { 2339 temp = CmtSystem::getenv (symbol.name); 2340 if (Cmt::get_debug ()) 2341 { 2342 cerr << "SetBuilder::build> getenv (" << symbol.name 2343 << ") => " << temp << endl; 2344 } 2345 } 2346 else 2347 { 2348 if (Cmt::get_debug ()) 2349 { 2350 cerr << "SetBuilder::build> getenv (" << symbol.name 2351 << ") denied" << endl; 2352 } 2353 CmtError::set (CmtError::warning, 2354 "getenv (" + symbol.name + ") denied"); 2355 return ""; 2356 } 2205 2357 } 2206 2358 … … 2263 2415 } 2264 2416 2417 namespace 2418 { 2419 int find_path_entry (const CmtSystem::cmt_string_vector& items, const cmt_string& value) 2420 { 2421 // if (value.size () == 0) return true; 2422 2423 static cmt_vmap <cmt_string, cmt_string> realpaths; 2424 2425 cmt_string rvalue; 2426 const cmt_string * prvalue; 2427 2428 if (!(prvalue = realpaths.find (value))) 2429 { 2430 // if (!CmtSystem::realpath_ (value, rvalue)) 2431 //{ 2432 rvalue = value; 2433 CmtSystem::compress_path (rvalue); 2434 //} 2435 prvalue = &rvalue; 2436 realpaths.add (value, rvalue); 2437 // cerr << "realpaths.add: " << value << " , " << rvalue << endl; 2438 } 2439 2440 for (int i = 0; i < items.size (); i++) 2441 { 2442 const cmt_string& item = items[i]; 2443 if (item.size () == 0) continue; 2444 cmt_string ritem; 2445 const cmt_string * pritem; 2446 2447 if (!(pritem = realpaths.find (item))) 2448 { 2449 //if (!CmtSystem::realpath_ (item, ritem)) 2450 //{ 2451 ritem = item; 2452 CmtSystem::compress_path (ritem); 2453 //} 2454 pritem = &ritem; 2455 realpaths.add (item, ritem); 2456 // cerr << "realpaths.add: " << item << " , " << ritem << endl; 2457 } 2458 if (*pritem == *prvalue) 2459 { 2460 return i; 2461 } 2462 } 2463 2464 return -1; 2465 } 2466 2467 } 2468 /* 2265 2469 static bool find_path_entry (const CmtSystem::cmt_string_vector& items, const cmt_string& value) 2470 { 2471 if (value.size () == 0) return true; 2472 2473 static cmt_vmap <cmt_string, cmt_string> realpaths; 2474 2475 cmt_string rvalue; 2476 const cmt_string * prvalue; 2477 2478 if (!(prvalue = realpaths.find (value))) 2479 { 2480 // if (!CmtSystem::realpath_ (value, rvalue)) 2481 //{ 2482 rvalue = value; 2483 CmtSystem::compress_path (rvalue); 2484 //} 2485 prvalue = &rvalue; 2486 realpaths.add (value, rvalue); 2487 // cerr << "realpaths.add: " << value << " , " << rvalue << endl; 2488 } 2489 2490 for (int i = 0; i < items.size (); i++) 2491 { 2492 const cmt_string& item = items[i]; 2493 if (item.size () == 0) continue; 2494 cmt_string ritem; 2495 const cmt_string * pritem; 2496 2497 if (!(pritem = realpaths.find (item))) 2498 { 2499 //if (!CmtSystem::realpath_ (item, ritem)) 2500 //{ 2501 ritem = item; 2502 CmtSystem::compress_path (ritem); 2503 //} 2504 pritem = &ritem; 2505 realpaths.add (item, ritem); 2506 // cerr << "realpaths.add: " << item << " , " << ritem << endl; 2507 } 2508 if (*pritem == *prvalue) 2509 { 2510 return true; 2511 } 2512 } 2513 2514 return false; 2515 } 2516 */ 2517 /* 2518 static bool find_path_entry (const cmt_string& paths, const cmt_string& value) 2266 2519 { 2267 2520 static const cmt_string path_separator = CmtSystem::path_separator (); 2268 2521 static cmt_vmap <cmt_string, cmt_string> realpaths; 2269 2270 if (value.size () == 0) return true;2271 2522 2272 2523 cmt_string rvalue; … … 2285 2536 } 2286 2537 2287 //CmtSystem::cmt_string_vector items;2288 //CmtSystem::split (paths, path_separator, items);2538 CmtSystem::cmt_string_vector items; 2539 CmtSystem::split (paths, path_separator, items); 2289 2540 2290 2541 bool found = false; … … 2293 2544 { 2294 2545 const cmt_string& item = items[i]; 2295 if (item.size () == 0) continue;2296 2546 cmt_string ritem; 2297 2547 const cmt_string * pritem; … … 2317 2567 return (found); 2318 2568 } 2319 2320 static bool find_path_entry (const cmt_string& paths, const cmt_string& value) 2321 { 2322 static const cmt_string path_separator = CmtSystem::path_separator (); 2323 static cmt_vmap <cmt_string, cmt_string> realpaths; 2324 2325 cmt_string rvalue; 2326 const cmt_string * prvalue; 2327 2328 if (!(prvalue = realpaths.find (value))) 2329 { 2330 if (!CmtSystem::realpath_ (value, rvalue)) 2331 { 2332 rvalue = value; 2333 CmtSystem::compress_path (rvalue); 2334 } 2335 prvalue = &rvalue; 2336 realpaths.add (value, rvalue); 2337 // cerr << "realpaths.add: " << value << " , " << rvalue << endl; 2338 } 2339 2340 CmtSystem::cmt_string_vector items; 2341 CmtSystem::split (paths, path_separator, items); 2342 2343 bool found = false; 2344 2345 for (int i = 0; i < items.size (); i++) 2346 { 2347 const cmt_string& item = items[i]; 2348 cmt_string ritem; 2349 const cmt_string * pritem; 2350 2351 if (!(pritem = realpaths.find (item))) 2352 { 2353 if (!CmtSystem::realpath_ (item, ritem)) 2354 { 2355 ritem = item; 2356 CmtSystem::compress_path (ritem); 2357 } 2358 pritem = &ritem; 2359 realpaths.add (item, ritem); 2360 // cerr << "realpaths.add: " << item << " , " << ritem << endl; 2361 } 2362 if (*pritem == *prvalue) 2363 { 2364 found = true; 2365 break; 2366 } 2367 } 2368 2369 return (found); 2569 */ 2570 //------------------------------------------------------------- 2571 PathBuilder::PathBuilder () 2572 : m_path_strip (false) 2573 { 2574 } 2575 2576 //------------------------------------------------------------- 2577 PathBuilder::PathBuilder (bool path_strip) 2578 { 2579 PathBuilder (); 2580 m_path_strip = path_strip; 2370 2581 } 2371 2582 … … 2401 2612 level++; 2402 2613 2614 if (Cmt::get_env_access () || 2615 Symbol::std_env_vars ().has (symbol.name)) 2616 { 2617 //temp = CmtSystem::getenv (symbol.name); 2403 2618 CmtSystem::split (CmtSystem::getenv (symbol.name), path_separator, temp_vector); 2404 //temp = CmtSystem::getenv (symbol.name); 2619 filter_path_value (symbol, temp_vector); 2620 if (Cmt::get_debug ()) 2621 { 2622 cmt_string temp_txt; 2623 Cmt::vector_to_string (temp_vector, path_separator, temp_txt); 2624 cerr << "PathBuilder::build> getenv (" << symbol.name 2625 << ") => " << temp_txt << endl; 2626 } 2627 } 2628 else 2629 { 2630 if (Cmt::get_debug ()) 2631 { 2632 cerr << "PathBuilder::build> getenv (" << symbol.name 2633 << ") denied" << endl; 2634 } 2635 CmtError::set (CmtError::warning, 2636 "getenv (" + symbol.name + ") denied"); 2637 return ""; 2638 } 2405 2639 2406 2640 bool first_definition = true; … … 2442 2676 CmtSystem::split (new_value, path_separator, temp_vector); 2443 2677 //temp = new_value; 2678 filter_path_value (symbol, temp_vector); 2444 2679 } 2445 2680 … … 2451 2686 CmtSystem::split (new_value, path_separator, new_value_vector); 2452 2687 for (int i = 0; i < new_value_vector.size (); i++) 2453 if (!find_path_entry (temp_vector, new_value_vector[i])) 2454 //if (!find_path_entry (temp, new_value)) 2455 { 2456 temp_vector.push_back (new_value_vector[i]); 2457 /* 2458 if (temp != "") temp += path_separator; 2459 2460 temp += new_value; 2461 */ 2462 } 2688 { 2689 if (new_value_vector[i].size () == 0) continue; 2690 int j = find_path_entry (temp_vector, new_value_vector[i]); 2691 if (j < 0) 2692 { 2693 temp_vector.push_back (new_value_vector[i]); 2694 } 2695 else if (j < temp_vector.size () - 1) 2696 { 2697 temp_vector [j] = ""; 2698 temp_vector.push_back (new_value_vector[i]); 2699 } 2700 } 2463 2701 } 2464 2702 … … 2473 2711 for (int i = temp_vector.size () - 1; i > n - 1; i--) 2474 2712 temp_vector [i] = temp_vector [i - n]; 2713 for (int i = 0; i < n; i++) 2714 temp_vector [i] = ""; 2475 2715 for (int i = 0; i < new_value_vector.size (); i++) 2476 if (!find_path_entry (temp_vector, new_value_vector[i]))2477 //if (!find_path_entry (temp, new_value))2478 {2479 temp_vector [i] = new_value_vector[i];2480 /*2481 previous_temp = temp;2482 temp = new_value;2483 if (previous_temp != "") temp += path_separator;2484 temp += previous_temp;2485 */2486 }2487 else2488 temp_vector [i] = "";2716 { 2717 if (new_value_vector[i].size () == 0) continue; 2718 int j = find_path_entry (temp_vector, new_value_vector[i]); 2719 if (j < 0) 2720 { 2721 temp_vector [i] = new_value_vector[i]; 2722 } 2723 else if (j >= n) 2724 { 2725 temp_vector [i] = new_value_vector[i]; 2726 temp_vector [j] = ""; 2727 } 2728 } 2489 2729 } 2490 2730 … … 2614 2854 2615 2855 level--; 2616 2856 /* 2617 2857 for (;;) 2618 2858 { … … 2637 2877 temp.replace_all ("::", ":"); 2638 2878 temp.replace_all (";;", ";"); 2639 2879 */ 2640 2880 return (temp); 2641 2881 } … … 2767 3007 2768 3008 return (temp); 3009 } 3010 3011 //------------------------------------------------------------- 3012 void PathBuilder::filter_path_value (const Symbol& symbol, 3013 CmtSystem::cmt_string_vector& value, 3014 const cmt_string& /* tag_name */) const 3015 { 3016 static cmt_regexp reg ("[$%`]"); 3017 3018 cmt_vector<int> path (value.size ()); 3019 int n (0); 3020 3021 for (int j = 0; j < value.size (); j++) 3022 { 3023 const cmt_string& v = value[j]; 3024 bool exists (false); 3025 for (int i = 0; i < j; i++) 3026 { 3027 if (value[i] == v) 3028 { 3029 exists = true; 3030 break; 3031 } 3032 } 3033 if (!exists) 3034 { 3035 if (m_path_strip) 3036 { 3037 if (!reg.match (v)) 3038 { 3039 if (!CmtSystem::test_directory (v)) 3040 { 3041 CmtMessage::verbose ("Non-existent directory " + v + " in " + symbol.name + " skipped"); 3042 continue; 3043 } 3044 } 3045 else 3046 { 3047 if (CmtMessage::active (Verbose)) 3048 { 3049 CmtMessage::warning ("Unresolved directory name " + v + " in " + symbol.name); 3050 } 3051 } 3052 } 3053 else 3054 { 3055 if (CmtMessage::active (Verbose)) 3056 if (!reg.match (v) && 3057 !CmtSystem::test_directory (v)) 3058 { 3059 CmtMessage::warning ("Non-existent directory " + v + " in " + symbol.name); 3060 } 3061 } 3062 path[n++] = j; 3063 } 3064 } 3065 3066 for (int i = 0; i < n; i++) 3067 if (i != path[i]) value[i] = value[path[i]]; 3068 3069 value.resize (n); 3070 } 3071 3072 //------------------------------------------------------------- 3073 void PathBuilder::filter_path_value (const Symbol& symbol, 3074 cmt_string& value, 3075 const cmt_string& tag_name) const 3076 { 3077 static cmt_string ps (CmtSystem::path_separator ()); 3078 CmtSystem::cmt_string_vector paths; 3079 3080 CmtSystem::split (value, ps, paths); 3081 filter_path_value (symbol, paths, tag_name); 3082 Cmt::vector_to_string (paths, ps, value); 3083 } 3084 3085 //------------------------------------------------------------- 3086 inline const bool& PathBuilder::get_path_strip () const 3087 { 3088 return m_path_strip; 3089 } 3090 3091 //------------------------------------------------------------- 3092 inline void PathBuilder::set_path_strip (const bool& path_strip) 3093 { 3094 m_path_strip = path_strip; 2769 3095 } 2770 3096 … … 3275 3601 int SymbolValueList::print (const Symbol& symbol, 3276 3602 const SymbolValue& value, 3277 bool& first_definition) const 3603 bool& first_definition, 3604 ostream& out) const 3278 3605 { 3279 3606 int result (0); 3280 3281 //if (use->get_package_name () == "CMT") return result;3282 3607 3283 3608 cmt_string discarded_text; 3284 3609 cmt_string define_text; 3285 3610 ActionType action = Cmt::get_action (); 3611 3612 static PathBuilder* pb (0); 3613 cmt_string rvalue (value.text); 3286 3614 3287 3615 switch (command_type) … … 3306 3634 case CommandMacroRemoveAllRegexp : 3307 3635 //case CommandAction : 3308 if (value.text == "") return result; 3636 if (value.text.size () == 0) return result; 3637 break; 3638 } 3639 3640 CmtError::code code (CmtError::ok); 3641 cmt_string msg, n; 3642 int exec_err (0); 3643 3644 switch (command_type) 3645 { 3646 case CommandSet : 3647 case CommandSetAppend : 3648 case CommandSetPrepend : 3649 case CommandSetRemove : 3650 case CommandSetRemoveRegexp : 3651 3652 if (CmtError::has_pending_error ()) 3653 { 3654 code = CmtError::get_last_error_code (); 3655 msg = CmtError::get_last_error (); 3656 exec_err = CmtError::get_last_execution_error (); 3657 n = CmtError::get_error_name (code); 3658 CmtError::clear (); 3659 } 3660 resolve_value_for_macros (rvalue); 3661 if (CmtError::get_last_error_code () != CmtError::warning) 3662 { 3663 if (CmtError::has_pending_error ()) 3664 { 3665 CmtError::print (); 3666 CmtError::clear (); 3667 } 3668 if (CmtError::ok != code) 3669 { 3670 // restore error occurred before value expansion 3671 CmtError::set (code, 3672 (msg.replace (n + ": ", cmt_string ("")), msg), 3673 exec_err); 3674 } 3675 if (CommandSet != command_type && 3676 rvalue.size () == 0) 3677 return result; 3678 } 3679 else 3680 { 3681 if (CmtMessage::active (Verbose)) 3682 CmtError::print (); 3683 CmtError::clear (); 3684 if (CmtError::ok != code) 3685 { 3686 // restore error occurred before value expansion 3687 CmtError::set (code, 3688 (msg.replace (n + ": ", cmt_string ("")), msg), 3689 exec_err); 3690 } 3691 // Ignore the error, keep the value unresolved 3692 rvalue = value.text; 3693 } 3694 3695 break; 3696 3697 //case CommandAlias : 3698 case CommandPath : 3699 case CommandPathAppend : 3700 case CommandPathPrepend : 3701 case CommandPathRemove : 3702 case CommandPathRemoveRegexp : 3703 //case CommandMacroPrepend : 3704 //case CommandMacro : 3705 //case CommandMacroAppend : 3706 //case CommandMacroRemove : 3707 //case CommandMacroRemoveRegexp : 3708 //case CommandMacroRemoveAll : 3709 //case CommandMacroRemoveAllRegexp : 3710 //case CommandAction : 3711 3712 if (!pb) 3713 pb = static_cast<PathBuilder*> (symbol.builder); 3714 if (pb->get_path_strip ()) 3715 { 3716 /* 3717 CmtError::code code (CmtError::ok); 3718 cmt_string msg, n; 3719 int exec_err (0); 3720 */ 3721 if (CmtError::has_pending_error ()) 3722 { 3723 code = CmtError::get_last_error_code (); 3724 msg = CmtError::get_last_error (); 3725 exec_err = CmtError::get_last_execution_error (); 3726 n = CmtError::get_error_name (code); 3727 CmtError::clear (); 3728 } 3729 resolve_value (rvalue); 3730 if (CmtError::get_last_error_code () != CmtError::warning) 3731 { 3732 if (CmtError::has_pending_error ()) 3733 { 3734 CmtError::print (); 3735 CmtError::clear (); 3736 } 3737 if (CmtError::ok != code) 3738 { 3739 // restore error occurred before value expansion 3740 CmtError::set (code, 3741 (msg.replace (n + ": ", cmt_string ("")), msg), 3742 exec_err); 3743 } 3744 if (CommandPath != command_type && 3745 rvalue.size () == 0) 3746 return result; 3747 } 3748 else 3749 { 3750 if (CommandPathRemove == command_type || 3751 CommandPathRemoveRegexp == command_type) 3752 { 3753 // This means that the value is not resolved via symbols 3754 // and, possibly, standard environment variables and 3755 // * either has no effect on the path at all, 3756 // or 3757 // * there should be similar contribution from 3758 // and, hence, we should get the same error with 3759 // CommandPath, CommandPathAppend, or CommandPathPrepend 3760 // Either way, we can ignore this error. 3761 3762 if (CmtMessage::active (Verbose)) 3763 CmtError::print (); 3764 CmtError::clear (); 3765 if (CmtError::ok != code) 3766 { 3767 // restore error occurred before value expansion 3768 CmtError::set (code, 3769 (msg.replace (n + ": ", cmt_string ("")), msg), 3770 exec_err); 3771 } 3772 } 3773 else if (CmtError::ok != code) 3774 { 3775 // print error occurred before value expansion 3776 CmtMessage::error (msg); 3777 } 3778 // We keep CmtError::warning to indicate that 3779 // we could not resolve path 3780 // (without referencing the environment) 3781 // and strip path of non-existent directories 3782 // 3783 rvalue = value.text; 3784 } 3785 } 3786 else // (!pb->get_path_strip ()) 3787 { 3788 if (CmtError::has_pending_error ()) 3789 { 3790 code = CmtError::get_last_error_code (); 3791 msg = CmtError::get_last_error (); 3792 exec_err = CmtError::get_last_execution_error (); 3793 n = CmtError::get_error_name (code); 3794 CmtError::clear (); 3795 } 3796 resolve_value_for_macros (rvalue); 3797 if (CmtError::get_last_error_code () != CmtError::warning) 3798 { 3799 if (CmtError::has_pending_error ()) 3800 { 3801 CmtError::print (); 3802 CmtError::clear (); 3803 } 3804 if (CmtError::ok != code) 3805 { 3806 // restore error occurred before value expansion 3807 CmtError::set (code, 3808 (msg.replace (n + ": ", cmt_string ("")), msg), 3809 exec_err); 3810 } 3811 if (CommandPath != command_type && 3812 rvalue.size () == 0) 3813 return result; 3814 } 3815 else 3816 { 3817 if (CmtMessage::active (Verbose)) 3818 CmtError::print (); 3819 CmtError::clear (); 3820 if (CmtError::ok != code) 3821 { 3822 // restore error occurred before value expansion 3823 CmtError::set (code, 3824 (msg.replace (n + ": ", cmt_string ("")), msg), 3825 exec_err); 3826 } 3827 // Ignore the error, keep the value unresolved 3828 rvalue = value.text; 3829 } 3830 } 3831 3309 3832 break; 3310 3833 } … … 3317 3840 3318 3841 if (CmtMessage::active (Verbose)) 3319 cout << "# Package " << (use != 0 ? use->get_package_name () + " " + use->version : ""); 3320 /* 3321 if (use != 0) 3322 { 3323 cout << use->get_package_name () << " " << use->version; 3324 } 3325 */ 3842 out << "# Package " << (use ? use->get_package_name () + " " + use->version : ""); 3326 3843 3327 3844 switch (command_type) … … 3329 3846 case CommandSet : 3330 3847 if (CmtMessage::active (Verbose)) 3331 cout << " " << define_text << " set " << symbol.name << " as " << endl;3332 // cout << " " << define_text << " set " << symbol.name << " as ";3333 cout << "set " << symbol.name;3848 out << " " << define_text << " set " << symbol.name << " as " << endl; 3849 // out << " " << define_text << " set " << symbol.name << " as "; 3850 out << "set " << symbol.name; 3334 3851 first_definition = false; 3335 3852 result = 1; … … 3337 3854 case CommandSetAppend : 3338 3855 if (CmtMessage::active (Verbose)) 3339 cout << " appends to set " << symbol.name << " : " << endl;3340 // cout << " appends to set " << symbol.name << " : ";3341 cout << "set_append " << symbol.name;3856 out << " appends to set " << symbol.name << " : " << endl; 3857 // out << " appends to set " << symbol.name << " : "; 3858 out << "set_append " << symbol.name; 3342 3859 result = 1; 3343 3860 break; 3344 3861 case CommandSetPrepend : 3345 3862 if (CmtMessage::active (Verbose)) 3346 cout << " prepends to set " << symbol.name << " : " << endl;3347 // cout << " prepends to set " << symbol.name << " : ";3348 cout << "set_prepend " << symbol.name;3863 out << " prepends to set " << symbol.name << " : " << endl; 3864 // out << " prepends to set " << symbol.name << " : "; 3865 out << "set_prepend " << symbol.name; 3349 3866 result = 1; 3350 3867 break; 3351 3868 case CommandSetRemove : 3352 3869 if (CmtMessage::active (Verbose)) 3353 cout << " removes from set " << symbol.name << " : " << endl;3354 // cout << " removes from set " << symbol.name << " : ";3355 cout << "set_remove " << symbol.name;3870 out << " removes from set " << symbol.name << " : " << endl; 3871 // out << " removes from set " << symbol.name << " : "; 3872 out << "set_remove " << symbol.name; 3356 3873 result = 1; 3357 3874 break; 3358 3875 case CommandSetRemoveRegexp : 3359 3876 if (CmtMessage::active (Verbose)) 3360 cout << " removes RE from set " << symbol.name << " : " << endl;3361 // cout << " removes RE from set " << symbol.name << " : ";3362 cout << "set_remove_regexp " << symbol.name;3877 out << " removes RE from set " << symbol.name << " : " << endl; 3878 // out << " removes RE from set " << symbol.name << " : "; 3879 out << "set_remove_regexp " << symbol.name; 3363 3880 result = 1; 3364 3881 break; 3365 3882 case CommandAlias : 3366 3883 if (CmtMessage::active (Verbose)) 3367 cout << " " << define_text << " alias " << symbol.name << endl;3368 // cout << " " << define_text << " alias " << symbol.name << " as ";3369 cout << "alias " << symbol.name;3884 out << " " << define_text << " alias " << symbol.name << endl; 3885 // out << " " << define_text << " alias " << symbol.name << " as "; 3886 out << "alias " << symbol.name; 3370 3887 first_definition = false; 3371 3888 result = 1; 3372 3889 break; 3373 3890 case CommandPath : 3374 3891 if (CmtMessage::active (Verbose)) 3375 cout << " " << define_text << " path " << symbol.name << endl; 3376 // cout << " " << define_text << " path " << symbol.name << " as "; 3377 cout << "path " << symbol.name; 3892 out << " " << define_text << " path " << symbol.name << endl; 3893 // out << " " << define_text << " path " << symbol.name << " as "; 3894 pb->filter_path_value (symbol, rvalue); 3895 3896 if (Cmt::get_debug ()) 3897 { 3898 cerr << "|SymbolValueList::print> path " << symbol.name 3899 << " " << value.text << " => " << rvalue << endl; 3900 } 3901 3902 out << "path " << symbol.name; 3378 3903 first_definition = false; 3379 3904 result = 1; … … 3381 3906 case CommandPathAppend : 3382 3907 if (CmtMessage::active (Verbose)) 3383 cout << " appends to path " << symbol.name << endl; 3384 // cout << " appends to path " << symbol.name << " : "; 3385 cout << "path_append " << symbol.name; 3908 out << " appends to path " << symbol.name << endl; 3909 // out << " appends to path " << symbol.name << " : "; 3910 pb->filter_path_value (symbol, rvalue); 3911 3912 if (Cmt::get_debug ()) 3913 { 3914 cerr << "|SymbolValueList::print> path_append " << symbol.name 3915 << " " << value.text << " => " << rvalue << endl; 3916 } 3917 3918 if (rvalue.size () == 0) return result; 3919 out << "path_append " << symbol.name; 3386 3920 result = 1; 3387 3921 break; 3388 3922 case CommandPathPrepend : 3389 3923 if (CmtMessage::active (Verbose)) 3390 cout << " prepends to path " << symbol.name << " : " << endl; 3391 // cout << " prepends to path " << symbol.name << " : "; 3392 cout << "path_prepend " << symbol.name; 3924 out << " prepends to path " << symbol.name << " : " << endl; 3925 // out << " prepends to path " << symbol.name << " : "; 3926 pb->filter_path_value (symbol, rvalue); 3927 3928 if (Cmt::get_debug ()) 3929 { 3930 cerr << "|SymbolValueList::print> path_prepend " << symbol.name 3931 << " " << value.text << " => " << rvalue << endl; 3932 } 3933 3934 if (rvalue.size () == 0) return result; 3935 out << "path_prepend " << symbol.name; 3393 3936 result = 1; 3394 3937 break; 3395 3938 case CommandPathRemove : 3396 3939 if (CmtMessage::active (Verbose)) 3397 cout << " removes from path " << symbol.name << " : " << endl; 3398 // cout << " removes from path " << symbol.name << " : "; 3399 cout << "path_remove " << symbol.name; 3940 out << " removes from path " << symbol.name << " : " << endl; 3941 // out << " removes from path " << symbol.name << " : "; 3942 3943 if (Cmt::get_debug ()) 3944 { 3945 cerr << "|SymbolValueList::print> path_remove " << symbol.name 3946 << " " << value.text << " => " << rvalue << endl; 3947 } 3948 3949 out << "path_remove " << symbol.name; 3400 3950 result = 1; 3401 3951 break; 3402 3952 case CommandPathRemoveRegexp : 3403 3953 if (CmtMessage::active (Verbose)) 3404 cout << " removes RE from path " << symbol.name << " : " << endl; 3405 // cout << " removes RE from path " << symbol.name << " : "; 3406 cout << "path_remove_regexp " << symbol.name; 3954 out << " removes RE from path " << symbol.name << " : " << endl; 3955 // out << " removes RE from path " << symbol.name << " : "; 3956 3957 if (Cmt::get_debug ()) 3958 { 3959 cerr << "|SymbolValueList::print> path_remove_regexp " << symbol.name 3960 << " " << value.text << " => " << rvalue << endl; 3961 } 3962 3963 out << "path_remove_regexp " << symbol.name; 3407 3964 result = 1; 3408 3965 break; 3409 3966 case CommandMacro : 3410 3967 if (CmtMessage::active (Verbose)) 3411 cout << " " << define_text << " macro " << symbol.name << " as " << endl;3412 // cout << " " << define_text << " macro " << symbol.name << " as ";3413 cout << "macro " << symbol.name;3968 out << " " << define_text << " macro " << symbol.name << " as " << endl; 3969 // out << " " << define_text << " macro " << symbol.name << " as "; 3970 out << "macro " << symbol.name; 3414 3971 result = 1; 3415 3972 break; 3416 3973 case CommandMacroPrepend : 3417 3974 if (CmtMessage::active (Verbose)) 3418 cout << " prepends to macro " << symbol.name << " : " << endl;3419 // cout << " prepends to macro " << symbol.name << " : ";3420 cout << "macro_prepend " << symbol.name;3975 out << " prepends to macro " << symbol.name << " : " << endl; 3976 // out << " prepends to macro " << symbol.name << " : "; 3977 out << "macro_prepend " << symbol.name; 3421 3978 result = 1; 3422 3979 break; 3423 3980 case CommandMacroAppend : 3424 3981 if (CmtMessage::active (Verbose)) 3425 cout << " appends to macro " << symbol.name << " : " << endl;3426 // cout << " appends to macro " << symbol.name << " : ";3427 cout << "macro_append " << symbol.name;3982 out << " appends to macro " << symbol.name << " : " << endl; 3983 // out << " appends to macro " << symbol.name << " : "; 3984 out << "macro_append " << symbol.name; 3428 3985 result = 1; 3429 3986 break; 3430 3987 case CommandMacroRemove : 3431 3988 if (CmtMessage::active (Verbose)) 3432 cout << " remove from macro " << symbol.name << " : " << endl;3433 // cout << " remove from macro " << symbol.name << " : ";3434 cout << "macro_remove " << symbol.name;3989 out << " remove from macro " << symbol.name << " : " << endl; 3990 // out << " remove from macro " << symbol.name << " : "; 3991 out << "macro_remove " << symbol.name; 3435 3992 result = 1; 3436 3993 break; 3437 3994 case CommandMacroRemoveRegexp : 3438 3995 if (CmtMessage::active (Verbose)) 3439 cout << " remove RE from macro " << symbol.name << " : " << endl;3440 // cout << " remove RE from macro " << symbol.name << " : ";3441 cout << "macro_remove_regexp " << symbol.name;3996 out << " remove RE from macro " << symbol.name << " : " << endl; 3997 // out << " remove RE from macro " << symbol.name << " : "; 3998 out << "macro_remove_regexp " << symbol.name; 3442 3999 result = 1; 3443 4000 break; 3444 4001 case CommandMacroRemoveAll : 3445 4002 if (CmtMessage::active (Verbose)) 3446 cout << " remove all from macro " << symbol.name << " : " << endl;3447 // cout << " remove all from macro " << symbol.name << " : ";3448 cout << "macro_remove_all " << symbol.name;4003 out << " remove all from macro " << symbol.name << " : " << endl; 4004 // out << " remove all from macro " << symbol.name << " : "; 4005 out << "macro_remove_all " << symbol.name; 3449 4006 result = 1; 3450 4007 break; 3451 4008 case CommandMacroRemoveAllRegexp : 3452 4009 if (CmtMessage::active (Verbose)) 3453 cout << " remove all RE from macro " << symbol.name << " : " << endl;3454 // cout << " remove all RE from macro " << symbol.name << " : ";3455 cout << "macro_remove_all_regexp " << symbol.name;4010 out << " remove all RE from macro " << symbol.name << " : " << endl; 4011 // out << " remove all RE from macro " << symbol.name << " : "; 4012 out << "macro_remove_all_regexp " << symbol.name; 3456 4013 result = 1; 3457 4014 break; 3458 4015 case CommandSetupScript : 3459 4016 if (CmtMessage::active (Verbose)) 3460 cout << " " << define_text << " setup script " << symbol.name << endl;3461 // cout << " " << define_text << " action " << symbol.name << " as ";3462 cout << "setup_script" /* << symbol.name */;4017 out << " " << define_text << " setup script " << symbol.name << endl; 4018 // out << " " << define_text << " action " << symbol.name << " as "; 4019 out << "setup_script" /* << symbol.name */; 3463 4020 first_definition = false; 3464 4021 result = 1; … … 3466 4023 /* 3467 4024 case CommandAction : 3468 cout << " " << define_text << " action " << symbol.name << " as ";4025 out << " " << define_text << " action " << symbol.name << " as "; 3469 4026 first_definition = false; 3470 4027 break; … … 3472 4029 } 3473 4030 3474 cout << " " << CmtSystem::quote (value.text, " \t"); 3475 // cout << "'" << value.text << "'"; 4031 out << " " << CmtSystem::quote (rvalue, " \t"); 4032 // out << " " << CmtSystem::quote (value.text, " \t"); 4033 // out << "'" << value.text << "'"; 3476 4034 3477 4035 /* … … 3481 4039 (selected_tag == Tag::get_default ())) 3482 4040 { 3483 cout << " for default tag";4041 out << " for default tag"; 3484 4042 } 3485 4043 else 3486 4044 { 3487 cout << " for tag '" << selected_tag->get_name () << "'";4045 out << " for tag '" << selected_tag->get_name () << "'"; 3488 4046 } 3489 4047 */ 3490 4048 3491 cout << endl;3492 // cout << discarded_text << endl;4049 out << endl; 4050 // out << discarded_text << endl; 3493 4051 return result; 3494 4052 } … … 3547 4105 else 3548 4106 { 4107 if (Cmt::get_env_access () || 4108 Symbol::std_env_vars ().has (name)) 4109 { 3549 4110 s = CmtSystem::getenv (name); 4111 if (Cmt::get_debug ()) 4112 { 4113 cerr << "Symbol::get_env_value> getenv (" << name 4114 << ") => " << s << endl; 4115 } 4116 } 4117 else 4118 { 4119 if (Cmt::get_debug ()) 4120 { 4121 cerr << "Symbol::get_env_value> getenv (" << name 4122 << ") denied" << endl; 4123 } 4124 CmtError::set (CmtError::warning, 4125 "getenv (" + name + ") denied"); 4126 return (s); 4127 } 3550 4128 } 3551 4129 -
CMT/HEAD/source/cmt_symbol.h
r588 r656 34 34 int select_last () const; 35 35 void show (const Symbol& symbol, const SymbolValue& value, bool& first_definition) const; 36 int print (const Symbol& symbol, const SymbolValue& value, bool& first_definition ) const;36 int print (const Symbol& symbol, const SymbolValue& value, bool& first_definition, ostream& out = cout) const; 37 37 38 38 CommandType command_type; … … 89 89 90 90 static void all_set (); 91 static void all_print (PrintMode mode); 91 static void all_print (PrintMode mode, ostream& out = cout); 92 //static void all_print (PrintMode mode); 92 93 static void all_print_clean (PrintMode mode); 93 94 static void check_all_paths (); … … 96 97 static SymbolVector& symbols (); 97 98 static SymbolMap& symbol_map (); 99 static SymbolMap& std_env_vars (); 98 100 static Symbol& symbol (int index); 99 101 static void clear_all (); … … 107 109 108 110 static bool get_inhibit_display (); 111 static bool set_path_strip (const bool& path_strip); 109 112 110 113 public: … … 118 121 119 122 int print_clean (PrintMode mode); 120 int print (PrintMode mode); 123 int print (PrintMode mode, ostream& out = cout); 124 //int print (PrintMode mode); 121 125 cmt_string build_macro_value (bool display_it = false) const; 122 126 int print_macro (PrintMode mode, ostream& out = cout) const; -
CMT/HEAD/source/cmt_use.cxx
r655 r656 1934 1934 { 1935 1935 cout << "|Use::change_path> path: " << new_path 1936 << " :project: " << (project ? project->get_cmtpath () : "0")1937 << " : " << get_info () << endl;1936 << " project: " << (project ? project->get_cmtpath () : "0") 1937 << " use: " << get_info () << endl; 1938 1938 } 1939 1939 … … 1978 1978 { 1979 1979 cout << "<Use::change_path| real_path: " << real_path 1980 << " :m_project: " << (m_project ? m_project->get_cmtpath () : "0")1981 << " : " << get_info () << endl;1980 << " m_project: " << (m_project ? m_project->get_cmtpath () : "0") 1981 << " use: " << get_info () << endl; 1982 1982 } 1983 1983 } … … 3770 3770 } 3771 3771 3772 if (action_setup == Cmt::get_action () && 3773 Requirements == Cmt::get_print_mode ()) 3774 { 3775 //cerr << "|Use::fill_standard_macros> Checking for " << prefix << "CONFIG" << endl; 3776 if (!discarded && 3777 get_package_name () != "cmt_standalone" && 3778 get_strategy ("SetupConfig")) 3779 { 3780 buffer += "macro "; 3781 buffer += prefix; 3782 buffer += "CONFIG"; 3783 buffer += " \""; 3784 buffer += CmtSystem::get_cmt_config (); 3785 buffer += "\""; 3786 buffer += "\n"; 3787 } 3788 } 3789 3772 3790 buffer += "macro "; 3773 3791 buffer += prefix;
Note: See TracChangeset
for help on using the changeset viewer.