Ok. I'm really not sure what I'm doing wrong here (hence the post). It may be blaringly obvious, but I can't see it. I always get a seg fault when I hit the function call Tcl_RegExpRange in this snippet of code:
string reg_1("(\\d+)(?:-(\\d+))?");
string fullReg(reg_1 + "(?::" + reg_1 + ")?");
Tcl_Interp *error = Tcl_CreateInterp();
Tcl_Obj
* ptrExpObj = Tcl_NewStringObj(fullReg.c_str(), fullReg.size());
Tcl_RegExp tclRegExp = Tcl_GetRegExpFromObj(error, ptrExpObj, TCL_REG_ADVANCED);
if(tclRegExp != 0)
{
const char *fullArg, *search;
fullArg = search = arg.c_str();
while(Tcl_RegExpExec(error, tclRegExp, search, fullArg) > 0)
{
const char **start = 0, **end = 0;
for(int j = 1; j <= 4; ++j)
{
int num;
Tcl_RegExpRange(tclRegExp, j, start, end);
memcpy(&num, *start, *end - *start);
tcout << "Num: " << num << std::endl;
}
search = *end;
}
}
I don't *think* I'm doing anything wrong here... But clearly I am if I'm seg faulting. Anywho, anything wrong with my syntax? Any help is appreciated! Thanks!
My apologies if this code loses it's formatting
Justin Miller
string reg_1("(\\d+)(?:-(\\d+))?");
string fullReg(reg_1 + "(?::" + reg_1 + ")?");
Tcl_Interp *error = Tcl_CreateInterp();
Tcl_Obj
* ptrExpObj = Tcl_NewStringObj(fullReg.c_str(), fullReg.size());
Tcl_RegExp tclRegExp = Tcl_GetRegExpFromObj(error, ptrExpObj, TCL_REG_ADVANCED);
if(tclRegExp != 0)
{
const char *fullArg, *search;
fullArg = search = arg.c_str();
while(Tcl_RegExpExec(error, tclRegExp, search, fullArg) > 0)
{
const char **start = 0, **end = 0;
for(int j = 1; j <= 4; ++j)
{
int num;
Tcl_RegExpRange(tclRegExp, j, start, end);
memcpy(&num, *start, *end - *start);
tcout << "Num: " << num << std::endl;
}
search = *end;
}
}
I don't *think* I'm doing anything wrong here... But clearly I am if I'm seg faulting. Anywho, anything wrong with my syntax? Any help is appreciated! Thanks!
My apologies if this code loses it's formatting
Justin Miller