version 1.6, 2009/04/12 19:49:35 |
version 1.10, 2009/06/16 19:45:51 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org> |
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
|
|
|
|
enum mwarn { |
enum mwarn { |
WPRINT, |
WPRINT, |
|
WNOWIDTH, |
|
WMISSWIDTH, |
WESCAPE, |
WESCAPE, |
|
WDEPCOL, |
WWRONGMSEC, |
WWRONGMSEC, |
WSECOOO, |
WSECOOO, |
WSECREP, |
WSECREP, |
Line 188 static v_post posts_bf[] = { hwarn_le1, post_bf, NULL |
|
Line 191 static v_post posts_bf[] = { hwarn_le1, post_bf, NULL |
|
static v_post posts_fo[] = { hwarn_eq1, bwarn_ge1, NULL }; |
static v_post posts_fo[] = { hwarn_eq1, bwarn_ge1, NULL }; |
|
|
const struct valids mdoc_valids[MDOC_MAX] = { |
const struct valids mdoc_valids[MDOC_MAX] = { |
{ NULL, NULL }, /* \" */ |
{ NULL, NULL }, /* Ap */ |
{ pres_dd, posts_text }, /* Dd */ |
{ pres_dd, posts_text }, /* Dd */ |
{ pres_dt, NULL }, /* Dt */ |
{ pres_dt, NULL }, /* Dt */ |
{ pres_os, NULL }, /* Os */ |
{ pres_os, NULL }, /* Os */ |
Line 295 const struct valids mdoc_valids[MDOC_MAX] = { |
|
Line 298 const struct valids mdoc_valids[MDOC_MAX] = { |
|
{ NULL, NULL }, /* Fr */ |
{ NULL, NULL }, /* Fr */ |
{ NULL, posts_notext }, /* Ud */ |
{ NULL, posts_notext }, /* Ud */ |
{ pres_lb, posts_lb }, /* Lb */ |
{ pres_lb, posts_lb }, /* Lb */ |
{ NULL, NULL }, /* Ap */ |
|
{ NULL, posts_pp }, /* Lp */ |
{ NULL, posts_pp }, /* Lp */ |
{ NULL, posts_text }, /* Lk */ |
{ NULL, NULL }, /* Lk */ |
{ NULL, posts_text }, /* Mt */ |
{ NULL, posts_text }, /* Mt */ |
{ NULL, posts_wline }, /* Brq */ |
{ NULL, posts_wline }, /* Brq */ |
{ NULL, NULL }, /* Bro */ |
{ NULL, NULL }, /* Bro */ |
Line 460 pwarn(struct mdoc *m, int line, int pos, enum mwarn ty |
|
Line 462 pwarn(struct mdoc *m, int line, int pos, enum mwarn ty |
|
p = "prologue macros out-of-order"; |
p = "prologue macros out-of-order"; |
c = WARN_COMPAT; |
c = WARN_COMPAT; |
break; |
break; |
|
case (WDEPCOL): |
|
p = "deprecated column argument syntax"; |
|
c = WARN_COMPAT; |
|
break; |
|
case (WNOWIDTH): |
|
p = "superfluous width argument"; |
|
break; |
|
case (WMISSWIDTH): |
|
p = "missing width argument"; |
|
break; |
case (WPRINT): |
case (WPRINT): |
p = "invalid character"; |
p = "invalid character"; |
break; |
break; |
Line 776 pre_display(PRE_ARGS) |
|
Line 788 pre_display(PRE_ARGS) |
|
static int |
static int |
pre_bl(PRE_ARGS) |
pre_bl(PRE_ARGS) |
{ |
{ |
int i, type, width, offset; |
int pos, col, type, width, offset; |
|
|
if (MDOC_BLOCK != n->type) |
if (MDOC_BLOCK != n->type) |
return(1); |
return(1); |
Line 785 pre_bl(PRE_ARGS) |
|
Line 797 pre_bl(PRE_ARGS) |
|
|
|
/* Make sure that only one type of list is specified. */ |
/* Make sure that only one type of list is specified. */ |
|
|
type = offset = width = -1; |
type = offset = width = col = -1; |
|
|
/* LINTED */ |
/* LINTED */ |
for (i = 0; i < (int)n->args->argc; i++) |
for (pos = 0; pos < (int)n->args->argc; pos++) |
switch (n->args->argv[i].arg) { |
switch (n->args->argv[pos].arg) { |
case (MDOC_Bullet): |
case (MDOC_Bullet): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Dash): |
case (MDOC_Dash): |
Line 811 pre_bl(PRE_ARGS) |
|
Line 823 pre_bl(PRE_ARGS) |
|
case (MDOC_Inset): |
case (MDOC_Inset): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Column): |
case (MDOC_Column): |
if (-1 == type) { |
if (-1 != type) |
type = n->args->argv[i].arg; |
return(nerr(mdoc, n, EMULTILIST)); |
break; |
type = n->args->argv[pos].arg; |
} |
col = pos; |
return(nerr(mdoc, n, EMULTILIST)); |
break; |
case (MDOC_Width): |
case (MDOC_Width): |
if (-1 == width) { |
if (-1 != width) |
width = n->args->argv[i].arg; |
return(nerr(mdoc, n, EARGREP)); |
break; |
width = n->args->argv[pos].arg; |
} |
break; |
return(nerr(mdoc, n, EARGREP)); |
|
case (MDOC_Offset): |
case (MDOC_Offset): |
if (-1 == offset) { |
if (-1 != offset) |
offset = n->args->argv[i].arg; |
return(nerr(mdoc, n, EARGREP)); |
break; |
offset = n->args->argv[pos].arg; |
} |
break; |
return(nerr(mdoc, n, EARGREP)); |
|
default: |
default: |
break; |
break; |
} |
} |
Line 835 pre_bl(PRE_ARGS) |
|
Line 845 pre_bl(PRE_ARGS) |
|
if (-1 == type) |
if (-1 == type) |
return(nerr(mdoc, n, ELISTTYPE)); |
return(nerr(mdoc, n, ELISTTYPE)); |
|
|
|
/* |
|
* Validate the width field. Some list types don't need width |
|
* types and should be warned about them. Others should have it |
|
* and must also be warned. |
|
*/ |
|
|
switch (type) { |
switch (type) { |
|
case (MDOC_Tag): |
|
if (-1 == width && ! nwarn(mdoc, n, WMISSWIDTH)) |
|
return(0); |
|
break; |
case (MDOC_Column): |
case (MDOC_Column): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Diag): |
case (MDOC_Diag): |
Line 843 pre_bl(PRE_ARGS) |
|
Line 863 pre_bl(PRE_ARGS) |
|
case (MDOC_Inset): |
case (MDOC_Inset): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Item): |
case (MDOC_Item): |
if (-1 == width) |
if (-1 != width && ! nwarn(mdoc, n, WNOWIDTH)) |
|
return(0); |
|
break; |
|
default: |
|
break; |
|
} |
|
|
|
/* |
|
* General validation of fields. |
|
*/ |
|
|
|
switch (type) { |
|
case (MDOC_Column): |
|
assert(col >= 0); |
|
if (0 == n->args->argv[col].sz) |
break; |
break; |
return(mdoc_nwarn(mdoc, n, WARN_SYNTAX, |
if ( ! nwarn(mdoc, n, WDEPCOL)) |
"superfluous %s argument", |
return(0); |
mdoc_argnames[MDOC_Width])); |
break; |
case (MDOC_Tag): |
|
if (-1 != width) |
|
break; |
|
return(mdoc_nwarn(mdoc, n, WARN_SYNTAX, |
|
"suggest %s argument", |
|
mdoc_argnames[MDOC_Width])); |
|
default: |
default: |
break; |
break; |
} |
} |