aboutsummaryrefslogtreecommitdiff
path: root/src/string_immutable.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/string_immutable.zig')
-rw-r--r--src/string_immutable.zig21
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);