Changeset 664 for CMT/v1r25-branch/source/cmt_symbol.cxx
- Timestamp:
- Jan 13, 2014, 4:09:37 PM (10 years ago)
- Location:
- CMT/v1r25-branch
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/v1r25-branch
-
CMT/v1r25-branch/source/cmt_symbol.cxx
r637 r664 2 2 // Copyright Christian Arnault LAL-Orsay CNRS 3 3 // arnault@lal.in2p3.fr 4 // Modified by Grigory Rybkin 4 5 // See the complete license in cmt_license.txt "http://www.cecill.info". 5 6 //----------------------------------------------------------- … … 15 16 #include "cmt_database.h" 16 17 #include "cmt_log.h" 18 #include "cmt_error.h" 17 19 18 20 // Global inhibitor of any display … … 42 44 const cmt_string clean (const Symbol& symbol, 43 45 const cmt_string& tag_name = ""); 46 47 void filter_path_value (const Symbol& symbol, 48 cmt_string& value, 49 const cmt_string& tag_name = "") const; 50 void filter_path_value (const Symbol& symbol, 51 CmtSystem::cmt_string_vector& value, 52 const cmt_string& tag_name = "") const; 53 inline const bool& get_strip_path () const; 54 inline void set_strip_path (const bool& strip_path); 55 56 static PathBuilder* get_path_builder (); 57 58 private: 59 PathBuilder (); 60 PathBuilder (bool strip_path); 61 PathBuilder (const PathBuilder& other); 62 PathBuilder& operator = (const PathBuilder& other); 63 64 bool m_strip_path; 44 65 }; 45 66 //------------------------------------------------------------- … … 248 269 } 249 270 271 // 272 // Global cache 273 // 274 namespace 275 { 276 cmt_vmap <cmt_string, cmt_string> cmdoutputs; 277 } 250 278 /** 251 279 … … 285 313 int start = 0; 286 314 315 // static cmt_vmap <cmt_string, cmt_string> cmdoutputs; 316 287 317 for (;;) 288 318 { … … 337 367 // to be applied. The output of the command is then substituted 338 368 369 Symbol::all_set (); 370 339 371 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 372 const cmt_string * presult; 373 if (!(presult = cmdoutputs.find (command))) 374 { 375 CmtSystem::execute (command, result); 376 377 process_cmd_output (result); 378 cmdoutputs.add (command, result); 379 if (Cmt::get_debug ()) 380 { 381 cout << "resolve_value: Executing [" << command << "] to expand a symbol value =>[" 382 << result << "]" << endl; 383 } 384 } 385 else 386 { 387 result = *presult; 388 if (Cmt::get_debug ()) 389 { 390 cout << "resolve_value: Found in cache [" << command << "] to expand a symbol value =>[" 391 << result << "]" << endl; 392 } 393 } 394 359 395 text.replace_all (pattern, result); 360 396 … … 378 414 else 379 415 { 416 if (Cmt::get_env_access () || 417 Symbol::std_env_vars ().has (symbol_name)) 418 { 380 419 // Symbol not found. Look for env. variable 381 420 cmt_string value = CmtSystem::getenv (symbol_name); 382 383 421 // When the env. variable is not defined, the replacement is empty 384 422 // thus all $(xxx) ${xxx} %xxx% patterns are always filtered away. 385 423 text.replace_all (pattern, value); 386 424 425 if (Cmt::get_debug ()) 426 { 427 cerr << "resolve_value: getenv (" << symbol_name 428 << ") => " << value << endl; 429 } 387 430 // The substitution will restart from the same place 388 431 // allowing for recursive replacements 389 432 start = begin; 433 } 434 else 435 { 436 if (Cmt::get_debug ()) 437 { 438 cerr << "resolve_value: getenv (" << symbol_name 439 << ") denied" << endl; 440 } 441 CmtError::set (CmtError::warning, 442 "getenv (" + symbol_name + ") denied"); 443 return; 444 } 390 445 } 391 446 } … … 484 539 // to be applied. The output of the command is substituted 485 540 541 Symbol::all_set (); 542 486 543 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 544 const cmt_string * presult; 545 if (!(presult = cmdoutputs.find (command))) 546 { 547 CmtSystem::execute (command, result); 548 549 process_cmd_output (result); 550 cmdoutputs.add (command, result); 551 if (Cmt::get_debug ()) 552 { 553 cout << "resolve_value_for_macros: Executing [" << command << "] to expand a symbol value =>[" 554 << result << "]" << endl; 555 } 556 } 557 else 558 { 559 result = *presult; 560 if (Cmt::get_debug ()) 561 { 562 cout << "resolve_value_for_macros: Found in cache [" << command << "] to expand a symbol value =>[" 563 << result << "]" << endl; 564 } 565 } 566 506 567 text.replace_all (pattern, result); 507 568 … … 621 682 // to be applied. The output of the command is substituted 622 683 684 Symbol::all_set (); 685 623 686 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 687 const cmt_string * presult; 688 if (!(presult = cmdoutputs.find (command))) 689 { 690 CmtSystem::execute (command, result); 691 692 process_cmd_output (result); 693 cmdoutputs.add (command, result); 694 if (Cmt::get_debug ()) 695 { 696 cout << "suppress_OS_delimiters: Executing [" << command << "] to expand a symbol value =>[" 697 << result << "]" << endl; 698 } 699 } 700 else 701 { 702 result = *presult; 703 if (Cmt::get_debug ()) 704 { 705 cout << "suppress_OS_delimiters: Found in cache [" << command << "] to expand a symbol value =>[" 706 << result << "]" << endl; 707 } 708 } 709 643 710 text.replace_all (pattern, result); 644 711 … … 692 759 { 693 760 static SetBuilder Set; 694 static PathBuilder Path; 761 static PathBuilder* PathPtr (PathBuilder::get_path_builder ()); 762 //static PathBuilder Path (Cmt::get_strip_path ()); 763 //static PathBuilder Path; 695 764 static MacroBuilder Macro; 696 765 static ScriptBuilder Script; … … 852 921 break; 853 922 case SymbolPath: 854 symbol.builder = &Path; 923 symbol.builder = PathPtr; 924 //symbol.builder = &Path; 855 925 break; 856 926 case SymbolAlias: … … 911 981 912 982 return (SymbolMap); 983 } 984 985 //------------------------------------------------------------- 986 Symbol::SymbolMap& Symbol::std_env_vars () 987 { 988 static SymbolMap env_vars; 989 static Symbol std_sym; 990 static bool initialized (false); 991 if (!initialized) 992 { 993 env_vars.add ("SITEROOT", std_sym); 994 env_vars.add ("CMTCONFIG", std_sym); 995 env_vars.add ("CMTBIN", std_sym); 996 env_vars.add ("CMTPATH", std_sym); 997 env_vars.add ("CMTHEADVERSION", std_sym); 998 env_vars.add ("CMTPROJECTPATH", std_sym); 999 env_vars.add ("CMTSITE", std_sym); 1000 env_vars.add ("CMTEXTRATAGS", std_sym); 1001 env_vars.add ("CMTSTRUCTURINGSTYLE", std_sym); 1002 env_vars.add ("CMTHOME", std_sym); 1003 env_vars.add ("CMTUSERCONTEXT", std_sym); 1004 initialized = true; 1005 } 1006 return env_vars; 913 1007 } 914 1008 … … 1021 1115 { 1022 1116 if (use->get_strategy ("SetupRoot") && 1023 use->get_package_name () != "cmt_standalone") 1117 use->get_package_name () != "cmt_standalone" && 1118 (action_setup == Cmt::get_action () || 1119 action_cleanup == Cmt::get_action ()) && 1120 Requirements != Cmt::get_print_mode () && 1121 Xml != Cmt::get_print_mode ()) 1024 1122 { 1025 1123 #ifdef WIN32 … … 1084 1182 */ 1085 1183 if (name == "constituents") return; 1086 if (name == "constituentsc clean") return;1184 if (name == "constituentsclean") return; 1087 1185 1088 1186 if (use->get_current_scope () == ScopePrivate) return; … … 1165 1263 } 1166 1264 } 1265 } 1266 1267 //------------------------------------------------------------- 1268 bool Symbol::set_strip_path (const bool& strip_path) 1269 { 1270 PathBuilder::get_path_builder ()->set_strip_path (strip_path); 1271 return true; 1272 /* 1273 // searching for a path symbol 1274 for (int number = 0; number < Symbol::symbol_number (); number++) 1275 { 1276 Symbol& symbol = Symbol::symbol (number); 1277 1278 if (symbol.type == Symbol::SymbolPath) 1279 { 1280 static_cast<PathBuilder*> (symbol.builder)->set_strip_path (strip_path); 1281 return true; 1282 } 1283 } 1284 1285 return false; 1286 */ 1167 1287 } 1168 1288 … … 1422 1542 cmt_string value; 1423 1543 1544 if (Cmt::get_env_access ()) 1545 { 1424 1546 for (number = 0; number < Symbol::symbol_number (); number++) 1425 1547 { … … 1433 1555 Symbol::expand (value); 1434 1556 1557 if (Cmt::get_debug ()) 1558 { 1559 cerr << "Symbol::all_set (set)> " << symbol.name << " = " << value << endl; 1560 } 1561 1435 1562 CmtSystem::putenv (symbol.name, value); 1436 1563 } 1564 } 1437 1565 } 1438 1566 … … 1500 1628 } 1501 1629 1630 static PathBuilder* pb (0); 1631 1632 if (Cmt::get_env_access ()) 1633 { 1502 1634 for (number = 0; number < Symbol::symbol_number (); number++) 1503 1635 { … … 1510 1642 { 1511 1643 Symbol::expand (value); 1512 filter_path_value (symbol.name, value); 1644 if (!pb) 1645 pb = static_cast<PathBuilder*> (symbol.builder); 1646 pb->filter_path_value (symbol, value); 1647 //filter_path_value (symbol.name, value); 1513 1648 1514 1649 #ifdef WIN32 … … 1518 1653 if (Cmt::get_debug ()) 1519 1654 { 1520 cerr << "Symbol::all_set -2> " << symbol.name << " = " << value << endl;1655 cerr << "Symbol::all_set (path)> " << symbol.name << " = " << value << endl; 1521 1656 } 1522 1657 … … 1524 1659 } 1525 1660 } 1661 } 1526 1662 1527 1663 running = false; … … 1529 1665 1530 1666 //------------------------------------------------------------- 1531 void Symbol::all_print (PrintMode mode) 1667 void Symbol::all_print (PrintMode mode, ostream& out) 1668 //void Symbol::all_print (PrintMode mode) 1532 1669 { 1533 1670 static SymbolVector& Symbols = symbols (); … … 1550 1687 (symbol.type == SymbolMacro)) 1551 1688 { 1552 if (symbol.print_macro (mode ))1689 if (symbol.print_macro (mode, out)) 1553 1690 { 1554 1691 // cout << endl; … … 1567 1704 (symbol.type == SymbolPath)) 1568 1705 { 1569 if (symbol.print (mode ))1706 if (symbol.print (mode, out)) 1570 1707 { 1571 1708 if (mode == Bat) 1572 1709 { 1573 cout << endl;1710 out << endl; 1574 1711 } 1575 1712 else if (mode == Xml) … … 1579 1716 else 1580 1717 { 1581 cout << endl;1718 out << endl; 1582 1719 } 1583 1720 } … … 1593 1730 static SymbolVector& Symbols = symbols (); 1594 1731 1732 static PathBuilder* pb (0); 1733 1595 1734 int number; 1596 1735 … … 1608 1747 expand (temp); 1609 1748 1610 Symbol::filter_path_value (symbol.name, temp); 1749 if (!pb) 1750 pb = static_cast<PathBuilder*> (symbol.builder); 1751 pb->filter_path_value (symbol, temp); 1752 //Symbol::filter_path_value (symbol.name, temp); 1611 1753 } 1612 1754 } … … 1696 1838 break; 1697 1839 case Sh : 1698 cout << "[ -z ${" << name << "+CMT} ] || unset " << name; 1699 // cout << "unset " << name; 1840 cout << "alias " << name << " >/dev/null 2>&1 && unalias " << name; 1700 1841 result = 1; 1701 1842 break; … … 1762 1903 1763 1904 //------------------------------------------------------------- 1764 int Symbol::print (PrintMode mode) 1765 { 1905 int Symbol::print (PrintMode mode, ostream& out) 1906 { 1907 static PathBuilder* pb (0); 1908 1766 1909 int result = 0; 1767 1910 … … 1769 1912 bool empty = (temp.size () == 0) ? true : false; 1770 1913 1914 cmt_string _name (name); 1915 switch (type) 1916 { 1917 case SymbolSet : 1918 case SymbolPath : 1919 expand (temp); 1920 if (type == SymbolPath) 1921 { 1922 if (!pb) 1923 pb = static_cast<PathBuilder*> (builder); 1924 pb->filter_path_value (*this, temp); 1925 } 1926 switch (mode) 1927 { 1928 case Xml : 1929 break; 1930 default: 1931 if (0 != CmtSystem::mangle (name, _name)) 1932 CmtMessage::info ("Replace " + name + " with " + _name); 1933 break; 1934 } 1935 break; 1936 default: 1937 break; 1938 } 1939 1940 /* 1771 1941 if (type == SymbolPath) 1772 1942 { 1773 1943 expand (temp); 1774 Symbol::filter_path_value (name, temp); 1775 } 1776 1777 cmt_string _name; 1944 //Symbol::filter_path_value (name, temp); 1945 if (!pb) 1946 pb = static_cast<PathBuilder*> (builder); 1947 pb->filter_path_value (*this, temp); 1948 } 1949 */ 1778 1950 switch (type) 1779 1951 { 1780 1952 case SymbolSet : 1781 1953 case SymbolPath : 1782 if (0 != CmtSystem::mangle (name, _name))1783 CmtMessage::info ("Replace " + name + " with " + _name);1784 1954 switch (mode) 1785 1955 { 1786 1956 case Csh : 1787 if (empty) cout << "unsetenv " << _name;1788 else cout << "setenv " << _name << " \"" << temp << "\"";1789 //else cout << "setenv " << name << " " << CmtSystem::quote (temp, " \t");1957 if (empty) out << "unsetenv " << _name; 1958 else out << "setenv " << _name << " \"" << temp << "\""; 1959 //else out << "setenv " << name << " " << CmtSystem::quote (temp, " \t"); 1790 1960 1791 1961 result = 1; 1792 1962 break; 1793 1963 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;1964 if (empty) out << "[ -z ${" << _name << "+CMT} ] || unset " << _name; 1965 // if (empty) out << "unset " << _name; 1966 else out << _name << "=\"" << temp << "\"; export " << _name; 1967 //else out << name << "=" << CmtSystem::quote (temp, " \t") << "; export " << name; 1798 1968 1799 1969 result = 1; … … 1801 1971 case Bat : 1802 1972 temp.replace_all ("/", "\\"); 1803 cout << "set " << _name << "=" << CmtSystem::quote (temp, " \t");1804 // cout << "set " << name << "=" << temp;1973 out << "set " << _name << "=" << CmtSystem::quote (temp, " \t"); 1974 //out << "set " << name << "=" << temp; 1805 1975 result = 1; 1806 1976 break; 1807 1977 case Xml : 1808 cout << "<variable><name>" << _name << "</name>"1978 out << "<variable><name>" << _name << "</name>" 1809 1979 << "<value>" << temp << "</value></variable>"; 1810 1980 result = 1; … … 1816 1986 { 1817 1987 case Csh : 1818 cout << "alias " << name <<1988 out << "alias " << name << 1819 1989 " \"" << temp << "\""; 1820 1990 //CmtSystem::quote (temp, " \t"); … … 1822 1992 break; 1823 1993 case Sh : 1824 cout << "alias " << name <<1994 out << "alias " << name << 1825 1995 "=\"" << temp << "\""; 1826 1996 //"=" << CmtSystem::quote (temp, " \t"); … … 1828 1998 break; 1829 1999 case Bat : 1830 cout << "set " << name <<2000 out << "set " << name << 1831 2001 "=" << CmtSystem::quote (temp, " \t"); 1832 2002 //"=" << temp; … … 1834 2004 break; 1835 2005 case Xml : 1836 cout << "<alias><name>" << name << "</name>"2006 out << "<alias><name>" << name << "</name>" 1837 2007 << "<value>" << temp << "</value></alias>"; 1838 2008 result = 1; … … 1852 2022 { 1853 2023 case Csh : 1854 cout << "if ( -f " << CmtSystem::quote (name, " \t") << ".csh ) then" << endl;1855 cout << " source " << CmtSystem::quote (name, " \t") << ".csh" << endl;1856 cout <<2024 out << "if ( -f " << CmtSystem::quote (name, " \t") << ".csh ) then" << endl; 2025 out << " source " << CmtSystem::quote (name, " \t") << ".csh" << endl; 2026 out << 1857 2027 "if ( $status != 0 ) then\n" 1858 2028 " set cmtsetupstatus=1\n" 1859 2029 "endif\n"; 1860 cout << "endif" << endl;2030 out << "endif" << endl; 1861 2031 result = 1; 1862 2032 break; 1863 2033 case Sh : 1864 cout << "if test -f " << CmtSystem::quote (name, " \t") << ".sh; then" << endl;1865 cout << " . " << CmtSystem::quote (name, " \t") << ".sh" << endl;1866 cout <<2034 out << "if test -f " << CmtSystem::quote (name, " \t") << ".sh; then" << endl; 2035 out << " . " << CmtSystem::quote (name, " \t") << ".sh" << endl; 2036 out << 1867 2037 "if test $? != 0; then\n" 1868 2038 " cmtsetupstatus=1\n" 1869 2039 "fi\n"; 1870 cout << "fi" << endl;2040 out << "fi" << endl; 1871 2041 result = 1; 1872 2042 break; 1873 2043 case Bat : 1874 cout << "call " << CmtSystem::quote (name, " \t");2044 out << "call " << CmtSystem::quote (name, " \t"); 1875 2045 result = 1; 1876 2046 break; 1877 2047 case Xml : 1878 cout << "<script>" << name << "</script>";2048 out << "<script>" << name << "</script>"; 1879 2049 result = 1; 1880 2050 break; … … 2124 2294 SymbolValue& value = value_list.values[selected]; 2125 2295 2126 result += value_list.print (symbol, value, first_definition );2296 result += value_list.print (symbol, value, first_definition, out); 2127 2297 } 2128 2298 … … 2202 2372 else if (temp == "") 2203 2373 { 2204 temp = CmtSystem::getenv (symbol.name); 2374 if (Cmt::get_env_access () || 2375 Symbol::std_env_vars ().has (symbol.name)) 2376 { 2377 temp = CmtSystem::getenv (symbol.name); 2378 if (Cmt::get_debug ()) 2379 { 2380 cerr << "SetBuilder::build> getenv (" << symbol.name 2381 << ") => " << temp << endl; 2382 } 2383 } 2384 else 2385 { 2386 if (Cmt::get_debug ()) 2387 { 2388 cerr << "SetBuilder::build> getenv (" << symbol.name 2389 << ") denied" << endl; 2390 } 2391 CmtError::set (CmtError::warning, 2392 "getenv (" + symbol.name + ") denied"); 2393 return ""; 2394 } 2205 2395 } 2206 2396 … … 2263 2453 } 2264 2454 2455 namespace 2456 { 2457 int find_path_entry (const CmtSystem::cmt_string_vector& items, const cmt_string& value) 2458 { 2459 // if (value.size () == 0) return true; 2460 2461 static cmt_vmap <cmt_string, cmt_string> realpaths; 2462 2463 cmt_string rvalue; 2464 const cmt_string * prvalue; 2465 2466 if (!(prvalue = realpaths.find (value))) 2467 { 2468 // if (!CmtSystem::realpath_ (value, rvalue)) 2469 //{ 2470 rvalue = value; 2471 CmtSystem::compress_path (rvalue); 2472 //} 2473 prvalue = &rvalue; 2474 realpaths.add (value, rvalue); 2475 // cerr << "realpaths.add: " << value << " , " << rvalue << endl; 2476 } 2477 2478 for (int i = 0; i < items.size (); i++) 2479 { 2480 const cmt_string& item = items[i]; 2481 if (item.size () == 0) continue; 2482 cmt_string ritem; 2483 const cmt_string * pritem; 2484 2485 if (!(pritem = realpaths.find (item))) 2486 { 2487 //if (!CmtSystem::realpath_ (item, ritem)) 2488 //{ 2489 ritem = item; 2490 CmtSystem::compress_path (ritem); 2491 //} 2492 pritem = &ritem; 2493 realpaths.add (item, ritem); 2494 // cerr << "realpaths.add: " << item << " , " << ritem << endl; 2495 } 2496 if (*pritem == *prvalue) 2497 { 2498 return i; 2499 } 2500 } 2501 2502 return -1; 2503 } 2504 2505 } 2506 /* 2265 2507 static bool find_path_entry (const CmtSystem::cmt_string_vector& items, const cmt_string& value) 2508 { 2509 if (value.size () == 0) return true; 2510 2511 static cmt_vmap <cmt_string, cmt_string> realpaths; 2512 2513 cmt_string rvalue; 2514 const cmt_string * prvalue; 2515 2516 if (!(prvalue = realpaths.find (value))) 2517 { 2518 // if (!CmtSystem::realpath_ (value, rvalue)) 2519 //{ 2520 rvalue = value; 2521 CmtSystem::compress_path (rvalue); 2522 //} 2523 prvalue = &rvalue; 2524 realpaths.add (value, rvalue); 2525 // cerr << "realpaths.add: " << value << " , " << rvalue << endl; 2526 } 2527 2528 for (int i = 0; i < items.size (); i++) 2529 { 2530 const cmt_string& item = items[i]; 2531 if (item.size () == 0) continue; 2532 cmt_string ritem; 2533 const cmt_string * pritem; 2534 2535 if (!(pritem = realpaths.find (item))) 2536 { 2537 //if (!CmtSystem::realpath_ (item, ritem)) 2538 //{ 2539 ritem = item; 2540 CmtSystem::compress_path (ritem); 2541 //} 2542 pritem = &ritem; 2543 realpaths.add (item, ritem); 2544 // cerr << "realpaths.add: " << item << " , " << ritem << endl; 2545 } 2546 if (*pritem == *prvalue) 2547 { 2548 return true; 2549 } 2550 } 2551 2552 return false; 2553 } 2554 */ 2555 /* 2556 static bool find_path_entry (const cmt_string& paths, const cmt_string& value) 2266 2557 { 2267 2558 static const cmt_string path_separator = CmtSystem::path_separator (); 2268 2559 static cmt_vmap <cmt_string, cmt_string> realpaths; 2269 2270 if (value.size () == 0) return true;2271 2560 2272 2561 cmt_string rvalue; … … 2285 2574 } 2286 2575 2287 //CmtSystem::cmt_string_vector items;2288 //CmtSystem::split (paths, path_separator, items);2576 CmtSystem::cmt_string_vector items; 2577 CmtSystem::split (paths, path_separator, items); 2289 2578 2290 2579 bool found = false; … … 2293 2582 { 2294 2583 const cmt_string& item = items[i]; 2295 if (item.size () == 0) continue;2296 2584 cmt_string ritem; 2297 2585 const cmt_string * pritem; … … 2317 2605 return (found); 2318 2606 } 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); 2607 */ 2608 //------------------------------------------------------------- 2609 PathBuilder* PathBuilder::get_path_builder () 2610 { 2611 static PathBuilder Path (Cmt::get_strip_path ()); 2612 return &Path; 2613 } 2614 2615 //------------------------------------------------------------- 2616 PathBuilder::PathBuilder () 2617 : m_strip_path (false) 2618 { 2619 } 2620 2621 //------------------------------------------------------------- 2622 PathBuilder::PathBuilder (bool strip_path) 2623 { 2624 PathBuilder (); 2625 m_strip_path = strip_path; 2370 2626 } 2371 2627 … … 2401 2657 level++; 2402 2658 2659 if (Cmt::get_env_access () || 2660 Symbol::std_env_vars ().has (symbol.name)) 2661 { 2662 //temp = CmtSystem::getenv (symbol.name); 2403 2663 CmtSystem::split (CmtSystem::getenv (symbol.name), path_separator, temp_vector); 2404 //temp = CmtSystem::getenv (symbol.name); 2664 filter_path_value (symbol, temp_vector); 2665 if (Cmt::get_debug ()) 2666 { 2667 cmt_string temp_txt; 2668 Cmt::vector_to_string (temp_vector, path_separator, temp_txt); 2669 cerr << "PathBuilder::build> getenv (" << symbol.name 2670 << ") => " << temp_txt << endl; 2671 } 2672 } 2673 else 2674 { 2675 if (Cmt::get_debug ()) 2676 { 2677 cerr << "PathBuilder::build> getenv (" << symbol.name 2678 << ") denied" << endl; 2679 } 2680 CmtError::set (CmtError::warning, 2681 "getenv (" + symbol.name + ") denied"); 2682 return ""; 2683 } 2405 2684 2406 2685 bool first_definition = true; … … 2442 2721 CmtSystem::split (new_value, path_separator, temp_vector); 2443 2722 //temp = new_value; 2723 filter_path_value (symbol, temp_vector); 2444 2724 } 2445 2725 … … 2451 2731 CmtSystem::split (new_value, path_separator, new_value_vector); 2452 2732 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 } 2733 { 2734 if (new_value_vector[i].size () == 0) continue; 2735 int j = find_path_entry (temp_vector, new_value_vector[i]); 2736 if (j < 0) 2737 { 2738 temp_vector.push_back (new_value_vector[i]); 2739 } 2740 else if (j < temp_vector.size () - 1) 2741 { 2742 temp_vector [j] = ""; 2743 temp_vector.push_back (new_value_vector[i]); 2744 } 2745 } 2463 2746 } 2464 2747 … … 2473 2756 for (int i = temp_vector.size () - 1; i > n - 1; i--) 2474 2757 temp_vector [i] = temp_vector [i - n]; 2758 for (int i = 0; i < n; i++) 2759 temp_vector [i] = ""; 2475 2760 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] = "";2761 { 2762 if (new_value_vector[i].size () == 0) continue; 2763 int j = find_path_entry (temp_vector, new_value_vector[i]); 2764 if (j < 0) 2765 { 2766 temp_vector [i] = new_value_vector[i]; 2767 } 2768 else if (j >= n) 2769 { 2770 temp_vector [i] = new_value_vector[i]; 2771 temp_vector [j] = ""; 2772 } 2773 } 2489 2774 } 2490 2775 … … 2614 2899 2615 2900 level--; 2616 2901 /* 2617 2902 for (;;) 2618 2903 { … … 2637 2922 temp.replace_all ("::", ":"); 2638 2923 temp.replace_all (";;", ";"); 2639 2924 */ 2640 2925 return (temp); 2641 2926 } … … 2767 3052 2768 3053 return (temp); 3054 } 3055 3056 //------------------------------------------------------------- 3057 void PathBuilder::filter_path_value (const Symbol& symbol, 3058 CmtSystem::cmt_string_vector& value, 3059 const cmt_string& /* tag_name */) const 3060 { 3061 static cmt_regexp reg ("[$%`]"); 3062 3063 cmt_vector<int> path (value.size ()); 3064 int n (0); 3065 3066 for (int j = 0; j < value.size (); j++) 3067 { 3068 const cmt_string& v = value[j]; 3069 bool exists (false); 3070 for (int i = 0; i < j; i++) 3071 { 3072 if (value[i] == v) 3073 { 3074 exists = true; 3075 break; 3076 } 3077 } 3078 if (!exists) 3079 { 3080 if (m_strip_path) 3081 { 3082 if (!reg.match (v)) 3083 { 3084 if (!CmtSystem::test_directory (v)) 3085 { 3086 CmtMessage::verbose ("Non-existent directory " + v + " in " + symbol.name + " skipped"); 3087 continue; 3088 } 3089 } 3090 else 3091 { 3092 if (CmtMessage::active (Verbose)) 3093 { 3094 CmtMessage::warning ("Unresolved directory name " + v + " in " + symbol.name); 3095 } 3096 } 3097 } 3098 else 3099 { 3100 if (CmtMessage::active (Verbose)) 3101 if (!reg.match (v) && 3102 !CmtSystem::test_directory (v)) 3103 { 3104 CmtMessage::warning ("Non-existent directory " + v + " in " + symbol.name); 3105 } 3106 } 3107 path[n++] = j; 3108 } 3109 } 3110 3111 for (int i = 0; i < n; i++) 3112 if (i != path[i]) value[i] = value[path[i]]; 3113 3114 value.resize (n); 3115 } 3116 3117 //------------------------------------------------------------- 3118 void PathBuilder::filter_path_value (const Symbol& symbol, 3119 cmt_string& value, 3120 const cmt_string& tag_name) const 3121 { 3122 static cmt_string ps (CmtSystem::path_separator ()); 3123 CmtSystem::cmt_string_vector paths; 3124 3125 CmtSystem::split (value, ps, paths); 3126 filter_path_value (symbol, paths, tag_name); 3127 Cmt::vector_to_string (paths, ps, value); 3128 } 3129 3130 //------------------------------------------------------------- 3131 inline const bool& PathBuilder::get_strip_path () const 3132 { 3133 return m_strip_path; 3134 } 3135 3136 //------------------------------------------------------------- 3137 inline void PathBuilder::set_strip_path (const bool& strip_path) 3138 { 3139 m_strip_path = strip_path; 2769 3140 } 2770 3141 … … 3275 3646 int SymbolValueList::print (const Symbol& symbol, 3276 3647 const SymbolValue& value, 3277 bool& first_definition) const 3648 bool& first_definition, 3649 ostream& out) const 3278 3650 { 3279 3651 int result (0); 3280 3281 //if (use->get_package_name () == "CMT") return result;3282 3652 3283 3653 cmt_string discarded_text; 3284 3654 cmt_string define_text; 3285 3655 ActionType action = Cmt::get_action (); 3656 3657 static PathBuilder* pb (0); 3658 cmt_string rvalue (value.text); 3286 3659 3287 3660 switch (command_type) … … 3306 3679 case CommandMacroRemoveAllRegexp : 3307 3680 //case CommandAction : 3308 if (value.text == "") return result; 3681 if (value.text.size () == 0) return result; 3682 break; 3683 } 3684 3685 CmtError::code code (CmtError::ok); 3686 cmt_string msg, n; 3687 int exec_err (0); 3688 3689 switch (command_type) 3690 { 3691 case CommandSet : 3692 case CommandSetAppend : 3693 case CommandSetPrepend : 3694 case CommandSetRemove : 3695 case CommandSetRemoveRegexp : 3696 3697 if (CmtError::has_pending_error ()) 3698 { 3699 code = CmtError::get_last_error_code (); 3700 msg = CmtError::get_last_error (); 3701 exec_err = CmtError::get_last_execution_error (); 3702 n = CmtError::get_error_name (code); 3703 CmtError::clear (); 3704 } 3705 resolve_value_for_macros (rvalue); 3706 if (CmtError::get_last_error_code () != CmtError::warning) 3707 { 3708 if (CmtError::has_pending_error ()) 3709 { 3710 CmtError::print (); 3711 CmtError::clear (); 3712 } 3713 if (CmtError::ok != code) 3714 { 3715 // restore error occurred before value expansion 3716 CmtError::set (code, 3717 (msg.replace (n + ": ", cmt_string ("")), msg), 3718 exec_err); 3719 } 3720 if (CommandSet != command_type && 3721 rvalue.size () == 0) 3722 return result; 3723 } 3724 else 3725 { 3726 if (CmtMessage::active (Verbose)) 3727 CmtError::print (); 3728 CmtError::clear (); 3729 if (CmtError::ok != code) 3730 { 3731 // restore error occurred before value expansion 3732 CmtError::set (code, 3733 (msg.replace (n + ": ", cmt_string ("")), msg), 3734 exec_err); 3735 } 3736 // Ignore the error, keep the value unresolved 3737 rvalue = value.text; 3738 } 3739 3740 break; 3741 3742 //case CommandAlias : 3743 case CommandPath : 3744 case CommandPathAppend : 3745 case CommandPathPrepend : 3746 case CommandPathRemove : 3747 case CommandPathRemoveRegexp : 3748 //case CommandMacroPrepend : 3749 //case CommandMacro : 3750 //case CommandMacroAppend : 3751 //case CommandMacroRemove : 3752 //case CommandMacroRemoveRegexp : 3753 //case CommandMacroRemoveAll : 3754 //case CommandMacroRemoveAllRegexp : 3755 //case CommandAction : 3756 3757 if (!pb) 3758 pb = static_cast<PathBuilder*> (symbol.builder); 3759 if (pb->get_strip_path ()) 3760 { 3761 /* 3762 CmtError::code code (CmtError::ok); 3763 cmt_string msg, n; 3764 int exec_err (0); 3765 */ 3766 if (CmtError::has_pending_error ()) 3767 { 3768 code = CmtError::get_last_error_code (); 3769 msg = CmtError::get_last_error (); 3770 exec_err = CmtError::get_last_execution_error (); 3771 n = CmtError::get_error_name (code); 3772 CmtError::clear (); 3773 } 3774 resolve_value (rvalue); 3775 if (CmtError::get_last_error_code () != CmtError::warning) 3776 { 3777 if (CmtError::has_pending_error ()) 3778 { 3779 CmtError::print (); 3780 CmtError::clear (); 3781 } 3782 if (CmtError::ok != code) 3783 { 3784 // restore error occurred before value expansion 3785 CmtError::set (code, 3786 (msg.replace (n + ": ", cmt_string ("")), msg), 3787 exec_err); 3788 } 3789 if (CommandPath != command_type && 3790 rvalue.size () == 0) 3791 return result; 3792 } 3793 else 3794 { 3795 if (CommandPathRemove == command_type || 3796 CommandPathRemoveRegexp == command_type) 3797 { 3798 // This means that the value is not resolved via symbols 3799 // and, possibly, standard environment variables and 3800 // * either has no effect on the path at all, 3801 // or 3802 // * there should be similar contribution from 3803 // and, hence, we should get the same error with 3804 // CommandPath, CommandPathAppend, or CommandPathPrepend 3805 // Either way, we can ignore this error. 3806 3807 if (CmtMessage::active (Verbose)) 3808 CmtError::print (); 3809 CmtError::clear (); 3810 if (CmtError::ok != code) 3811 { 3812 // restore error occurred before value expansion 3813 CmtError::set (code, 3814 (msg.replace (n + ": ", cmt_string ("")), msg), 3815 exec_err); 3816 } 3817 } 3818 else if (CmtError::ok != code) 3819 { 3820 // print error occurred before value expansion 3821 CmtMessage::error (msg); 3822 } 3823 // We keep CmtError::warning to indicate that 3824 // we could not resolve path 3825 // (without referencing the environment) 3826 // and strip path of non-existent directories 3827 // 3828 rvalue = value.text; 3829 } 3830 } 3831 else // (!pb->get_strip_path ()) 3832 { 3833 if (CmtError::has_pending_error ()) 3834 { 3835 code = CmtError::get_last_error_code (); 3836 msg = CmtError::get_last_error (); 3837 exec_err = CmtError::get_last_execution_error (); 3838 n = CmtError::get_error_name (code); 3839 CmtError::clear (); 3840 } 3841 resolve_value_for_macros (rvalue); 3842 if (CmtError::get_last_error_code () != CmtError::warning) 3843 { 3844 if (CmtError::has_pending_error ()) 3845 { 3846 CmtError::print (); 3847 CmtError::clear (); 3848 } 3849 if (CmtError::ok != code) 3850 { 3851 // restore error occurred before value expansion 3852 CmtError::set (code, 3853 (msg.replace (n + ": ", cmt_string ("")), msg), 3854 exec_err); 3855 } 3856 if (CommandPath != command_type && 3857 rvalue.size () == 0) 3858 return result; 3859 } 3860 else 3861 { 3862 if (CmtMessage::active (Verbose)) 3863 CmtError::print (); 3864 CmtError::clear (); 3865 if (CmtError::ok != code) 3866 { 3867 // restore error occurred before value expansion 3868 CmtError::set (code, 3869 (msg.replace (n + ": ", cmt_string ("")), msg), 3870 exec_err); 3871 } 3872 // Ignore the error, keep the value unresolved 3873 rvalue = value.text; 3874 } 3875 } 3876 3309 3877 break; 3310 3878 } … … 3317 3885 3318 3886 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 */ 3887 out << "# Package " << (use ? use->get_package_name () + " " + use->version : ""); 3326 3888 3327 3889 switch (command_type) … … 3329 3891 case CommandSet : 3330 3892 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;3893 out << " " << define_text << " set " << symbol.name << " as " << endl; 3894 // out << " " << define_text << " set " << symbol.name << " as "; 3895 out << "set " << symbol.name; 3334 3896 first_definition = false; 3335 3897 result = 1; … … 3337 3899 case CommandSetAppend : 3338 3900 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;3901 out << " appends to set " << symbol.name << " : " << endl; 3902 // out << " appends to set " << symbol.name << " : "; 3903 out << "set_append " << symbol.name; 3342 3904 result = 1; 3343 3905 break; 3344 3906 case CommandSetPrepend : 3345 3907 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;3908 out << " prepends to set " << symbol.name << " : " << endl; 3909 // out << " prepends to set " << symbol.name << " : "; 3910 out << "set_prepend " << symbol.name; 3349 3911 result = 1; 3350 3912 break; 3351 3913 case CommandSetRemove : 3352 3914 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;3915 out << " removes from set " << symbol.name << " : " << endl; 3916 // out << " removes from set " << symbol.name << " : "; 3917 out << "set_remove " << symbol.name; 3356 3918 result = 1; 3357 3919 break; 3358 3920 case CommandSetRemoveRegexp : 3359 3921 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;3922 out << " removes RE from set " << symbol.name << " : " << endl; 3923 // out << " removes RE from set " << symbol.name << " : "; 3924 out << "set_remove_regexp " << symbol.name; 3363 3925 result = 1; 3364 3926 break; 3365 3927 case CommandAlias : 3366 3928 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;3929 out << " " << define_text << " alias " << symbol.name << endl; 3930 // out << " " << define_text << " alias " << symbol.name << " as "; 3931 out << "alias " << symbol.name; 3370 3932 first_definition = false; 3371 3933 result = 1; 3372 3934 break; 3373 3935 case CommandPath : 3374 3936 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; 3937 out << " " << define_text << " path " << symbol.name << endl; 3938 // out << " " << define_text << " path " << symbol.name << " as "; 3939 pb->filter_path_value (symbol, rvalue); 3940 3941 if (Cmt::get_debug ()) 3942 { 3943 cerr << "|SymbolValueList::print> path " << symbol.name 3944 << " " << value.text << " => " << rvalue << endl; 3945 } 3946 3947 out << "path " << symbol.name; 3378 3948 first_definition = false; 3379 3949 result = 1; … … 3381 3951 case CommandPathAppend : 3382 3952 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; 3953 out << " appends to path " << symbol.name << endl; 3954 // out << " appends to path " << symbol.name << " : "; 3955 pb->filter_path_value (symbol, rvalue); 3956 3957 if (Cmt::get_debug ()) 3958 { 3959 cerr << "|SymbolValueList::print> path_append " << symbol.name 3960 << " " << value.text << " => " << rvalue << endl; 3961 } 3962 3963 if (rvalue.size () == 0) return result; 3964 out << "path_append " << symbol.name; 3386 3965 result = 1; 3387 3966 break; 3388 3967 case CommandPathPrepend : 3389 3968 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; 3969 out << " prepends to path " << symbol.name << " : " << endl; 3970 // out << " prepends to path " << symbol.name << " : "; 3971 pb->filter_path_value (symbol, rvalue); 3972 3973 if (Cmt::get_debug ()) 3974 { 3975 cerr << "|SymbolValueList::print> path_prepend " << symbol.name 3976 << " " << value.text << " => " << rvalue << endl; 3977 } 3978 3979 if (rvalue.size () == 0) return result; 3980 out << "path_prepend " << symbol.name; 3393 3981 result = 1; 3394 3982 break; 3395 3983 case CommandPathRemove : 3396 3984 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; 3985 out << " removes from path " << symbol.name << " : " << endl; 3986 // out << " removes from path " << symbol.name << " : "; 3987 3988 if (Cmt::get_debug ()) 3989 { 3990 cerr << "|SymbolValueList::print> path_remove " << symbol.name 3991 << " " << value.text << " => " << rvalue << endl; 3992 } 3993 3994 out << "path_remove " << symbol.name; 3400 3995 result = 1; 3401 3996 break; 3402 3997 case CommandPathRemoveRegexp : 3403 3998 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; 3999 out << " removes RE from path " << symbol.name << " : " << endl; 4000 // out << " removes RE from path " << symbol.name << " : "; 4001 4002 if (Cmt::get_debug ()) 4003 { 4004 cerr << "|SymbolValueList::print> path_remove_regexp " << symbol.name 4005 << " " << value.text << " => " << rvalue << endl; 4006 } 4007 4008 out << "path_remove_regexp " << symbol.name; 3407 4009 result = 1; 3408 4010 break; 3409 4011 case CommandMacro : 3410 4012 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;4013 out << " " << define_text << " macro " << symbol.name << " as " << endl; 4014 // out << " " << define_text << " macro " << symbol.name << " as "; 4015 out << "macro " << symbol.name; 3414 4016 result = 1; 3415 4017 break; 3416 4018 case CommandMacroPrepend : 3417 4019 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;4020 out << " prepends to macro " << symbol.name << " : " << endl; 4021 // out << " prepends to macro " << symbol.name << " : "; 4022 out << "macro_prepend " << symbol.name; 3421 4023 result = 1; 3422 4024 break; 3423 4025 case CommandMacroAppend : 3424 4026 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;4027 out << " appends to macro " << symbol.name << " : " << endl; 4028 // out << " appends to macro " << symbol.name << " : "; 4029 out << "macro_append " << symbol.name; 3428 4030 result = 1; 3429 4031 break; 3430 4032 case CommandMacroRemove : 3431 4033 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;4034 out << " remove from macro " << symbol.name << " : " << endl; 4035 // out << " remove from macro " << symbol.name << " : "; 4036 out << "macro_remove " << symbol.name; 3435 4037 result = 1; 3436 4038 break; 3437 4039 case CommandMacroRemoveRegexp : 3438 4040 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;4041 out << " remove RE from macro " << symbol.name << " : " << endl; 4042 // out << " remove RE from macro " << symbol.name << " : "; 4043 out << "macro_remove_regexp " << symbol.name; 3442 4044 result = 1; 3443 4045 break; 3444 4046 case CommandMacroRemoveAll : 3445 4047 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;4048 out << " remove all from macro " << symbol.name << " : " << endl; 4049 // out << " remove all from macro " << symbol.name << " : "; 4050 out << "macro_remove_all " << symbol.name; 3449 4051 result = 1; 3450 4052 break; 3451 4053 case CommandMacroRemoveAllRegexp : 3452 4054 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;4055 out << " remove all RE from macro " << symbol.name << " : " << endl; 4056 // out << " remove all RE from macro " << symbol.name << " : "; 4057 out << "macro_remove_all_regexp " << symbol.name; 3456 4058 result = 1; 3457 4059 break; 3458 4060 case CommandSetupScript : 3459 4061 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 */;4062 out << " " << define_text << " setup script " << symbol.name << endl; 4063 // out << " " << define_text << " action " << symbol.name << " as "; 4064 out << "setup_script" /* << symbol.name */; 3463 4065 first_definition = false; 3464 4066 result = 1; … … 3466 4068 /* 3467 4069 case CommandAction : 3468 cout << " " << define_text << " action " << symbol.name << " as ";4070 out << " " << define_text << " action " << symbol.name << " as "; 3469 4071 first_definition = false; 3470 4072 break; … … 3472 4074 } 3473 4075 3474 cout << " " << CmtSystem::quote (value.text, " \t"); 3475 // cout << "'" << value.text << "'"; 4076 out << " " << CmtSystem::quote (rvalue, " \t"); 4077 // out << " " << CmtSystem::quote (value.text, " \t"); 4078 // out << "'" << value.text << "'"; 3476 4079 3477 4080 /* … … 3481 4084 (selected_tag == Tag::get_default ())) 3482 4085 { 3483 cout << " for default tag";4086 out << " for default tag"; 3484 4087 } 3485 4088 else 3486 4089 { 3487 cout << " for tag '" << selected_tag->get_name () << "'";4090 out << " for tag '" << selected_tag->get_name () << "'"; 3488 4091 } 3489 4092 */ 3490 4093 3491 cout << endl;3492 // cout << discarded_text << endl;4094 out << endl; 4095 // out << discarded_text << endl; 3493 4096 return result; 3494 4097 } … … 3547 4150 else 3548 4151 { 4152 if (Cmt::get_env_access () || 4153 Symbol::std_env_vars ().has (name)) 4154 { 3549 4155 s = CmtSystem::getenv (name); 4156 if (Cmt::get_debug ()) 4157 { 4158 cerr << "Symbol::get_env_value> getenv (" << name 4159 << ") => " << s << endl; 4160 } 4161 } 4162 else 4163 { 4164 if (Cmt::get_debug ()) 4165 { 4166 cerr << "Symbol::get_env_value> getenv (" << name 4167 << ") denied" << endl; 4168 } 4169 CmtError::set (CmtError::warning, 4170 "getenv (" + name + ") denied"); 4171 return (s); 4172 } 3550 4173 } 3551 4174
Note: See TracChangeset
for help on using the changeset viewer.