summaryrefslogtreecommitdiffstats
path: root/usr.bin/rcs/rcsutil.c
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2007-02-22 19:11:13 +0000
committerotto <otto@openbsd.org>2007-02-22 19:11:13 +0000
commit168f4dca489f790262d4e96fcbd2eb26100bcf1e (patch)
treed1f93a3934f3546e278a0163dafb52686c2829ed /usr.bin/rcs/rcsutil.c
parentAdded changes to dump all tables not just DSDT (diff)
downloadwireguard-openbsd-168f4dca489f790262d4e96fcbd2eb26100bcf1e.tar.xz
wireguard-openbsd-168f4dca489f790262d4e96fcbd2eb26100bcf1e.zip
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);
+ }
+}