diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-04-20 16:44:45 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-04-20 16:44:45 +0000 |
commit | f56d2a77de87d6c6c8084d18333b3f9f288b8c4b (patch) | |
tree | 7f74e9e22008ed89e57a4078654c6c4c078a6b2f /usr.bin/mandoc/man_term.c | |
parent | 8c82f12e94a9ffb9fe72703c36cff406a144d775 (diff) |
KNF: case (FOO): -> case FOO, remove /* LINTED */ and /* ARGSUSED */,
remove trailing whitespace and blanks before tabs, improve some indenting;
no functional change
Diffstat (limited to 'usr.bin/mandoc/man_term.c')
-rw-r--r-- | usr.bin/mandoc/man_term.c | 190 |
1 files changed, 73 insertions, 117 deletions
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c index 4d39aa4469f..f23ceecde16 100644 --- a/usr.bin/mandoc/man_term.c +++ b/usr.bin/mandoc/man_term.c @@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.99 2014/04/08 07:13:01 schwarze Exp $ */ +/* $Id: man_term.c,v 1.100 2014/04/20 16:44:44 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -41,7 +41,7 @@ struct mtermp { int pardist; /* vert. space before par., unit: [v] */ }; -#define DECL_ARGS struct termp *p, \ +#define DECL_ARGS struct termp *p, \ struct mtermp *mt, \ const struct man_node *n, \ const struct man_meta *meta @@ -60,7 +60,7 @@ static void print_man_nodelist(DECL_ARGS); static void print_man_node(DECL_ARGS); static void print_man_head(struct termp *, const void *); static void print_man_foot(struct termp *, const void *); -static void print_bvspace(struct termp *, +static void print_bvspace(struct termp *, const struct man_node *, int); static int pre_B(DECL_ARGS); @@ -101,7 +101,7 @@ static const struct termact termacts[MAN_MAX] = { { pre_PP, NULL, 0 }, /* PP */ { pre_PP, NULL, 0 }, /* P */ { pre_IP, post_IP, 0 }, /* IP */ - { pre_HP, post_HP, 0 }, /* HP */ + { pre_HP, post_HP, 0 }, /* HP */ { NULL, NULL, 0 }, /* SM */ { pre_B, NULL, 0 }, /* SB */ { pre_alternate, NULL, 0 }, /* BI */ @@ -134,7 +134,6 @@ static const struct termact termacts[MAN_MAX] = { }; - void terminal_man(void *arg, const struct man *man) { @@ -185,7 +184,6 @@ a2height(const struct termp *p, const char *cp) return(term_vspan(p, &su)); } - static int a2width(const struct termp *p, const char *cp) { @@ -224,7 +222,7 @@ print_bvspace(struct termp *p, const struct man_node *n, int pardist) term_vspace(p); } -/* ARGSUSED */ + static int pre_ign(DECL_ARGS) { @@ -232,8 +230,6 @@ pre_ign(DECL_ARGS) return(0); } - -/* ARGSUSED */ static int pre_ll(DECL_ARGS) { @@ -242,8 +238,6 @@ pre_ll(DECL_ARGS) return(0); } - -/* ARGSUSED */ static int pre_I(DECL_ARGS) { @@ -252,8 +246,6 @@ pre_I(DECL_ARGS) return(1); } - -/* ARGSUSED */ static int pre_literal(DECL_ARGS) { @@ -281,7 +273,6 @@ pre_literal(DECL_ARGS) return(0); } -/* ARGSUSED */ static int pre_PD(DECL_ARGS) { @@ -296,7 +287,6 @@ pre_PD(DECL_ARGS) return(0); } -/* ARGSUSED */ static int pre_alternate(DECL_ARGS) { @@ -305,27 +295,27 @@ pre_alternate(DECL_ARGS) int savelit, i; switch (n->tok) { - case (MAN_RB): + case MAN_RB: font[0] = TERMFONT_NONE; font[1] = TERMFONT_BOLD; break; - case (MAN_RI): + case MAN_RI: font[0] = TERMFONT_NONE; font[1] = TERMFONT_UNDER; break; - case (MAN_BR): + case MAN_BR: font[0] = TERMFONT_BOLD; font[1] = TERMFONT_NONE; break; - case (MAN_BI): + case MAN_BI: font[0] = TERMFONT_BOLD; font[1] = TERMFONT_UNDER; break; - case (MAN_IR): + case MAN_IR: font[0] = TERMFONT_UNDER; font[1] = TERMFONT_NONE; break; - case (MAN_IB): + case MAN_IB: font[0] = TERMFONT_UNDER; font[1] = TERMFONT_BOLD; break; @@ -348,7 +338,6 @@ pre_alternate(DECL_ARGS) return(0); } -/* ARGSUSED */ static int pre_B(DECL_ARGS) { @@ -357,7 +346,6 @@ pre_B(DECL_ARGS) return(1); } -/* ARGSUSED */ static int pre_OP(DECL_ARGS) { @@ -380,7 +368,6 @@ pre_OP(DECL_ARGS) return(0); } -/* ARGSUSED */ static int pre_ft(DECL_ARGS) { @@ -393,26 +380,26 @@ pre_ft(DECL_ARGS) cp = n->child->string; switch (*cp) { - case ('4'): + case '4': /* FALLTHROUGH */ - case ('3'): + case '3': /* FALLTHROUGH */ - case ('B'): + case 'B': term_fontrepl(p, TERMFONT_BOLD); break; - case ('2'): + case '2': /* FALLTHROUGH */ - case ('I'): + case 'I': term_fontrepl(p, TERMFONT_UNDER); break; - case ('P'): + case 'P': term_fontlast(p); break; - case ('1'): + case '1': /* FALLTHROUGH */ - case ('C'): + case 'C': /* FALLTHROUGH */ - case ('R'): + case 'R': term_fontrepl(p, TERMFONT_NONE); break; default: @@ -421,7 +408,6 @@ pre_ft(DECL_ARGS) return(0); } -/* ARGSUSED */ static int pre_in(DECL_ARGS) { @@ -455,7 +441,7 @@ pre_in(DECL_ARGS) p->offset -= p->offset > v ? v : p->offset; else if (less > 0) p->offset += v; - else + else p->offset = v; /* Don't let this creep beyond the right margin. */ @@ -466,8 +452,6 @@ pre_in(DECL_ARGS) return(0); } - -/* ARGSUSED */ static int pre_sp(DECL_ARGS) { @@ -477,15 +461,15 @@ pre_sp(DECL_ARGS) if ((NULL == n->prev && n->parent)) { switch (n->parent->tok) { - case (MAN_SH): + case MAN_SH: /* FALLTHROUGH */ - case (MAN_SS): + case MAN_SS: /* FALLTHROUGH */ - case (MAN_PP): + case MAN_PP: /* FALLTHROUGH */ - case (MAN_LP): + case MAN_LP: /* FALLTHROUGH */ - case (MAN_P): + case MAN_P: /* FALLTHROUGH */ return(0); default: @@ -495,7 +479,7 @@ pre_sp(DECL_ARGS) neg = 0; switch (n->tok) { - case (MAN_br): + case MAN_br: len = 0; break; default: @@ -523,8 +507,6 @@ pre_sp(DECL_ARGS) return(0); } - -/* ARGSUSED */ static int pre_HP(DECL_ARGS) { @@ -533,10 +515,10 @@ pre_HP(DECL_ARGS) const struct man_node *nn; switch (n->type) { - case (MAN_BLOCK): + case MAN_BLOCK: print_bvspace(p, n, mt->pardist); return(1); - case (MAN_BODY): + case MAN_BODY: break; default: return(0); @@ -569,14 +551,12 @@ pre_HP(DECL_ARGS) return(1); } - -/* ARGSUSED */ static void post_HP(DECL_ARGS) { switch (n->type) { - case (MAN_BODY): + case MAN_BODY: term_newln(p); p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); p->trailspace = 0; @@ -588,14 +568,12 @@ post_HP(DECL_ARGS) } } - -/* ARGSUSED */ static int pre_PP(DECL_ARGS) { switch (n->type) { - case (MAN_BLOCK): + case MAN_BLOCK: mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); print_bvspace(p, n, mt->pardist); break; @@ -607,8 +585,6 @@ pre_PP(DECL_ARGS) return(MAN_HEAD != n->type); } - -/* ARGSUSED */ static int pre_IP(DECL_ARGS) { @@ -617,14 +593,14 @@ pre_IP(DECL_ARGS) int savelit, ival; switch (n->type) { - case (MAN_BODY): + case MAN_BODY: p->flags |= TERMP_NOSPACE; break; - case (MAN_HEAD): + case MAN_HEAD: p->flags |= TERMP_NOBREAK; p->trailspace = 1; break; - case (MAN_BLOCK): + case MAN_BLOCK: print_bvspace(p, n, mt->pardist); /* FALLTHROUGH */ default: @@ -641,7 +617,7 @@ pre_IP(DECL_ARGS) len = (size_t)ival; switch (n->type) { - case (MAN_HEAD): + case MAN_HEAD: /* Handle zero-width lengths. */ if (0 == len) len = term_len(p, 1); @@ -664,10 +640,10 @@ pre_IP(DECL_ARGS) mt->fl |= MANT_LITERAL; return(0); - case (MAN_BODY): + case MAN_BODY: p->offset = mt->offset + len; p->rmargin = p->maxrmargin > p->offset ? - p->maxrmargin : p->offset; + p->maxrmargin : p->offset; break; default: break; @@ -676,20 +652,18 @@ pre_IP(DECL_ARGS) return(1); } - -/* ARGSUSED */ static void post_IP(DECL_ARGS) { switch (n->type) { - case (MAN_HEAD): + case MAN_HEAD: term_flushln(p); p->flags &= ~TERMP_NOBREAK; p->trailspace = 0; p->rmargin = p->maxrmargin; break; - case (MAN_BODY): + case MAN_BODY: term_newln(p); p->offset = mt->offset; break; @@ -698,8 +672,6 @@ post_IP(DECL_ARGS) } } - -/* ARGSUSED */ static int pre_TP(DECL_ARGS) { @@ -708,14 +680,14 @@ pre_TP(DECL_ARGS) int savelit, ival; switch (n->type) { - case (MAN_HEAD): + case MAN_HEAD: p->flags |= TERMP_NOBREAK; p->trailspace = 1; break; - case (MAN_BODY): + case MAN_BODY: p->flags |= TERMP_NOSPACE; break; - case (MAN_BLOCK): + case MAN_BLOCK: print_bvspace(p, n, mt->pardist); /* FALLTHROUGH */ default: @@ -733,7 +705,7 @@ pre_TP(DECL_ARGS) len = (size_t)ival; switch (n->type) { - case (MAN_HEAD): + case MAN_HEAD: /* Handle zero-length properly. */ if (0 == len) len = term_len(p, 1); @@ -760,10 +732,10 @@ pre_TP(DECL_ARGS) mt->lmargin[mt->lmargincur] = (size_t)ival; return(0); - case (MAN_BODY): + case MAN_BODY: p->offset = mt->offset + len; p->rmargin = p->maxrmargin > p->offset ? - p->maxrmargin : p->offset; + p->maxrmargin : p->offset; p->trailspace = 0; p->flags &= ~TERMP_NOBREAK; break; @@ -774,17 +746,15 @@ pre_TP(DECL_ARGS) return(1); } - -/* ARGSUSED */ static void post_TP(DECL_ARGS) { switch (n->type) { - case (MAN_HEAD): + case MAN_HEAD: term_flushln(p); break; - case (MAN_BODY): + case MAN_BODY: term_newln(p); p->offset = mt->offset; break; @@ -793,15 +763,13 @@ post_TP(DECL_ARGS) } } - -/* ARGSUSED */ static int pre_SS(DECL_ARGS) { int i; switch (n->type) { - case (MAN_BLOCK): + case MAN_BLOCK: mt->fl &= ~MANT_LITERAL; mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); mt->offset = term_len(p, p->defindent); @@ -814,11 +782,11 @@ pre_SS(DECL_ARGS) for (i = 0; i < mt->pardist; i++) term_vspace(p); break; - case (MAN_HEAD): + case MAN_HEAD: term_fontrepl(p, TERMFONT_BOLD); p->offset = term_len(p, 3); break; - case (MAN_BODY): + case MAN_BODY: p->offset = mt->offset; break; default: @@ -828,17 +796,15 @@ pre_SS(DECL_ARGS) return(1); } - -/* ARGSUSED */ static void post_SS(DECL_ARGS) { - + switch (n->type) { - case (MAN_HEAD): + case MAN_HEAD: term_newln(p); break; - case (MAN_BODY): + case MAN_BODY: term_newln(p); break; default: @@ -846,15 +812,13 @@ post_SS(DECL_ARGS) } } - -/* ARGSUSED */ static int pre_SH(DECL_ARGS) { int i; switch (n->type) { - case (MAN_BLOCK): + case MAN_BLOCK: mt->fl &= ~MANT_LITERAL; mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); mt->offset = term_len(p, p->defindent); @@ -868,11 +832,11 @@ pre_SH(DECL_ARGS) for (i = 0; i < mt->pardist; i++) term_vspace(p); break; - case (MAN_HEAD): + case MAN_HEAD: term_fontrepl(p, TERMFONT_BOLD); p->offset = 0; break; - case (MAN_BODY): + case MAN_BODY: p->offset = mt->offset; break; default: @@ -882,17 +846,15 @@ pre_SH(DECL_ARGS) return(1); } - -/* ARGSUSED */ static void post_SH(DECL_ARGS) { - + switch (n->type) { - case (MAN_HEAD): + case MAN_HEAD: term_newln(p); break; - case (MAN_BODY): + case MAN_BODY: term_newln(p); break; default: @@ -900,7 +862,6 @@ post_SH(DECL_ARGS) } } -/* ARGSUSED */ static int pre_RS(DECL_ARGS) { @@ -908,10 +869,10 @@ pre_RS(DECL_ARGS) size_t sz; switch (n->type) { - case (MAN_BLOCK): + case MAN_BLOCK: term_newln(p); return(1); - case (MAN_HEAD): + case MAN_HEAD: return(0); default: break; @@ -920,13 +881,13 @@ pre_RS(DECL_ARGS) sz = term_len(p, p->defindent); if (NULL != (n = n->parent->head->child)) - if ((ival = a2width(p, n->string)) >= 0) + if ((ival = a2width(p, n->string)) >= 0) sz = (size_t)ival; mt->offset += sz; p->offset = mt->offset; p->rmargin = p->maxrmargin > p->offset ? - p->maxrmargin : p->offset; + p->maxrmargin : p->offset; if (++mt->lmarginsz < MAXMARGINS) mt->lmargincur = mt->lmarginsz; @@ -935,7 +896,6 @@ pre_RS(DECL_ARGS) return(1); } -/* ARGSUSED */ static void post_RS(DECL_ARGS) { @@ -943,9 +903,9 @@ post_RS(DECL_ARGS) size_t sz; switch (n->type) { - case (MAN_BLOCK): + case MAN_BLOCK: return; - case (MAN_HEAD): + case MAN_HEAD: return; default: term_newln(p); @@ -954,8 +914,8 @@ post_RS(DECL_ARGS) sz = term_len(p, p->defindent); - if (NULL != (n = n->parent->head->child)) - if ((ival = a2width(p, n->string)) >= 0) + if (NULL != (n = n->parent->head->child)) + if ((ival = a2width(p, n->string)) >= 0) sz = (size_t)ival; mt->offset = mt->offset < sz ? 0 : mt->offset - sz; @@ -965,7 +925,6 @@ post_RS(DECL_ARGS) mt->lmargincur = mt->lmarginsz; } -/* ARGSUSED */ static int pre_UR(DECL_ARGS) { @@ -973,7 +932,6 @@ pre_UR(DECL_ARGS) return (MAN_HEAD != n->type); } -/* ARGSUSED */ static void post_UR(DECL_ARGS) { @@ -998,7 +956,7 @@ print_man_node(DECL_ARGS) int c; switch (n->type) { - case(MAN_TEXT): + case MAN_TEXT: /* * If we have a blank line, output a vertical space. * If we have a space as the first character, break @@ -1013,15 +971,15 @@ print_man_node(DECL_ARGS) term_word(p, n->string); goto out; - case (MAN_EQN): + case MAN_EQN: term_eqn(p, n->eqn); return; - case (MAN_TBL): + case MAN_TBL: /* * Tables are preceded by a newline. Then process a * table line, which will cause line termination, */ - if (TBL_SPAN_FIRST & n->span->flags) + if (TBL_SPAN_FIRST & n->span->flags) term_newln(p); term_tbl(p, n->span); return; @@ -1084,7 +1042,6 @@ print_man_nodelist(DECL_ARGS) print_man_nodelist(p, mt, n->next, meta); } - static void print_man_foot(struct termp *p, const void *arg) { @@ -1152,7 +1109,6 @@ print_man_foot(struct termp *p, const void *arg) term_flushln(p); } - static void print_man_head(struct termp *p, const void *arg) { @@ -1179,7 +1135,7 @@ print_man_head(struct termp *p, const void *arg) p->trailspace = 1; p->offset = 0; p->rmargin = 2 * (titlen+1) + buflen < p->maxrmargin ? - (p->maxrmargin - + (p->maxrmargin - term_strlen(p, buf) + term_len(p, 1)) / 2 : p->maxrmargin - buflen; @@ -1212,7 +1168,7 @@ print_man_head(struct termp *p, const void *arg) p->offset = 0; p->rmargin = p->maxrmargin; - /* + /* * Groff prints three blank lines before the content. * Do the same, except in the temporary, undocumented * mode imitating mdoc(7) output. |