summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2012-05-27 17:48:57 +0000
committerIngo Schwarze <schwarze@openbsd.org>2012-05-27 17:48:57 +0000
commitcc286dde362eb32238e74c6bd62962a7ffe6e872 (patch)
tree97852d737c2a1eefdd93d854c28cb4b9aa0236eb /main.c
parent7c536cb6230f46a3b6438c2611168d45f1ef2cb2 (diff)
downloadmandoc-cc286dde362eb32238e74c6bd62962a7ffe6e872.tar.gz
Support -Ios='OpenBSD 5.1' to override uname(3) as the source of the
default value for the mdoc(7) .Os macro. Needed for man.cgi on the OpenBSD website. Problem with man.cgi first noticed by deraadt@; beck@ and deraadt@ agree with the way to solve the issue. "Please check them in and I'll look into them later!" kristaps@
Diffstat (limited to 'main.c')
-rw-r--r--main.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/main.c b/main.c
index 36d02e3a..7c9a5c60 100644
--- a/main.c
+++ b/main.c
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2011, 2012 Ingo Schwarze <schwarze@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
@@ -85,6 +85,7 @@ main(int argc, char *argv[])
struct curparse curp;
enum mparset type;
enum mandoclevel rc;
+ char *defos;
progname = strrchr(argv[0], '/');
if (progname == NULL)
@@ -97,10 +98,24 @@ main(int argc, char *argv[])
type = MPARSE_AUTO;
curp.outtype = OUTT_ASCII;
curp.wlevel = MANDOCLEVEL_FATAL;
+ defos = NULL;
/* LINTED */
- while (-1 != (c = getopt(argc, argv, "m:O:T:VW:")))
+ while (-1 != (c = getopt(argc, argv, "I:m:O:T:VW:")))
switch (c) {
+ case ('I'):
+ if (strncmp(optarg, "os=", 3)) {
+ fprintf(stderr, "-I%s: Bad argument\n",
+ optarg);
+ return((int)MANDOCLEVEL_BADARG);
+ }
+ if (defos) {
+ fprintf(stderr, "-I%s: Duplicate argument\n",
+ optarg);
+ return((int)MANDOCLEVEL_BADARG);
+ }
+ defos = mandoc_strdup(optarg + 3);
+ break;
case ('m'):
if ( ! moptions(&type, optarg))
return((int)MANDOCLEVEL_BADARG);
@@ -125,7 +140,7 @@ main(int argc, char *argv[])
/* NOTREACHED */
}
- curp.mp = mparse_alloc(type, curp.wlevel, mmsg, &curp);
+ curp.mp = mparse_alloc(type, curp.wlevel, mmsg, &curp, defos);
/*
* Conditionally start up the lookaside buffer before parsing.
@@ -152,6 +167,7 @@ main(int argc, char *argv[])
(*curp.outfree)(curp.outdata);
if (curp.mp)
mparse_free(curp.mp);
+ free(defos);
return((int)rc);
}