summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2006-05-27 18:04:47 +0000
committerJoris Vink <joris@cvs.openbsd.org>2006-05-27 18:04:47 +0000
commit6d366b32cd3519770f283b99108385bea25aa920 (patch)
tree5f67579c5a7a961b4cf66a41a84f01ef29efe06f /usr.bin/cvs
parentb907f62049533bcc6b33cfea01c4ea839dbb389c (diff)
basic support for CVSROOT/config - only supporting the 'tag' and
'umask' keyword right now.
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/Makefile4
-rw-r--r--usr.bin/cvs/config.c76
-rw-r--r--usr.bin/cvs/config.h23
-rw-r--r--usr.bin/cvs/cvs.c9
-rw-r--r--usr.bin/cvs/cvs.h5
-rw-r--r--usr.bin/cvs/rcs.c10
6 files changed, 122 insertions, 5 deletions
diff --git a/usr.bin/cvs/Makefile b/usr.bin/cvs/Makefile
index bf5a0cf28fe..c1dd20d8ca6 100644
--- a/usr.bin/cvs/Makefile
+++ b/usr.bin/cvs/Makefile
@@ -1,10 +1,10 @@
-# $OpenBSD: Makefile,v 1.22 2006/05/27 03:30:30 joris Exp $
+# $OpenBSD: Makefile,v 1.23 2006/05/27 18:04:46 joris Exp $
PROG= opencvs
MAN= cvs.1 cvsignore.5 cvsrc.5 cvswrappers.5 cvsintro.7
CPPFLAGS+=-I${.CURDIR}
-SRCS= cvs.c commit.c checkout.c buf.c cmd.c date.y diff.c diff3.c \
+SRCS= cvs.c commit.c config.c checkout.c buf.c cmd.c date.y diff.c diff3.c \
diff_internals.c entries.c fatal.c file.c log.c repository.c \
rcs.c rcsnum.c rcstime.c root.c status.c worklist.c util.c \
update.c xmalloc.c
diff --git a/usr.bin/cvs/config.c b/usr.bin/cvs/config.c
new file mode 100644
index 00000000000..99da5009a3f
--- /dev/null
+++ b/usr.bin/cvs/config.c
@@ -0,0 +1,76 @@
+/* $OpenBSD: config.c,v 1.1 2006/05/27 18:04:46 joris Exp $ */
+/*
+ * Copyright (c) 2006 Joris Vink <joris@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "includes.h"
+
+#include "cvs.h"
+#include "config.h"
+#include "diff.h"
+#include "log.h"
+#include "proto.h"
+
+void
+cvs_parse_configfile(void)
+{
+ int i;
+ FILE *fp;
+ size_t len;
+ const char *errstr;
+ char *buf, *lbuf, *opt, *val, fpath[MAXPATHLEN];
+
+ i = snprintf(fpath, sizeof(fpath), "%s/%s", current_cvsroot->cr_dir,
+ CVS_PATH_CONFIG);
+ if (i == -1 || i >= (int)sizeof(fpath))
+ fatal("cvs_parse_configfile: overflow");
+
+ if ((fp = fopen(fpath, "r")) == NULL)
+ fatal("cvs_config_parse: %s: %s",
+ CVS_PATH_CONFIG, strerror(errno));
+
+ lbuf = NULL;
+ while ((buf = fgetln(fp, &len))) {
+ if (buf[len - 1] == '\n') {
+ buf[len - 1] = '\0';
+ } else {
+ lbuf = xmalloc(len + 1);
+ strlcpy(lbuf, buf, len);
+ buf = lbuf;
+ }
+
+ opt = buf;
+ if ((val = strrchr(opt, '=')) == NULL)
+ fatal("cvs_parse_configfile: bad option '%s'", opt);
+
+ *(val++) = '\0';
+
+ if (!strcmp(opt, "tag")) {
+ cvs_tagname = xstrdup(val);
+ } else if (!strcmp(opt, "umask")) {
+ cvs_umask = (int)strtonum(val, 0, INT_MAX, &errstr);
+ if (errstr != NULL)
+ fatal("cvs_parse_configfile: %s: %s", val,
+ errstr);
+ } else {
+ cvs_log(LP_ERR, "ignoring unknown option '%s'", opt);
+ }
+
+ if (lbuf != NULL)
+ xfree(lbuf);
+ }
+
+ (void)fclose(fp);
+}
diff --git a/usr.bin/cvs/config.h b/usr.bin/cvs/config.h
new file mode 100644
index 00000000000..1c56e0d04ec
--- /dev/null
+++ b/usr.bin/cvs/config.h
@@ -0,0 +1,23 @@
+/* $OpenBSD: config.h,v 1.1 2006/05/27 18:04:46 joris Exp $ */
+/*
+ * Copyright (c) 2006 Joris Vink <joris@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+void cvs_parse_configfile(void);
+
+#endif
diff --git a/usr.bin/cvs/cvs.c b/usr.bin/cvs/cvs.c
index 37229a523ee..8f4400467a6 100644
--- a/usr.bin/cvs/cvs.c
+++ b/usr.bin/cvs/cvs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.c,v 1.98 2006/05/27 03:30:30 joris Exp $ */
+/* $OpenBSD: cvs.c,v 1.99 2006/05/27 18:04:46 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -28,6 +28,7 @@
#include "includes.h"
#include "cvs.h"
+#include "config.h"
#include "log.h"
#include "file.h"
@@ -46,7 +47,9 @@ int cvs_nocase = 0; /* set to 1 to disable filename case sensitivity */
int cvs_noexec = 0; /* set to 1 to disable disk operations (-n option) */
int cvs_error = -1; /* set to the correct error code on failure */
int cvs_cmdop;
+int cvs_umask = CVS_UMASK_DEFAULT;
+char *cvs_tagname = NULL;
char *cvs_defargs; /* default global arguments from .cvsrc */
char *cvs_command; /* name of the command we are running */
char *cvs_rootstr;
@@ -223,6 +226,10 @@ main(int argc, char **argv)
if (current_cvsroot->cr_method != CVS_METHOD_LOCAL)
fatal("remote setups are not supported yet");
+ cvs_parse_configfile();
+
+ umask(cvs_umask);
+
cmdp->cmd(cmd_argc, cmd_argv);
cvs_cleanup();
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index d0bda653934..7b13e2dc8d4 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.106 2006/05/27 15:14:27 joris Exp $ */
+/* $OpenBSD: cvs.h,v 1.107 2006/05/27 18:04:46 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -99,6 +99,7 @@
#define CVS_RSH_DEFAULT "ssh"
#define CVS_EDITOR_DEFAULT "vi"
#define CVS_TMPDIR_DEFAULT "/tmp"
+#define CVS_UMASK_DEFAULT 002
/* extensions */
#define CVS_DESCR_FILE_EXT ",t"
@@ -262,6 +263,7 @@ extern struct cvs_wklhead temp_files;
extern volatile sig_atomic_t sig_received;
extern volatile sig_atomic_t cvs_quit;
extern struct cvsroot *current_cvsroot;
+extern char *cvs_tagname;
extern char *cvs_repo_base;
extern char *cvs_command;
extern char *cvs_editor;
@@ -270,6 +272,7 @@ extern char *cvs_msg;
extern char *cvs_rsh;
extern char *cvs_tmpdir;
+extern int cvs_umask;
extern int verbosity;
extern int cvs_trace;
extern int cvs_nolog;
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c
index a2e8afa123d..93c487c32b7 100644
--- a/usr.bin/cvs/rcs.c
+++ b/usr.bin/cvs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.173 2006/05/27 05:59:32 joris Exp $ */
+/* $OpenBSD: rcs.c,v 1.174 2006/05/27 18:04:46 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -2613,6 +2613,14 @@ rcs_expand_keywords(char *rcsfile, struct rcs_delta *rdp, char *data,
}
}
+ if (cvs_tagname != NULL &&
+ !strncmp(c, cvs_tagname, strlen(cvs_tagname)) &&
+ found != 1) {
+ found = 1;
+ kwstr = cvs_tagname;
+ kwtype = RCS_KW_ID;
+ }
+
/* unknown keyword, continue looking */
if (found == 0) {
c = start;