Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of IVOS/regexp #2204

Merged
merged 49 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
026fd5a
Remove usage of IVOS/regexp
alkino Jan 30, 2023
9009929
Format
alkino Jan 30, 2023
62ceafe
Fix errors
alkino Jan 30, 2023
68f0bef
Fix multiline
alkino Jan 31, 2023
a9dbd49
Merge remote-tracking branch 'origin/master'
alkino Jan 31, 2023
331612a
Avoid using multiline to rstrip \n
alkino Feb 1, 2023
981efdf
Format
alkino Feb 1, 2023
cf8c258
Merge branch 'master' into cornu/remove_regexp
alkino Feb 1, 2023
d098cb0
Merge branch 'master' into cornu/remove_regexp
alkino Jun 22, 2023
c91839a
Update netcvode.cpp
alkino Jun 22, 2023
d55fb9e
Format
alkino Jun 22, 2023
59b1ab7
Merge branch 'master' into cornu/remove_regexp
alkino Jul 18, 2023
b9fd54a
Merge branch 'master' into cornu/remove_regexp
alkino Aug 3, 2023
d4ef9a7
fix l_head, l_tail
alkino Aug 4, 2023
0839e9f
Merge branch 'master' into cornu/remove_regexp
alkino Aug 4, 2023
e70ac65
Fix algorithm with local tests
alkino Aug 6, 2023
57f1e07
Old implem use std::cerr for errors
alkino Aug 6, 2023
e13c383
Merge branch 'master' into cornu/remove_regexp
alkino Oct 23, 2023
b307231
No more error with sonar
alkino Oct 23, 2023
502ed1b
Add test for StringFunctions
alkino Oct 26, 2023
872fb1d
More tests
alkino Oct 27, 2023
c97dd41
More coverage for alias/alias_list
alkino Oct 28, 2023
791cfff
Format
alkino Oct 30, 2023
456d3ed
Merge branch 'master' into cornu/add_test_stringfunctions
alkino Oct 30, 2023
628a77a
99% coverage of strfun.cpp
nrnhines Oct 30, 2023
70d49cb
fix the sonarcloud issues (replace NULL and some 0 with nullptr).
nrnhines Oct 30, 2023
7adc1e2
fix sonarcloud errors
nrnhines Oct 30, 2023
856ddaa
Fix bug in IVOS::Search
alkino Oct 31, 2023
c62d180
Merge branch 'master' into cornu/add_test_stringfunctions
alkino Oct 31, 2023
86c86ea
Merge remote-tracking branch 'origin/cornu/add_test_stringfunctions'
alkino Nov 1, 2023
ebfa582
Merge remote-tracking branch 'origin/master'
alkino Nov 1, 2023
0d02808
Revert all except head/tail
alkino Nov 1, 2023
9642c43
Merge branch 'master' into cornu/remove_regexp
alkino Nov 1, 2023
f0e3845
Simplify
alkino Nov 1, 2023
eb5ab0f
Merge remote-tracking branch 'origin/cornu/remove_regexp'
alkino Nov 1, 2023
31e4d2b
Merge remote-tracking branch 'origin/master'
alkino Nov 1, 2023
47d2d81
try other version
alkino Nov 2, 2023
447c146
Last try
alkino Nov 3, 2023
0a7e2a9
No std::multiline
alkino Nov 3, 2023
7b0eeed
Add a StringFunctions().rtrim()
alkino Nov 3, 2023
ecf4d32
Add a ltrim
alkino Nov 6, 2023
5ca689e
Add optional chars
alkino Nov 7, 2023
59ed5ff
Merge branch 'master' into cornu/remove_regexp
alkino Nov 10, 2023
4a24345
Merge branch 'master' into cornu/remove_regexp
alkino Dec 13, 2023
f98ebed
Merge branch 'master' into cornu/remove_regexp
alkino Jan 25, 2024
3eef6d3
Merge branch 'master' into cornu/remove_regexp
alkino Jan 26, 2024
24404d5
Revert "Revert all except head/tail"
Jan 26, 2024
bc73147
Merge branch 'master' into cornu/remove_regexp
pramodk Jan 27, 2024
d3f783f
Merge branch 'master' into cornu/remove_regexp
nrnhines Jan 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/NeuronFileLists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ set(NMODL_FILES_LIST
units.cpp
version.cpp)

