From d244deb59ef744feb6bd418ee27b5ab98c02fae5 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 8 Sep 2017 09:19:02 -0400 Subject: [PATCH] fix std.Buffer.endsWith thanks for the report by jean-dao closes #443 --- std/buffer.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/std/buffer.zig b/std/buffer.zig index c73fc9b079..0ad530d7cf 100644 --- a/std/buffer.zig +++ b/std/buffer.zig @@ -87,7 +87,7 @@ pub const Buffer = struct { const l = self.len(); if (l < m.len) return false; const start = l - m.len; - return mem.eql(u8, self.list.items[start..], m); + return mem.eql(u8, self.list.items[start..l], m); } pub fn replaceContents(self: &const Buffer, m: []const u8) -> %void { @@ -111,6 +111,7 @@ test "simple Buffer" { assert(buf.eql(buf2.toSliceConst())); assert(buf.startsWith("hell")); + assert(buf.endsWith("orld")); %%buf2.resize(4); assert(buf.startsWith(buf2.toSliceConst()));