summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-02-25 17:02:47 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-02-25 17:02:47 +0000
commit5851ee4d2b64ce06c48c8cfb740d681250066ca5 (patch)
treeece2553e4a24af4c3e30aa8ca963745d75ad7784
parent1961c1d89494c7fce047f0bc339a5feae46efc7d (diff)
downloadmandoc-5851ee4d2b64ce06c48c8cfb740d681250066ca5.tar.gz
mandoc-5851ee4d2b64ce06c48c8cfb740d681250066ca5.tar.zst
mandoc-5851ee4d2b64ce06c48c8cfb740d681250066ca5.zip
*** empty log message ***
-rw-r--r--mdoc.39
-rw-r--r--mdocterm.c74
-rw-r--r--term.c26
-rw-r--r--term.h3
4 files changed, 67 insertions, 45 deletions
diff --git a/mdoc.3 b/mdoc.3
index 0adf9302..5b5f70e8 100644
--- a/mdoc.3
+++ b/mdoc.3
@@ -1,4 +1,4 @@
-.\" $Id: mdoc.3,v 1.10 2009/02/24 13:46:54 kristaps Exp $
+.\" $Id: mdoc.3,v 1.11 2009/02/25 17:02:47 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
.\"
@@ -16,7 +16,7 @@
.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: February 24 2009 $
+.Dd $Mdocdate: February 25 2009 $
.Dt mdoc 3
.Os
.\" SECTION
@@ -59,7 +59,10 @@ library implements only those macros documented in the
.Xr mdoc 7
and
.Xr mdoc.samples 7
-manuals.
+manuals. Documents with
+.Xr refer 1 ,
+.Xr eqn 1
+and other pre-processor sections aren't accomodated.
.\" PARAGRAPH
.Pp
.Nm
diff --git a/mdocterm.c b/mdocterm.c
index 35d14168..9a344639 100644
--- a/mdocterm.c
+++ b/mdocterm.c
@@ -1,4 +1,4 @@
-/* $Id: mdocterm.c,v 1.12 2009/02/25 15:12:26 kristaps Exp $ */
+/* $Id: mdocterm.c,v 1.13 2009/02/25 17:02:47 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -345,6 +345,8 @@ pescape(struct termp *p, const char *word, size_t *i, size_t len)
/* FALLTHROUGH */
case ('-'):
/* FALLTHROUGH */
+ case (' '):
+ /* FALLTHROUGH */
case ('.'):
chara(p, word[*i]);
default:
@@ -372,7 +374,8 @@ pword(struct termp *p, const char *word, size_t len)
! (p->flags & TERMP_LITERAL))
chara(p, ' ');
- p->flags &= ~TERMP_NOSPACE;
+ if ( ! (p->flags & TERMP_NONOSPACE))
+ p->flags &= ~TERMP_NOSPACE;
if (p->flags & TERMP_BOLD)
style(p, STYLE_BOLD);
@@ -530,8 +533,7 @@ static void
header(struct termp *p, const struct mdoc_meta *meta)
{
char *buf, *title;
- const char *pp, *msec;
- size_t ssz, tsz, ttsz, i;;
+ const char *pp;
if (NULL == (buf = malloc(p->rmargin)))
err(1, "malloc");
@@ -568,50 +570,44 @@ header(struct termp *p, const struct mdoc_meta *meta)
pp = mdoc_msec2a(MSEC_local);
break;
}
- assert(pp);
-
- tsz = strlcpy(buf, pp, p->rmargin);
- assert(tsz < p->rmargin);
-
- if ((pp = mdoc_arch2a(meta->arch))) {
- tsz = strlcat(buf, " (", p->rmargin);
- assert(tsz < p->rmargin);
- tsz = strlcat(buf, pp, p->rmargin);
- assert(tsz < p->rmargin);
- tsz = strlcat(buf, ")", p->rmargin);
- assert(tsz < p->rmargin);
- }
- ttsz = strlcpy(title, meta->title, p->rmargin);
+ if (mdoc_arch2a(meta->arch))
+ (void)snprintf(buf, p->rmargin, "%s(%s)",
+ pp, mdoc_arch2a(meta->arch));
+ else
+ (void)strlcpy(buf, pp, p->rmargin);
- if (NULL == (msec = mdoc_msec2a(meta->msec)))
- msec = "";
+ pp = mdoc_msec2a(meta->msec);
- ssz = (2 * (ttsz + 2 + strlen(msec))) + tsz + 2;
+ (void)snprintf(title, p->rmargin, "%s(%s)",
+ meta->title, pp ? pp : "");
- if (ssz > p->rmargin) {
- if ((ssz -= p->rmargin) % 2)
- ssz++;
- ssz /= 2;
-
- assert(ssz <= ttsz);
- title[ttsz - ssz] = 0;
- ssz = 1;
- } else
- ssz = ((p->rmargin - ssz) / 2) + 1;
+ p->offset = 0;
+ p->rmargin = (p->maxrmargin - strlen(buf)) / 2;
+ p->flags |= TERMP_NOBREAK;
+ p->flags |= TERMP_NOSPACE;
- printf("%s(%s)", title, msec);
+ word(p, title);
+ flushln(p);
- for (i = 0; i < ssz; i++)
- printf(" ");
+ p->offset = p->rmargin;
+ p->rmargin += strlen(buf);
- printf("%s", buf);
+ word(p, buf);
+ flushln(p);
- for (i = 0; i < ssz; i++)
- printf(" ");
+ exit(1);
- printf("%s(%s)\n", title, msec);
- fflush(stdout);
+ p->offset = p->rmargin;
+ p->rmargin = p->maxrmargin;
+ p->flags &= ~TERMP_NOBREAK;
+
+ word(p, title);
+ flushln(p);
+
+ p->rmargin = p->maxrmargin;
+ p->offset = 0;
+ p->flags &= ~TERMP_NOSPACE;
free(title);
free(buf);
diff --git a/term.c b/term.c
index 5fd868dd..8d4b3dbd 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.21 2009/02/25 15:12:26 kristaps Exp $ */
+/* $Id: term.c,v 1.22 2009/02/25 17:02:47 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -17,6 +17,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <assert.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -148,6 +149,7 @@ DECL_PRE(termp_ox);
DECL_PRE(termp_pa);
DECL_PRE(termp_pp);
DECL_PRE(termp_rv);
+DECL_PRE(termp_sm);
DECL_PRE(termp_st);
DECL_PRE(termp_sx);
DECL_PRE(termp_sy);
@@ -248,7 +250,7 @@ const struct termact __termacts[MDOC_MAX] = {
{ NULL, NULL }, /* Sc */
{ termp_sq_pre, termp_sq_post }, /* So */
{ termp_sq_pre, termp_sq_post }, /* Sq */
- { NULL, NULL }, /* Sm */
+ { termp_sm_pre, NULL }, /* Sm */
{ termp_sx_pre, NULL }, /* Sx */
{ termp_sy_pre, NULL }, /* Sy */
{ NULL, NULL }, /* Tn */
@@ -1404,3 +1406,23 @@ termp_ms_pre(DECL_ARGS)
return(1);
}
+
+
+/* ARGSUSED */
+static int
+termp_sm_pre(DECL_ARGS)
+{
+
+#if notyet
+ assert(node->child);
+ if (0 == strcmp("off", node->child->data.text.string)) {
+ p->flags &= ~TERMP_NONOSPACE;
+ p->flags &= ~TERMP_NOSPACE;
+ } else {
+ p->flags |= TERMP_NONOSPACE;
+ p->flags |= TERMP_NOSPACE;
+ }
+#endif
+
+ return(0);
+}
diff --git a/term.h b/term.h
index 297632cb..fcf45e40 100644
--- a/term.h
+++ b/term.h
@@ -1,4 +1,4 @@
-/* $Id: term.h,v 1.9 2009/02/25 15:12:26 kristaps Exp $ */
+/* $Id: term.h,v 1.10 2009/02/25 17:02:47 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -37,6 +37,7 @@ struct termp {
#define TERMP_NOBREAK (1 << 4) /* No break after flush. */
#define TERMP_LITERAL (1 << 5) /* Literal words. */
#define TERMP_IGNDELIM (1 << 6) /* Delims like regulars. */
+#define TERMP_NONOSPACE (1 << 7) /* No space (no autounset). */
char *buf;
};