=================================================================== RCS file: /cvs/mandoc/mdoc_validate.c,v retrieving revision 1.355 retrieving revision 1.360 diff -u -p -r1.355 -r1.360 --- mandoc/mdoc_validate.c 2018/03/16 15:05:44 1.355 +++ mandoc/mdoc_validate.c 2018/08/01 16:00:58 1.360 @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.355 2018/03/16 15:05:44 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.360 2018/08/01 16:00:58 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2018 Ingo Schwarze @@ -320,6 +320,7 @@ mdoc_node_validate(struct roff_man *mdoc) (np->tok == MDOC_Sh || np->tok == MDOC_Ss))) check_toptext(mdoc, n->line, n->pos, n->string); break; + case ROFFT_COMMENT: case ROFFT_EQN: case ROFFT_TBL: break; @@ -412,8 +413,9 @@ check_text_em(struct roff_man *mdoc, int ln, int pos, /* Look for em-dashes wrongly encoded as "--". */ for (cp = p; *cp != '\0'; cp++) { - if (*cp != '-' || *++cp != '-') + if (cp[0] != '-' || cp[1] != '-') continue; + cp++; /* Skip input sequences of more than two '-'. */ @@ -435,14 +437,13 @@ check_text_em(struct roff_man *mdoc, int ln, int pos, isalpha((unsigned char)cp[-3]) : np != NULL && np->type == ROFFT_TEXT && - np->string != '\0' && + *np->string != '\0' && isalpha((unsigned char)np->string[ strlen(np->string) - 1])) || - (cp[2] != '\0' ? + (cp[1] != '\0' && cp[2] != '\0' ? isalpha((unsigned char)cp[2]) : nn != NULL && nn->type == ROFFT_TEXT && - nn->string != '\0' && isalpha((unsigned char)*nn->string))) { mandoc_msg(MANDOCERR_DASHDASH, mdoc->parse, ln, pos + (int)(cp - p) - 1, NULL); @@ -1003,10 +1004,10 @@ post_lb(POST_ARGS) roff_word_alloc(mdoc, n->line, n->pos, "library"); mdoc->last->flags = NODE_NOSRC; - roff_word_alloc(mdoc, n->line, n->pos, "\\(Lq"); + roff_word_alloc(mdoc, n->line, n->pos, "\\(lq"); mdoc->last->flags = NODE_DELIMO | NODE_NOSRC; mdoc->last = mdoc->last->next; - roff_word_alloc(mdoc, n->line, n->pos, "\\(Rq"); + roff_word_alloc(mdoc, n->line, n->pos, "\\(rq"); mdoc->last->flags = NODE_DELIMC | NODE_NOSRC; mdoc->last = n; } @@ -1987,8 +1988,10 @@ post_root(POST_ARGS) /* Check that we begin with a proper `Sh'. */ n = mdoc->first->child; - while (n != NULL && n->tok >= MDOC_Dd && - mdoc_macros[n->tok].flags & MDOC_PROLOGUE) + while (n != NULL && + (n->type == ROFFT_COMMENT || + (n->tok >= MDOC_Dd && + mdoc_macros[n->tok].flags & MDOC_PROLOGUE))) n = n->next; if (n == NULL)