diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2006-05-28 22:43:56 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2006-05-28 22:43:56 +0000 |
commit | b40f9ab72b387e9999bcc49b0aa2e9c95776f7b0 (patch) | |
tree | 5a582371940c3ae76c370cc7d03f610846e191db /usr.bin/cvs/buf.c | |
parent | 85a7c09af274739ece226ba92ca4316bdb4ea051 (diff) |
add a way to look if a buffer differs from another one
Diffstat (limited to 'usr.bin/cvs/buf.c')
-rw-r--r-- | usr.bin/cvs/buf.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/usr.bin/cvs/buf.c b/usr.bin/cvs/buf.c index a4d0b2573b7..f9b3a2a57cf 100644 --- a/usr.bin/cvs/buf.c +++ b/usr.bin/cvs/buf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.c,v 1.51 2006/05/27 03:30:30 joris Exp $ */ +/* $OpenBSD: buf.c,v 1.52 2006/05/28 22:43:54 joris Exp $ */ /* * Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -452,3 +452,29 @@ cvs_buf_peek(BUF *b, size_t off) return (b->cb_buf + off); } + +int +cvs_buf_differ(BUF *b1, BUF *b2) +{ + char *c1, *c2; + int i, l1, l2, len, ret; + + l1 = cvs_buf_len(b1); + l2 = cvs_buf_len(b2); + len = MIN(l1, l2); + + if (l1 != l2) + return (1); + + c1 = cvs_buf_release(b1); + c2 = cvs_buf_release(b2); + + ret = memcmp(c1, c2, len); + + if (c1 != NULL) + xfree(c1); + if (c2 != NULL) + xfree(c2); + + return (ret); +} |