Ignore:
Timestamp:
Apr 16, 2012, 12:17:30 PM (12 years ago)
Author:
rybkin
Message:

See C.L. 485

File:
1 edited

Legend:

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

    r608 r610  
    22202220}
    22212221
    2222 static bool find_path_entry (const cmt_string& paths, const cmt_string& value)
     2222static bool find_path_entry (const CmtSystem::cmt_string_vector& items, const cmt_string& value)
    22232223{
    22242224  static const cmt_string path_separator = CmtSystem::path_separator ();
    22252225  static cmt_vmap <cmt_string, cmt_string> realpaths;
     2226
     2227  if (value.size () == 0) return true;
    22262228
    22272229  cmt_string rvalue;
     
    22402242    }
    22412243
    2242   CmtSystem::cmt_string_vector items;
    2243   CmtSystem::split (paths, path_separator, items);
     2244  //  CmtSystem::cmt_string_vector items;
     2245  //  CmtSystem::split (paths, path_separator, items);
    22442246
    22452247  bool found = false;
     
    22482250    {
    22492251      const cmt_string& item = items[i];
     2252      if (item.size () == 0) continue;
    22502253      cmt_string ritem;
    22512254      const cmt_string * pritem;
     
    22722275}
    22732276
     2277static bool find_path_entry (const cmt_string& paths, const cmt_string& value)
     2278{
     2279  static const cmt_string path_separator = CmtSystem::path_separator ();
     2280  static cmt_vmap <cmt_string, cmt_string> realpaths;
     2281
     2282  cmt_string rvalue;
     2283  const cmt_string * prvalue;
     2284
     2285  if (!(prvalue = realpaths.find (value)))
     2286    {
     2287      if (!CmtSystem::realpath_ (value, rvalue))
     2288        {
     2289          rvalue = value;
     2290          CmtSystem::compress_path (rvalue);
     2291        }
     2292      prvalue = &rvalue;
     2293      realpaths.add (value, rvalue);
     2294      //      cerr << "realpaths.add: " << value << " , " << rvalue << endl;
     2295    }
     2296
     2297  CmtSystem::cmt_string_vector items;
     2298  CmtSystem::split (paths, path_separator, items);
     2299
     2300  bool found = false;
     2301
     2302  for (int i = 0; i < items.size (); i++)
     2303    {
     2304      const cmt_string& item = items[i];
     2305      cmt_string ritem;
     2306      const cmt_string * pritem;
     2307
     2308      if (!(pritem = realpaths.find (item)))
     2309        {
     2310          if (!CmtSystem::realpath_ (item, ritem))
     2311            {
     2312              ritem = item;
     2313              CmtSystem::compress_path (ritem);
     2314            }
     2315          pritem = &ritem;
     2316          realpaths.add (item, ritem);
     2317          //  cerr << "realpaths.add: " << item << " , " << ritem << endl;
     2318        }
     2319      if (*pritem == *prvalue)
     2320        {
     2321          found = true;
     2322          break;
     2323        }
     2324    }
     2325
     2326  return (found);
     2327}
     2328
    22742329//-------------------------------------------------------------
    22752330const cmt_string PathBuilder::build (const Symbol& symbol,
     
    22822337
    22832338  cmt_string temp;
    2284   cmt_string previous_temp;
     2339  CmtSystem::cmt_string_vector temp_vector;
     2340  //  cmt_string previous_temp;
     2341  CmtSystem::cmt_string_vector new_value_vector;
    22852342  cmt_string new_value;
    22862343  static const cmt_string empty;
     
    23012358  level++;
    23022359
    2303   temp = CmtSystem::getenv (symbol.name);
     2360  CmtSystem::split (CmtSystem::getenv (symbol.name), path_separator, temp_vector);
     2361  //temp = CmtSystem::getenv (symbol.name);
    23042362
    23052363  bool first_definition = true;
     
    23372395                !symbol.value_is_reflexive (value.text))
    23382396              {
     2397                Cmt::vector_to_string (temp_vector, path_separator, temp);
    23392398                resolve_value (new_value, symbol.name, temp);
    2340                 temp = new_value;
     2399                CmtSystem::split (new_value, path_separator, temp_vector);
     2400                //temp = new_value;
    23412401              }
    23422402
     
    23462406            if (new_value != "")
    23472407              {
    2348                 if (!find_path_entry (temp, new_value))
    2349                   {
    2350                     if (temp != "") temp += path_separator;
    2351                      
    2352                     temp += new_value;
    2353                   }
     2408                CmtSystem::split (new_value, path_separator, new_value_vector);
     2409                for (int i = 0; i < new_value_vector.size (); i++)
     2410                  if (!find_path_entry (temp_vector, new_value_vector[i]))
     2411                    //if (!find_path_entry (temp, new_value))
     2412                    {
     2413                      temp_vector.push_back (new_value_vector[i]);
     2414                      /*
     2415                        if (temp != "") temp += path_separator;
     2416                       
     2417                        temp += new_value;
     2418                      */
     2419                    }
    23542420              }
    23552421                 
     
    23592425            if (new_value != "")
    23602426              {
    2361                 if (!find_path_entry (temp, new_value))
    2362                   {
    2363                     previous_temp = temp;
    2364                     temp = new_value;
    2365                     if (previous_temp != "") temp += path_separator;
    2366                     temp += previous_temp;
    2367                   }
     2427                CmtSystem::split (new_value, path_separator, new_value_vector);
     2428                int n (new_value_vector.size ());
     2429                temp_vector.resize (temp_vector.size () + n);
     2430                for (int i = temp_vector.size () - 1; i > n - 1; i--)
     2431                  temp_vector [i] = temp_vector [i - n];
     2432                for (int i = 0; i < new_value_vector.size (); i++)
     2433                  if (!find_path_entry (temp_vector, new_value_vector[i]))
     2434                    //if (!find_path_entry (temp, new_value))
     2435                    {
     2436                      temp_vector [i] = new_value_vector[i];
     2437                      /*
     2438                        previous_temp = temp;
     2439                        temp = new_value;
     2440                        if (previous_temp != "") temp += path_separator;
     2441                        temp += previous_temp;
     2442                      */
     2443                    }
     2444                  else
     2445                    temp_vector [i] = "";
    23682446              }
    2369                  
     2447           
    23702448            break;
    23712449          case CommandPathRemove :
     
    23732451            if (new_value != "")
    23742452              {
     2453                for (int j = 0; j < temp_vector.size (); ++j)
     2454                  {
     2455                    cmt_string& s = temp_vector[j];
     2456                   
     2457                    if (s.find (new_value) != cmt_string::npos)
     2458                      {
     2459                        s = "";
     2460                      }
     2461                  }
     2462                /*
    23752463                CmtSystem::cmt_string_vector paths;
    23762464                 
     
    23882476
    23892477                Cmt::vector_to_string (paths, path_separator, temp);
     2478                */
    23902479              }
    23912480             
     
    23972486                cmt_regexp e (new_value);
    23982487
     2488                for (int j = 0; j < temp_vector.size (); ++j)
     2489                  {
     2490                    cmt_string& s = temp_vector[j];
     2491
     2492                    if (Cmt::get_debug () &&
     2493                        CmtSystem::getenv ("TESTPRR") != "")
     2494                      {
     2495                        cerr << "PRR> s=[" << s << "]";
     2496                      }
     2497
     2498                    if (e.match (s))
     2499                      {
     2500                        s = "";
     2501
     2502                        if (Cmt::get_debug () &&
     2503                            CmtSystem::getenv ("TESTPRR") != "")
     2504                          {
     2505                            cerr << " match ";
     2506                          }
     2507                      }
     2508                    else
     2509                      {
     2510                        if (Cmt::get_debug () &&
     2511                            CmtSystem::getenv ("TESTPRR") != "")
     2512                          {
     2513                            cerr << " no match ";
     2514                          }
     2515                      }
     2516
     2517                    if (Cmt::get_debug () &&
     2518                        CmtSystem::getenv ("TESTPRR") != "")
     2519                      {
     2520                        cerr << endl;
     2521                      }
     2522                  }
     2523
     2524                /*
    23992525                CmtSystem::cmt_string_vector paths;
    24002526                 
     
    24342560
    24352561                Cmt::vector_to_string (paths, path_separator, temp);
     2562                */
    24362563              }
    24372564             
     
    24402567
    24412568    }
     2569
     2570  Cmt::vector_to_string (temp_vector, path_separator, temp);
    24422571
    24432572  level--;
Note: See TracChangeset for help on using the changeset viewer.