summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorray <ray@openbsd.org>2006-04-24 04:51:57 +0000
committerray <ray@openbsd.org>2006-04-24 04:51:57 +0000
commitd491b5ed9aba7fa7215e5bb16c9c435a64011bce (patch)
treec2392732f3e103c0bb408326edb9da2ede21e381
parentoops (diff)
downloadwireguard-openbsd-d491b5ed9aba7fa7215e5bb16c9c435a64011bce.tar.xz
wireguard-openbsd-d491b5ed9aba7fa7215e5bb16c9c435a64011bce.zip
o Better match GNU behavior (a bare -t does NOT read from stdin,
unlike rcs). o Share code with rcs by moving rcs_set_description() to rcsutil.c. o Change description prompt from #define to const char *. OK xsa@
-rw-r--r--usr.bin/rcs/ci.c58
-rw-r--r--usr.bin/rcs/rcsprog.c39
-rw-r--r--usr.bin/rcs/rcsprog.h6
-rw-r--r--usr.bin/rcs/rcsutil.c34
-rw-r--r--usr.bin/rcs/rcsutil.h3
5 files changed, 53 insertions, 87 deletions
diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c
index 974a755d597..a2d8b7b346c 100644
--- a/usr.bin/rcs/ci.c
+++ b/usr.bin/rcs/ci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ci.c,v 1.156 2006/04/21 17:17:29 xsa Exp $ */
+/* $OpenBSD: ci.c,v 1.157 2006/04/24 04:51:57 ray Exp $ */
/*
* Copyright (c) 2005, 2006 Niall O'Higgins <niallo@openbsd.org>
* All rights reserved.
@@ -29,7 +29,7 @@
#include "rcsprog.h"
#include "diff.h"
-#define CI_OPTSTRING "d::f::I::i::j::k::l::M::m::N:n:qr::s:Tt:u::Vw:x::z::"
+#define CI_OPTSTRING "d::f::I::i::j::k::l::M::m::N:n:qr::s:Tt::u::Vw:x::z::"
#define DATE_NOW -1
#define DATE_MTIME -2
@@ -68,7 +68,6 @@ struct checkin_params {
static int checkin_attach_symbol(struct checkin_params *);
static int checkin_checklock(struct checkin_params *);
static char *checkin_diff_file(struct checkin_params *);
-static char *checkin_getdesc(void);
static char *checkin_getlogmsg(RCSNUM *, RCSNUM *, int);
static int checkin_init(struct checkin_params *);
static int checkin_keywordscan(char *, RCSNUM **, time_t *, char **,
@@ -184,9 +183,11 @@ checkin_main(int argc, char **argv)
pb.flags |= PRESERVETIME;
break;
case 't':
- if (pb.description != NULL)
- xfree(pb.description);
- pb.description = xstrdup(rcs_optarg);
+ /* Ignore bare -t; kept for backwards compatibility. */
+ if (rcs_optarg == NULL)
+ break;
+ pb.description = rcs_optarg;
+ pb.flags |= DESCRIPTION;
break;
case 'u':
rcs_setrevstr(&rev_str, rcs_optarg);
@@ -266,10 +267,12 @@ checkin_main(int argc, char **argv)
}
pb.file = rcs_open(pb.fpath, pb.openflags, pb.fmode);
-
if (pb.file == NULL)
fatal("failed to open rcsfile '%s'", pb.fpath);
+ if (pb.flags & DESCRIPTION)
+ rcs_set_description(pb.file, pb.description);
+
if (!(pb.flags & QUIET))
printf("%s <-- %s\n", pb.fpath, pb.filename);
@@ -404,26 +407,6 @@ checkin_getlogmsg(RCSNUM *rev, RCSNUM *rev2, int flags)
return (rcs_msg);
}
-
-/*
- * checkin_getdesc()
- *
- * Get file description interactively.
- * Returns pointer to a char array on success, NULL on failure.
- */
-static char *
-checkin_getdesc()
-{
- char *description;
- const char *prompt =
- "enter description, terminated with single '.' or end of file:\n"
- "NOTE: This is NOT the log message!\n";
-
- description = rcs_prompt(prompt);
-
- return (description);
-}
-
/*
* checkin_update()
*
@@ -609,10 +592,9 @@ fail:
static int
checkin_init(struct checkin_params *pb)
{
- BUF *bp, *dp;
+ BUF *bp;
char *filec, numb[64];
int fetchlog = 0;
- const char *rcs_desc;
struct stat st;
filec = NULL;
@@ -642,23 +624,7 @@ checkin_init(struct checkin_params *pb)
/* Get description from user */
if (pb->description == NULL)
- rcs_desc = (const char *)checkin_getdesc();
- else {
- if (*pb->description == '-') {
- pb->description++;
- rcs_desc = (const char *)pb->description;
- } else {
- dp = cvs_buf_load(pb->description, BUF_AUTOEXT);
- if (dp == NULL) {
- warnx("failed to load description file '%s'",
- pb->description);
- goto fail;
- }
- cvs_buf_putc(dp, '\0');
- rcs_desc = (const char *)cvs_buf_release(dp);
- }
- }
- rcs_desc_set(pb->file, rcs_desc);
+ rcs_set_description(pb->file, NULL);
skipdesc:
diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c
index 866ee2c696d..aa6c26d286d 100644
--- a/usr.bin/rcs/rcsprog.c
+++ b/usr.bin/rcs/rcsprog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsprog.c,v 1.112 2006/04/21 17:17:29 xsa Exp $ */
+/* $OpenBSD: rcsprog.c,v 1.113 2006/04/24 04:51:57 ray Exp $ */
/*
* Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -31,9 +31,6 @@
#define RCS_CMD_MAXARG 128
#define RCSPROG_OPTSTRING "A:a:b::c:e::ik:Ll::m:Mn:N:o:qt::TUu::Vx::z::"
-#define DESC_PROMPT "enter description, terminated with single '.' " \
- "or end of file:\nNOTE: This is NOT the log message!\n"
-
const char rcs_version[] = "OpenCVS RCS version 3.6";
int rcsflags;
@@ -60,7 +57,6 @@ struct rcs_prog {
struct cvs_wklhead rcs_temp_files;
void sighdlr(int);
-static void rcs_set_description(RCSFILE *, const char *);
static void rcs_attach_symbol(RCSFILE *, const char *);
/* ARGSUSED */
@@ -260,7 +256,7 @@ rcs_main(int argc, char **argv)
break;
case 't':
descfile = rcs_optarg;
- rcsflags |= RCSPROG_TFLAG;
+ rcsflags |= DESCRIPTION;
break;
case 'T':
rcsflags |= PRESERVETIME;
@@ -313,7 +309,7 @@ rcs_main(int argc, char **argv)
if ((file = rcs_open(fpath, flags, fmode)) == NULL)
continue;
- if (rcsflags & RCSPROG_TFLAG)
+ if (rcsflags & DESCRIPTION)
rcs_set_description(file, descfile);
else if (flags & RCS_CREATE)
rcs_set_description(file, NULL);
@@ -540,32 +536,3 @@ rcs_attach_symbol(RCSFILE *file, const char *symname)
}
}
}
-
-/*
- * Load description from <in> to <file>.
- * If <in> starts with a `-', <in> is taken as the description.
- * Otherwise <in> is the name of the file containing the description.
- * If <in> is NULL, the description is read from stdin.
- */
-static void
-rcs_set_description(RCSFILE *file, const char *in)
-{
- BUF *bp;
- char *content;
-
- /* Description is in file <in>. */
- if (in != NULL && *in != '-') {
- bp = cvs_buf_load(in, BUF_AUTOEXT);
- cvs_buf_putc(bp, '\0');
- content = cvs_buf_release(bp);
- /* Description is in <in>. */
- } else if (in != NULL)
- /* Skip leading `-'. */
- content = xstrdup(in + 1);
- /* Get description from stdin. */
- else
- content = rcs_prompt(DESC_PROMPT);
-
- rcs_desc_set(file, content);
- xfree(content);
-}
diff --git a/usr.bin/rcs/rcsprog.h b/usr.bin/rcs/rcsprog.h
index 2c3011ffabe..d06ce4f5f84 100644
--- a/usr.bin/rcs/rcsprog.h
+++ b/usr.bin/rcs/rcsprog.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsprog.h,v 1.53 2006/04/21 17:17:29 xsa Exp $ */
+/* $OpenBSD: rcsprog.h,v 1.54 2006/04/24 04:51:57 ray Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -59,10 +59,10 @@
#define RCSPROG_EFLAG (1<<12)
#define RCSPROG_LFLAG (1<<13)
#define RCSPROG_NFLAG (1<<14)
-#define RCSPROG_TFLAG (1<<15)
-#define RCSPROG_UFLAG (1<<16)
+#define RCSPROG_UFLAG (1<<15)
/* shared flags */
+#define DESCRIPTION (1<<16)
#define FORCE (1<<17)
#define INTERACTIVE (1<<18)
#define NEWFILE (1<<19)
diff --git a/usr.bin/rcs/rcsutil.c b/usr.bin/rcs/rcsutil.c
index 9e0dba9d535..2ee29b38499 100644
--- a/usr.bin/rcs/rcsutil.c
+++ b/usr.bin/rcs/rcsutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsutil.c,v 1.1 2006/04/21 17:17:29 xsa Exp $ */
+/* $OpenBSD: rcsutil.c,v 1.2 2006/04/24 04:51:57 ray Exp $ */
/*
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -443,3 +443,35 @@ rcs_rev_select(RCSFILE *file, char *range)
return (nrev);
}
+
+/*
+ * Load description from <in> to <file>.
+ * If <in> starts with a `-', <in> is taken as the description.
+ * Otherwise <in> is the name of the file containing the description.
+ * If <in> is NULL, the description is read from stdin.
+ */
+void
+rcs_set_description(RCSFILE *file, const char *in)
+{
+ BUF *bp;
+ char *content;
+ const char *prompt =
+ "enter description, terminated with single '.' or end of file:\n"
+ "NOTE: This is NOT the log message!\n";
+
+ /* Description is in file <in>. */
+ if (in != NULL && *in != '-') {
+ bp = cvs_buf_load(in, BUF_AUTOEXT);
+ cvs_buf_putc(bp, '\0');
+ content = cvs_buf_release(bp);
+ /* Description is in <in>. */
+ } else if (in != NULL)
+ /* Skip leading `-'. */
+ content = xstrdup(in + 1);
+ /* Get description from stdin. */
+ else
+ content = rcs_prompt(prompt);
+
+ rcs_desc_set(file, content);
+ xfree(content);
+}
diff --git a/usr.bin/rcs/rcsutil.h b/usr.bin/rcs/rcsutil.h
index 717a75d3916..69017e287b4 100644
--- a/usr.bin/rcs/rcsutil.h
+++ b/usr.bin/rcs/rcsutil.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsutil.h,v 1.1 2006/04/21 17:17:29 xsa Exp $ */
+/* $OpenBSD: rcsutil.h,v 1.2 2006/04/24 04:51:57 ray Exp $ */
/*
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
* All rights reserved.
@@ -38,6 +38,7 @@ time_t rcs_get_mtime(const char *);
RCSNUM *rcs_getrevnum(const char *, RCSFILE *);
char *rcs_prompt(const char *);
u_int rcs_rev_select(RCSFILE *, char *);
+void rcs_set_description(RCSFILE *, const char *);
void rcs_set_rev(const char *, RCSNUM **);
void rcs_setrevstr(char **, char *);
void rcs_setrevstr2(char **, char **, char *);