fix: guarantee progress in find_all_ranges when pattern is shorter than a utf8 sequence
This commit is contained in:
parent
99f9f95dbc
commit
74e7406034
2 changed files with 6 additions and 2 deletions
|
|
@ -989,7 +989,11 @@ const Node = union(enum) {
|
|||
.case_folded => {
|
||||
const input_consume_size = @min(ctx.buf.len - ctx.rest.len, input.len);
|
||||
var writer = std.Io.Writer.fixed(ctx.buf[ctx.rest.len..]);
|
||||
const folded = unicode.case_folded_write_partial(&writer, input[0..input_consume_size]) catch return error.WriteFailed;
|
||||
var folded = unicode.case_folded_write_partial(&writer, input[0..input_consume_size]) catch return error.WriteFailed;
|
||||
if (folded.len == 0) {
|
||||
try writer.writeByte(input[0]);
|
||||
folded = input[0..1];
|
||||
}
|
||||
ctx.rest = ctx.buf[0 .. ctx.rest.len + folded.len];
|
||||
input = input[folded.len..];
|
||||
},
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ const Utf8PartialIterator = struct {
|
|||
return null;
|
||||
}
|
||||
|
||||
const cp_len = utf8ByteSequenceLength(it.bytes[it.end]) catch unreachable;
|
||||
const cp_len = utf8ByteSequenceLength(it.bytes[it.end]) catch return null;
|
||||
if (it.end + cp_len > it.bytes.len) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue