diff options
author | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-11-16 08:15:22 +0000 |
---|---|---|
committer | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-11-16 08:15:22 +0000 |
commit | 4b4ce312d36015bfef380b71e966eb43352f415d (patch) | |
tree | 05a92d71734ef6fbe9d60b222929215323e7903c | |
parent | b994b38fd7105b9dccd01fe6dd3116b44b0e095c (diff) |
fix writing of RCS files; it has been bugging us for a while now...
now, former RCS suite can make a use of our newly written RCS files;
ok joris niallo
-rw-r--r-- | usr.bin/cvs/rcs.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index d0c7a0d80d4..9d6047740fd 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.99 2005/11/12 21:34:48 niallo Exp $ */ +/* $OpenBSD: rcs.c,v 1.100 2005/11/16 08:15:21 xsa Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -445,6 +445,7 @@ rcs_write(RCSFILE *rfp) struct rcs_delta *rdp; struct rcs_lock *lkp; ssize_t nread; + size_t len; int fd, from_fd, to_fd; from_fd = to_fd = fd = -1; @@ -539,21 +540,32 @@ rcs_write(RCSFILE *rfp) } fputs("\ndesc\n@", fp); - if (rfp->rf_desc != NULL) - rcs_strprint((const u_char *)rfp->rf_desc, - strlen(rfp->rf_desc), fp); - fputs("@\n\n", fp); + if (rfp->rf_desc != NULL) { + len = strlen(rfp->rf_desc); + rcs_strprint((const u_char *)rfp->rf_desc, len, fp); + if (rfp->rf_desc[len-1] != '\n') + fputc('\n', fp); + } + fputs("@\n", fp); /* deltatexts */ TAILQ_FOREACH(rdp, &(rfp->rf_delta), rd_list) { - fprintf(fp, "\n%s\n", rcsnum_tostr(rdp->rd_num, numbuf, + fprintf(fp, "\n\n%s\n", rcsnum_tostr(rdp->rd_num, numbuf, sizeof(numbuf))); fputs("log\n@", fp); - rcs_strprint((const u_char *)rdp->rd_log, - strlen(rdp->rd_log), fp); + if (rdp->rd_log != NULL) { + len = strlen(rdp->rd_log); + rcs_strprint((const u_char *)rdp->rd_log, len, fp); + if (rdp->rd_log[len-1] != '\n') + fputc('\n', fp); + } fputs("@\ntext\n@", fp); - rcs_strprint(rdp->rd_text, rdp->rd_tlen, fp); - fputs("\n@\n\n", fp); + if (rdp->rd_text != NULL) { + rcs_strprint(rdp->rd_text, rdp->rd_tlen, fp); + if (rdp->rd_text[rdp->rd_tlen-1] != '\n') + fputc('\n', fp); + } + fputs("@\n", fp); } fclose(fp); |