summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-07-19 21:26:27 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-07-19 21:26:27 +0000
commit9954ffcf73634d2ae338d61164daa96a0e60235b (patch)
treedc34b7581dc3ef70c32d9dff80eb100d282b8055
parent83b4aa04039660d0f4e9d18e868999f54dc74589 (diff)
downloadmandoc-9954ffcf73634d2ae338d61164daa96a0e60235b.tar.gz
mandoc-9954ffcf73634d2ae338d61164daa96a0e60235b.tar.zst
mandoc-9954ffcf73634d2ae338d61164daa96a0e60235b.zip
Fixed and cleaned up "phrase" handling (`Bl -column' columns).
Found strange newline bug in -diag handling (and others?).
-rw-r--r--libmdoc.h4
-rw-r--r--mdoc_argv.c10
-rw-r--r--mdoc_macro.c86
-rw-r--r--term.c7
4 files changed, 43 insertions, 64 deletions
diff --git a/libmdoc.h b/libmdoc.h
index f539473c..d68f2964 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -1,4 +1,4 @@
-/* $Id: libmdoc.h,v 1.19 2009/07/17 12:27:49 kristaps Exp $ */
+/* $Id: libmdoc.h,v 1.20 2009/07/19 21:26:27 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -174,6 +174,8 @@ int mdoc_argv(struct mdoc *, int, int,
void mdoc_argv_free(struct mdoc_arg *);
int mdoc_args(struct mdoc *, int,
int *, char *, int, char **);
+int mdoc_zargs(struct mdoc *, int,
+ int *, char *, char **);
#define ARGS_ERROR (-1)
#define ARGS_EOLN (0)
#define ARGS_WORD (1)
diff --git a/mdoc_argv.c b/mdoc_argv.c
index 287913f6..cb3e2404 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_argv.c,v 1.18 2009/07/18 18:59:33 kristaps Exp $ */
+/* $Id: mdoc_argv.c,v 1.19 2009/07/19 21:26:27 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -327,6 +327,14 @@ mdoc_argv_free(struct mdoc_arg *p)
int
+mdoc_zargs(struct mdoc *m, int line, int *pos, char *buf, char **v)
+{
+
+ return(args(m, line, pos, buf, 0, v));
+}
+
+
+int
mdoc_args(struct mdoc *m, int line,
int *pos, char *buf, int tok, char **v)
{
diff --git a/mdoc_macro.c b/mdoc_macro.c
index 66e2f6e4..a8956c44 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.23 2009/07/19 09:17:42 kristaps Exp $ */
+/* $Id: mdoc_macro.c,v 1.24 2009/07/19 21:26:27 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -1385,78 +1385,44 @@ obsolete(MACRO_PROT_ARGS)
}
+/*
+ * Phrases occur within `Bl -column' entries, separated by `Ta' or tabs.
+ * They're unusual because they're basically free-form text until a
+ * macro is encountered.
+ */
static int
phrase(struct mdoc *mdoc, int line, int ppos, char *buf)
{
- int i, la, c, quoted;
-
- /*
- * Parse over words in a phrase. We have to handle this
- * specially because we assume no calling context -- in normal
- * circumstances, we switch argument parsing based on whether
- * the parent macro accepts quotes, tabs, etc. Here, anything
- * goes.
- */
-
- for (i = ppos; buf[i]; ) {
- assert(' ' != buf[i]);
- la = i;
- quoted = 0;
+ int c, w, la, pos;
+ char *p;
- /*
- * Read to next token. If quoted (check not escaped),
- * scan ahead to next unescaped quote. If not quoted or
- * escape-quoted, then scan ahead to next space.
- */
+ for (pos = ppos; ; ) {
+ la = pos;
- if ((i && '\"' == buf[i] && '\\' != buf[i - 1]) ||
- (0 == i && '\"' == buf[i])) {
- for (la = ++i; buf[i]; i++)
- if ('\"' != buf[i])
- continue;
- else if ('\\' != buf[i - 1])
- break;
- if (0 == buf[i])
- return(mdoc_perr(mdoc, line, la, EQUOTPHR));
- quoted = 1;
- } else
- for ( ; buf[i]; i++)
- if (i && ' ' == buf[i]) {
- if ('\\' != buf[i - 1])
- break;
- } else if (' ' == buf[i])
- break;
-
- /* If not end-of-line, terminate argument. */
-
- if (buf[i])
- buf[i++] = 0;
-
- /* Read to next argument. */
-
- for ( ; buf[i] && ' ' == buf[i]; i++)
- /* Spin. */ ;
+ /* Note: no calling context! */
+ w = mdoc_zargs(mdoc, line, &pos, buf, &p);
- /*
- * If we're a non-quoted string, try to look up the
- * value as a macro and execute it, if found.
- */
+ if (ARGS_ERROR == w)
+ return(0);
+ if (ARGS_EOLN == w)
+ break;
- c = quoted ? MDOC_MAX :
- mdoc_hash_find(mdoc->htab, &buf[la]);
+ c = ARGS_QWORD == w ? MDOC_MAX :
+ mdoc_hash_find(mdoc->htab, p);
- if (MDOC_MAX != c) {
- if ( ! mdoc_macro(mdoc, c, line, la, &i, buf))
+ if (MDOC_MAX != c && -1 != c) {
+ if ( ! mdoc_macro(mdoc, c, line, la, &pos, buf))
return(0);
- return(append_delims(mdoc, line, &i, buf));
- }
-
- /* A regular word or quoted string. */
+ return(append_delims(mdoc, line, &pos, buf));
+ } else if (-1 == c)
+ return(0);
- if ( ! mdoc_word_alloc(mdoc, line, la, &buf[la]))
+ if ( ! mdoc_word_alloc(mdoc, line, la, p))
return(0);
mdoc->next = MDOC_NEXT_SIBLING;
}
return(1);
}
+
+
diff --git a/term.c b/term.c
index 908c5854..4d33ce8d 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.89 2009/07/16 13:17:51 kristaps Exp $ */
+/* $Id: term.c,v 1.90 2009/07/19 21:26:27 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -204,7 +204,10 @@ term_isopendelim(const char *p)
* possible).
*
* FIXME: newline breaks occur (in groff) also occur when a single
- * space follows a NOBREAK!
+ * space follows a NOBREAK (try `Bl -tag')
+ *
+ * FIXME: there's a newline error where a `Bl -diag' will have a
+ * trailing newline if the line is exactly 73 chars long.
*/
void
term_flushln(struct termp *p)