L
Lothar Behrens
Hi,
I have selected strtok to be used in my string replacement function.
But I lost the last token, if there is one.
This string would be replaced
select "name", "vorname", "userid", "passwort" from "users" order by
"users"
by this one:
select "name", "vorname", "userid",
"passwort" from "users" order by "users
Thus the last quot is lost.
Is there something missing in the code ?
Thanks, Lothar
lb_I_String& LB_STDCALL lbString::replace(const char* toReplace, const
char* with) {
// Don't worry about my object variables
UAP_REQUEST(getModuleInstance(), lb_I_String, rep)
// the string
char* token = strtok(stringdata, toReplace);
if ((token != NULL) && (token != stringdata)) {
*rep += with;
}
while(token != NULL)
{
*rep += token;
token = strtok(NULL, toReplace);
if (token != NULL) *rep += with;
}
setData(rep->charrep());
return *this;
}
I have selected strtok to be used in my string replacement function.
But I lost the last token, if there is one.
This string would be replaced
select "name", "vorname", "userid", "passwort" from "users" order by
"users"
by this one:
select "name", "vorname", "userid",
"passwort" from "users" order by "users
Thus the last quot is lost.
Is there something missing in the code ?
Thanks, Lothar
lb_I_String& LB_STDCALL lbString::replace(const char* toReplace, const
char* with) {
// Don't worry about my object variables
UAP_REQUEST(getModuleInstance(), lb_I_String, rep)
// the string
char* token = strtok(stringdata, toReplace);
if ((token != NULL) && (token != stringdata)) {
*rep += with;
}
while(token != NULL)
{
*rep += token;
token = strtok(NULL, toReplace);
if (token != NULL) *rep += with;
}
setData(rep->charrep());
return *this;
}