set(IVOS_FILES_LIST observe.cpp regexp.cpp resource.cpp)
set(IVOS_FILES_LIST observe.cpp resource.cpp)

set(MPI_DYNAMIC_INCLUDE nrnmpi_dynam.h nrnmpi_dynam_cinc nrnmpi_dynam_wrappers.inc)

Expand Down
2 changes: 1 addition & 1 deletion share/lib/hoc/import3d/read_nlcda3.hoc
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ proc b2soption_split() {local i, n, id, ip localobj p, newsec, tobj
}

proc remove_trailspace() { // yuck
hoc_sf_.head(line, " *$", line)
hoc_sf_.rtrim(line, line)
sprint(line, "%s\n", line)
}

Expand Down
57 changes: 39 additions & 18 deletions src/ivoc/strfun.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <../../nrnconf.h>
#include <InterViews/regexp.h>
#include <stdio.h>
#include <stdlib.h>
#include "classreg.h"
#include "oc2iv.h"
#include <string.h>
#include <regex>
// for alias
#include <symdir.h>
#include <oclist.h>
Expand Down Expand Up @@ -39,31 +39,52 @@ static double l_len(void*) {

static double l_head(void*) {
std::string text(gargstr(1));
Regexp r(gargstr(2));
r.Search(text.c_str(), text.size(), 0, text.size());
int i = r.BeginningOfMatch();
// text.set_to_left(i); doesnt work
char** head = hoc_pgargstr(3);
if (i > 0) {
hoc_assign_str(head, text.substr(0, i).c_str());
} else {
hoc_assign_str(head, "");
{ // Clean the text so we keep only the first line
// Imitation of std::multiline in our case
std::regex r("^(.*)(\n|$)");
std::smatch sm;
std::regex_search(text, sm, r);
text = sm[1];
}
int i = -1;
std::string result{};
try {
std::regex r(gargstr(2), std::regex::egrep);
if (std::smatch sm; std::regex_search(text, sm, r)) {
i = sm.position();
result = sm.prefix().str();
}
} catch (const std::regex_error& e) {
std::cerr << e.what() << std::endl;
}
char** head = hoc_pgargstr(3);
hoc_assign_str(head, result.c_str());
hoc_return_type_code = 1; // integer
return double(i);
}

static double l_tail(void*) {
std::string text(gargstr(1));
Regexp r(gargstr(2));
r.Search(text.c_str(), text.size(), 0, text.size());
int i = r.EndOfMatch();
char** tail = hoc_pgargstr(3);
if (i >= 0) {
hoc_assign_str(tail, text.c_str() + i);
} else {
hoc_assign_str(tail, "");
{ // Clean the text so we keep only the first line
// Imitation of std::multiline in our case
std::regex r("^(.*)(\n|$)");
std::smatch sm;
std::regex_search(text, sm, r);
text = sm[1];
}
int i = -1;
std::string result{};
try {
std::regex r(gargstr(2), std::regex::egrep);
if (std::smatch sm; std::regex_search(text, sm, r)) {
i = sm.position() + sm.length();
result = sm.suffix().str();
}
} catch (const std::regex_error& e) {
std::cerr << e.what() << std::endl;
}
char** tail = hoc_pgargstr(3);
hoc_assign_str(tail, result.c_str());
hoc_return_type_code = 1; // integer
return double(i);
}
Expand Down
1 change: 0 additions & 1 deletion src/ivos/InterViews/_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@
#define Raster _lib_iv(Raster)
#define RasterRep _lib_iv(RasterRep)
#define Reducer _lib_iv(Reducer)
#define Regexp _lib_iv(Regexp)
#define ReqErr _lib_iv(ReqErr)
#define Requirement _lib_iv(Requirement)
#define Requisition _lib_iv(Requisition)
Expand Down
1 change: 0 additions & 1 deletion src/ivos/InterViews/_undefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@
#undef Raster
#undef RasterRep
#undef Reducer
#undef Regexp
#undef ReqErr
#undef Requirement
#undef Requisition
Expand Down
80 changes: 0 additions & 80 deletions src/ivos/InterViews/regexp.h

This file was deleted.

Loading
Loading