Ignore:
Timestamp:
Jan 13, 2014, 4:09:37 PM (10 years ago)
Author:
rybkin
Message:

merge -r 646:663 HEAD

Location:
CMT/v1r25-branch
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CMT/v1r25-branch

  • CMT/v1r25-branch/source/cmt_symbol.cxx

    r637 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
     
    1516#include "cmt_database.h"
    1617#include "cmt_log.h"
     18#include "cmt_error.h"
    1719
    1820// Global inhibitor of any display
     
    4244  const cmt_string clean (const Symbol& symbol,
    4345                          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
     58private:
     59  PathBuilder ();
     60  PathBuilder (bool strip_path);
     61  PathBuilder (const PathBuilder& other);
     62  PathBuilder& operator = (const PathBuilder& other);
     63
     64  bool m_strip_path;
    4465};
    4566//-------------------------------------------------------------
     
    248269}
    249270
     271//
     272// Global cache
     273//
     274namespace
     275{
     276  cmt_vmap <cmt_string, cmt_string> cmdoutputs;
     277}
    250278/**
    251279
     
    285313  int start = 0;
    286314
     315  //  static cmt_vmap <cmt_string, cmt_string> cmdoutputs;
     316
    287317  for (;;)
    288318    {
     
    337367            // to be applied. The output of the command is then substituted
    338368
     369          Symbol::all_set ();
     370
    339371          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
    359395          text.replace_all (pattern, result);
    360396
     
    378414          else
    379415            {
     416              if (Cmt::get_env_access () ||
     417                  Symbol::std_env_vars ().has (symbol_name))
     418                {
    380419                // Symbol not found. Look for env. variable
    381420              cmt_string value = CmtSystem::getenv (symbol_name);
    382              
    383421                // When the env. variable is not defined, the replacement is empty
    384422                // thus all $(xxx) ${xxx} %xxx% patterns are always filtered away.
    385423              text.replace_all (pattern, value);
    386424             
     425                  if (Cmt::get_debug ())
     426                    {
     427                      cerr << "resolve_value: getenv (" << symbol_name
     428                           << ") => " << value << endl;
     429                    }
    387430                // The substitution will restart from the same place
    388431                // allowing for recursive replacements
    389432              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                }
    390445            }
    391446        }
     
    484539            // to be applied. The output of the command is substituted
    485540
     541          Symbol::all_set ();
     542
    486543          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
    506567          text.replace_all (pattern, result);
    507568
     
    621682            // to be applied. The output of the command is substituted
    622683
     684          Symbol::all_set ();
     685
    623686          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
    643710          text.replace_all (pattern, result);
    644711
     
    692759{
    693760  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;
    695764  static MacroBuilder Macro;
    696765  static ScriptBuilder Script;
     
    852921      break;
    853922    case SymbolPath:
    854       symbol.builder = &Path;
     923      symbol.builder = PathPtr;
     924      //symbol.builder = &Path;
    855925      break;
    856926    case SymbolAlias:
     
    911981
    912982  return (SymbolMap);
     983}
     984
     985//-------------------------------------------------------------
     986Symbol::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;
    9131007}
    9141008
     
    10211115            {
    10221116              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 ())
    10241122                {
    10251123#ifdef WIN32
     
    10841182           */
    10851183          if (name == "constituents") return;
    1086           if (name == "constituentscclean") return;
     1184          if (name == "constituentsclean") return;
    10871185
    10881186          if (use->get_current_scope () == ScopePrivate) return;
     
    11651263        }
    11661264    }
     1265}
     1266
     1267//-------------------------------------------------------------
     1268bool 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  */
    11671287}
    11681288
     
    14221542  cmt_string value;
    14231543
     1544  if (Cmt::get_env_access ())
     1545    {
    14241546  for (number = 0; number < Symbol::symbol_number (); number++)
    14251547    {
     
    14331555          Symbol::expand (value);
    14341556
     1557          if (Cmt::get_debug ())
     1558            {
     1559              cerr << "Symbol::all_set (set)> " << symbol.name << " = " << value << endl;
     1560            }
     1561
    14351562          CmtSystem::putenv (symbol.name, value);
    14361563        }
     1564    }
    14371565    }
    14381566
     
    15001628  }
    15011629
     1630  static PathBuilder* pb (0);
     1631
     1632  if (Cmt::get_env_access ())
     1633    {
    15021634  for (number = 0; number < Symbol::symbol_number (); number++)
    15031635    {
     
    15101642        {
    15111643          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);
    15131648
    15141649#ifdef WIN32
     
    15181653          if (Cmt::get_debug ())
    15191654            {
    1520               cerr << "Symbol::all_set-2> " << symbol.name << " = " << value << endl;
     1655              cerr << "Symbol::all_set (path)> " << symbol.name << " = " << value << endl;
    15211656            }
    15221657
     
    15241659        }
    15251660    }
     1661    }
    15261662
    15271663  running = false;
     
    15291665
    15301666//-------------------------------------------------------------
    1531 void Symbol::all_print (PrintMode mode)
     1667void Symbol::all_print (PrintMode mode, ostream& out)
     1668//void Symbol::all_print (PrintMode mode)
    15321669{
    15331670  static SymbolVector& Symbols = symbols ();
     
    15501687              (symbol.type == SymbolMacro))
    15511688            {
    1552               if (symbol.print_macro (mode))
     1689              if (symbol.print_macro (mode, out))
    15531690                {
    15541691                  //              cout << endl;
     
    15671704              (symbol.type == SymbolPath))
    15681705            {
    1569               if (symbol.print (mode))
     1706              if (symbol.print (mode, out))
    15701707                {
    15711708                  if (mode == Bat)
    15721709                    {
    1573                       cout << endl;
     1710                      out << endl;
    15741711                    }
    15751712                  else if (mode == Xml)
     
    15791716                  else
    15801717                    {
    1581                       cout << endl;
     1718                      out << endl;
    15821719                    }
    15831720                }
     
    15931730  static SymbolVector& Symbols = symbols ();
    15941731
     1732  static PathBuilder* pb (0);
     1733
    15951734  int number;
    15961735
     
    16081747          expand (temp);
    16091748
    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);
    16111753        }
    16121754    }
     
    16961838            break;
    16971839          case Sh :
    1698             cout << "[ -z ${" << name << "+CMT} ] || unset " << name;
    1699           //            cout << "unset " << name;
     1840            cout << "alias " << name << " >/dev/null 2>&1 && unalias " << name;
    17001841            result = 1;
    17011842            break;
     
    17621903
    17631904//-------------------------------------------------------------
    1764 int Symbol::print (PrintMode mode)
    1765 {
     1905int Symbol::print (PrintMode mode, ostream& out)
     1906{
     1907  static PathBuilder* pb (0);
     1908
    17661909  int result = 0;
    17671910
     
    17691912  bool empty = (temp.size () == 0) ? true : false;
    17701913
     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  /*
    17711941  if (type == SymbolPath)
    17721942    {
    17731943      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  */
    17781950  switch (type)
    17791951    {
    17801952      case SymbolSet :
    17811953      case SymbolPath :
    1782         if (0 != CmtSystem::mangle (name, _name))
    1783           CmtMessage::info ("Replace " + name + " with " + _name);
    17841954        switch (mode)
    17851955          {
    17861956            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");
    17901960
    17911961              result = 1;
    17921962              break;
    17931963            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;
    17981968
    17991969              result = 1;
     
    18011971            case Bat :
    18021972              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;
    18051975              result = 1;
    18061976              break;
    18071977            case Xml :
    1808               cout << "<variable><name>" << _name << "</name>"
     1978              out << "<variable><name>" << _name << "</name>"
    18091979                   << "<value>" << temp << "</value></variable>";
    18101980              result = 1;
     
    18161986          {
    18171987            case Csh :
    1818               cout << "alias " << name <<
     1988              out << "alias " << name <<
    18191989                " \"" << temp << "\"";
    18201990              //CmtSystem::quote (temp, " \t");
     
    18221992              break;
    18231993            case Sh :
    1824               cout << "alias " << name <<
     1994              out << "alias " << name <<
    18251995                "=\"" << temp << "\"";
    18261996              //"=" << CmtSystem::quote (temp, " \t");
     
    18281998              break;
    18291999            case Bat :
    1830               cout << "set " << name <<
     2000              out << "set " << name <<
    18312001                "=" << CmtSystem::quote (temp, " \t");
    18322002              //"=" << temp;
     
    18342004              break;
    18352005            case Xml :
    1836               cout << "<alias><name>" << name << "</name>"
     2006              out << "<alias><name>" << name << "</name>"
    18372007                   << "<value>" << temp << "</value></alias>";
    18382008              result = 1;
     
    18522022              {
    18532023                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 <<
    18572027                    "if ( $status != 0 ) then\n"
    18582028                    "    set cmtsetupstatus=1\n"
    18592029                    "endif\n";
    1860                   cout << "endif" << endl;
     2030                  out << "endif" << endl;
    18612031                  result = 1;
    18622032                  break;
    18632033                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 <<
    18672037                    "if test $? != 0; then\n"
    18682038                    "    cmtsetupstatus=1\n"
    18692039                    "fi\n";
    1870                   cout << "fi" << endl;
     2040                  out << "fi" << endl;
    18712041                  result = 1;
    18722042                  break;
    18732043                case Bat :
    1874                   cout << "call " << CmtSystem::quote (name, " \t");
     2044                  out << "call " << CmtSystem::quote (name, " \t");
    18752045                  result = 1;
    18762046                  break;
    18772047                case Xml :
    1878                   cout << "<script>" << name << "</script>";
     2048                  out << "<script>" << name << "</script>";
    18792049                  result = 1;
    18802050                  break;
     
    21242294      SymbolValue& value = value_list.values[selected];
    21252295
    2126       result += value_list.print (symbol, value, first_definition);
     2296      result += value_list.print (symbol, value, first_definition, out);
    21272297    }
    21282298
     
    22022372            else if (temp == "")
    22032373              {
    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                  }
    22052395              }
    22062396
     
    22632453}
    22642454
     2455namespace
     2456{
     2457int 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/*
    22652507static 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/*
     2556static bool find_path_entry (const cmt_string& paths, const cmt_string& value)
    22662557{
    22672558  static const cmt_string path_separator = CmtSystem::path_separator ();
    22682559  static cmt_vmap <cmt_string, cmt_string> realpaths;
    2269 
    2270   if (value.size () == 0) return true;
    22712560
    22722561  cmt_string rvalue;
     
    22852574    }
    22862575
    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);
    22892578
    22902579  bool found = false;
     
    22932582    {
    22942583      const cmt_string& item = items[i];
    2295       if (item.size () == 0) continue;
    22962584      cmt_string ritem;
    22972585      const cmt_string * pritem;
     
    23172605  return (found);
    23182606}
    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//-------------------------------------------------------------
     2609PathBuilder* PathBuilder::get_path_builder ()
     2610{
     2611  static PathBuilder Path (Cmt::get_strip_path ());
     2612  return &Path;
     2613}
     2614
     2615//-------------------------------------------------------------
     2616PathBuilder::PathBuilder ()
     2617  : m_strip_path (false)
     2618{
     2619}
     2620
     2621//-------------------------------------------------------------
     2622PathBuilder::PathBuilder (bool strip_path)
     2623{
     2624  PathBuilder ();
     2625  m_strip_path = strip_path;
    23702626}
    23712627
     
    24012657  level++;
    24022658
     2659                if (Cmt::get_env_access () ||
     2660                    Symbol::std_env_vars ().has (symbol.name))
     2661                  {
     2662  //temp = CmtSystem::getenv (symbol.name);
    24032663  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                  }
    24052684
    24062685  bool first_definition = true;
     
    24422721                CmtSystem::split (new_value, path_separator, temp_vector);
    24432722                //temp = new_value;
     2723                filter_path_value (symbol, temp_vector);
    24442724              }
    24452725
     
    24512731                CmtSystem::split (new_value, path_separator, new_value_vector);
    24522732                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                  }
    24632746              }
    24642747                 
     
    24732756                for (int i = temp_vector.size () - 1; i > n - 1; i--)
    24742757                  temp_vector [i] = temp_vector [i - n];
     2758                for (int i = 0; i < n; i++)
     2759                  temp_vector [i] = "";
    24752760                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                   else
    2488                     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                  }
    24892774              }
    24902775           
     
    26142899
    26152900  level--;
    2616 
     2901  /*
    26172902  for (;;)
    26182903    {
     
    26372922  temp.replace_all ("::", ":");
    26382923  temp.replace_all (";;", ";");
    2639  
     2924  */
    26402925  return (temp);
    26412926}
     
    27673052 
    27683053  return (temp);
     3054}
     3055
     3056//-------------------------------------------------------------
     3057void 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//-------------------------------------------------------------
     3118void 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//-------------------------------------------------------------
     3131inline const bool& PathBuilder::get_strip_path () const
     3132{
     3133  return m_strip_path;
     3134}
     3135
     3136//-------------------------------------------------------------
     3137inline void PathBuilder::set_strip_path (const bool& strip_path)
     3138{
     3139  m_strip_path = strip_path;
    27693140}
    27703141
     
    32753646int SymbolValueList::print (const Symbol& symbol,
    32763647                            const SymbolValue& value,
    3277                             bool& first_definition) const
     3648                            bool& first_definition,
     3649                            ostream& out) const
    32783650{
    32793651  int result (0);
    3280 
    3281   //if (use->get_package_name () == "CMT") return result;
    32823652
    32833653  cmt_string discarded_text;
    32843654  cmt_string define_text;
    32853655  ActionType action = Cmt::get_action ();
     3656
     3657  static PathBuilder* pb (0);
     3658  cmt_string rvalue (value.text);
    32863659
    32873660  switch (command_type)
     
    33063679      case CommandMacroRemoveAllRegexp :
    33073680        //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
    33093877        break;
    33103878    }
     
    33173885
    33183886  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 : "");
    33263888
    33273889  switch (command_type)
     
    33293891      case CommandSet :
    33303892        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;
    33343896        first_definition = false;
    33353897        result = 1;
     
    33373899      case CommandSetAppend :
    33383900        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;
    33423904        result = 1;
    33433905        break;
    33443906      case CommandSetPrepend :
    33453907        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;
    33493911        result = 1;
    33503912        break;
    33513913      case CommandSetRemove :
    33523914        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;
    33563918        result = 1;
    33573919        break;
    33583920      case CommandSetRemoveRegexp :
    33593921        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;
    33633925        result = 1;
    33643926        break;
    33653927      case CommandAlias :
    33663928        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;
    33703932        first_definition = false;
    33713933        result = 1;
    33723934        break;
    3373       case CommandPath :
     3935    case CommandPath :
    33743936        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;
    33783948        first_definition = false;
    33793949        result = 1;
     
    33813951      case CommandPathAppend :
    33823952        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;
    33863965        result = 1;
    33873966        break;
    33883967      case CommandPathPrepend :
    33893968        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;
    33933981        result = 1;
    33943982        break;
    33953983      case CommandPathRemove :
    33963984        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;
    34003995        result = 1;
    34013996        break;
    34023997      case CommandPathRemoveRegexp :
    34033998        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;
    34074009        result = 1;
    34084010        break;
    34094011      case CommandMacro :
    34104012        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;
    34144016        result = 1;
    34154017        break;
    34164018      case CommandMacroPrepend :
    34174019        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;
    34214023        result = 1;
    34224024        break;
    34234025      case CommandMacroAppend :
    34244026        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;
    34284030        result = 1;
    34294031        break;
    34304032      case CommandMacroRemove :
    34314033        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;
    34354037        result = 1;
    34364038        break;
    34374039      case CommandMacroRemoveRegexp :
    34384040        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;
    34424044        result = 1;
    34434045        break;
    34444046      case CommandMacroRemoveAll :
    34454047        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;
    34494051        result = 1;
    34504052        break;
    34514053      case CommandMacroRemoveAllRegexp :
    34524054        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;
    34564058        result = 1;
    34574059        break;
    34584060      case CommandSetupScript :
    34594061        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 */;
    34634065        first_definition = false;
    34644066        result = 1;
     
    34664068        /*
    34674069      case CommandAction :
    3468         cout << " " << define_text << " action " << symbol.name << " as ";
     4070        out << " " << define_text << " action " << symbol.name << " as ";
    34694071        first_definition = false;
    34704072        break;
     
    34724074    }
    34734075
    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 << "'";
    34764079         
    34774080  /*
     
    34814084      (selected_tag == Tag::get_default ()))
    34824085    {
    3483       cout << " for default tag";
     4086      out << " for default tag";
    34844087    }
    34854088  else
    34864089    {
    3487       cout << " for tag '" << selected_tag->get_name () << "'";
     4090      out << " for tag '" << selected_tag->get_name () << "'";
    34884091    }
    34894092  */
    34904093
    3491   cout << endl;
    3492   //  cout << discarded_text << endl;
     4094  out << endl;
     4095  //  out << discarded_text << endl;
    34934096  return result;
    34944097}
     
    35474150  else
    35484151    {
     4152                if (Cmt::get_env_access () ||
     4153                    Symbol::std_env_vars ().has (name))
     4154                  {
    35494155      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                  }
    35504173    }
    35514174
Note: See TracChangeset for help on using the changeset viewer.