version 1.15, 2009/06/17 14:10:09 |
version 1.19, 2009/07/04 10:41:29 |
|
|
#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, |
Line 99 static int err_child_gt(struct mdoc *, const char *, i |
|
Line 98 static int err_child_gt(struct mdoc *, const char *, i |
|
static int warn_child_gt(struct mdoc *, const char *, int); |
static int warn_child_gt(struct mdoc *, const char *, int); |
static int err_child_eq(struct mdoc *, const char *, int); |
static int err_child_eq(struct mdoc *, const char *, int); |
static int warn_child_eq(struct mdoc *, const char *, int); |
static int warn_child_eq(struct mdoc *, const char *, int); |
static int count_child(struct mdoc *); |
|
static int warn_print(struct mdoc *, int, int); |
static int warn_print(struct mdoc *, int, int); |
static int warn_count(struct mdoc *, const char *, |
static int warn_count(struct mdoc *, const char *, |
int, const char *, int); |
int, const char *, int); |
Line 471 pwarn(struct mdoc *m, int line, int pos, enum mwarn ty |
|
Line 469 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): |
case (WNOWIDTH): |
p = "superfluous width argument"; |
p = "superfluous width argument"; |
break; |
break; |
Line 487 pwarn(struct mdoc *m, int line, int pos, enum mwarn ty |
|
Line 481 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 553 err_count(struct mdoc *m, const char *k, |
|
Line 544 err_count(struct mdoc *m, const char *k, |
|
} |
} |
|
|
|
|
static inline int |
|
count_child(struct mdoc *mdoc) |
|
{ |
|
int i; |
|
struct mdoc_node *n; |
|
|
|
for (i = 0, n = mdoc->last->child; n; n = n->next, i++) |
|
/* Do nothing */ ; |
|
|
|
return(i); |
|
} |
|
|
|
|
|
/* |
/* |
* Build these up with macros because they're basically the same check |
* Build these up with macros because they're basically the same check |
* for different inequalities. Yes, this could be done with functions, |
* for different inequalities. Yes, this could be done with functions, |
Line 576 count_child(struct mdoc *mdoc) |
|
Line 554 count_child(struct mdoc *mdoc) |
|
static int \ |
static int \ |
lvl##_child_##name(struct mdoc *mdoc, const char *p, int sz) \ |
lvl##_child_##name(struct mdoc *mdoc, const char *p, int sz) \ |
{ \ |
{ \ |
int i; \ |
if (mdoc->last->nchild ineq sz) \ |
if ((i = count_child(mdoc)) ineq sz) \ |
|
return(1); \ |
return(1); \ |
return(lvl##_count(mdoc, #ineq, sz, p, i)); \ |
return(lvl##_count(mdoc, #ineq, sz, p, mdoc->last->nchild)); \ |
} |
} |
|
|
#define CHECK_BODY_DEFN(name, lvl, func, num) \ |
#define CHECK_BODY_DEFN(name, lvl, func, num) \ |
Line 727 check_argv(struct mdoc *m, const struct mdoc_node *n, |
|
Line 704 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 741 check_text(struct mdoc *mdoc, int line, int pos, const |
|
Line 718 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)) |