src/viewer/scrollview.cpp
char *ScrollView::AddEscapeChars(const char *input) {
  const char *nextptr = strchr(input, '\'');
  const char *lastptr = input;
  char *message = new char[kMaxMsgSize];
  int pos = 0;
  while (nextptr != nullptr) {
    strncpy(message + pos, lastptr, nextptr - lastptr);
    pos += nextptr - lastptr;
    message[pos] = '\\';
    pos += 1;
    lastptr = nextptr;
    nextptr = strchr(nextptr + 1, '\'');
  }
  strcpy(message + pos, lastptr);
  return message;
}
// Escapes the ' character with a \, so it can be processed by LUA.
// Note: The caller will have to make sure he deletes the newly allocated item.
Escapes the ' character with a \, so it can be processed by LUA.
Note: The caller will have to make sure he deletes the newly allocated item.
Escapes the ' character with a \ so it can be processed by LUA . Note : The caller will have to make sure he deletes the newly allocated item .
char *ScrollView::AddEscapeChars(const char *input) {
  const char *nextptr = strchr(input, '\'');
  const char *lastptr = input;
  char *message = new char[kMaxMsgSize];
  int pos = 0;
  while (nextptr != nullptr) {
    strncpy(message + pos, lastptr, nextptr - lastptr);
    pos += nextptr - lastptr;
    message[pos] = '\\';
    pos += 1;
    lastptr = nextptr;
    nextptr = strchr(nextptr + 1, '\'');
  }
  strcpy(message + pos, lastptr);
  return message;
}
char * ScrollView :: AddEscapeChars ( const char * input ) { const char * nextptr = strchr ( input , ' \' ' ) ; const char * lastptr = input ; char * message = new char [ kMaxMsgSize ] ; int pos = 0 ; while ( nextptr != nullptr ) { strncpy ( message + pos , lastptr , nextptr - lastptr ) ; pos += nextptr - lastptr ; message [ pos ] = ' \\ ' ; pos += 1 ; lastptr = nextptr ; nextptr = strchr ( nextptr + 1 , ' \' ' ) ; } strcpy ( message + pos , lastptr ) ; return message ; }
Escapes the ' character with a \, so it can be processed by LUA.
Escapes the ' character with a \ so it can be processed by LUA .