int (int start) { if (start == myBufferEnd) { myState = AFTER_LAST_QUOTE; } if (myState == AFTER_LAST_QUOTE) return start; // exhausted int i = start; if (myBuffer.charAt(i) == '\\') { LOG.assertTrue(myState == AFTER_FIRST_QUOTE); final int end = locateEscapeSequence(i); if (end == myBufferEnd) { myState = AFTER_LAST_QUOTE; } return end; } else { // not a \something //LOG.assertTrue(myState == AFTER_FIRST_QUOTE || myBuffer.charAt(i) == myQuoteChar); final int quote_limit = myIsTriple ? 3 : 1; int qcnt = 0; // count consequent quotes while (i < myBufferEnd) { // scan to next \something if (myBuffer.charAt(i) == '\\' && !isRaw()) { return i; } if (myState == BEFORE_FIRST_QUOTE && myBuffer.charAt(i) == myQuoteChar) { qcnt += 1; if (qcnt == quote_limit) { myState = AFTER_FIRST_QUOTE; qcnt = 0; // for last quote detection in the same pass } } else if (myState == AFTER_FIRST_QUOTE && myBuffer.charAt(i) == myQuoteChar && (!isRaw() || myBuffer.charAt(i-1) != '\\')) { // done? qcnt += 1; if (qcnt == quote_limit) { myState = AFTER_LAST_QUOTE; return i + 1; // skip the last remaining quote } } else { // not an escape, not a quote qcnt = 0; } i++; } } return i; }