summaryrefslogtreecommitdiffstatshomepage
path: root/macro.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-03-06 14:13:47 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-03-06 14:13:47 +0000
commit236dae9fb3183b9c1d8bc6f77614797d65800987 (patch)
tree21d3944488650e4b2b02aa011f1ec70b538620f5 /macro.c
parent898c9b0f76e9e166aa032a9d01aac9500a114b31 (diff)
downloadmandoc-236dae9fb3183b9c1d8bc6f77614797d65800987.tar.gz
mandoc-236dae9fb3183b9c1d8bc6f77614797d65800987.tar.zst
mandoc-236dae9fb3183b9c1d8bc6f77614797d65800987.zip
Strings abstracted into dynamically-created C files.
Added -V option. Deprecated README files.
Diffstat (limited to 'macro.c')
-rw-r--r--macro.c73
1 files changed, 52 insertions, 21 deletions
diff --git a/macro.c b/macro.c
index 1f4642fd..939ac3bd 100644
--- a/macro.c
+++ b/macro.c
@@ -1,4 +1,4 @@
-/* $Id: macro.c,v 1.56 2009/03/05 12:08:53 kristaps Exp $ */
+/* $Id: macro.c,v 1.57 2009/03/06 14:13:47 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -184,6 +184,7 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
{ macro_constant, 0 }, /* Hf */
{ macro_obsolete, 0 }, /* Fr */
{ macro_constant, 0 }, /* Ud */
+ { macro_constant, 0 }, /* Lb */
};
const struct mdoc_macro * const mdoc_macros = __mdoc_macros;
@@ -522,7 +523,9 @@ rewind_subblock(enum mdoc_type type, struct mdoc *mdoc,
break;
else if (rewind_dobreak(tok, n))
continue;
- return(mdoc_perr(mdoc, line, ppos, "scope breaks prior %s", mdoc_node2a(n)));
+ return(mdoc_perr(mdoc, line, ppos,
+ "scope breaks %s", MDOC_ROOT == n->type ?
+ "<root>" : mdoc_macronames[n->tok]));
}
assert(n);
@@ -546,8 +549,8 @@ rewind_expblock(struct mdoc *mdoc, int tok, int line, int ppos)
else if (rewind_dobreak(tok, n))
continue;
return(mdoc_perr(mdoc, line, ppos,
- "scope breaks prior %s",
- mdoc_node2a(n)));
+ "scope breaks %s", MDOC_ROOT == n->type ?
+ "<root>" : mdoc_macronames[n->tok]));
}
assert(n);
@@ -571,8 +574,8 @@ rewind_impblock(struct mdoc *mdoc, int tok, int line, int ppos)
else if (rewind_dobreak(tok, n))
continue;
return(mdoc_perr(mdoc, line, ppos,
- "scope breaks prior %s",
- mdoc_node2a(n)));
+ "scope breaks %s", MDOC_ROOT == n->type ?
+ "<root>" : mdoc_macronames[n->tok]));
}
assert(n);
@@ -1183,21 +1186,25 @@ static int
macro_constant_delimited(MACRO_PROT_ARGS)
{
int lastarg, flushed, j, c, maxargs, argc,
- igndelim;
+ igndelim, ignargs;
struct mdoc_arg argv[MDOC_LINEARG_MAX];
char *p;
lastarg = ppos;
flushed = 0;
+
+ /*
+ * Maximum arguments per macro. Some of these have none and
+ * exit as soon as they're parsed.
+ */
+
switch (tok) {
case (MDOC_No):
/* FALLTHROUGH */
case (MDOC_Ns):
/* FALLTHROUGH */
case (MDOC_Ux):
- /* FALLTHROUGH */
- case (MDOC_St):
maxargs = 0;
break;
default:
@@ -1205,6 +1212,12 @@ macro_constant_delimited(MACRO_PROT_ARGS)
break;
}
+ /*
+ * Whether to ignore delimiter characters. `Pf' accepts its
+ * first token as a parameter no matter what it looks like (if
+ * it's text).
+ */
+
switch (tok) {
case (MDOC_Pf):
igndelim = 1;
@@ -1214,20 +1227,38 @@ macro_constant_delimited(MACRO_PROT_ARGS)
break;
}
- for (argc = 0; argc < MDOC_LINEARG_MAX; argc++) {
- lastarg = *pos;
- c = mdoc_argv(mdoc, line, tok, &argv[argc], pos, buf);
- if (ARGV_EOLN == c)
- break;
- if (ARGV_WORD == c) {
- *pos = lastarg;
- break;
- } else if (ARGV_ARG == c)
- continue;
- mdoc_argv_free(argc, argv);
- return(0);
+ /*
+ * Whether to ignore arguments: `St', for example, handles its
+ * argument-like parameters as regular parameters.
+ */
+
+ switch (tok) {
+ case (MDOC_St):
+ ignargs = 1;
+ break;
+ default:
+ ignargs = 0;
+ break;
}
+ argc = 0;
+
+ if ( ! ignargs)
+ for ( ; argc < MDOC_LINEARG_MAX; argc++) {
+ lastarg = *pos;
+ c = mdoc_argv(mdoc, line, tok,
+ &argv[argc], pos, buf);
+ if (ARGV_EOLN == c)
+ break;
+ if (ARGV_WORD == c) {
+ *pos = lastarg;
+ break;
+ } else if (ARGV_ARG == c)
+ continue;
+ mdoc_argv_free(argc, argv);
+ return(0);
+ }
+
if (MDOC_LINEARG_MAX == argc) {
mdoc_argv_free(argc - 1, argv);
return(perr(mdoc, line, ppos, EARGVLIM));