authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-08 09:19:02-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-08 09:19:02-04:00
logd244deb59ef744feb6bd418ee27b5ab98c02fae5
tree5fa0736c54b884a6bb79ff208b2d5096a1c34d2a
parent2c8ff1d47bab77295920cec7b0cb2d40257d2167

fix std.Buffer.endsWith

thanks for the report by jean-dao closes #443

1 files changed, 2 insertions(+), 1 deletions(-)

std/buffer.zig+2-1
......@@ -87,7 +87,7 @@ pub const Buffer = struct {
8787 const l = self.len();
8888 if (l < m.len) return false;
8989 const start = l - m.len;
90 return mem.eql(u8, self.list.items[start..], m);
90 return mem.eql(u8, self.list.items[start..l], m);
9191 }
9292
9393 pub fn replaceContents(self: &const Buffer, m: []const u8) -> %void {
......@@ -111,6 +111,7 @@ test "simple Buffer" {
111111 assert(buf.eql(buf2.toSliceConst()));
112112
113113 assert(buf.startsWith("hell"));
114 assert(buf.endsWith("orld"));
114115
115116 %%buf2.resize(4);
116117 assert(buf.startsWith(buf2.toSliceConst()));