version 1.16, 2009/06/18 20:46:19 |
version 1.20, 2009/07/06 09:21:24 |
|
|
#include <string.h> |
#include <string.h> |
|
|
#include "libmdoc.h" |
#include "libmdoc.h" |
|
#include "libmandoc.h" |
|
|
/* FIXME: .Bl -diag can't have non-text children in HEAD. */ |
/* FIXME: .Bl -diag can't have non-text children in HEAD. */ |
/* TODO: ignoring Pp (it's superfluous in some invocations). */ |
/* TODO: ignoring Pp (it's superfluous in some invocations). */ |
|
|
WNOWIDTH, |
WNOWIDTH, |
WMISSWIDTH, |
WMISSWIDTH, |
WESCAPE, |
WESCAPE, |
WDEPESC, |
|
WDEPCOL, |
|
WWRONGMSEC, |
WWRONGMSEC, |
WSECOOO, |
WSECOOO, |
WSECREP, |
WSECREP, |
|
|
pwarn(struct mdoc *m, int line, int pos, enum mwarn type) |
pwarn(struct mdoc *m, int line, int pos, enum mwarn type) |
{ |
{ |
char *p; |
char *p; |
enum mdoc_warn c; |
|
|
|
c = WARN_SYNTAX; |
|
p = NULL; |
p = NULL; |
|
|
switch (type) { |
switch (type) { |
case (WBADMSEC): |
case (WBADMSEC): |
p = "inappropriate manual section"; |
p = "inappropriate manual section"; |
c = WARN_COMPAT; |
|
break; |
break; |
case (WBADSEC): |
case (WBADSEC): |
p = "inappropriate document section"; |
p = "inappropriate document section"; |
c = WARN_COMPAT; |
|
break; |
break; |
case (WARGVAL): |
case (WARGVAL): |
p = "argument value suggested"; |
p = "argument value suggested"; |
c = WARN_COMPAT; |
|
break; |
break; |
case (WPROLREP): |
case (WPROLREP): |
p = "prologue macros repeated"; |
p = "prologue macros repeated"; |
c = WARN_COMPAT; |
|
break; |
break; |
case (WPROLOOO): |
case (WPROLOOO): |
p = "prologue macros out-of-order"; |
p = "prologue macros out-of-order"; |
c = WARN_COMPAT; |
|
break; |
break; |
case (WDEPCOL): |
|
p = "deprecated column argument syntax"; |
|
c = WARN_COMPAT; |
|
break; |
|
case (WNOWIDTH): |
case (WNOWIDTH): |
p = "superfluous width argument"; |
p = "superfluous width argument"; |
break; |
break; |
Line 486 pwarn(struct mdoc *m, int line, int pos, enum mwarn ty |
|
Line 475 pwarn(struct mdoc *m, int line, int pos, enum mwarn ty |
|
case (WESCAPE): |
case (WESCAPE): |
p = "invalid escape sequence"; |
p = "invalid escape sequence"; |
break; |
break; |
case (WDEPESC): |
|
p = "deprecated special-character escape"; |
|
break; |
|
case (WNOLINE): |
case (WNOLINE): |
p = "suggested no line arguments"; |
p = "suggested no line arguments"; |
break; |
break; |
Line 503 pwarn(struct mdoc *m, int line, int pos, enum mwarn ty |
|
Line 489 pwarn(struct mdoc *m, int line, int pos, enum mwarn ty |
|
break; |
break; |
case (WWRONGMSEC): |
case (WWRONGMSEC): |
p = "document section in wrong manual section"; |
p = "document section in wrong manual section"; |
c = WARN_COMPAT; |
|
break; |
break; |
case (WSECOOO): |
case (WSECOOO): |
p = "document section out of conventional order"; |
p = "document section out of conventional order"; |
Line 518 pwarn(struct mdoc *m, int line, int pos, enum mwarn ty |
|
Line 503 pwarn(struct mdoc *m, int line, int pos, enum mwarn ty |
|
p = "NAME section contents incomplete/badly-ordered"; |
p = "NAME section contents incomplete/badly-ordered"; |
break; |
break; |
} |
} |
|
|
assert(p); |
assert(p); |
return(mdoc_pwarn(m, line, pos, c, p)); |
return(mdoc_pwarn(m, line, pos, p)); |
} |
} |
|
|
|
|
Line 537 warn_count(struct mdoc *m, const char *k, |
|
Line 523 warn_count(struct mdoc *m, const char *k, |
|
int want, const char *v, int has) |
int want, const char *v, int has) |
{ |
{ |
|
|
return(mdoc_warn(m, WARN_SYNTAX, |
return(mdoc_warn(m, "suggests %s %s %d (has %d)", |
"suggests %s %s %d (has %d)", v, k, want, has)); |
v, k, want, has)); |
} |
} |
|
|
|
|
Line 712 check_argv(struct mdoc *m, const struct mdoc_node *n, |
|
Line 698 check_argv(struct mdoc *m, const struct mdoc_node *n, |
|
static int |
static int |
check_text(struct mdoc *mdoc, int line, int pos, const char *p) |
check_text(struct mdoc *mdoc, int line, int pos, const char *p) |
{ |
{ |
size_t c; |
int c; |
|
|
for ( ; *p; p++) { |
for ( ; *p; p++, pos++) { |
if ('\t' == *p) { |
if ('\t' == *p) { |
if ( ! (MDOC_LITERAL & mdoc->flags)) |
if ( ! (MDOC_LITERAL & mdoc->flags)) |
if ( ! warn_print(mdoc, line, pos)) |
if ( ! warn_print(mdoc, line, pos)) |
Line 726 check_text(struct mdoc *mdoc, int line, int pos, const |
|
Line 712 check_text(struct mdoc *mdoc, int line, int pos, const |
|
if ('\\' != *p) |
if ('\\' != *p) |
continue; |
continue; |
|
|
c = mdoc_isescape(p); |
c = mandoc_special(p); |
if (c) { |
if (c) { |
/* See if form is deprecated. */ |
p += c - 1; |
if ('*' == p[1]) |
pos += c - 1; |
if ( ! pwarn(mdoc, line, pos, WDEPESC)) |
|
return(0); |
|
p += (int)c - 1; |
|
continue; |
continue; |
} |
} |
if ( ! (MDOC_IGN_ESCAPE & mdoc->pflags)) |
if ( ! (MDOC_IGN_ESCAPE & mdoc->pflags)) |