Ignore:
Timestamp:
05/04/05 16:53:10 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc

    r6858 r6994  
    856856        // Replace source by destination
    857857        const TRegexp regexp(src);
    858         while (1)
    859         {
    860             idx = regexp.Index(fname, &len);
     858
     859        Ssiz_t ichar = 0;
     860        while (1) // Replace all occurrences of src by dest
     861        {
     862            idx = regexp.Index(fname, &len, ichar);
    861863            if (idx<0)
    862864                break;
    863865
    864866            fname.Replace(idx, len, dest);
     867            ichar = idx + dest.Length();
     868
     869            // In next iteration, we start searching the string fname
     870            // right after the last character of the previous substitution
     871            // (indicated by ichar). This avoids infinite loops in the case
     872            // we want to replace, for instance, "_w" by "_Y_w". Without
     873            // the use of ichar, the second string would be replaced by
     874            // "_Y_Y_w", and this would never end...
    865875        }
    866876    }
Note: See TracChangeset for help on using the changeset viewer.