summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--argv.c6
-rw-r--r--macro.c119
-rw-r--r--mdoc.c8
-rw-r--r--mdoc.h3
-rw-r--r--mdocml.c5
-rw-r--r--private.h7
-rw-r--r--validate.c6
7 files changed, 76 insertions, 78 deletions
diff --git a/argv.c b/argv.c
index 8a4c6a9b..3f491883 100644
--- a/argv.c
+++ b/argv.c
@@ -1,4 +1,4 @@
-/* $Id: argv.c,v 1.3 2008/12/30 13:43:53 kristaps Exp $ */
+/* $Id: argv.c,v 1.4 2008/12/30 19:06:03 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 d39a1c67..7c5b1bf2 100644
--- a/macro.c
+++ b/macro.c
@@ -1,4 +1,4 @@
-/* $Id: macro.c,v 1.14 2008/12/30 18:15:26 kristaps Exp $ */
+/* $Id: macro.c,v 1.15 2008/12/30 19:06:03 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 3043e293..1914e12e 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.11 2008/12/30 13:43:53 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.12 2008/12/30 19:06:03 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 418441ed..38980a0a 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.9 2008/12/29 19:25:29 kristaps Exp $ */
+/* $Id: mdoc.h,v 1.10 2008/12/30 19:06:03 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 80875e0f..8a896bba 100644
--- a/mdocml.c
+++ b/mdocml.c
@@ -1,4 +1,4 @@
-/* $Id: mdocml.c,v 1.29 2008/12/29 19:25:29 kristaps Exp $ */
+/* $Id: mdocml.c,v 1.30 2008/12/30 19:06:03 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 d6b26cc1..a172c970 100644
--- a/private.h
+++ b/private.h
@@ -1,4 +1,4 @@
-/* $Id: private.h,v 1.50 2008/12/30 18:15:26 kristaps Exp $ */
+/* $Id: private.h,v 1.51 2008/12/30 19:06:03 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 7b724633..d379a8b7 100644
--- a/validate.c
+++ b/validate.c
@@ -1,4 +1,4 @@
-/* $Id: validate.c,v 1.9 2008/12/30 18:15:26 kristaps Exp $ */
+/* $Id: validate.c,v 1.10 2008/12/30 19:06:03 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 */