diff options
author | 2012-05-24 23:33:23 +0000 | |
---|---|---|
committer | 2012-05-24 23:33:23 +0000 | |
commit | 353fa9ecab66599dba632aa54915bbe0fbe656ac (patch) | |
tree | 2a469278bd9e4beedad8c0a735f0950503389800 /usr.bin/mandoc/mdoc_validate.c | |
parent | If _MIN > _MAX consider a WordBus resource to be invalid. Fixes a panic on (diff) | |
download | wireguard-openbsd-353fa9ecab66599dba632aa54915bbe0fbe656ac.tar.xz wireguard-openbsd-353fa9ecab66599dba632aa54915bbe0fbe656ac.zip |
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.
Diffstat (limited to 'usr.bin/mandoc/mdoc_validate.c')
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 75a93f6e094..eabced7ac31 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,7 +1,7 @@ -/* $Id: mdoc_validate.c,v 1.101 2012/04/15 10:31:00 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.102 2012/05/24 23:33:23 schwarze Exp $ */ /* * Copyright (c) 2008-2012 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 @@ -2188,14 +2188,15 @@ post_os(POST_ARGS) n = mdoc->last; /* - * Set the operating system by way of the `Os' macro. Note that - * if an argument isn't provided and -DOSNAME="\"foo\"" is - * provided during compilation, this value will be used instead - * of filling in "sysname release" from uname(). + * Set the operating system by way of the `Os' macro. + * The order of precedence is: + * 1. the argument of the `Os' macro, unless empty + * 2. the -Ios=foo command line argument, if provided + * 3. -DOSNAME="\"foo\"", if provided during compilation + * 4. "sysname release" from uname(3) */ - if (mdoc->meta.os) - free(mdoc->meta.os); + free(mdoc->meta.os); buf[0] = '\0'; if (-1 == (c = concat(buf, n->child, BUFSIZ))) { @@ -2205,11 +2206,11 @@ post_os(POST_ARGS) assert(c); - /* XXX: yes, these can all be dynamically-adjusted buffers, but - * it's really not worth the extra hackery. - */ - if ('\0' == buf[0]) { + if (mdoc->defos) { + mdoc->meta.os = mandoc_strdup(mdoc->defos); + return(1); + } #ifdef OSNAME if (strlcat(buf, OSNAME, BUFSIZ) >= BUFSIZ) { mdoc_nmsg(mdoc, n, MANDOCERR_MEM); |