MCPcopy Index your code
hub / github.com/bytebase/bytebase / readString

Method readString

backend/plugin/parser/tsql/batch/batch.go:270–289  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

268// If the string's terminator was not found, then the result will be the passed
269// end.
270func (*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.
292func (b *Batcher) Reset(r []rune) {

Callers 1

NextMethod · 0.95

Calls 1

grabFunction · 0.85

Tested by

no test coverage detected