From 00f4e67c8b4581e30edad24f197a1bff37ec3356 Mon Sep 17 00:00:00 2001 From: millert Date: Mon, 4 Jul 2016 01:39:12 +0000 Subject: [PATCH] The -I flag is documented but not implemented. This fixes that and also honors the -I flag from ci/co when prompting like GNU RCS. OK jca@ --- usr.bin/rcs/ci.c | 8 ++++---- usr.bin/rcs/rcsprog.c | 11 +++++++---- usr.bin/rcs/rcsutil.c | 17 ++++++++++------- usr.bin/rcs/rcsutil.h | 6 +++--- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c index 0188da9ab37..765b03a9388 100644 --- a/usr.bin/rcs/ci.c +++ b/usr.bin/rcs/ci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ci.c,v 1.223 2015/11/02 16:45:21 nicm Exp $ */ +/* $OpenBSD: ci.c,v 1.224 2016/07/04 01:39:12 millert Exp $ */ /* * Copyright (c) 2005, 2006 Niall O'Higgins * All rights reserved. @@ -279,7 +279,7 @@ checkin_main(int argc, char **argv) errx(1, "failed to open rcsfile `%s'", pb.fpath); if ((pb.flags & DESCRIPTION) && - rcs_set_description(pb.file, pb.description) == -1) + rcs_set_description(pb.file, pb.description, pb.flags) == -1) err(1, "%s", pb.filename); if (!(pb.flags & QUIET)) @@ -406,7 +406,7 @@ checkin_getlogmsg(RCSNUM *rev, RCSNUM *rev2, int flags) (void)fprintf(stderr, "new revision: %s; " "previous revision: %s\n", nrev, prev); - rcs_msg = rcs_prompt(prompt); + rcs_msg = rcs_prompt(prompt, flags); return (rcs_msg); } @@ -621,7 +621,7 @@ checkin_init(struct checkin_params *pb) /* Get description from user */ if (pb->description == NULL && - rcs_set_description(pb->file, NULL) == -1) { + rcs_set_description(pb->file, NULL, pb->flags) == -1) { warn("%s", pb->filename); return (-1); } diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c index efb21459b9f..0a14b8a19b3 100644 --- a/usr.bin/rcs/rcsprog.c +++ b/usr.bin/rcs/rcsprog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.c,v 1.160 2015/12/29 19:12:56 gsoares Exp $ */ +/* $OpenBSD: rcsprog.c,v 1.161 2016/07/04 01:39:12 millert Exp $ */ /* * Copyright (c) 2005 Jean-Francois Brousseau * All rights reserved. @@ -35,7 +35,7 @@ #include "rcsprog.h" -#define RCSPROG_OPTSTRING "A:a:b::c:e::ik:Ll::m:Mn:N:o:qt::TUu::Vx::z::" +#define RCSPROG_OPTSTRING "A:a:b::c:e::Iik:Ll::m:Mn:N:o:qt::TUu::Vx::z::" const char rcs_version[] = "OpenRCS 4.5"; @@ -222,6 +222,9 @@ rcs_main(int argc, char **argv) elist = rcs_optarg; rcsflags |= RCSPROG_EFLAG; break; + case 'I': + rcsflags |= INTERACTIVE; + break; case 'i': flags |= RCS_CREATE; break; @@ -324,14 +327,14 @@ rcs_main(int argc, char **argv) } if (rcsflags & DESCRIPTION) { - if (rcs_set_description(file, descfile) == -1) { + if (rcs_set_description(file, descfile, rcsflags) == -1) { warn("%s", descfile); rcs_close(file); continue; } } else if (flags & RCS_CREATE) { - if (rcs_set_description(file, NULL) == -1) { + if (rcs_set_description(file, NULL, rcsflags) == -1) { warn("stdin"); rcs_close(file); continue; diff --git a/usr.bin/rcs/rcsutil.c b/usr.bin/rcs/rcsutil.c index 27bac4ff8c4..ff100a600c4 100644 --- a/usr.bin/rcs/rcsutil.c +++ b/usr.bin/rcs/rcsutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsutil.c,v 1.44 2015/06/13 20:15:21 nicm Exp $ */ +/* $OpenBSD: rcsutil.c,v 1.45 2016/07/04 01:39:12 millert Exp $ */ /* * Copyright (c) 2005, 2006 Joris Vink * Copyright (c) 2006 Xavier Santolaria @@ -330,16 +330,19 @@ rcs_getrevnum(const char *rev_str, RCSFILE *file) * Returns the string's pointer. */ char * -rcs_prompt(const char *prompt) +rcs_prompt(const char *prompt, int flags) { BUF *bp; size_t len; char *buf; + if (!(flags & INTERACTIVE) && isatty(STDIN_FILENO)) + flags |= INTERACTIVE; + bp = buf_alloc(0); - if (isatty(STDIN_FILENO)) + if (flags & INTERACTIVE) (void)fprintf(stderr, "%s", prompt); - if (isatty(STDIN_FILENO)) + if (flags & INTERACTIVE) (void)fprintf(stderr, ">> "); clearerr(stdin); while ((buf = fgetln(stdin, &len)) != NULL) { @@ -349,7 +352,7 @@ rcs_prompt(const char *prompt) else buf_append(bp, buf, len); - if (isatty(STDIN_FILENO)) + if (flags & INTERACTIVE) (void)fprintf(stderr, ">> "); } buf_putc(bp, '\0'); @@ -438,7 +441,7 @@ rcs_rev_select(RCSFILE *file, const char *range) * Returns 0 on success, -1 on failure, setting errno. */ int -rcs_set_description(RCSFILE *file, const char *in) +rcs_set_description(RCSFILE *file, const char *in, int flags) { BUF *bp; char *content; @@ -458,7 +461,7 @@ rcs_set_description(RCSFILE *file, const char *in) content = xstrdup(in + 1); /* Get description from stdin. */ else - content = rcs_prompt(prompt); + content = rcs_prompt(prompt, flags); rcs_desc_set(file, content); free(content); diff --git a/usr.bin/rcs/rcsutil.h b/usr.bin/rcs/rcsutil.h index b9dbeb09dd4..cb046efcf3c 100644 --- a/usr.bin/rcs/rcsutil.h +++ b/usr.bin/rcs/rcsutil.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsutil.h,v 1.14 2010/07/23 08:31:19 ray Exp $ */ +/* $OpenBSD: rcsutil.h,v 1.15 2016/07/04 01:39:12 millert Exp $ */ /* * Copyright (c) 2006 Xavier Santolaria * All rights reserved. @@ -54,9 +54,9 @@ void rcs_set_mtime(RCSFILE *, time_t); int rcs_choosefile(const char *, char *, size_t); time_t rcs_get_mtime(RCSFILE *); RCSNUM *rcs_getrevnum(const char *, RCSFILE *); -char *rcs_prompt(const char *); +char *rcs_prompt(const char *, int); u_int rcs_rev_select(RCSFILE *, const char *); -int rcs_set_description(RCSFILE *, const char *); +int rcs_set_description(RCSFILE *, const char *, int); void rcs_setrevstr(char **, char *); void rcs_setrevstr2(char **, char **, char *); BUF *rcs_patchfile(u_char *, size_t, u_char *, size_t, -- 2.20.1