skipQuotesString function

void skipQuotesString(
  1. String s,
  2. TIntRef p,
  3. String quoteChar,
  4. bool escapeSlash,
  5. bool escapeRepeat,
)

Implementation

void skipQuotesString(
    String s, TIntRef p, String quoteChar, bool escapeSlash, bool escapeRepeat) {
  p.value++;
  bool notRepeatEscaped;
  do {
    notRepeatEscaped = true;
    while (p.value < s.length && s[p.value] != quoteChar) {
      if (escapeSlash &&
          s[p.value] == '\\' &&
          p.value + 1 < s.length) {
        p.value += 2; // make sure we handle escaped quotes and double backslashes (original comment's meaning)
      } else {
        p.value++;
      }
    }
    if (p.value < s.length && s[p.value] == quoteChar) {
      p.value++; // skip final '
      if (p.value < s.length && s[p.value] == quoteChar && escapeRepeat) {
        // Handle escaping by '' (original comment kept as-is)
        notRepeatEscaped = false;
        p.value++;
      }
    }
  } while (!notRepeatEscaped);
}