=================================================================== RCS file: /cvs/mandoc/mdoc_validate.c,v retrieving revision 1.183 retrieving revision 1.184 diff -u -p -r1.183 -r1.184 --- mandoc/mdoc_validate.c 2012/05/27 17:39:28 1.183 +++ mandoc/mdoc_validate.c 2012/05/27 17:48:57 1.184 @@ -1,7 +1,7 @@ -/* $Id: mdoc_validate.c,v 1.183 2012/05/27 17:39:28 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.184 2012/05/27 17:48:57 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons - * Copyright (c) 2010, 2011 Ingo Schwarze + * Copyright (c) 2010, 2011, 2012 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -2192,14 +2192,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))) { @@ -2209,11 +2210,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);