- Timestamp:
- Jan 15, 2007, 1:03:48 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/RpLibrary.cc
r554 r564 57 57 58 58 int 59 RpLibrary::_path2list (std::string& path, std::string** list, int listLen) 59 RpLibrary::_path2list (std::string& path, std::string** list, int listLen) 60 60 { 61 61 std::string::size_type pos = 0; 62 62 std::string::size_type start = 0; 63 std::string::size_type end = path.length(); 63 64 int index = 0; 64 65 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 } 73 84 } 74 85 75 86 // 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++; 83 93 84 94 // 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.