fix stringDeleteCodepointAtByte() logic

This commit is contained in:
Tenari committed 2026-10-02 07:19:29 -05:00
1 parent 4afb043509
commit ed69bc8923
1 file changed
+4 -8
+4 -8
View File
@@ -262,14 +262,10 @@ fn u8 stringDeleteCodepointAtByte(String* s, u32 byte_offset) {
if (s->length == 0) return 0; if (s->length == 0) return 0;
Codepoint cp = codepointFromBytes(s->bytes, byte_offset); Codepoint cp = codepointFromBytes(s->bytes, byte_offset);
// shift all the bytes from the back towards the byte_offset assert(cp.size + byte_offset <= s->length);
for (u32 i = 0; i < cp.size; i++) { MemoryCopy(s->bytes + byte_offset, s->bytes + byte_offset + cp.size, s->length - byte_offset - cp.size);
for (u32 ii = byte_offset+i; ii < s->length; ii++) { s->length -= cp.size;
s->bytes[ii] = s->bytes[ii+1]; s->bytes[s->length] = '\0';
}
s->length -= 1;
}
s->bytes[byte_offset] = '\0';
return cp.size; return cp.size;
} }