Ignore:
Timestamp:
Nov 5, 2013, 3:40:52 PM (11 years ago)
Author:
rybkin
Message:

See C.L. 511

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/source/cmt_parser.cxx

    r649 r652  
    1010#include <string.h>
    1111#include <ctype.h>
     12#include <errno.h>
    1213
    1314//----------------------------------------------------------
     
    4849{
    4950  clear ();
     51
     52  cmt_string tags = CmtSystem::getenv ("CMTEXTRATAGS");
     53  CmtSystem::cmt_string_vector words;
     54  CmtSystem::split (tags, " \t,", words);
     55  for (int i = 0; i < words.size (); i++)
     56    {
     57      bool has (false);
     58      for (int j = 0; j < m_extra_tags.size (); j++)
     59        {
     60          if (m_extra_tags[j] == words[i])
     61            {
     62              has = true;
     63              break;
     64            }
     65        }
     66      if (!has)
     67        m_extra_tags.push_back (words[i]);
     68    }
    5069}
    5170
     
    5978  m_build_nmake    = false;
    6079  m_cmt_config     = "";
    61   //m_cmt_path.clear ();
    62   //m_cmt_path_pwds.clear ();
    63   //m_cmt_path_sources.clear ();
    6480  m_cmt_root       = "";
     81  m_cmt_home       = "";
     82  m_cmt_user_context = "";
     83  m_cmt_site       = "";
    6584  m_cmt_version    = "";
    6685  m_use_cmt        = true;
     86
    6787  m_current_dir     = "";
    6888  m_current_file_path = "";
     
    7494  m_current_offset  = "";
    7595
    76   m_current_access   = DeveloperMode;
     96  m_current_access  = UserMode;
     97  m_current_style   = cmt_style;
     98  m_current_structuring_style = default_structuring_style;
    7799
    78100  m_current_tag      = "";
    79101  m_current_target   = "";
    80102  m_current_version  = "";
     103
     104  //  m_extra_tags       = "";
     105  m_extra_tags.clear ();
     106  m_tags.clear ();
     107  m_tags_add.clear ();
     108  m_tags_remove.clear ();
     109
     110  m_configure_error  = "";
     111
     112  m_debug = (::getenv ("CMTDEBUG") != 0) ? true : false;
     113
    81114  m_default_path     = "";
    82 
    83   //m_quiet            = false;
    84 
     115  m_quiet            = false;
    85116  m_disable_warnings = false;
    86117  m_warnings         = false;
     
    91122
    92123  m_standard_macros_done = false;
    93   m_current_access = UserMode;
    94   m_current_style = cmt_style;
    95   m_current_structuring_style = default_structuring_style;
    96124  m_all_sets_done = false;
     125
    97126  m_autoconfigure_cmtpath = false;
    98   m_debug = false;
    99   if (getenv ("CMTDEBUG") != 0) m_debug = true;
    100127}
    101128
     
    497524void Cmt::clear ()
    498525{
    499   Me.m_quiet = false;
    500526  Me.clear ();
     527  //Me.m_quiet = false;
    501528
    502529  Database::clear ();
     
    515542  if (configured) return;
    516543
    517   Me.clear ();
     544  //  Me.clear ();
    518545
    519546  log << "configure_cmt_message" << log_endl;
     
    533560  log << "configure_site_tag" << log_endl;
    534561  configure_site_tag (0);
     562
     563  if (Me.m_current_package.size () != 0 &&
     564      Me.m_current_package != "cmt_standalone")
     565    { // we have a package name (not "cmt_standalone")
     566      Use& use = Use::current();
     567      use.set (Me.m_current_package,
     568               Me.m_current_version,
     569               Me.m_current_path);
     570      if (CmtSystem::absolute_path (Me.m_current_path))
     571        {
     572          if (!use.move_to ())
     573            {
     574              CmtError::set (CmtError::package_not_found, use.get_info ());
     575              return;
     576            }
     577        }
     578      else
     579        {
     580          if (!use.move_to ("", true))
     581            {
     582              // will try again later from CMTPATH entries
     583            }
     584        }
     585    }
     586  else
     587    {
     588      if (Me.m_current_path.size () != 0 &&
     589          !CmtSystem::cd (Me.m_current_path))
     590        {
     591          CmtError::set (CmtError::path_not_found, Me.m_current_path);
     592          return;
     593        }
     594    }
     595
    535596  log << "configure_current_dir" << log_endl;
    536597  configure_current_dir ();
     
    540601  //  log << "configure_current_dir" << log_endl;
    541602
    542 
    543603  bool save_quiet = Me.m_quiet;
    544604  Me.m_quiet = true;
     
    554614  guess_current_project ();
    555615
     616  if (Me.m_current_package.size () != 0 &&
     617      Me.m_current_package != "cmt_standalone")
     618    {
     619      Use& use = Use::current();
     620      if (!use.located ())
     621        {
     622          if (!use.move_to ())
     623            {
     624              CmtError::set (CmtError::package_not_found, use.get_info ());
     625              return;
     626            }
     627          else
     628            {
     629              use.get_full_path (Me.m_current_dir);
     630              switch (use.style)
     631                {
     632                case cmt_style:
     633                  Me.m_current_dir += CmtSystem::file_separator ();
     634                  Me.m_current_dir += "cmt";
     635                  break;
     636                case mgr_style:
     637                  Me.m_current_dir += CmtSystem::file_separator ();
     638                  Me.m_current_dir += "mgr";
     639                  break;
     640                default:
     641                  break;
     642                }
     643              Me.m_current_file_path = Me.m_current_dir;
     644
     645              Project::order_all ();
     646              Cmt::guess_current_project ();
     647            }
     648        }
     649    }
     650
    556651  log << "configure_current_structuring_style" << log_endl;
    557652  //  configure_current_structuring_style ();
     
    562657
    563658  Use& use = Use::current();
    564 
    565   use.set (Me.m_current_package,
    566            Me.m_current_version,
    567            Me.m_current_path,
    568            "",
    569            "");
    570 
    571   use.style = Me.m_current_style;
    572   use.structuring_style = Me.m_current_structuring_style;
    573 
    574   use.change_path (Me.m_current_path);
     659  if (!use.located ())
     660    {
     661      use.set (Me.m_current_package,
     662               Me.m_current_version,
     663               Me.m_current_path);
     664      use.style = Me.m_current_style;
     665
     666      if (use.style != none_style)
     667        {
     668          use.structuring_style = Me.m_current_structuring_style;
     669          use.change_path (Me.m_current_path, Project::get_current ());
     670        }
     671      else
     672        {
     673          use.real_path = Me.m_current_path;
     674        }
     675    }
     676  else if (const Project * p = Project::get_current ())
     677    {
     678      use.set_project (p);
     679    }
    575680
    576681  if (CmtError::has_pending_error ())
     
    621726{
    622727  Use& current_use = Use::current ();
    623 
     728  current_use.get_cmtpath_and_offset (Me.m_current_cmtpath, Me.m_current_offset);
     729  /*
    624730  Me.m_current_cmtpath = "";
    625731  Me.m_current_offset = "";
     
    633739
    634740      Me.m_current_offset = current_use.path;
    635 
     741  */
    636742      /**
    637743         try to remove this current CMTPATH entry from path.  This
     
    639745         absolute path.
    640746      */
    641      
     747  /*     
    642748      Me.m_current_offset.replace (Me.m_current_cmtpath, empty_string);
    643749      if (Me.m_current_offset[0] == CmtSystem::file_separator ())
     
    648754        }
    649755    }
     756  */
    650757}
    651758
     
    788895  Me.m_current_file_path = mount_filter.get_current_dir ();
    789896
    790   cmt_string t = Me.m_current_file_path;
     897  //  cmt_string t = Me.m_current_file_path;
    791898}
    792899
     
    800907    standard directory tree (i.e. <package>/<version>/cmt or mgr)
    801908  */
     909  Use& use = Use::current();
     910  if (use.located ())
     911    {
     912      Me.m_current_style = use.style;
     913      build_prefix (Me.m_current_package, Me.m_current_prefix);
     914      build_config (Me.m_current_prefix, Me.m_current_config);
     915      return;
     916    }
    802917
    803918  cmt_string req = "..";
     
    10621177      // Do NOT (re)set m_current_structuring_style yet
    10631178      // (as requirements may NOT exist, so this is not a package)
    1064       // rather do it in reach_current_package (if/when requirements is read)
     1179      // rather do it in use_current_package (if/when requirements is read)
    10651180      //Me.m_current_structuring_style = without_version_directory;
    10661181      build_prefix (Me.m_current_package, Me.m_current_prefix);
     
    10741189{
    10751190  cmt_string s;
    1076   s = CmtSystem::getenv ("CMTSTRUCTURINGSTYLE");
    1077   if (s == "without_version_directory")
    1078     {
    1079       Me.m_current_structuring_style = without_version_directory;
    1080     }
    1081   else if (s == "with_version_directory")
    1082     {
    1083       Me.m_current_structuring_style = with_version_directory;
    1084     }
    1085 
    1086   CmtSystem::cmt_string_vector flags;
    1087   Cmt::get_cmt_flags (flags);
    1088   for (int i = 0; i < flags.size (); i++)
    1089     {
    1090       const cmt_string& flag = flags[i];
    1091       if (flag == "-without_version_directory")
     1191  if (Me.m_current_structuring_style == default_structuring_style)
     1192    {
     1193      s = CmtSystem::getenv ("CMTSTRUCTURINGSTYLE");
     1194      if (s == "without_version_directory")
    10921195        {
    10931196          Me.m_current_structuring_style = without_version_directory;
    10941197        }
    1095       else if (flag == "-with_version_directory")
     1198      else if (s == "with_version_directory")
    10961199        {
    10971200          Me.m_current_structuring_style = with_version_directory;
    1098         }
    1099     }
    1100 
    1101   for (int i = 1; i < ap.argc; i++)
    1102     {
    1103       const cmt_string& arg = ap.argv[i];
    1104       if (arg[0] != '-') break;
    1105       if (arg == "-without_v" ||
    1106           arg == "-without_ve" ||
    1107           arg == "-without_ver" ||
    1108           arg == "-without_vers" ||
    1109           arg == "-without_versi" ||
    1110           arg == "-without_versio" ||
    1111           arg == "-without_version" ||
    1112           arg == "-without_version_" ||
    1113           arg == "-without_version_d" ||
    1114           arg == "-without_version_di" ||
    1115           arg == "-without_version_dir" ||
    1116           arg == "-without_version_dire" ||
    1117           arg == "-without_version_direc" ||
    1118           arg == "-without_version_direct" ||
    1119           arg == "-without_version_directo" ||
    1120           arg == "-without_version_director" ||
    1121           arg == "-without_version_directory")
    1122         {
    1123           Me.m_current_structuring_style = without_version_directory;
    1124           //      if (!CmtSystem::putenv ("CMTSTRUCTURINGSTYLE", "without_version_directory"))
    1125           //        CmtMessage::error ("Cannot set `CMTSTRUCTURINGSTYLE' to"
    1126           //                           " `without_version_directory' in the environment");
    1127           if (!Cmt::add_cmt_flag ("-without_version_directory"))
    1128             CmtMessage::error ("Cannot add flag `-without_version_directory'");
    1129         }
    1130       else if (arg == "-with_v" ||
    1131                arg == "-with_ve" ||
    1132                arg == "-with_ver" ||
    1133                arg == "-with_vers" ||
    1134                arg == "-with_versi" ||
    1135                arg == "-with_versio" ||
    1136                arg == "-with_version" ||
    1137                arg == "-with_version_" ||
    1138                arg == "-with_version_d" ||
    1139                arg == "-with_version_di" ||
    1140                arg == "-with_version_dir" ||
    1141                arg == "-with_version_dire" ||
    1142                arg == "-with_version_direc" ||
    1143                arg == "-with_version_direct" ||
    1144                arg == "-with_version_directo" ||
    1145                arg == "-with_version_director" ||
    1146                arg == "-with_version_directory")
    1147         {
    1148           Me.m_current_structuring_style = with_version_directory;
    1149           //      if (!CmtSystem::putenv ("CMTSTRUCTURINGSTYLE", "with_version_directory"))
    1150           //        CmtMessage::error ("Cannot set `CMTSTRUCTURINGSTYLE' to"
    1151           //                           " `with_version_directory' in the environment");
    1152           if (!Cmt::add_cmt_flag ("-with_version_directory"))
    1153             CmtMessage::error ("Cannot add flag `-with_version_directory'");
     1201        }
     1202     
     1203      CmtSystem::cmt_string_vector flags;
     1204      Cmt::get_cmt_flags (flags);
     1205      for (int i = 0; i < flags.size (); i++)
     1206        {
     1207          const cmt_string& flag = flags[i];
     1208          if (flag == "-without_version_directory")
     1209            {
     1210              Me.m_current_structuring_style = without_version_directory;
     1211            }
     1212          else if (flag == "-with_version_directory")
     1213            {
     1214              Me.m_current_structuring_style = with_version_directory;
     1215            }
     1216        }
     1217    }
     1218 
     1219  if (Me.m_current_structuring_style != default_structuring_style)
     1220    {
     1221      StrategyDef* def = StrategyMgr::find_strategy ("VersionDirectory");
     1222      if (def != 0)
     1223        {
     1224          def->m_default_value =
     1225            Me.m_current_structuring_style == with_version_directory;
     1226          def->m_priority_value =
     1227            Me.m_current_structuring_style == without_version_directory;
    11541228        }
    11551229    }
     
    11711245void Cmt::configure_home (Use* use)
    11721246{
    1173   Me.m_cmt_home = "";
    1174 
    1175   Symbol* symbol = Symbol::find ("CMTHOME");
    1176   if (symbol != 0)
    1177     {
    1178       Me.m_cmt_home = symbol->build_macro_value ();
    1179       Symbol::expand (Me.m_cmt_home);
    1180     }
    1181   else if (CmtSystem::testenv ("CMTHOME"))
    1182     {
    1183       Me.m_cmt_home = CmtSystem::getenv ("CMTHOME");
     1247  if (Me.m_cmt_home.size () == 0)
     1248    {
     1249      // if not passed on the command line
     1250      if (const Symbol* symbol = Symbol::find ("CMTHOME"))
     1251        {
     1252          Me.m_cmt_home = symbol->build_macro_value ();
     1253          Symbol::expand (Me.m_cmt_home);
     1254        }
     1255      else if (CmtSystem::testenv ("CMTHOME"))
     1256        {
     1257          Me.m_cmt_home = CmtSystem::getenv ("CMTHOME");
     1258        }
    11841259    }
    11851260
     
    11951270void Cmt::configure_user_context (Use* use)
    11961271{
    1197   Me.m_cmt_user_context = "";
    1198 
    1199   Symbol* symbol = Symbol::find ("CMTUSERCONTEXT");
    1200   if (symbol != 0)
    1201     {
    1202       Me.m_cmt_user_context = symbol->build_macro_value ();
    1203       Symbol::expand (Me.m_cmt_user_context);
    1204     }
    1205   else if (CmtSystem::testenv ("CMTUSERCONTEXT"))
    1206     {
    1207       Me.m_cmt_user_context = CmtSystem::getenv ("CMTUSERCONTEXT");
     1272  if (Me.m_cmt_user_context.size () == 0)
     1273    {
     1274      // if not passed on the command line
     1275      if (const Symbol* symbol = Symbol::find ("CMTUSERCONTEXT"))
     1276        {
     1277          Me.m_cmt_user_context = symbol->build_macro_value ();
     1278          Symbol::expand (Me.m_cmt_user_context);
     1279        }
     1280      else if (CmtSystem::testenv ("CMTUSERCONTEXT"))
     1281        {
     1282          Me.m_cmt_user_context = CmtSystem::getenv ("CMTUSERCONTEXT");
     1283        }
    12081284    }
    12091285
     
    12721348
    12731349  Cmt::configure_tags (use);
     1350
     1351  cmt_string s, t;
     1352  if (0 < Me.m_extra_tags.size ())
     1353    {
     1354      s = "CMTEXTRATAGS";
     1355      t = use != 0 ? use->get_package_name () : s;
     1356    }
     1357  for (int i = 0; i < Me.m_extra_tags.size (); i++)
     1358    {
     1359      Tag* tag = Tag::add (Me.m_extra_tags[i], PriorityUserTag, s, use);
     1360      tag->mark (t);
     1361    }
     1362
     1363  for (int i = 0; i < Me.m_tags.size (); i++)
     1364    {
     1365      const cmt_string& a = Me.m_tags[i];
     1366      if (i == 0)
     1367        {
     1368          Me.m_current_tag = a;
     1369        }
     1370//       // Then restore uname if the specified tag is CMTCONFIG
     1371//       if (a == CmtSystem::get_cmt_config ())
     1372//      {
     1373//        Cmt::configure_uname_tag ();
     1374//      }
     1375      Tag* tag = Tag::add (a, PriorityArgument, "arguments", 0);
     1376      tag->mark ("arguments");
     1377    }
     1378
     1379  for (int i = 0; i < Me.m_tags_add.size (); i++)
     1380    {
     1381      const cmt_string& a = Me.m_tags_add[i];
     1382//       // Then restore uname if the specified tag is CMTCONFIG
     1383//       if (a == CmtSystem::get_cmt_config ())
     1384//      {
     1385//        Cmt::configure_uname_tag ();
     1386//      }
     1387      Tag* tag = Tag::add (a, PriorityUserTag, "arguments", 0);
     1388      tag->mark ("arguments");
     1389    }
    12741390
    12751391  /*
     
    12771393  */
    12781394
     1395  /*
    12791396  if (CmtSystem::testenv ("CMTEXTRATAGS"))
    12801397    {
     
    13091426        }
    13101427    }
     1428  */
    13111429}
    13121430
     
    13191437
    13201438  log << "current_tag=" << Me.m_current_tag << log_endl;
     1439
     1440  cmt_string s = "CMTCONFIG";
    13211441
    13221442  Symbol* symbol = Symbol::find ("CMTCONFIG");
     
    13471467    {
    13481468      config_tag = CmtSystem::getenv ("CMTBIN");
     1469      s = "CMTBIN";
    13491470    }
    13501471
     
    13521473    {
    13531474      CmtSystem::get_uname (config_tag);
     1475      s = "uname";
    13541476    }
    13551477
    13561478  log << "current_tag=" << Me.m_current_tag << log_endl;
    13571479
    1358   cmt_string s = "CMTCONFIG";
     1480  //  cmt_string s = "CMTCONFIG";
    13591481  cmt_string t = s;
    13601482
     
    15521674          if (CmtMessage::level () != Warning)
    15531675            CmtMessage::set_level (Warning);
    1554           //      if (CmtMessage::level () > Warning)
    1555         }
    1556     }
    1557 
    1558   for (int i = 1; i < ap.argc; i++)
    1559     {
    1560       const cmt_string& arg = ap.argv[i];
    1561       if (arg[0] != '-') break;
    1562       if (arg == "-d" ||
    1563           arg == "-di" ||
    1564           arg == "-dis" ||
    1565           arg == "-disa" ||
    1566           arg == "-disab" ||
    1567           arg == "-disabl" ||
    1568           arg == "-disable" ||
    1569           arg == "-disable_" ||
    1570           arg == "-disable_w" ||
    1571           arg == "-disable_wa" ||
    1572           arg == "-disable_war" ||
    1573           arg == "-disable_warn" ||
    1574           arg == "-disable_warni" ||
    1575           arg == "-disable_warnin" ||
    1576           arg == "-disable_warning" ||
    1577           arg == "-disable_warnings")
    1578         {
    1579           Me.m_disable_warnings = true;
    1580           if (CmtMessage::level () <= Warning)
    1581             {
    1582               CmtMessage::set_level (Error);
    1583               //              if (!CmtSystem::putenv ("CMTERROR", "1"))
    1584               //                CmtMessage::error ("Cannot set `CMTERROR' in the environment");
    1585             }
    1586           if (!Cmt::add_cmt_flag ("-disable_warnings"))
    1587             CmtMessage::error ("Cannot add flag `-disable_warnings'");
    1588         }
    1589       else if (arg == "-q" ||
    1590                arg == "-qu" ||
    1591                arg == "-qui" ||
    1592                arg == "-quie" ||
    1593                arg == "-quiet")
    1594         {
    1595           Me.m_quiet = true;
    1596           if (CmtMessage::level () <= Error)
    1597             {
    1598               CmtMessage::set_level (Fatal);
    1599               //              if (!CmtSystem::putenv ("CMTFATAL", "1"))
    1600               //                CmtMessage::error ("Cannot set `CMTFATAL' in the environment");
    1601             }
    1602           if (!Cmt::add_cmt_flag ("-quiet"))
    1603             CmtMessage::error ("Cannot add flag `-quiet'");
    1604         }
    1605       else if (arg == "-warn" ||
    1606                arg == "-warni" ||
    1607                arg == "-warnin" ||
    1608                arg == "-warning" ||
    1609                arg == "-warnings")
    1610         {
    1611           Me.m_warnings = true;
    1612           //      if (CmtMessage::level () > Warning)
    1613           if (CmtMessage::level () != Warning)
    1614             {
    1615               CmtMessage::set_level (Warning);
    1616               //              if (!CmtSystem::putenv ("CMTWARNING", "1"))
    1617               //                CmtMessage::error ("Cannot set `CMTWARNING' in the environment");
    1618             }
    1619           if (!Cmt::add_cmt_flag ("-warnings"))
    1620             CmtMessage::error ("Cannot add flag `-warnings'");
    16211676        }
    16221677    }
     
    16681723
    16691724  CmtSystem::cmt_string_vector uses;
     1725  cmt_vector<int> use_indexes;
    16701726  CmtSystem::cmt_string_vector packages;
    16711727  CmtSystem::cmt_string_vector versions;
    1672   CmtSystem::cmt_string_vector path_selections;
     1728  Project::ConstProjectPtrVector path_selections;
     1729  //  CmtSystem::cmt_string_vector path_selections;
     1730  Project::ConstProjectPtrVector path_exclusions;
    16731731  CmtSystem::cmt_string_vector selections;
    16741732  CmtSystem::cmt_string_vector exclusions;
     
    16771735  bool is_cmt = false;
    16781736  int first = 0;
    1679   int i;
    16801737  bool ignore_errors = false;
    16811738  bool all_packages = false;
    1682 
     1739  int depth (1);
    16831740  bool local = true;
    1684 
    1685   for (i = 0; i < ap.arguments.size (); i++)
     1741  bool global (false);
     1742
     1743  for (int i = 0; i < ap.arguments.size (); i++)
    16861744    {
    16871745      const cmt_string& w = ap.arguments[i];
     
    16991757            {
    17001758              local = false;
     1759              global = false;
    17011760
    17021761              cmt_string depth_str;
    1703               int depth_value = 0;
     1762              int depth_value;
    17041763                         
    17051764              w.substr (7, depth_str);
    1706               if ((sscanf (depth_str.c_str (), "%d", &depth_value) < 1) ||
    1707                   (depth_value < 1))
    1708                 {
     1765              int n = sscanf (depth_str.c_str (), "%d", &depth_value);
     1766              cmt_string msg;
     1767              switch (n)
     1768                {
     1769                case EOF:
     1770                  msg = "Cannot read `depth' value `";
     1771                  msg += depth_str;
     1772                  msg += cmt_string ("'");
     1773                  if (errno)
     1774                    msg += cmt_string (strerror (errno));
     1775                  CmtError::set (CmtError::system_error, msg);
     1776                  return;
     1777                  break;
     1778                case 0:
     1779                  msg = "Invalid `depth' value `";
     1780                  msg += depth_str;
     1781                  msg += cmt_string ("'");
     1782                  CmtError::set (CmtError::syntax_error, msg);
     1783                  return;
     1784                  break;
     1785                case 1:
     1786                  if (depth_value < -1)
     1787                    {
     1788                      char num[32]; sprintf (num, "%lu", -depth_value);
     1789                      msg = "Invalid `depth' value `-";
     1790                      msg += num;
     1791                      msg += cmt_string ("'");
     1792                      CmtError::set (CmtError::syntax_error, msg);
     1793                      return;
     1794                    }
     1795                  depth = depth_value;
     1796                  //cerr << "depth: " << depth << endl;
     1797                  break;
     1798                default:
     1799                  break;
     1800                }
     1801//               if ((sscanf (depth_str.c_str (), "%d", &depth_value) < 1) ||
     1802//                   (depth_value < 1))
     1803//                {
    17091804                  // Syntax error
    17101805                  //  We shall restrict to packages found within
     
    17121807                  //  If CMTPATH is empty, nothing is selected.
    17131808                  // depth=1 is equivalent to local
    1714                 }
    1715 
    1716               Project::fill_selection (depth_value, path_selections);
     1809//                }
     1810
     1811//            Project::fill_selection (depth_value, path_selections);
    17171812            }
    17181813          else if (w.substr (0, 9) == "-exclude=")
     
    17381833          else if (w.substr (0, 7) == "-global")
    17391834            {
    1740               path_selections.clear ();
    1741 
     1835              //path_selections.clear ();
     1836              global = true;
    17421837              local = false;
    17431838            }
     
    17451840            {
    17461841              local = true;
     1842              global = false;
    17471843            }
    17481844          else if (w.substr (0, 8) == "-select=")
     
    17871883    }
    17881884
    1789   if (local)
    1790     {
    1791       Project::fill_selection (1, path_selections);
     1885  const Project* p_cur (Project::get_current ());
     1886  if (global)
     1887    {
     1888      Project::fill_exclusion (path_exclusions);
     1889    }
     1890  else if (local)
     1891    {
     1892      if (p_cur)
     1893        Project::fill_selection (1, path_selections);
     1894      else
     1895        path_selections.push_back (0); // means that we want Use::current ()
     1896      //        path_selections.push_back ((Use::current ()).get_realpath ());
     1897    }
     1898  else
     1899    {
     1900      if (!p_cur
     1901          && depth != 0
     1902          && depth != -1)
     1903        path_selections.push_back (0); // means that we want Use::current ()
     1904//      path_selections.push_back ((Use::current ()).get_realpath ());
     1905      Project::fill_selection (depth, path_selections);
     1906      /*
     1907      cerr << "depth: " << depth << endl;
     1908      for (int j = 0; j < path_selections.size (); j++)
     1909        {
     1910          const Project* sp = path_selections[j];
     1911          cerr << "path_selections: " << (sp ? sp->get_cmtpath () : "current use") << endl;
     1912        }
     1913      */
    17921914    }
    17931915
     
    18001922  //if (command.substr (0, 3) == "cmt") is_cmt = true;
    18011923
    1802   cmt_string curuse = CmtSystem::pwd ();
     1924  //cmt_string curuse = CmtSystem::pwd ();
    18031925  if (all_packages)
    18041926    {
     
    18061928      PathScanner scanner;
    18071929      Project::scan_paths (scanner, selector);
     1930      return;
    18081931    }
    18091932  else
    18101933    {
    1811       for (i = Uses.size () - 1; i >= 0; i--)
     1934      for (int i = Uses.size () - 1; i >= 0; i--)
    18121935        {
    18131936          Use* use = Uses[i];
     
    18151938          if (use->discarded) continue;
    18161939          if (use->m_hidden) continue;
    1817 
    18181940          if (!use->located ())
    18191941            {
    1820               CmtMessage::warning ("package " + use->get_package_name ()
    1821                                    + " " + use->version + " " + use->path
    1822                                    + " not found");
    1823               /*
    1824               if (!Me.m_quiet)
    1825                 {
    1826                   cerr << "#CMT> package " << use->get_package_name () <<
    1827                     " " << use->version << " " << use->path <<
    1828                     " not found" <<
    1829                     endl;
    1830                 }
    1831               */
     1942              CmtMessage::warning
     1943                (CmtError::get_error_name (CmtError::package_not_found)
     1944                 + ": " + use->get_info ());
     1945              continue;
    18321946            }
    1833           else
    1834             {
    1835               if (use->get_package_name () != "CMT")
    1836                 {
    1837                   cmt_string& s = uses.add ();
    1838 
    1839                   use->get_full_path (s);
    1840 
    1841                   s += CmtSystem::file_separator ();
    1842                   if (use->style == mgr_style) s += "mgr";
    1843                   else s += "cmt";
    1844 
    1845                   cmt_string& v = versions.add ();
    1846                   v = use->version;
    1847 
    1848                   cmt_string& p = packages.add ();
    1849                   p = use->get_package_name ();
    1850                 }
    1851             }
    1852         }
     1947          if (use->get_package_name () == "CMT") continue;
     1948
     1949          cmt_string& s = uses.add ();
     1950          use->get_full_path (s);
     1951          switch (use->style)
     1952            {
     1953            case cmt_style:
     1954              s += CmtSystem::file_separator ();
     1955              s += "cmt";
     1956              break;
     1957            case mgr_style:
     1958              s += CmtSystem::file_separator ();
     1959              s += "mgr";
     1960              break;
     1961            default:
     1962              break;
     1963            }
     1964//                   if (use->style == mgr_style) s += "mgr";
     1965//                   else s += "cmt";
     1966
     1967          cmt_string& v = versions.add ();
     1968          v = use->version;
     1969         
     1970          cmt_string& p = packages.add ();
     1971          p = use->get_package_name ();
     1972         
     1973          int& use_index = use_indexes.add ();
     1974          use_index = i;
     1975        }
    18531976         
    18541977      {
     1978        Use* use = &(Use::current ());
     1979       
    18551980        cmt_string& s = uses.add ();
     1981        use->get_full_path (s);
     1982        switch (use->style)
     1983          {
     1984          case cmt_style:
     1985            s += CmtSystem::file_separator ();
     1986            s += "cmt";
     1987            break;
     1988          case mgr_style:
     1989            s += CmtSystem::file_separator ();
     1990            s += "mgr";
     1991            break;
     1992          default:
     1993            break;
     1994          }
     1995//         if (use->get_package_name ().find ("cmt_standalone") != cmt_string::npos)
     1996//           {
     1997//             s = CmtSystem::pwd ();
     1998//           }
     1999//         else
     2000//           {
     2001//             use->get_full_path (s);
     2002
     2003//             s += CmtSystem::file_separator ();
    18562004                 
    1857         Use* use = &(Use::current ());
    1858 
    1859         if (use->get_package_name ().find ("cmt_standalone") != cmt_string::npos)
    1860           {
    1861             s = CmtSystem::pwd ();
    1862           }
    1863         else
    1864           {
    1865             use->get_full_path (s);
    1866 
    1867             s += CmtSystem::file_separator ();
    1868                  
    1869             if (use->style == mgr_style) s += "mgr";
    1870             else s += "cmt";
    1871           }
    1872 
    1873         curuse = s;
     2005//             if (use->style == mgr_style) s += "mgr";
     2006//             else s += "cmt";
     2007//           }
     2008        //curuse = s;
    18742009
    18752010        cmt_string& v = versions.add ();
     
    18782013        cmt_string& p = packages.add ();
    18792014        p = use->get_package_name ();
     2015         
     2016        int& use_index = use_indexes.add ();
     2017        use_index = -1;
    18802018      }
    18812019    }
     
    18912029    CmtSystem::putenv ("CMTBCAST", "");
    18922030
    1893   for (i = 0; i < uses.size (); i++)
     2031  for (int i = 0; i < uses.size (); i++)
    18942032    {
    18952033      const cmt_string& s = uses[i];
    18962034      const cmt_string& v = versions[i];
    18972035      const cmt_string& p = packages[i];
     2036      const int use_index = use_indexes[i];
     2037
     2038      const Use* use = use_index >= 0 ? Uses[use_index] : &(Use::current ());
     2039      const Project* up = use->get_project ();
     2040
    18982041      cmt_string cmtpath;
    18992042
    19002043      bool ok = true;
    1901       bool selected = true;
     2044      bool selected = global ? true : false;
    19022045      bool excluded = false;
    19032046
    1904       /**
    1905          Ensure that the current package is not skipped
    1906          due to symlinks in the paths
    1907        */
    1908       //      if (path_selections.size () > 0)
    1909       if (path_selections.size () > 0 && s != curuse)
     2047      ok = selected;
     2048      if (path_selections.size () > 0)
    19102049        {
    19112050          selected = false;
    1912 
    19132051          for (int j = 0; j < path_selections.size (); j++)
    19142052            {
    1915               const cmt_string& sel = path_selections[j];
    1916              
    1917               if (s.find (sel) != cmt_string::npos)
    1918                 {
    1919                   cmtpath = sel;
    1920                   selected = true;
    1921                   break;
    1922                 }
    1923             }
    1924 
     2053              const Project* sp = path_selections[j];
     2054              if (sp)
     2055                {
     2056                  if (up)
     2057                    {
     2058                      if (up == sp)
     2059                        {
     2060                          cmtpath = sp->get_cmtpath ();
     2061                          selected = true;
     2062                          break;
     2063                        }
     2064                    }
     2065                  else
     2066                    {
     2067                      if (use->get_realpath ().find (sp->get_cmtpath_real ()) == 0)
     2068                        {
     2069                          cmtpath = sp->get_cmtpath ();
     2070                          selected = true;
     2071                          break;
     2072                        }
     2073                    }
     2074                }
     2075              else if (use == &(Use::current ()))
     2076                {
     2077                  // means that we want Use::current ()
     2078                  // cmtpath = sp->get_cmtpath ();
     2079                  if (up)
     2080                    cmtpath = up->get_cmtpath ();
     2081                  else
     2082                    cmtpath = "";
     2083                  selected = true;
     2084                  break;
     2085                }
     2086              // const cmt_string& sel = path_selections[j];
     2087              // if (s.find (sel) != cmt_string::npos)
     2088//                 {
     2089//                cmtpath = sel;
     2090//                   selected = true;
     2091//                   break;
     2092//                 }
     2093            }
    19252094          ok = selected;
    19262095        }
     
    19602129        }
    19612130
    1962 
    19632131      if (ok)
    19642132        {
     
    19742142                  break;
    19752143                }
     2144            }
     2145
     2146          if (excluded) ok = false;
     2147        }
     2148
     2149      if (ok)
     2150        {
     2151          excluded = false;
     2152          for (int j = 0; j < path_exclusions.size (); j++)
     2153            {
     2154              const Project* sp = path_exclusions[j];
     2155              if (up)
     2156                {
     2157                  if (up == sp)
     2158                    {
     2159                      excluded = true;
     2160                      break;
     2161                    }
     2162                }
     2163              else
     2164                {
     2165                  if (use->get_realpath ().find (sp->get_cmtpath_real ()) == 0)
     2166                    {
     2167                      excluded = true;
     2168                      break;
     2169                    }
     2170                }
    19762171            }
    19772172
     
    20212216        }
    20222217
     2218      /*
    20232219      if (cmtpath == "")
    20242220        {
     
    20262222          cmtpath = Project::find_in_cmt_paths (sel);
    20272223        }
     2224      */
    20282225
    20292226      cmt_string cmd = command;
     
    20412238      static const cmt_string empty_string;
    20422239      static const cmt_string fs = CmtSystem::file_separator ();
    2043       cmt_string offset = s;
    2044       offset.replace (cmtpath, empty_string);
    2045       if (offset[0] == CmtSystem::file_separator ())
    2046         {
    2047           offset.replace (fs, empty_string);
    2048         }
    2049       CmtSystem::dirname (offset, offset);
    2050 
    2051       cmt_string n;
    2052       CmtSystem::basename (offset, n);
    2053       if (n == p)
    2054         {
     2240      cmt_string offset;
     2241      if (cmtpath.size ())
     2242        {
     2243          offset = s;
     2244          offset.replace (cmtpath, empty_string);
     2245          if (offset[0] == CmtSystem::file_separator ())
     2246            {
     2247              offset.replace (fs, empty_string);
     2248            }
    20552249          CmtSystem::dirname (offset, offset);
     2250         
     2251          cmt_string n;
     2252          CmtSystem::basename (offset, n);
     2253          if (n == p)
     2254            {
     2255              CmtSystem::dirname (offset, offset);
     2256            }
     2257          else
     2258            {
     2259              CmtSystem::dirname (offset, offset);
     2260              CmtSystem::dirname (offset, offset);
     2261            }
    20562262        }
    20572263      else
    20582264        {
    2059           CmtSystem::dirname (offset, offset);
    2060           CmtSystem::dirname (offset, offset);
    2061         }
    2062 
     2265          offset = use->real_path;
     2266        }
    20632267      cmd.replace_all (offset_template, offset);
    20642268
     
    29043108    }
    29053109
    2906   static CmtSystem::cmt_string_vector tags;
     3110  //  static CmtSystem::cmt_string_vector tags;
    29073111
    29083112  if (action_build_constituents_config != get_action ())
    2909     CmtSystem::split (Me.m_extra_tags, " \t,", tags);
    2910 
    2911   for (int i = 0; i < tags.size (); i++)
    2912     {
    2913       const cmt_string& t = tags[i];
    2914 
    2915       tag = Tag::find (t);
    2916       if (tag == 0) continue;
    2917 
    2918       if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag))
    2919         {
    2920           CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling");
    2921           //      cerr << "#CMT> The tag " << t << " is not used in any tag expression. Please check spelling" << endl;
     3113    {
     3114    //    CmtSystem::split (Me.m_extra_tags, " \t,", tags);
     3115
     3116    //  for (int i = 0; i < tags.size (); i++)
     3117      //    {
     3118      //      const cmt_string& t = tags[i];
     3119      for (int i = 0; i < Me.m_extra_tags.size (); i++)
     3120        {
     3121          const cmt_string& t = Me.m_extra_tags[i];
     3122          tag = Tag::find (t);
     3123          if (tag == 0) continue;
     3124          if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag))
     3125            {
     3126              CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling");
     3127            }
     3128        }
     3129      for (int i = 0; i < Me.m_tags.size (); i++)
     3130        {
     3131          const cmt_string& t = Me.m_tags[i];
     3132          tag = Tag::find (t);
     3133          if (tag == 0) continue;
     3134          if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag))
     3135            {
     3136              CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling");
     3137            }
     3138        }
     3139      for (int i = 0; i < Me.m_tags_add.size (); i++)
     3140        {
     3141          const cmt_string& t = Me.m_tags_add[i];
     3142          tag = Tag::find (t);
     3143          if (tag == 0) continue;
     3144          if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag))
     3145            {
     3146              CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling");
     3147            }
    29223148        }
    29233149    }
     
    29403166    {
    29413167      CmtMessage::warning ("The CMTSITE value " + env + " is not used in any tag expression. Please check spelling");
    2942       //      cerr << "#CMT> The CMTSITE value " << env << " is not used in any tag expression. Please check spelling" << endl;
    29433168    }
    29443169
     
    44764701
    44774702  Use& use = Use::current();   
     4703  /*
    44784704  use.get_cmtpath_and_offset (cmtpath, offset);
    44794705
    44804706  Project* p = Project::find_by_cmtpath (cmtpath);
    4481 
    4482   cout << p->get_author () << endl;
     4707  */
     4708  if (const Project* p = use.get_project ())
     4709    cout << p->get_author () << endl;
    44834710}
    44844711
     
    45034730  ClientCollector collector (package, version);
    45044731
     4732  /*
    45054733  clear     ();
    45064734  //  configure ();
    45074735  configure (ap);
     4736  */
    45084737
    45094738  cout << "# ----------- Clients of " << package
     
    54255654  log << "guess_current_project" << log_endl;
    54265655
    5427   cmt_string here = CmtSystem::pwd ();
     5656  //  cmt_string here = CmtSystem::pwd ();
    54285657
    54295658  Use& use = Use::current();
     
    54385667    //  if (Project::find_in_cmt_paths (Me.m_current_dir) == "")
    54395668    {
     5669      /*
    54405670      if (!CmtSystem::cd (current_path))
    54415671        {
     
    54445674          return;
    54455675        }
     5676      */
    54465677      cmt_string project_file = "cmt";
    54475678      project_file += CmtSystem::file_separator ();
    54485679      project_file += Project::get_project_file_name ();
    54495680
    5450       cmt_string pwd;
     5681      /*
     5682      cmt_string pwd (CmtSystem::pwd ());
     5683      cmt_string pwd_prev;
     5684      */
     5685      cmt_string dir_cur (current_path);
     5686      cmt_string dir_par;
     5687
     5688      cmt_string proj_file_cur;
    54515689
    54525690      for (;;)
    54535691        {
    5454           pwd = CmtSystem::pwd ();
     5692          /*
     5693          //      pwd = CmtSystem::pwd ();
    54555694          if (CmtSystem::test_file (project_file))
    54565695            {
     
    54625701              break;
    54635702            }
    5464 
    5465           log << "pwd=" << CmtSystem::pwd () << log_endl;
     5703          */
     5704          proj_file_cur = dir_cur;
     5705          proj_file_cur += CmtSystem::file_separator ();
     5706          proj_file_cur += project_file;
     5707          if (CmtSystem::test_file (proj_file_cur))
     5708            {
     5709              //this directory should become the first entry of the CMTPATH
     5710
     5711              IProjectFactory& factory = ProjectFactory::instance ();
     5712              factory.create_project ("", dir_cur, "CurrentProject", 0);
     5713
     5714              break;
     5715            }
     5716
     5717          /*
     5718          log << "pwd=" << pwd << log_endl;
    54665719         
    54675720          if (!CmtSystem::cd (".."))
     
    54715724            }
    54725725
    5473           if (CmtSystem::pwd () == pwd)
     5726          pwd_prev = pwd;
     5727          pwd = CmtSystem::pwd ();
     5728          if (pwd == pwd_prev)
     5729            //    if (CmtSystem::pwd () == pwd)
    54745730            {
    54755731              log << "Looks the same pwd..." << log_endl;
    54765732              break;
    54775733            }
    5478         }
    5479 
    5480       CmtSystem::cd (Me.m_current_dir);
    5481     }
     5734          */
     5735          log << "dir_cur=`" << dir_cur << "'" << log_endl;
     5736          CmtSystem::dirname (dir_cur, dir_par);
     5737          if (dir_par == dir_cur)
     5738            {
     5739              log << "Looks the same dir_cur..." << log_endl;
     5740              break;
     5741            }
     5742          dir_cur = dir_par;
     5743        }
     5744
     5745      //      CmtSystem::cd (Me.m_current_dir);
     5746    } // if (Project::find_in_cmt_paths (current_path) == "")
    54825747
    54835748  //cmt_string buffer = "path CMTPATH \n";
     
    54965761  Me.m_autoconfigure_cmtpath = true;
    54975762
    5498   CmtSystem::cd (here);
     5763  //  CmtSystem::cd (Me.m_current_dir);
     5764  //CmtSystem::cd (here);
    54995765}
    55005766
     
    64096675
    64106676  /**
    6411    * See reach_current_package for an explanation of this call
     6677   * See apply_globals for an explanation of this call
    64126678   */
    64136679  Pattern::apply_all_globals ();
     
    64446710  Me.m_action = action_none;
    64456711
    6446   restore_all_tags (0);
     6712  //  restore_all_tags (0);
    64476713
    64486714#ifdef WIN32
     
    64986764  clear ();
    64996765
     6766  //  Me.clear ();
     6767
     6768  parse_arguments (ap);
     6769
    65006770  //  configure ();
    6501   configure (ap);
    6502 
    6503   CmtError::clear ();
     6771  switch (Me.m_action)
     6772    {
     6773    case action_none :
     6774    case action_build_temporary_name :
     6775    case action_help :
     6776      break;
     6777    default:
     6778      configure (ap);
     6779      restore_all_tags (0);
     6780      break;
     6781    }
     6782 
     6783  //  CmtError::clear ();
    65046784
    65056785  /*
    6506     Set private if positioned inside the package
     6786    Set DeveloperMode if positioned inside the package
    65076787    (which is detected since we were able to retreive the
    65086788    Version, Package and Path)
    65096789  */
    65106790
     6791  if (!Use::current().located ())
     6792  /*
    65116793  if ((Me.m_current_path.size () == 0) ||
    65126794      (Me.m_current_package.size () == 0) ||
    65136795      (Me.m_current_version.size () == 0))
     6796  */
    65146797    {
    65156798      Me.m_current_access = UserMode;
     
    65206803    }
    65216804 
    6522   parse_arguments (ap);
     6805  //  parse_arguments (ap);
    65236806 
    65246807  if (ap.help_action == action_help)
     
    69297212        Me.m_warnings = false;
    69307213        if (strlen (ap.extra_file.c_str ()) == 0)
    6931           reach_current_package ();
     7214          use_current_package ();
     7215        //        reach_current_package ();
    69327216        else
    69337217          use_extra_file (ap.extra_file);
     
    69357219        if (strlen (ap.extra_line.c_str ()) > 0)
    69367220          SyntaxParser::parse_requirements_text (ap.extra_line, "extra statement(s)", (Use*) 0);
     7221        apply_globals ();
    69377222        Me.m_warnings = w;
    6938         //if (strlen (ap.extra_line.c_str ()) > 0) SyntaxParser::parse_requirements_line (ap.extra_line, &(Use::current ()));
    69397223      }
    69407224      break;
     
    69527236  if (use != 0 && !use->discarded && !use->m_hidden && use->located ())
    69537237    uses.push_back (use);
    6954   uses.push_back (&(Use::current()));
     7238  use = &(Use::current());
     7239  if (use != 0 && !use->discarded && !use->m_hidden && use->located ())
     7240    uses.push_back (use);
     7241  //  uses.push_back (&(Use::current()));
    69557242  use = Use::find (CmtSystem::get_user_context_package ());
    69567243  if (use != 0 && !use->discarded && !use->m_hidden && use->located ())
     
    74527739  //
    74537740
     7741  /*
    74547742  {
    74557743    CmtSystem::cmt_string_vector words;
     
    74777765      }
    74787766  }
    7479 
     7767  */
    74807768  if (mode == Requirements)
    74817769    {
     
    79398227
    79408228//----------------------------------------------------------
    7941 int Cmt::reach_current_package ()
     8229int Cmt::use_current_package ()
    79428230{
    79438231  Use& use = Use::current ();
     
    79468234  if (Me.m_debug)
    79478235    {
    7948       cout << "Cmt::reach_current_package> pwd = "
     8236      cout << "Cmt::use_current_package> pwd = "
    79498237           << CmtSystem::pwd ()
    79508238           << " path=" << Me.m_current_path
     
    79598247  if (Me.m_current_package == "cmt_standalone")
    79608248    {
    7961       if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ()))
     8249      if ((Me.m_current_path != "") && (Me.m_current_path != Me.m_current_dir))
     8250//      if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ()))
    79628251        {
    79638252          if (!CmtSystem::cd (Me.m_current_path))
    79648253            {
    79658254              CmtError::set (CmtError::package_not_found,
    7966                              "ReachCurrentPackage> Cannot reach the path directory");
     8255                             "Cannot reach the path directory: "
     8256                             + Me.m_current_path);
    79678257              return (0);
    79688258            }
     
    79758265
    79768266      Me.m_current_structuring_style = without_version_directory;
     8267      use.structuring_style = Me.m_current_structuring_style;
     8268      use.change_path (Me.m_current_path, Project::get_current ());
     8269      Me.m_current_access = DeveloperMode;
    79778270    }
    79788271  else if (Me.m_current_package != "")
    79798272    {
    7980       if (!use.move_to () && !use.move_to ("", true))
    7981         //      if (!use.move_to ())
    7982         {
    7983           CmtError::set (CmtError::package_not_found, use.get_info ());
    7984 //           CmtError::set (CmtError::package_not_found,
    7985 //                          "ReachCurrentPackage> Cannot reach the path directory");
    7986           return (0);
    7987         }
    7988 
    7989       Me.m_current_path = use.real_path;
     8273      if (!use.located ())
     8274        {
     8275          //      if (!use.move_to () && !use.move_to ("", true))
     8276            //      if (!use.move_to ())
     8277          if (!use.move_to ())
     8278            {
     8279              if (!CmtSystem::cd (Cmt::get_current_dir ()))
     8280                {
     8281                  CmtError::set (CmtError::file_access_error,
     8282                                 Cmt::get_current_dir ()
     8283                                 + " (use_current_package)");
     8284                  return 0;
     8285                }
     8286              if (!use.move_to ("", true))
     8287                {
     8288                  CmtError::set (CmtError::package_not_found, use.get_info ());
     8289                  return 0;
     8290                }
     8291            }
     8292         
     8293          Me.m_current_path = use.real_path;
     8294          Me.m_current_access = DeveloperMode;
     8295        }
    79908296    }
    79918297  else
     
    80258331             
    80268332              CmtError::set (CmtError::package_not_found,
    8027                              "ReachCurrentPackage> Cannot reach the mgr/cmt directory");
     8333                             "Cannot reach the mgr/cmt directory: "
     8334                             + use.get_info ());
    80288335              return (0);
    80298336            }
     
    80318338      else
    80328339        Me.m_current_style = none_style;
     8340
     8341      Me.m_current_access = DeveloperMode;
    80338342
    80348343      dir = CmtSystem::pwd ();
     
    80588367      use.style   = Me.m_current_style;
    80598368      use.structuring_style = Me.m_current_structuring_style;
    8060     }
    8061 
     8369
     8370      configure_current_dir ();
     8371      build_prefix (Me.m_current_package, Me.m_current_prefix);
     8372      build_config (Me.m_current_prefix, Me.m_current_config);
     8373    }
     8374
     8375  /*
    80628376  configure_current_dir ();
    80638377  build_prefix (Me.m_current_package, Me.m_current_prefix);
    80648378  build_config (Me.m_current_prefix, Me.m_current_config);
     8379  */
    80658380
    80668381  /*
     
    80688383  */
    80698384
    8070   if (Me.m_debug) cout << "reach_current_package0> current_tag=" << Me.m_current_tag << endl;
     8385  if (Me.m_debug) cout << "use_current_package0> current_tag=" << Me.m_current_tag << endl;
    80718386
    80728387  if (Me.m_current_tag == "")
     
    80798394          Tag* tag;
    80808395
    8081           tag = Tag::add (env, PriorityConfig, "reach current package", 0);
     8396          tag = Tag::add (env, PriorityConfig, "current package", 0);
    80828397          tag->mark (use.get_package_name ());
    80838398          //Me.m_current_tag = env;
    80848399
    8085           //if (!Me.m_quiet) cerr << "reach_current_package1> current_tag=" << Me.m_current_tag << endl;
     8400          //if (!Me.m_quiet) cerr << "use_current_package1> current_tag=" << Me.m_current_tag << endl;
    80868401
    80878402        }
     
    81018416  SyntaxParser::parse_requirements (dir, &use);
    81028417
    8103   if (Me.m_debug) cout << "reach_current_package2> current_tag=" << Me.m_current_tag << endl;
     8418  if (CmtError::has_pending_error ()) return 0;
     8419
     8420  if (Me.m_debug) cout << "use_current_package2> current_tag=" << Me.m_current_tag << endl;
     8421
     8422  return 1;
     8423}
     8424
     8425//----------------------------------------------------------
     8426int Cmt::use_extra_file (const cmt_string& file)
     8427{
     8428  if (!CmtSystem::test_file (file))
     8429    {
     8430      CmtError::set (CmtError::path_not_found, file);
     8431      return 0;
     8432    }
     8433
     8434  // (almost) Cmt::use_current_package ()
     8435  Use& use = Use::current ();
     8436  /*
     8437    Try to access the package.
     8438  */
     8439
     8440  if (Me.m_current_package == "cmt_standalone")
     8441    {
     8442      if ((Me.m_current_path != "") && (Me.m_current_path != Me.m_current_dir))
     8443//      if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ()))
     8444        {
     8445          if (!CmtSystem::cd (Me.m_current_path))
     8446            {
     8447              CmtError::set (CmtError::package_not_found,
     8448                             "Cannot reach the path directory: "
     8449                             + Me.m_current_path);
     8450              return (0);
     8451            }
     8452        }
     8453      /*
     8454      if (!CmtSystem::test_file ("requirements"))
     8455        {
     8456          return (0);
     8457        }
     8458      */
     8459      Me.m_current_structuring_style = without_version_directory;
     8460      use.structuring_style = Me.m_current_structuring_style;
     8461      use.change_path (Me.m_current_path, Project::get_current ());
     8462      Me.m_current_access = DeveloperMode;
     8463    }
     8464  else if (Me.m_current_package != "")
     8465    {
     8466      if (!use.located ())
     8467        {
     8468          //      if (!use.move_to () && !use.move_to ("", true))
     8469            //      if (!use.move_to ())
     8470          if (!use.move_to ())
     8471            {
     8472              if (!CmtSystem::cd (Cmt::get_current_dir ()))
     8473                {
     8474                  CmtError::set (CmtError::file_access_error,
     8475                                 Cmt::get_current_dir ()
     8476                                 + " (use_extra_file)");
     8477                  return 0;
     8478                }
     8479              if (!use.move_to ("", true))
     8480                {
     8481                  CmtError::set (CmtError::package_not_found, use.get_info ());
     8482                  return 0;
     8483                }
     8484            }
     8485         
     8486          Me.m_current_path = use.real_path;
     8487          Me.m_current_access = DeveloperMode;
     8488        }
     8489    }
     8490  else
     8491    {
     8492      //
     8493      // The cmt command has been given without explicit search for
     8494      // a package. Thus it is expected that we are in the context of a
     8495      // true package.
     8496      //
     8497      //  This means that there should be a requirements file visible.
     8498      //
     8499      //  If this is not true, we'll make a try into ../cmt and then
     8500      // a last try into ../mgr
     8501      //
     8502
     8503      Me.m_current_access = DeveloperMode;
     8504      //...
     8505      configure_current_dir ();
     8506      build_prefix (Me.m_current_package, Me.m_current_prefix);
     8507      build_config (Me.m_current_prefix, Me.m_current_config);
     8508    }
     8509
     8510  /*
     8511  configure_current_dir ();
     8512  build_prefix (Me.m_current_package, Me.m_current_prefix);
     8513  build_config (Me.m_current_prefix, Me.m_current_config);
     8514  */
     8515
     8516  /*
     8517    Check Tag is always set up
     8518  */
     8519
     8520  if (Me.m_debug) cout << "use_extra_file0> current_tag=" << Me.m_current_tag << endl;
     8521
     8522  if (Me.m_current_tag == "")
     8523    {
     8524      cmt_string env;
     8525
     8526      env = CmtSystem::getenv (Me.m_current_config);
     8527      if (env != "")
     8528        {
     8529          Tag* tag;
     8530
     8531          tag = Tag::add (env, PriorityConfig, "current package", 0);
     8532          tag->mark (use.get_package_name ());
     8533          //Me.m_current_tag = env;
     8534
     8535          //if (!Me.m_quiet) cerr << "use_extra_file1> current_tag=" << Me.m_current_tag << endl;
     8536
     8537        }
     8538    }
     8539
     8540  if (Me.m_debug)
     8541    {
     8542      cout << "pwd = " << CmtSystem::pwd () << endl;
     8543    }
     8544
     8545  /*
     8546    Work on the requirements file.
     8547  */
     8548
     8549  SyntaxParser::parse_requirements (file, &use);
     8550
     8551  if (CmtError::has_pending_error ()) return 0;
     8552
     8553  if (Me.m_debug) cout << "use_extra_file2> current_tag=" << Me.m_current_tag << endl;
     8554  return 1;
     8555}
     8556
     8557//----------------------------------------------------------
     8558int Cmt::apply_globals ()
     8559{
    81048560
    81058561  /**
     
    81328588  Tag::restore_tree ();
    81338589
    8134   return (1);
    8135 }
    8136 
    8137 //----------------------------------------------------------
    8138 int Cmt::use_extra_file (const cmt_string& file)
    8139 {
    8140   if (!CmtSystem::test_file (file))
    8141     {
    8142       CmtError::set (CmtError::path_not_found, file);
    8143       return 0;
    8144     }
    8145 
    8146   // (almost) Cmt::reach_current_package ()
    8147   Use& use = Use::current ();
    8148   /*
    8149     Try to access the package.
    8150   */
    8151 
    8152   if (Me.m_current_package == "cmt_standalone")
    8153     {
    8154       if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ()))
    8155         {
    8156           if (!CmtSystem::cd (Me.m_current_path))
    8157             {
    8158               CmtError::set (CmtError::package_not_found,
    8159                              "ReachCurrentPackage> Cannot reach the path directory");
    8160               return (0);
    8161             }
    8162         }
    8163       /*
    8164       if (!CmtSystem::test_file ("requirements"))
    8165         {
    8166           return (0);
    8167         }
    8168       */
    8169       Me.m_current_structuring_style = without_version_directory;
    8170     }
    8171   else if (Me.m_current_package != "")
    8172     {
    8173       if (!use.move_to () && !use.move_to ("", true))
    8174         //      if (!use.move_to ())
    8175         {
    8176           CmtError::set (CmtError::package_not_found, use.get_info ());
    8177 //           CmtError::set (CmtError::package_not_found,
    8178 //                          "ReachCurrentPackage> Cannot reach the path directory");
    8179           //          return -1;
    8180           return (0);
    8181         }
    8182 
    8183       Me.m_current_path = use.real_path;
    8184     }
    8185   else
    8186     {
    8187       //
    8188       // The cmt command has been given without explicit search for
    8189       // a package. Thus it is expected that we are in the context of a
    8190       // true package.
    8191       //
    8192       //  This means that there should be a requirements file visible.
    8193       //
    8194       //  If this is not true, we'll make a try into ../cmt and then
    8195       // a last try into ../mgr
    8196       //
    8197 
    8198       //...
    8199     }
    8200 
    8201   configure_current_dir ();
    8202   build_prefix (Me.m_current_package, Me.m_current_prefix);
    8203   build_config (Me.m_current_prefix, Me.m_current_config);
    8204 
    8205   /*
    8206     Check Tag is always set up
    8207   */
    8208 
    8209   if (Me.m_debug) cout << "use_extra_file0> current_tag=" << Me.m_current_tag << endl;
    8210 
    8211   if (Me.m_current_tag == "")
    8212     {
    8213       cmt_string env;
    8214 
    8215       env = CmtSystem::getenv (Me.m_current_config);
    8216       if (env != "")
    8217         {
    8218           Tag* tag;
    8219 
    8220           tag = Tag::add (env, PriorityConfig, "reach current package", 0);
    8221           tag->mark (use.get_package_name ());
    8222           //Me.m_current_tag = env;
    8223 
    8224           //if (!Me.m_quiet) cerr << "use_extra_file1> current_tag=" << Me.m_current_tag << endl;
    8225 
    8226         }
    8227     }
    8228 
    8229   if (Me.m_debug)
    8230     {
    8231       cout << "pwd = " << CmtSystem::pwd () << endl;
    8232     }
    8233 
    8234   /*
    8235     Work on the requirements file.
    8236   */
    8237 
    8238   SyntaxParser::parse_requirements (file, &use);
    8239 
    8240   if (Me.m_debug) cout << "use_extra_file2> current_tag=" << Me.m_current_tag << endl;
    8241 
    8242   /**
    8243    *   It would be useful to change this mechanism. Instead of
    8244    *  applying all global patterns at once to all use contexts, it
    8245    *  would be much better to apply it at the end of each
    8246    *  requirements file parsing, and only in the context the
    8247    *  appropriate Use.
    8248    *
    8249    *   This would avoid the current flaw which is that when a global
    8250    *  pattern specifies a "private" definition, it is actually
    8251    *  applied in the scope context of the Current Use and not in
    8252    *  each individual Use. Therefore the private is lost.
    8253    *
    8254    *   However, this induces problems since some pattern definitions
    8255    *  are done AFTER the use statements, which will NOT receive the
    8256    *  pattern aplications.
    8257    *
    8258    *   Therefore it is decided to leave this "bad" mechanism until
    8259    *  everybody is aware of this constraint.
    8260    *
    8261    *
    8262    */
    8263   Pattern::apply_all_globals ();
    8264 
    8265   /*
    8266     Select all possible tags
    8267   */
    8268 
    8269   Tag::restore_tree ();
    8270 
    8271   return (1);
     8590  if (CmtError::has_pending_error ()) return 0;
     8591
     8592  return 1;
    82728593}
    82738594
     
    997210293  if (CmtSystem::test_file (f))
    997310294    {
    9974       use->m_located = true;
    9975     }
    9976   SyntaxParser::parse_requirements (f, use);
     10295      use->style = none_style;
     10296      use->structuring_style = without_version_directory;
     10297
     10298      if (name == CmtSystem::get_home_package () ||
     10299          name == CmtSystem::get_user_context_package ())
     10300        {
     10301          const Project::ProjectPtrVector& Ordered = Project::ordered_projects ();
     10302          if (0 == Ordered.size ())
     10303            {
     10304              CmtError::set(CmtError::configuration_error,
     10305                            "No ordered project: " + use->get_info ());
     10306              return;
     10307            }
     10308          if (name == CmtSystem::get_home_package ())
     10309            use->change_path (path, Ordered[Ordered.size () - 1]);
     10310          else if (name == CmtSystem::get_user_context_package ())
     10311            use->change_path (path, Ordered[0]);
     10312        }
     10313      else
     10314        {
     10315          CmtMessage::verbose
     10316            (CmtError::get_error_name (CmtError::configuration_error)
     10317             + ": Unknown special use: " + use->get_info ());
     10318          use->change_path (path);
     10319        }
     10320      //      use->m_located = true;
     10321      SyntaxParser::parse_requirements (f, use);
     10322    }
     10323  else
     10324    {
     10325      use->discard ();
     10326    }
    997710327
    997810328  Me.m_recursive = recursive_copy;
Note: See TracChangeset for help on using the changeset viewer.