I have written a function that parses a line from a text file and replaces cerain keywords with the appropriate counterpart in a list.
the code looks like this:
std::string __iec_parse_cl(const std::string &line){
std::string ret = line;
static const size_t num_tokens = 6;
static const char *tokens_search[6]{
filled ...
};
static const char *tokens_replace[6]{
filled ...
};
for(size_t x = 0; x < num_tokens; x++){
size_t yolo;
do{
yolo = ret.find(tokens_search[x];
if(yolo != std::string::npos){
ret.erase(yolo, strlen(tokens_search[x]));
ret.insert(yolo, tokens_replace[x]);
}
} while(yolo != std::string::npos);
}
return ret;
}
When I parse a token that looks like this:
globalid
and replace it with this: get_global_id
everything is fine...
BUT when I try to parse a token that looks like THIS:
global_id
and try to replace it with this: get_global_id
the program stalls somewhere in the function :/
What could be causing this?