=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mdoc_validate.c,v retrieving revision 1.246 retrieving revision 1.247 diff -u -r1.246 -r1.247 --- src/usr.bin/mandoc/mdoc_validate.c 2017/06/01 15:24:41 1.246 +++ src/usr.bin/mandoc/mdoc_validate.c 2017/06/07 23:29:31 1.247 @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_validate.c,v 1.246 2017/06/01 15:24:41 schwarze Exp $ */ +/* $OpenBSD: mdoc_validate.c,v 1.247 2017/06/07 23:29:31 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2017 Ingo Schwarze @@ -1467,6 +1467,8 @@ struct roff_node *nparent, *nprev; /* of the Bl block */ struct roff_node *nblock, *nbody; /* of the Bl */ struct roff_node *nchild, *nnext; /* of the Bl body */ + const char *prev_Er; + int order; nbody = mdoc->last; switch (nbody->type) { @@ -1567,6 +1569,34 @@ nchild = nnext; } + + if (mdoc->meta.os_e != MDOC_OS_NETBSD) + return; + + prev_Er = NULL; + for (nchild = nbody->child; nchild != NULL; nchild = nchild->next) { + if (nchild->tok != MDOC_It) + continue; + if ((nnext = nchild->head->child) == NULL) + continue; + if (nnext->type == ROFFT_BLOCK) + nnext = nnext->body->child; + if (nnext == NULL || nnext->tok != MDOC_Er) + continue; + nnext = nnext->child; + if (prev_Er != NULL) { + order = strcmp(prev_Er, nnext->string); + if (order > 0) + mandoc_vmsg(MANDOCERR_ER_ORDER, + mdoc->parse, nnext->line, nnext->pos, + "Er %s %s", prev_Er, nnext->string); + else if (order == 0) + mandoc_vmsg(MANDOCERR_ER_REP, + mdoc->parse, nnext->line, nnext->pos, + "Er %s", prev_Er); + } + prev_Er = nnext->string; + } } static void @@ -2373,11 +2403,11 @@ mdoc->meta.os = NULL; deroff(&mdoc->meta.os, n); if (mdoc->meta.os) - return; + goto out; if (mdoc->defos) { mdoc->meta.os = mandoc_strdup(mdoc->defos); - return; + goto out; } #ifdef OSNAME @@ -2394,6 +2424,10 @@ } mdoc->meta.os = mandoc_strdup(defbuf); #endif /*!OSNAME*/ + +out: mdoc->meta.os_e = strstr(mdoc->meta.os, "OpenBSD") != NULL ? + MDOC_OS_OPENBSD : strstr(mdoc->meta.os, "NetBSD") != NULL ? + MDOC_OS_NETBSD : MDOC_OS_OTHER; } enum roff_sec