summaryrefslogtreecommitdiff
path: root/usr.bin/rcs/rcsutil.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2007-02-22 19:11:14 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2007-02-22 19:11:14 +0000
commit4284f660a7d46b89668c59de40295122e1be7c06 (patch)
treeddc59c779a46430a49475ffdf634c714b3239265 /usr.bin/rcs/rcsutil.c
parent7b957b62ebc65d4f300af06463bb68b56cf3e597 (diff)
If a ,suffix file is given as an arg to ci and co, strip it. Avoids
potential disasters. Initial diff from niallo@, ok niallo@ joris@
Diffstat (limited to 'usr.bin/rcs/rcsutil.c')
-rw-r--r--usr.bin/rcs/rcsutil.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/usr.bin/rcs/rcsutil.c b/usr.bin/rcs/rcsutil.c
index 633862235f6..11976adc86c 100644
--- a/usr.bin/rcs/rcsutil.c
+++ b/usr.bin/rcs/rcsutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsutil.c,v 1.27 2007/02/22 08:30:45 xsa Exp $ */
+/* $OpenBSD: rcsutil.c,v 1.28 2007/02/22 19:11:13 otto Exp $ */
/*
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -619,3 +619,23 @@ rcs_argv_destroy(struct rcs_argvector *av)
xfree(av->argv);
xfree(av);
}
+
+/*
+ * Strip suffix from filename.
+ */
+void
+rcs_strip_suffix(char *filename)
+{
+ char *p, *suffixes, *next, *ext;
+
+ if ((p = strrchr(filename, ',')) != NULL) {
+ suffixes = xstrdup(rcs_suffixes);
+ for (next = suffixes; (ext = strsep(&next, "/")) != NULL;) {
+ if (!strcmp(p, ext)) {
+ *p = '\0';
+ break;
+ }
+ }
+ xfree(suffixes);
+ }
+}