From 41d2c558e3c15e2fd905ab93bfa04ff4c0441dfd Mon Sep 17 00:00:00 2001 From: "Stephen A. Wood" <saw@jlab.org> Date: Mon, 12 Oct 2015 14:59:13 -0400 Subject: [PATCH] Fix up problems in map file detector ID parsing --- src/THcDetectorMap.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/THcDetectorMap.cxx b/src/THcDetectorMap.cxx index 647cbae..7302135 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; } -- GitLab