From 35d7a7dabf8e1cb8891b2661e5798de4f9f06f87 Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 25 Feb 2019 18:07:48 +0000 Subject: Add a configtest flag (-n). based on a diff from Sascha Paunovic. --- calmwm.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'calmwm.c') diff --git a/calmwm.c b/calmwm.c index 101bdbf..1c3c2c0 100644 --- a/calmwm.c +++ b/calmwm.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.c,v 1.109 2018/02/09 19:54:54 okan Exp $ + * $OpenBSD: calmwm.c,v 1.110 2019/02/25 18:07:48 okan Exp $ */ #include @@ -55,7 +55,7 @@ main(int argc, char **argv) { char *display_name = NULL; char *fallback; - int ch, xfd; + int ch, xfd, nflag = 0; struct pollfd pfd[1]; if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) @@ -66,7 +66,7 @@ main(int argc, char **argv) fallback = u_argv(argv); Conf.wm_argv = u_argv(argv); - while ((ch = getopt(argc, argv, "c:d:v")) != -1) { + while ((ch = getopt(argc, argv, "c:d:nv")) != -1) { switch (ch) { case 'c': free(Conf.conf_file); @@ -75,6 +75,9 @@ main(int argc, char **argv) case 'd': display_name = optarg; break; + case 'n': + nflag = 1; + break; case 'v': Conf.debug++; break; @@ -90,8 +93,13 @@ main(int argc, char **argv) if (signal(SIGHUP, sighdlr) == SIG_ERR) err(1, "signal"); - if (parse_config(Conf.conf_file, &Conf) == -1) + if (parse_config(Conf.conf_file, &Conf) == -1) { warnx("error parsing config file"); + if (nflag) + return 1; + } + if (nflag) + return 0; xfd = x_init(display_name); cwm_status = CWM_RUNNING; @@ -219,7 +227,7 @@ usage(void) { extern char *__progname; - (void)fprintf(stderr, "usage: %s [-v] [-c file] [-d display]\n", + (void)fprintf(stderr, "usage: %s [-nv] [-c file] [-d display]\n", __progname); exit(1); } -- cgit v1.2.3-2-gb3c3