From 5d1a7dc92d6d88c1edd14b4ba858d5c9c87647e0 Mon Sep 17 00:00:00 2001 From: Niall O'Higgins Date: Thu, 11 Jan 2007 18:13:34 +0000 Subject: remove some un-needed buffer NUL-termination. in openrcs, diff3 is already NUL-terminating its buffers so we don't need to do it twice. this allows us to sync rcs_splitlines() with opencvs' cvs_splitlines(). ok joris@ --- usr.bin/rcs/diff3.c | 11 ++--------- usr.bin/rcs/rcsutil.c | 6 ++---- 2 files changed, 4 insertions(+), 13 deletions(-) (limited to 'usr.bin/rcs') diff --git a/usr.bin/rcs/diff3.c b/usr.bin/rcs/diff3.c index ee40c32d81a..bf8ce3b7dea 100644 --- a/usr.bin/rcs/diff3.c +++ b/usr.bin/rcs/diff3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff3.c,v 1.17 2007/01/02 16:43:45 niallo Exp $ */ +/* $OpenBSD: diff3.c,v 1.18 2007/01/11 18:13:33 niallo Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -72,7 +72,7 @@ static const char copyright[] = #ifndef lint static const char rcsid[] = - "$OpenBSD: diff3.c,v 1.17 2007/01/02 16:43:45 niallo Exp $"; + "$OpenBSD: diff3.c,v 1.18 2007/01/11 18:13:33 niallo Exp $"; #endif /* not lint */ #include "includes.h" @@ -228,10 +228,6 @@ merge_diff3(char **av, int flags) goto out; } - rcs_buf_putc(diffb, '\0'); - rcs_buf_putc(b1, '\0'); - - plen = rcs_buf_len(diffb); patch = rcs_buf_release(diffb); dlen = rcs_buf_len(b1); @@ -359,9 +355,6 @@ rcs_diff3(RCSFILE *rf, char *workfile, RCSNUM *rev1, RCSNUM *rev2, int flags) goto out; } - rcs_buf_putc(diffb, '\0'); - rcs_buf_putc(b1, '\0'); - plen = rcs_buf_len(diffb); patch = rcs_buf_release(diffb); dlen = rcs_buf_len(b1); diff --git a/usr.bin/rcs/rcsutil.c b/usr.bin/rcs/rcsutil.c index e9b7218570a..9210f4ed872 100644 --- a/usr.bin/rcs/rcsutil.c +++ b/usr.bin/rcs/rcsutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsutil.c,v 1.25 2007/01/10 02:13:23 ray Exp $ */ +/* $OpenBSD: rcsutil.c,v 1.26 2007/01/11 18:13:33 niallo Exp $ */ /* * Copyright (c) 2005, 2006 Joris Vink * Copyright (c) 2006 Xavier Santolaria @@ -492,9 +492,7 @@ rcs_splitlines(const u_char *data, size_t len) p = c = data; for (i = 0; i < len; i++) { if (*p == '\n' || (i == len - 1)) { - tlen = p - c; - if (*p == '\n') - tlen++; + tlen = p - c + 1; lp = xmalloc(sizeof(*lp)); lp->l_line = c; lp->l_len = tlen; -- cgit v1.2.3