summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-02-22 19:23:48 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-02-22 19:23:48 +0000
commit5134b2528e28222c6cfe6ab2b2977ea107397999 (patch)
tree7f5e62c6008e07831f58913277362fefe3f76add
parent9d6cd65d9c0228344fd1848a9f8c9343f5434599 (diff)
downloadmandoc-5134b2528e28222c6cfe6ab2b2977ea107397999.tar.gz
mandoc-5134b2528e28222c6cfe6ab2b2977ea107397999.tar.zst
mandoc-5134b2528e28222c6cfe6ab2b2977ea107397999.zip
Fixed `.Pf' handling.
System now supports all mdocml manual pages.
-rw-r--r--macro.c18
-rw-r--r--mdoctree.17
-rw-r--r--term.c9
-rw-r--r--term.h3
-rw-r--r--termact.c81
-rw-r--r--validate.c5
6 files changed, 105 insertions, 18 deletions
diff --git a/macro.c b/macro.c
index ad96ad0e..71955470 100644
--- a/macro.c
+++ b/macro.c
@@ -1,4 +1,4 @@
-/* $Id: macro.c,v 1.49 2009/01/22 14:56:21 kristaps Exp $ */
+/* $Id: macro.c,v 1.50 2009/02/22 19:23:48 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -1086,7 +1086,8 @@ macro_constant_scoped(MACRO_PROT_ARGS)
int
macro_constant_delimited(MACRO_PROT_ARGS)
{
- int lastarg, flushed, j, c, maxargs, argc;
+ int lastarg, flushed, j, c, maxargs, argc,
+ igndelim;
struct mdoc_arg argv[MDOC_LINEARG_MAX];
char *p;
@@ -1098,8 +1099,6 @@ macro_constant_delimited(MACRO_PROT_ARGS)
/* FALLTHROUGH */
case (MDOC_Ns):
/* FALLTHROUGH */
- case (MDOC_Pf):
- /* FALLTHROUGH */
case (MDOC_Ux):
/* FALLTHROUGH */
case (MDOC_St):
@@ -1110,6 +1109,15 @@ macro_constant_delimited(MACRO_PROT_ARGS)
break;
}
+ switch (tok) {
+ case (MDOC_Pf):
+ igndelim = 1;
+ break;
+ default:
+ igndelim = 0;
+ break;
+ }
+
for (argc = 0; argc < MDOC_LINEARG_MAX; argc++) {
lastarg = *pos;
c = mdoc_argv(mdoc, line, tok, &argv[argc], pos, buf);
@@ -1167,7 +1175,7 @@ macro_constant_delimited(MACRO_PROT_ARGS)
break;
}
- if ( ! flushed && mdoc_isdelim(p)) {
+ if ( ! flushed && mdoc_isdelim(p) && ! igndelim) {
if ( ! rewind_elem(mdoc, tok))
return(0);
flushed = 1;
diff --git a/mdoctree.1 b/mdoctree.1
index ba843617..3d96f0f3 100644
--- a/mdoctree.1
+++ b/mdoctree.1
@@ -1,4 +1,4 @@
-.\" $Id: mdoctree.1,v 1.2 2009/02/22 11:23:19 kristaps Exp $
+.\" $Id: mdoctree.1,v 1.3 2009/02/22 19:23:48 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
.\"
@@ -35,7 +35,10 @@ The
.Nm
utility parses a BSD
.Dq mdoc
-manual pages and prints its syntax tree. The arguments are as follows:
+manual pages and prints its syntax tree. It's commonly used to see the
+syntax tree of a document when building new
+.Xr mdoc 3
+utilities. The arguments are as follows:
.Bl -tag -width "\-Werr... "
.\" ITEM
.It Fl v
diff --git a/term.c b/term.c
index 5b7111dc..b9e4a936 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.8 2009/02/22 15:50:45 kristaps Exp $ */
+/* $Id: term.c,v 1.9 2009/02/22 19:23:48 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -319,8 +319,11 @@ word(struct termp *p, const char *word)
len = strlen(word);
assert(len > 0);
- if (mdoc_isdelim(word))
- p->flags |= TERMP_NOSPACE;
+ if (mdoc_isdelim(word)) {
+ if ( ! (p->flags & TERMP_IGNDELIM))
+ p->flags |= TERMP_NOSPACE;
+ p->flags &= ~TERMP_IGNDELIM;
+ }
/* LINTED */
for (j = i = 0; i < len; i++) {
diff --git a/term.h b/term.h
index 28c68b36..21e2b2d5 100644
--- a/term.h
+++ b/term.h
@@ -1,4 +1,4 @@
-/* $Id: term.h,v 1.3 2009/02/22 15:50:45 kristaps Exp $ */
+/* $Id: term.h,v 1.4 2009/02/22 19:23:48 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -36,6 +36,7 @@ struct termp {
#define TERMP_NOLPAD (1 << 3) /* No leftpad before flush. */
#define TERMP_NOBREAK (1 << 4) /* No break after flush. */
#define TERMP_LITERAL (1 << 5) /* Literal words. */
+#define TERMP_IGNDELIM (1 << 6) /* Delims like regulars. */
char *buf;
};
diff --git a/termact.c b/termact.c
index 44309418..0151dfc3 100644
--- a/termact.c
+++ b/termact.c
@@ -1,4 +1,4 @@
-/* $Id: termact.c,v 1.5 2009/02/22 15:50:45 kristaps Exp $ */
+/* $Id: termact.c,v 1.6 2009/02/22 19:23:48 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -96,10 +96,14 @@ DECL_PRE(termp_it);
DECL_PRE(termp_nd);
DECL_PRE(termp_nm);
DECL_PRE(termp_ns);
+DECL_PRE(termp_nx);
DECL_PRE(termp_op);
+DECL_PRE(termp_ox);
+DECL_PRE(termp_pf);
DECL_PRE(termp_pp);
DECL_PRE(termp_qq);
DECL_PRE(termp_sh);
+DECL_PRE(termp_sq);
DECL_PRE(termp_sx);
DECL_PRE(termp_ud);
DECL_PRE(termp_va);
@@ -119,8 +123,10 @@ DECL_POST(termp_ft);
DECL_POST(termp_it);
DECL_POST(termp_nm);
DECL_POST(termp_op);
+DECL_POST(termp_pf);
DECL_POST(termp_qq);
DECL_POST(termp_sh);
+DECL_POST(termp_sq);
DECL_POST(termp_sx);
DECL_POST(termp_va);
DECL_POST(termp_vt);
@@ -200,10 +206,10 @@ const struct termact __termacts[MDOC_MAX] = {
{ NULL, NULL }, /* Ms */
{ NULL, NULL }, /* No */
{ termp_ns_pre, NULL }, /* Ns */
- { NULL, NULL }, /* Nx */
- { NULL, NULL }, /* Ox */
+ { termp_nx_pre, NULL }, /* Nx */
+ { termp_ox_pre, NULL }, /* Ox */
{ NULL, NULL }, /* Pc */
- { NULL, NULL }, /* Pf */
+ { termp_pf_pre, termp_pf_post }, /* Pf */
{ NULL, NULL }, /* Po */
{ NULL, NULL }, /* Pq */
{ NULL, NULL }, /* Qc */
@@ -214,7 +220,7 @@ const struct termact __termacts[MDOC_MAX] = {
{ NULL, NULL }, /* Rs */
{ NULL, NULL }, /* Sc */
{ NULL, NULL }, /* So */
- { NULL, NULL }, /* Sq */
+ { termp_sq_pre, termp_sq_post }, /* Sq */
{ NULL, NULL }, /* Sm */
{ termp_sx_pre, termp_sx_post }, /* Sx */
{ NULL, NULL }, /* Sy */
@@ -969,3 +975,68 @@ termp_qq_post(DECL_ARGS)
}
+/* ARGSUSED */
+static int
+termp_ox_pre(DECL_ARGS)
+{
+
+ word(p, "OpenBSD");
+ return(1);
+}
+
+
+/* ARGSUSED */
+static int
+termp_nx_pre(DECL_ARGS)
+{
+
+ word(p, "NetBSD");
+ return(1);
+}
+
+
+/* ARGSUSED */
+static int
+termp_sq_pre(DECL_ARGS)
+{
+
+ if (MDOC_BODY != node->type)
+ return(1);
+ word(p, "`");
+ p->flags |= TERMP_NOSPACE;
+ return(1);
+}
+
+
+/* ARGSUSED */
+static void
+termp_sq_post(DECL_ARGS)
+{
+
+ if (MDOC_BODY != node->type)
+ return;
+ p->flags |= TERMP_NOSPACE;
+ word(p, "\'");
+}
+
+
+/* ARGSUSED */
+static int
+termp_pf_pre(DECL_ARGS)
+{
+
+ p->flags |= TERMP_IGNDELIM;
+ return(1);
+}
+
+
+/* ARGSUSED */
+static void
+termp_pf_post(DECL_ARGS)
+{
+
+ p->flags &= ~TERMP_IGNDELIM;
+ p->flags |= TERMP_NOSPACE;
+}
+
+
diff --git a/validate.c b/validate.c
index 698413b3..2bf5a0a1 100644
--- a/validate.c
+++ b/validate.c
@@ -1,4 +1,4 @@
-/* $Id: validate.c,v 1.51 2009/02/22 14:31:08 kristaps Exp $ */
+/* $Id: validate.c,v 1.52 2009/02/22 19:23:48 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -140,6 +140,7 @@ static v_post posts_bl[] = { herr_eq0, bwarn_ge1, post_bl, NULL };
static v_post posts_it[] = { post_it, NULL };
static v_post posts_in[] = { ewarn_eq1, NULL };
static v_post posts_ss[] = { herr_ge1, NULL };
+static v_post posts_pf[] = { eerr_eq1, NULL };
static v_post posts_pp[] = { ewarn_eq0, NULL };
static v_post posts_ex[] = { eerr_le1, post_ex, NULL };
static v_post posts_an[] = { post_an, NULL };
@@ -231,7 +232,7 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, NULL }, /* Nx */
{ NULL, NULL }, /* Ox */
{ NULL, NULL }, /* Pc */
- { NULL, NULL }, /* Pf */
+ { NULL, posts_pf }, /* Pf */
{ NULL, NULL }, /* Po */
{ NULL, posts_wline }, /* Pq */
{ NULL, NULL }, /* Qc */