readString seeks to the end of a string returning the position and whether or not the string's end was found. If the string's terminator was not found, then the result will be the passed end.
(r []rune, i, end int, quote rune)
| 268 | // If the string's terminator was not found, then the result will be the passed |
| 269 | // end. |
| 270 | func (*Batcher) readString(r []rune, i, end int, quote rune) (int, bool) { |
| 271 | var prev, c, next rune |
| 272 | for ; i < end; i++ { |
| 273 | c, next = r[i], grab(r, i+1, end) |
| 274 | switch { |
| 275 | case quote == '\'' && c == '\'' && next == '\'', |
| 276 | quote == '[' && c == ']' && next == ']': |
| 277 | i++ |
| 278 | continue |
| 279 | case quote == '\'' && c == '\'' && prev != '\'', |
| 280 | quote == '"' && c == '"', |
| 281 | quote == '[' && c == ']': |
| 282 | return i, true |
| 283 | default: |
| 284 | // Continue scanning for string terminator |
| 285 | } |
| 286 | prev = c |
| 287 | } |
| 288 | return end, false |
| 289 | } |
| 290 | |
| 291 | // Reset clears the current batch text and replaces it with new runes. |
| 292 | func (b *Batcher) Reset(r []rune) { |