summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2008-12-30 19:06:03 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2008-12-30 19:06:03 +0000
commit322cc23a55808335259ba133ec8d4067bf9a122f (patch)
tree647fc8991a040d3af906f278b6fe468156eb1250
parentc81a972eaeca9fe0e1dab0f88895af7623d58288 (diff)
downloadmandoc-322cc23a55808335259ba133ec8d4067bf9a122f.tar.gz
*** empty log message ***
-rw-r--r--argv.c4
-rw-r--r--macro.c117
-rw-r--r--mdoc.c6
-rw-r--r--mdoc.h1
-rw-r--r--mdocml.c3
-rw-r--r--private.h5
-rw-r--r--validate.c4
7 files changed, 69 insertions, 71 deletions
diff --git a/argv.c b/argv.c
index 87631712..5a34ff1b 100644
--- a/argv.c
+++ b/argv.c
@@ -98,10 +98,8 @@ mdoc_args(struct mdoc *mdoc, int tok, int *pos, char *buf, int fl, char **v)
/*
* If we're a quoted string (and quoted strings are allowed),
* then parse ahead to the next quote. If none's found, it's an
- * error. After, parse to the next word. We're not allowed to
- * also be DELIM requests (for now).
+ * error. After, parse to the next word.
*/
- assert( ! (fl & ARGS_DELIM));
*v = &buf[++(*pos)];
diff --git a/macro.c b/macro.c
index 87940c82..7cc44c46 100644
--- a/macro.c
+++ b/macro.c
@@ -29,6 +29,7 @@
/* FIXME: maxlineargs should be per LINE, no per TOKEN. */
/* FIXME: prologue check should be in macro_call. */
+/* FIXME: prologue macros should be part of macro_constant. */
#define _CC(p) ((const char **)p)
@@ -45,33 +46,6 @@ static int append_delims(struct mdoc *, int, int *, char *);
static int
-append_delims(struct mdoc *mdoc, int tok, int *pos, char *buf)
-{
- int c, lastarg;
- char *p;
-
- if (0 == buf[*pos])
- return(1);
-
- mdoc_msg(mdoc, *pos, "`%s' flushing punctuation",
- mdoc_macronames[tok]);
-
- for (;;) {
- lastarg = *pos;
- c = mdoc_args(mdoc, tok, pos, buf, 0, &p);
- if (ARGS_ERROR == c)
- return(0);
- else if (ARGS_EOLN == c)
- break;
- assert(mdoc_isdelim(p));
- mdoc_word_alloc(mdoc, lastarg, p);
- }
-
- return(1);
-}
-
-
-static int
scope_rewind_imp(struct mdoc *mdoc, int ppos, int tok)
{
struct mdoc_node *n;
@@ -90,15 +64,8 @@ scope_rewind_imp(struct mdoc *mdoc, int ppos, int tok)
return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_BREAK));
}
- if (n) {
+ if (n)
mdoc->last = n;
- mdoc_msg(mdoc, ppos, "scope: rewound implicit `%s'",
- mdoc_macronames[tok]);
- return(1);
- }
-
- mdoc_msg(mdoc, ppos, "scope: new implicit `%s'",
- mdoc_macronames[tok]);
return(1);
}
@@ -119,11 +86,31 @@ scope_rewind_exp(struct mdoc *mdoc, int ppos, int tok, int dst)
return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_BREAK));
}
- if (NULL == (mdoc->last = n))
- return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_NOCTX));
+ if ((mdoc->last = n))
+ return(1);
+ return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_NOCTX));
+}
- mdoc_msg(mdoc, ppos, "scope: rewound explicit `%s' to `%s'",
- mdoc_macronames[tok], mdoc_macronames[dst]);
+
+static int
+append_delims(struct mdoc *mdoc, int tok, int *pos, char *buf)
+{
+ int c, lastarg;
+ char *p;
+
+ if (0 == buf[*pos])
+ return(1);
+
+ for (;;) {
+ lastarg = *pos;
+ c = mdoc_args(mdoc, tok, pos, buf, 0, &p);
+ if (ARGS_ERROR == c)
+ return(0);
+ else if (ARGS_EOLN == c)
+ break;
+ assert(mdoc_isdelim(p));
+ mdoc_word_alloc(mdoc, lastarg, p);
+ }
return(1);
}
@@ -134,20 +121,13 @@ append_constarg(struct mdoc *mdoc, int tok, int pos,
int argc, const struct mdoc_arg *argv)
{
- switch (tok) {
- default:
- break;
- }
-
+ if ( ! mdoc_valid(mdoc, tok, pos, 0, NULL, argc, argv))
+ return(0);
mdoc_elem_alloc(mdoc, pos, tok, argc, argv, 0, NULL);
return(1);
}
-/*
- * Append a node with implicit or explicit scoping ONLY. ALL macros
- * with the implicit- or explicit-scope callback must be included here.
- */
static int
append_scoped(struct mdoc *mdoc, int tok, int pos,
int sz, const char *args[],
@@ -188,19 +168,16 @@ append_const(struct mdoc *mdoc, int tok,
case (MDOC_At):
if (0 == sz)
break;
-
- if (ATT_DEFAULT != mdoc_atoatt(args[0])) {
- mdoc_elem_alloc(mdoc, pos, tok, 0,
- NULL, 1, _CC(&args[0]));
- } else {
+ if (ATT_DEFAULT == mdoc_atoatt(args[0])) {
mdoc_elem_alloc(mdoc, pos, tok,
0, NULL, 0, NULL);
mdoc_word_alloc(mdoc, pos, args[0]);
- }
+ } else
+ mdoc_elem_alloc(mdoc, pos, tok, 0,
+ NULL, 1, _CC(&args[0]));
- if (1 == sz)
- return(1);
- mdoc_word_alloc(mdoc, pos, args[1]);
+ if (sz > 1)
+ mdoc_word_alloc(mdoc, pos, args[1]);
return(1);
default:
break;
@@ -226,7 +203,7 @@ append_text(struct mdoc *mdoc, int tok,
int
macro_text(MACRO_PROT_ARGS)
{
- int lastarg, lastpunct, c, j;
+ int lastarg, lastpunct, c, j, fl;
char *args[MDOC_LINEARG_MAX];
if (SEC_PROLOGUE == mdoc->sec_lastn)
@@ -260,6 +237,10 @@ macro_text(MACRO_PROT_ARGS)
j = 0;
lastarg = ppos;
lastpunct = 0;
+ fl = ARGS_DELIM;
+
+ if (MDOC_QUOTABLE & mdoc_macros[tok].flags)
+ fl |= ARGS_QUOTED;
again:
if (j == MDOC_LINEARG_MAX)
@@ -275,7 +256,7 @@ again:
lastarg = *pos;
- switch (mdoc_args(mdoc, tok, pos, buf, ARGS_DELIM, &args[j])) {
+ switch (mdoc_args(mdoc, tok, pos, buf, fl, &args[j])) {
case (ARGS_ERROR):
return(0);
case (ARGS_WORD):
@@ -410,6 +391,8 @@ macro_prologue_os(MACRO_PROT_ARGS)
int lastarg, j;
char *args[MDOC_LINEARG_MAX];
+ /* FIXME: if we use `Os' again... ? */
+
if (SEC_PROLOGUE != mdoc->sec_lastn)
return(mdoc_err(mdoc, tok, ppos, ERR_SEC_NPROLOGUE));
if (0 == mdoc->meta.title[0])
@@ -936,14 +919,16 @@ again:
int
macro_constant(MACRO_PROT_ARGS)
{
- int lastarg, j;
+ int lastarg, j, fl;
char *args[MDOC_LINEARG_MAX];
if (SEC_PROLOGUE == mdoc->sec_lastn)
return(mdoc_err(mdoc, tok, ppos, ERR_SEC_PROLOGUE));
- j = 0;
+ j = fl = 0;
lastarg = ppos;
+ if (MDOC_QUOTABLE & mdoc_macros[tok].flags)
+ fl = ARGS_QUOTED;
again:
if (j == MDOC_LINEARG_MAX)
@@ -951,7 +936,7 @@ again:
lastarg = *pos;
- switch (mdoc_args(mdoc, tok, pos, buf, 0, &args[j])) {
+ switch (mdoc_args(mdoc, tok, pos, buf, fl, &args[j])) {
case (ARGS_ERROR):
return(0);
case (ARGS_WORD):
@@ -1005,3 +990,11 @@ macro_constant_argv(MACRO_PROT_ARGS)
mdoc_argv_free(j, argv);
return(c);
}
+
+
+int
+macro_obsolete(MACRO_PROT_ARGS)
+{
+
+ return(mdoc_warn(mdoc, tok, ppos, WARN_IGN_OBSOLETE));
+}
diff --git a/mdoc.c b/mdoc.c
index 26bb70bd..57f6d49c 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -100,7 +100,7 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
{ macro_text, MDOC_CALLABLE }, /* Ad */
{ NULL, 0 }, /* An */
{ macro_text, MDOC_CALLABLE }, /* Ar */
- { NULL, 0 }, /* Cd */
+ { macro_constant, MDOC_QUOTABLE }, /* Cd */
{ macro_text, MDOC_CALLABLE }, /* Cm */
{ macro_text, MDOC_CALLABLE }, /* Dv */
{ macro_text, MDOC_CALLABLE }, /* Er */
@@ -109,7 +109,7 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
{ macro_text, MDOC_CALLABLE }, /* Fa */
{ NULL, 0 }, /* Fd */
{ macro_text, MDOC_CALLABLE }, /* Fl */
- { NULL, 0 }, /* Fn */
+ { macro_text, MDOC_CALLABLE | MDOC_QUOTABLE }, /* Fn */
{ macro_text, 0 }, /* Ft */
{ macro_text, MDOC_CALLABLE }, /* Ic */
{ NULL, 0 }, /* In */
@@ -187,7 +187,7 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
{ NULL, 0 }, /* Ek */
{ macro_constant, 0 }, /* Bt */
{ macro_constant, 0 }, /* Hf */
- { NULL, 0 }, /* Fr */
+ { macro_obsolete, 0 }, /* Fr */
{ macro_constant, 0 }, /* Ud */
};
diff --git a/mdoc.h b/mdoc.h
index e54c6056..4c27dc22 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -241,6 +241,7 @@ enum mdoc_warn {
WARN_SYNTAX_QUOTED,
WARN_IGN_AFTER_BLK,
WARN_IGN_BEFORE_BLK,
+ WARN_IGN_OBSOLETE,
WARN_SEC_OO,
WARN_ARGS_GE1,
WARN_ARGS_EQ0,
diff --git a/mdocml.c b/mdocml.c
index df8094ca..1b6cd227 100644
--- a/mdocml.c
+++ b/mdocml.c
@@ -500,6 +500,9 @@ msg_warn(void *arg, int tok, int col, enum mdoc_warn type)
case (WARN_IGN_AFTER_BLK):
fmt = "ignore: macro `%s' ignored after block macro";
break;
+ case (WARN_IGN_OBSOLETE):
+ fmt = "ignore: macro `%s' is obsolete";
+ break;
case (WARN_IGN_BEFORE_BLK):
fmt = "ignore: macro before block macro `%s' ignored";
break;
diff --git a/private.h b/private.h
index fcc2d6fa..595f8799 100644
--- a/private.h
+++ b/private.h
@@ -37,7 +37,7 @@ struct mdoc_macro {
int flags;
#define MDOC_CALLABLE (1 << 0)
#define MDOC_EXPLICIT (1 << 1)
-#define MDOC_PPOST (1 << 2) /* Linescope: punctuation post-line. */
+#define MDOC_QUOTABLE (1 << 2)
};
extern const struct mdoc_macro *const mdoc_macros;
@@ -99,6 +99,9 @@ int xstrcmp(const char *, const char *);
void *xcalloc(size_t, size_t);
char *xstrdup(const char *);
+int macro_obsolete(MACRO_PROT_ARGS);
+int macro_constant_quoted(MACRO_PROT_ARGS);
+int macro_constant_obsolete(MACRO_PROT_ARGS);
int macro_constant_argv(MACRO_PROT_ARGS);
int macro_constant(MACRO_PROT_ARGS);
int macro_constant_delimited(MACRO_PROT_ARGS);
diff --git a/validate.c b/validate.c
index a7425854..103b21ad 100644
--- a/validate.c
+++ b/validate.c
@@ -65,7 +65,7 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ need_ge1, NULL }, /* Ad */
{ NULL, NULL }, /* An */
{ NULL, NULL }, /* Ar */
- { NULL, NULL }, /* Cd */
+ { need_ge1, NULL }, /* Cd */
{ NULL, NULL }, /* Cm */
{ need_ge1, NULL }, /* Dv */
{ need_ge1, NULL }, /* Er */
@@ -74,7 +74,7 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ need_ge1, NULL }, /* Fa */
{ NULL, NULL }, /* Fd */
{ NULL, NULL }, /* Fl */
- { NULL, NULL }, /* Fn */
+ { need_ge1, NULL }, /* Fn */
{ want_ge1, NULL }, /* Ft */
{ need_ge1, NULL }, /* Ic */
{ NULL, NULL }, /* In */