Changeset 564


Ignore:
Timestamp:
Jan 15, 2007 1:03:48 AM (17 years ago)
Author:
dkearney
Message:

new path parsing algorithm, this fix should allow us to place floating point numbers in the id portion of a path like this example
input.curve(Vdd=3.5V).component.xy, app-nanocmos or app-sbcnfet can be used as tests for this fix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/RpLibrary.cc

    r554 r564  
    5757
    5858int
    59 RpLibrary::_path2list (std::string& path, std::string** list, int listLen) 
     59RpLibrary::_path2list (std::string& path, std::string** list, int listLen)
    6060{
    6161    std::string::size_type pos = 0;
    6262    std::string::size_type start = 0;
     63    std::string::size_type end = path.length();
    6364    int index = 0;
    6465    int retVal = 0;
    65 
    66     // listLen should be the highest index + 1
    67     for (   pos = path.find(".",NO_CREATE_PATH);
    68             (pos != std::string::npos) || (index >= listLen);
    69             pos = path.find(".",pos)   )
    70     {
    71         list[index++] = new std::string(path.substr(start,pos-start));
    72         start = ++pos;
     66    unsigned int parenDepth = 0;
     67
     68    for (   pos = 0; (pos < end) && (index < listLen); pos++) {
     69        if (path[pos] == '(') {
     70            parenDepth++;
     71            continue;
     72        }
     73
     74        if (path[pos] == ')') {
     75            parenDepth--;
     76            continue;
     77        }
     78
     79        if ( (path[pos] == '.') && (parenDepth == 0) ) {
     80            list[index] = new std::string(path.substr(start,pos-start));
     81            index++;
     82            start = pos + 1;
     83        }
    7384    }
    7485
    7586    // add the last path to the list
    76     if (index < listLen) {
    77         // error checking for path names?
    78         // what if you get something like p1.p2. ?
    79         list[index] = new std::string(path.substr(start,path.length()-start));
    80     }
    81 
    82     retVal = index++;
     87    // error checking for path names like p1.p2.
     88    if ( (start < end) && (pos == end) ) {
     89        list[index] = new std::string(path.substr(start,pos-start));
     90    }
     91    retVal = index;
     92    index++;
    8393
    8494    // null out the rest of the pointers so we know where to stop free'ing
Note: See TracChangeset for help on using the changeset viewer.