Changeset 656 for CMT/HEAD/source/cmt_symbol.cxx
- Timestamp:
- Dec 4, 2013, 10:57:15 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.