From 5fc69eea983a583664e0b8762f0275a2c85e10c4 Mon Sep 17 00:00:00 2001 From: Jean-Francois Brousseau Date: Thu, 26 May 2005 22:27:12 +0000 Subject: make cvs_getln() return the length of the line that was read, so we don't have to call strlen() right after --- usr.bin/cvs/proto.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'usr.bin/cvs/proto.c') diff --git a/usr.bin/cvs/proto.c b/usr.bin/cvs/proto.c index 1418ec6d373..e24f24dc5eb 100644 --- a/usr.bin/cvs/proto.c +++ b/usr.bin/cvs/proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proto.c,v 1.54 2005/05/24 06:42:38 joris Exp $ */ +/* $OpenBSD: proto.c,v 1.55 2005/05/26 22:27:11 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. @@ -660,7 +660,6 @@ cvs_recvfile(struct cvsroot *root, mode_t *mode) return (fbuf); } - /* * cvs_sendreq() * @@ -767,6 +766,8 @@ cvs_getresp(struct cvsroot *root) * * Get a line from the remote end and store it in . The terminating * newline character is stripped from the result. + * Returns the length in bytes of the line (not including the NUL byte), or + * -1 on failure. */ int cvs_getln(struct cvsroot *root, char *lbuf, size_t len) @@ -796,7 +797,7 @@ cvs_getln(struct cvsroot *root, char *lbuf, size_t len) if ((rlen > 0) && (lbuf[rlen - 1] == '\n')) lbuf[--rlen] = '\0'; - return (0); + return (rlen); } @@ -898,11 +899,11 @@ cvs_sendln(struct cvsroot *root, const char *line) if (cvs_server_inlog != NULL) { fputs(line, cvs_server_inlog); if (nl) - fputc('\n', cvs_server_inlog); + putc('\n', cvs_server_inlog); } fputs(line, out); if (nl) - fputc('\n', out); + putc('\n', out); return (0); } -- cgit v1.2.3