summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-08-21 12:32:38 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-08-21 12:32:38 +0000
commit133b6ec86f5c1723d06abd3b096c24406be4cea6 (patch)
treef10cd43a94a200c0c5610c9ff8879e71ded62b1a
parent3c7b73a2f8774480e0df1984d751f9ead2c8c29d (diff)
downloadmandoc-133b6ec86f5c1723d06abd3b096c24406be4cea6.tar.gz
mandoc-133b6ec86f5c1723d06abd3b096c24406be4cea6.tar.zst
mandoc-133b6ec86f5c1723d06abd3b096c24406be4cea6.zip
Fixed `nf' behaviour (had broken with de-chunking).
Added warnings if literal context already open/closed.
-rw-r--r--libman.h6
-rw-r--r--man.c14
-rw-r--r--man_action.c54
3 files changed, 57 insertions, 17 deletions
diff --git a/libman.h b/libman.h
index f7853fc6..ee1f67a6 100644
--- a/libman.h
+++ b/libman.h
@@ -1,4 +1,4 @@
-/* $Id: libman.h,v 1.18 2009/08/19 12:15:58 kristaps Exp $ */
+/* $Id: libman.h,v 1.19 2009/08/21 12:32:38 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -33,6 +33,7 @@ struct man {
#define MAN_HALT (1 << 0)
#define MAN_ELINE (1 << 1) /* Next-line element scope. */
#define MAN_BLINE (1 << 2) /* Next-line block scope. */
+#define MAN_LITERAL (1 << 3) /* Literal input. */
enum man_next next;
struct man_node *last;
struct man_node *first;
@@ -58,6 +59,8 @@ enum merr {
WMACROFORM,
WEXITSCOPE,
WNOSCOPE,
+ WOLITERAL,
+ WNLITERAL,
WERRMAX
};
@@ -106,6 +109,7 @@ int man_verr(struct man *, int, int, const char *, ...);
int man_valid_post(struct man *);
int man_valid_pre(struct man *, const struct man_node *);
int man_action_post(struct man *);
+int man_action_pre(struct man *, struct man_node *);
int man_unscope(struct man *, const struct man_node *);
__END_DECLS
diff --git a/man.c b/man.c
index f1c461e6..6666d748 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.34 2009/08/21 12:12:12 kristaps Exp $ */
+/* $Id: man.c,v 1.35 2009/08/21 12:32:38 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -41,7 +41,9 @@ const char *const __man_merrnames[WERRMAX] = {
"unknown macro", /* WMACRO */
"ill-formed macro", /* WMACROFORM */
"scope open on exit", /* WEXITSCOPE */
- "no scope context" /* WNOSCOPE */
+ "no scope context", /* WNOSCOPE */
+ "literal context already open", /* WOLITERAL */
+ "no literal context open" /* WNLITERAL */
};
const char *const __man_macronames[MAN_MAX] = {
@@ -392,6 +394,14 @@ man_ptext(struct man *m, int line, char *buf)
{
int i, j;
+ /* Literal free-form text whitespace is preserved. */
+
+ if (MAN_LITERAL & m->flags) {
+ if ( ! man_word_alloc(m, line, 0, buf))
+ return(0);
+ goto descope;
+ }
+
/* First de-chunk and allocate words. */
for (i = 0; ' ' == buf[i]; i++)
diff --git a/man_action.c b/man_action.c
index e90065ad..456a746c 100644
--- a/man_action.c
+++ b/man_action.c
@@ -1,4 +1,4 @@
-/* $Id: man_action.c,v 1.17 2009/08/20 11:51:07 kristaps Exp $ */
+/* $Id: man_action.c,v 1.18 2009/08/21 12:32:38 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -23,17 +23,13 @@
#include "libman.h"
-#ifdef __linux__
-extern char *strptime(const char *, const char *, struct tm *);
-#endif
-
struct actions {
int (*post)(struct man *);
};
-
static int post_TH(struct man *);
-static time_t man_atotime(const char *);
+static int post_fi(struct man *);
+static int post_nf(struct man *);
const struct actions man_actions[MAN_MAX] = {
{ NULL }, /* br */
@@ -60,14 +56,19 @@ const struct actions man_actions[MAN_MAX] = {
{ NULL }, /* na */
{ NULL }, /* i */
{ NULL }, /* sp */
- { NULL }, /* nf */
- { NULL }, /* fi */
+ { post_nf }, /* nf */
+ { post_fi }, /* fi */
{ NULL }, /* r */
{ NULL }, /* RE */
{ NULL }, /* RS */
{ NULL }, /* DT */
};
+static time_t man_atotime(const char *);
+#ifdef __linux__
+extern char *strptime(const char *, const char *, struct tm *);
+#endif
+
int
man_action_post(struct man *m)
@@ -79,14 +80,39 @@ man_action_post(struct man *m)
switch (m->last->type) {
case (MAN_TEXT):
- break;
+ /* FALLTHROUGH */
case (MAN_ROOT):
- break;
+ return(1);
default:
- if (NULL == man_actions[m->last->tok].post)
- break;
- return((*man_actions[m->last->tok].post)(m));
+ break;
}
+
+ if (NULL == man_actions[m->last->tok].post)
+ return(1);
+ return((*man_actions[m->last->tok].post)(m));
+}
+
+
+static int
+post_fi(struct man *m)
+{
+
+ if ( ! (MAN_LITERAL & m->flags))
+ if ( ! man_nwarn(m, m->last, WNLITERAL))
+ return(0);
+ m->flags &= ~MAN_LITERAL;
+ return(1);
+}
+
+
+static int
+post_nf(struct man *m)
+{
+
+ if (MAN_LITERAL & m->flags)
+ if ( ! man_nwarn(m, m->last, WOLITERAL))
+ return(0);
+ m->flags |= MAN_LITERAL;
return(1);
}