summaryrefslogtreecommitdiffstats
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
commitfbb8e6b42e8895e80dccf310a84f381246f9ac58 (patch)
tree744567f6fc356d6650369c39fc49a60fc2002d46
parentf3d5c8db4c02e31a44ed81c1faa87a057f79585b (diff)
downloadmandoc-fbb8e6b42e8895e80dccf310a84f381246f9ac58.tar.gz
*** empty log message ***
-rw-r--r--mdoc.35
-rw-r--r--mdocterm.c72
-rw-r--r--term.c24
-rw-r--r--term.h1
4 files changed, 62 insertions, 40 deletions
diff --git a/mdoc.3 b/mdoc.3
index 7bddf115..711ce654 100644
--- a/mdoc.3
+++ b/mdoc.3
@@ -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 3a07b32e..978393f6 100644
--- a/mdocterm.c
+++ b/mdocterm.c
@@ -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 567da478..57e9975c 100644
--- a/term.c
+++ b/term.c
@@ -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 594329f1..884c65df 100644
--- a/term.h
+++ b/term.h
@@ -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;
};