diff options
-rw-r--r-- | usr.bin/rcs/co.c | 31 | ||||
-rw-r--r-- | usr.bin/rcs/rcsprog.c | 13 | ||||
-rw-r--r-- | usr.bin/rcs/rcsprog.h | 3 |
3 files changed, 32 insertions, 15 deletions
diff --git a/usr.bin/rcs/co.c b/usr.bin/rcs/co.c index 3173ae021c3..23b4f62f801 100644 --- a/usr.bin/rcs/co.c +++ b/usr.bin/rcs/co.c @@ -1,4 +1,4 @@ -/* $OpenBSD: co.c,v 1.19 2005/10/18 01:22:14 joris Exp $ */ +/* $OpenBSD: co.c,v 1.20 2005/10/19 00:30:22 joris Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -58,7 +58,7 @@ checkout_main(int argc, char **argv) exit (1); } - while ((ch = rcs_getopt(argc, argv, "f::l::qr::u::V")) != -1) { + while ((ch = rcs_getopt(argc, argv, "f::l::p::qr::u::V")) != -1) { switch (ch) { case 'f': rcs_set_rev(rcs_optarg, &rev); @@ -68,6 +68,10 @@ checkout_main(int argc, char **argv) rcs_set_rev(rcs_optarg, &rev); lock = LOCK_LOCK; break; + case 'p': + rcs_set_rev(rcs_optarg, &rev); + pipeout = 1; + break; case 'q': verbose = 0; break; @@ -148,6 +152,7 @@ checkout_rev(RCSFILE *file, RCSNUM *frev, const char *dst, int lkmode, mode_t mode = 0444; BUF *bp; struct stat st; + char *content; /* * Check out the latest revision if <frev> is greater than HEAD @@ -210,16 +215,22 @@ checkout_rev(RCSFILE *file, RCSNUM *frev, const char *dst, int lkmode, } } - if (cvs_buf_write(bp, dst, mode) < 0) { - cvs_log(LP_ERR, "failed to write revision to file"); + if (pipeout == 1) { + cvs_buf_putc(bp, '\0'); + content = cvs_buf_release(bp); + printf("%s", content); + free(content); + } else { + if (cvs_buf_write(bp, dst, mode) < 0) { + cvs_log(LP_ERR, "failed to write revision to file"); + cvs_buf_free(bp); + return (-1); + } cvs_buf_free(bp); - return (-1); - } - cvs_buf_free(bp); - - if (verbose == 1) - printf("done\n"); + if (verbose == 1) + printf("done\n"); + } return (0); } diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c index ba6b4183888..50821390348 100644 --- a/usr.bin/rcs/rcsprog.c +++ b/usr.bin/rcs/rcsprog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.c,v 1.33 2005/10/18 16:20:31 xsa Exp $ */ +/* $OpenBSD: rcsprog.c,v 1.34 2005/10/19 00:30:22 joris Exp $ */ /* * Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -46,6 +46,7 @@ const char rcs_version[] = "OpenCVS RCS version 3.6"; int verbose = 1; +int pipeout = 0; int rcs_optind; char *rcs_optarg; @@ -208,9 +209,13 @@ rcs_statfile(char *fname, char *out, size_t len) if ((verbose == 1) && (strcmp(__progname, "rcsclean"))) { if (!strcmp(__progname, "co")) { printf("%s --> ", fpath); - if ((s = strrchr(filev, ',')) != NULL) { - *s = '\0'; - printf("%s\n", fname); + if (pipeout == 1) { + printf("standard output\n"); + } else { + if ((s = strrchr(filev, ',')) != NULL) { + *s = '\0'; + printf("%s\n", fname); + } } } else { printf("RCS file: %s\n", fpath); diff --git a/usr.bin/rcs/rcsprog.h b/usr.bin/rcs/rcsprog.h index d44b55c97d3..61cea0ae9f9 100644 --- a/usr.bin/rcs/rcsprog.h +++ b/usr.bin/rcs/rcsprog.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.h,v 1.15 2005/10/18 16:20:31 xsa Exp $ */ +/* $OpenBSD: rcsprog.h,v 1.16 2005/10/19 00:30:22 joris Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -30,6 +30,7 @@ extern char *__progname; extern const char rcs_version[]; extern int verbose; +extern int pipeout; extern int rcs_optind; extern char *rcs_optarg; |