diff options
Diffstat (limited to 'src/string_immutable.zig')
-rw-r--r-- | src/string_immutable.zig | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 83719571b..564a4f94d 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -679,6 +679,27 @@ pub const CodepointIterator = struct { } } + pub fn scanUntilQuotedValueOrEOF(iter: *CodepointIterator, comptime quote: CodePoint) usize { + @setRuntimeSafety(false); + + while (iter.c > -1) { + if (!switch (iter.nextCodepoint()) { + quote => false, + '\\' => brk: { + if (iter.nextCodepoint() == quote) { + continue; + } + break :brk true; + }, + else => true, + }) { + return iter.i + 1; + } + } + + return iter.i; + } + pub fn nextCodepoint(it: *CodepointIterator) CodePoint { const slice = it.nextCodepointSlice(); it.width = @intCast(u3, slice.len); |