From 5a614b48d4e480e6aecbb9f6257de42dee05e3ae Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 16 Oct 2011 12:20:34 +0000 Subject: Remove a bunch of useless assignments, and assert that print_bvspace cannot be called on NULL pointers. No change in behaviour, none of these were bugs, but the code becomes easier to understand. Based on a clang report posted by joerg@; ok kristaps@. --- man_validate.c | 13 ++++++------- mdoc_html.c | 4 ++-- mdoc_macro.c | 7 ++----- mdoc_term.c | 4 +++- mdoc_validate.c | 11 +++++------ term_ps.c | 7 +++---- 6 files changed, 21 insertions(+), 25 deletions(-) diff --git a/man_validate.c b/man_validate.c index 3a178e65..28352a0c 100644 --- a/man_validate.c +++ b/man_validate.c @@ -1,4 +1,4 @@ -/* $Id: man_validate.c,v 1.75 2011/09/06 17:53:50 kristaps Exp $ */ +/* $Id: man_validate.c,v 1.76 2011/10/16 12:20:34 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze @@ -213,12 +213,12 @@ check_text(CHKARGS) { char *cp, *p; - cp = p = n->string; - for (cp = p; NULL != (p = strchr(p, '\t')); p++) { - if (MAN_LITERAL & m->flags) - continue; + if (MAN_LITERAL & m->flags) + return; + + cp = n->string; + for (p = cp; NULL != (p = strchr(p, '\t')); p++) man_pmsg(m, n->line, (int)(p - cp), MANDOCERR_BADTAB); - } } #define INEQ_DEFINE(x, ineq, name) \ @@ -474,7 +474,6 @@ post_UC(CHKARGS) const char *p, *s; n = n->child; - n = m->last->child; if (NULL == n || MAN_TEXT != n->type) p = bsd_versions[0]; diff --git a/mdoc_html.c b/mdoc_html.c index 09314270..5109ae4c 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.180 2011/10/09 22:10:53 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.181 2011/10/16 12:20:34 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * @@ -503,7 +503,7 @@ mdoc_root_post(MDOC_ARGS) print_otag(h, TAG_COL, 1, tag); print_otag(h, TAG_COL, 1, tag); - t = print_otag(h, TAG_TBODY, 0, NULL); + print_otag(h, TAG_TBODY, 0, NULL); tt = print_otag(h, TAG_TR, 0, NULL); diff --git a/mdoc_macro.c b/mdoc_macro.c index 8b87d4e6..9f8e76be 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.111 2011/09/18 14:14:15 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.112 2011/10/16 12:20:34 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze @@ -1443,18 +1443,15 @@ blk_part_exp(MACRO_PROT_ARGS) /* Clean-up to leave in a consistent state. */ - if (NULL == head) { + if (NULL == head) if ( ! mdoc_head_alloc(m, line, ppos, tok)) return(0); - head = m->last; - } if (NULL == body) { if ( ! rew_sub(MDOC_HEAD, m, tok, line, ppos)) return(0); if ( ! mdoc_body_alloc(m, line, ppos, tok)) return(0); - body = m->last; } /* Standard appending of delimiters. */ diff --git a/mdoc_term.c b/mdoc_term.c index 5f55d648..a6f279db 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.235 2011/09/20 09:02:23 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.236 2011/10/16 12:20:34 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze @@ -584,6 +584,8 @@ print_bvspace(struct termp *p, { const struct mdoc_node *nn; + assert(n); + term_newln(p); if (MDOC_Bd == bl->tok && bl->norm->Bd.comp) diff --git a/mdoc_validate.c b/mdoc_validate.c index 5299253b..56936424 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.176 2011/09/02 19:40:18 kristaps Exp $ */ +/* $Id: mdoc_validate.c,v 1.177 2011/10/16 12:20:34 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2011 Ingo Schwarze @@ -545,12 +545,11 @@ check_text(struct mdoc *m, int ln, int pos, char *p) { char *cp; - cp = p; - for (cp = p; NULL != (p = strchr(p, '\t')); p++) { - if (MDOC_LITERAL & m->flags) - continue; + if (MDOC_LITERAL & m->flags) + return; + + for (cp = p; NULL != (p = strchr(p, '\t')); p++) mdoc_pmsg(m, ln, pos + (int)(p - cp), MANDOCERR_BADTAB); - } } static int diff --git a/term_ps.c b/term_ps.c index aa5d1470..e8a90685 100644 --- a/term_ps.c +++ b/term_ps.c @@ -1,4 +1,4 @@ -/* $Id: term_ps.c,v 1.53 2011/09/18 14:14:15 schwarze Exp $ */ +/* $Id: term_ps.c,v 1.54 2011/10/16 12:20:34 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * @@ -488,8 +488,7 @@ pspdf_alloc(char *outopts) pagey = 356; } else if (2 != sscanf(pp, "%ux%u", &pagex, &pagey)) fprintf(stderr, "%s: Unknown paper\n", pp); - } else if (NULL == pp) - pp = "letter"; + } /* * This MUST be defined before any PNT2AFM or AFM2PNT @@ -576,7 +575,7 @@ ps_printf(struct termp *p, const char *fmt, ...) ps_growbuf(p, PS_BUFSLOP); pos = (int)p->ps->psmargcur; - len = vsnprintf(&p->ps->psmarg[pos], PS_BUFSLOP, fmt, ap); + vsnprintf(&p->ps->psmarg[pos], PS_BUFSLOP, fmt, ap); va_end(ap); -- cgit v1.2.3-56-ge451