diff --git a/src/THcDetectorMap.cxx b/src/THcDetectorMap.cxx index 647cbae045bbaf833812e8f20aea9f1b097f2eb9..7302135951ba92472de3030cd7ebce3fbe383111 100644 --- a/src/THcDetectorMap.cxx +++ b/src/THcDetectorMap.cxx @@ -236,12 +236,19 @@ void THcDetectorMap::Load(const char *fname) } line.erase(0,1); // Erase "!" if(! ((pos=line.find("_ID=")) == string::npos)) { + Int_t llen = line.length(); fIDMap[fNIDs].name = new char [pos+1]; strncpy(fIDMap[fNIDs].name,line.c_str(),pos); fIDMap[fNIDs].name[pos] = '\0'; start = (pos += 4); // Move to after "=" - while(isdigit(line.at(pos++))); - fIDMap[fNIDs++].id = atoi(line.substr(start,pos).c_str()); + while(pos < llen) { + if(isdigit(line.at(pos))) { + pos++; + } else { + break; + } + } + fIDMap[fNIDs++].id = atoi(line.substr(start,pos-start).c_str()); } continue; }