summaryrefslogtreecommitdiffstats
path: root/usr.bin/rcs/rcsutil.c
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 /usr.bin/rcs/rcsutil.c
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@
Diffstat (limited to 'usr.bin/rcs/rcsutil.c')
-rw-r--r--usr.bin/rcs/rcsutil.c34
1 files changed, 33 insertions, 1 deletions
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);
+}