Skip to content

Commit

Permalink
Only call once escape_bracket
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Cornu committed Jan 29, 2024
1 parent 76bdb89 commit ccaeb31
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/nrnoc/cabcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1998,11 +1998,11 @@ void forall_section(void) {
s = hoc_strpop();
buf[0] = '\0';
if (s) {
Sprintf(buf, "%s.*%s.*", escape_bracket(objectname()), escape_bracket(*s));
Sprintf(buf, "%s.*%s.*", objectname(), *s);
} else {
char* o = objectname();
if (o[0]) {
Sprintf(buf, "%s.*", escape_bracket(o));
Sprintf(buf, "%s.*", o);
}
}
istk = nrn_isecstack();
Expand All @@ -2011,8 +2011,7 @@ void forall_section(void) {
Section* sec = hocSEC(qsec);
qsec = qsec->next;
if (buf[0]) {
std::cout << "forall_section: " << buf << " : " << secname(sec) << std::endl;
std::regex pattern(buf);
std::regex pattern(escape_bracket(buf));
if (!std::regex_match(secname(sec), pattern)) {
continue;
}
Expand Down Expand Up @@ -2043,9 +2042,8 @@ void hoc_ifsec(void) {
extern int hoc_returning;

s = hoc_strpop();
Sprintf(buf, ".*%s.*", escape_bracket(*s));
std::regex pattern(buf);
std::cout << "hoc_ifsec: " << buf << " : " << secname(chk_access()) << std::endl;
Sprintf(buf, ".*%s.*", *s);
std::regex pattern(escape_bracket(buf));
if (std::regex_match(secname(chk_access()), pattern)) {

Check warning on line 2047 in src/nrnoc/cabcode.cpp

View check run for this annotation

Codecov / codecov/patch

src/nrnoc/cabcode.cpp#L2046-L2047

Added lines #L2046 - L2047 were not covered by tests
hoc_execute(relative(savepc));
}
Expand All @@ -2055,7 +2053,6 @@ void hoc_ifsec(void) {

void issection(void) { /* returns true if string is the access section */
std::regex pattern(escape_bracket(gargstr(1)));
std::cout << "hoc_ifsec: " << escape_bracket(gargstr(1)) << " : " << secname(chk_access()) << std::endl;
if (std::regex_match(secname(chk_access()), pattern)) {
hoc_retpushx(1.);
} else {
Expand Down

0 comments on commit ccaeb31

Please sign in to comment.