source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: LIBRARY can also occur in section 9.
@ 2010-05-15 16:24 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2010-05-15 16:24 UTC (permalink / raw)
  To: source

Log Message:
-----------
LIBRARY can also occur in section 9.
All manual sections (unknown, 3p, 3f, etc.) correctly handled by -mdoc.
Useful warning printed if unknown manual section.
Checking for manual sections (e.g., LIBRARY) checks only first character, so 3p, 3f, etc. are free.

Modified Files:
--------------
    mdocml:
        libmdoc.h
        mdoc.7
        mdoc.c
        mdoc.h
        mdoc.template
        mdoc_action.c
        mdoc_html.c
        mdoc_term.c
        mdoc_validate.c

Revision Data
-------------
Index: mdoc_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_html.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.62 -r1.63
--- mdoc_html.c
+++ mdoc_html.c
@@ -387,7 +387,7 @@ print_mdoc_head(MDOC_ARGS)
 
 	print_gen_head(h);
 	bufinit(h);
-	buffmt(h, "%s(%d)", m->title, m->msec);
+	buffmt(h, "%s(%s)", m->title, m->msec);
 
 	if (m->arch) {
 		bufcat(h, " (");
@@ -509,7 +509,7 @@ mdoc_root_pre(MDOC_ARGS)
 	}
 
 	(void)snprintf(title, BUFSIZ - 1, 
-			"%s(%d)", m->title, m->msec);
+			"%s(%s)", m->title, m->msec);
 
 	/* XXX: see note in mdoc_root_post() about divs. */
 
Index: mdoc_action.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_action.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -Lmdoc_action.c -Lmdoc_action.c -u -p -r1.57 -r1.58
--- mdoc_action.c
+++ mdoc_action.c
@@ -446,17 +446,14 @@ post_sh(POST_ARGS)
 	case (SEC_RETURN_VALUES):
 		/* FALLTHROUGH */
 	case (SEC_ERRORS):
-		switch (m->meta.msec) {
-		case (2):
-			/* FALLTHROUGH */
-		case (3):
-			/* FALLTHROUGH */
-		case (9):
+		assert(m->meta.msec);
+		if (*m->meta.msec == '2')
 			break;
-		default:
-			return(mdoc_nwarn(m, n, EBADSEC));
-		}
-		break;
+		if (*m->meta.msec == '3')
+			break;
+		if (*m->meta.msec == '9')
+			break;
+		return(mdoc_nwarn(m, n, EWRONGMSEC));
 	default:
 		break;
 	}
@@ -473,8 +470,6 @@ post_dt(POST_ARGS)
 {
 	struct mdoc_node *nn;
 	const char	 *cp;
-	char		 *ep;
-	long		  lval;
 
 	if (m->meta.title)
 		free(m->meta.title);
@@ -484,16 +479,16 @@ post_dt(POST_ARGS)
 		free(m->meta.arch);
 
 	m->meta.title = m->meta.vol = m->meta.arch = NULL;
-	m->meta.msec = 0;
-
 	/* Handles: `.Dt' 
 	 *   --> title = unknown, volume = local, msec = 0, arch = NULL
 	 */
 
 	if (NULL == (nn = n->child)) {
 		/* XXX: make these macro values. */
+		/* FIXME: warn about missing values. */
 		m->meta.title = mandoc_strdup("unknown");
 		m->meta.vol = mandoc_strdup("local");
+		m->meta.msec = mandoc_strdup("1");
 		return(post_prol(m, n));
 	}
 
@@ -504,8 +499,10 @@ post_dt(POST_ARGS)
 	m->meta.title = mandoc_strdup(nn->string);
 
 	if (NULL == (nn = nn->next)) {
+		/* FIXME: warn about missing msec. */
 		/* XXX: make this a macro value. */
 		m->meta.vol = mandoc_strdup("local");
+		m->meta.msec = mandoc_strdup("1");
 		return(post_prol(m, n));
 	}
 
@@ -518,13 +515,13 @@ post_dt(POST_ARGS)
 
 	cp = mdoc_a2msec(nn->string);
 	if (cp) {
-		/* FIXME: where is strtonum!? */
 		m->meta.vol = mandoc_strdup(cp);
-		lval = strtol(nn->string, &ep, 10);
-		if (nn->string[0] != '\0' && *ep == '\0')
-			m->meta.msec = (int)lval;
-	} else 
+		m->meta.msec = mandoc_strdup(nn->string);
+	} else if (mdoc_nwarn(m, n, EBADMSEC)) {
 		m->meta.vol = mandoc_strdup(nn->string);
+		m->meta.msec = mandoc_strdup(nn->string);
+	} else
+		return(0);
 
 	if (NULL == (nn = nn->next))
 		return(post_prol(m, n));
@@ -541,6 +538,7 @@ post_dt(POST_ARGS)
 		free(m->meta.vol);
 		m->meta.vol = mandoc_strdup(cp);
 	} else {
+		/* FIXME: warn about bad arch. */
 		cp = mdoc_a2arch(nn->string);
 		if (NULL == cp) {
 			free(m->meta.vol);
Index: libmdoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/libmdoc.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -Llibmdoc.h -Llibmdoc.h -u -p -r1.46 -r1.47
--- libmdoc.h
+++ libmdoc.h
@@ -80,7 +80,7 @@ enum	merr {
 	ENOLINE,
 	EPROLOOO,
 	EPROLREP,
-	EBADSEC,
+	EBADMSEC,
 	EFONT,
 	EBADDATE,
 	ENUMFMT,
Index: mdoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -Lmdoc.c -Lmdoc.c -u -p -r1.132 -r1.133
--- mdoc.c
+++ mdoc.c
@@ -68,7 +68,7 @@ const	char *const __mdoc_merrnames[MERRM
 	"line arguments discouraged", /* ENOLINE */
 	"prologue macro out of conventional order", /* EPROLOOO */
 	"prologue macro repeated", /* EPROLREP */
-	"invalid section", /* EBADSEC */
+	"invalid manual section", /* EBADMSEC */
 	"invalid font mode", /* EFONT */
 	"invalid date syntax", /* EBADDATE */
 	"invalid number format", /* ENUMFMT */
@@ -190,6 +190,8 @@ mdoc_free1(struct mdoc *mdoc)
 		free(mdoc->meta.arch);
 	if (mdoc->meta.vol)
 		free(mdoc->meta.vol);
+	if (mdoc->meta.msec)
+		free(mdoc->meta.msec);
 }
 
 
Index: mdoc.7
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.7,v
retrieving revision 1.107
retrieving revision 1.108
diff -Lmdoc.7 -Lmdoc.7 -u -p -r1.107 -r1.108
--- mdoc.7
+++ mdoc.7
@@ -347,7 +347,7 @@ file:
 \&.Sh NAME
 \&.Nm foo
 \&.Nd a description goes here
-\&.\e\*q The next is for sections 2 & 3 only.
+\&.\e\*q The next is for sections 2, 3, & 9 only.
 \&.\e\*q .Sh LIBRARY
 \&.
 \&.Sh SYNOPSIS
@@ -409,7 +409,7 @@ and
 .Sx \&Nd .
 .It Em LIBRARY
 The name of the library containing the documented material, which is
-assumed to be a function in a section 2 or 3 manual.
+assumed to be a function in a section 2, 3, or 9 manual.
 The syntax for this is as follows:
 .Bd -literal -offset indent
 \&.Lb libarm
Index: mdoc.template
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.template,v
retrieving revision 1.5
retrieving revision 1.6
diff -Lmdoc.template -Lmdoc.template -u -p -r1.5 -r1.6
--- mdoc.template
+++ mdoc.template
@@ -14,7 +14,7 @@
 .Sh NAME
 .Nm name
 .Nd short description
-.\" The next is for sections 2 & 3 only.
+.\" The next is for sections 2, 3, & 9 only.
 .\" .Sh LIBRARY
 .Sh SYNOPSIS
 .Sh DESCRIPTION
Index: mdoc_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.77 -r1.78
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -1240,20 +1240,19 @@ post_sh_head(POST_ARGS)
 
 	/* 
 	 * Check particular section/manual conventions.  LIBRARY can
-	 * only occur in msec 2, 3 (TODO: are there more of these?).
+	 * only occur in manual section 2, 3, and 9.
 	 */
 
 	switch (sec) {
 	case (SEC_LIBRARY):
-		switch (mdoc->meta.msec) {
-		case (2):
-			/* FALLTHROUGH */
-		case (3):
+		assert(mdoc->meta.msec);
+		if (*mdoc->meta.msec == '2')
 			break;
-		default:
-			return(mdoc_nwarn(mdoc, mdoc->last, EWRONGMSEC));
-		}
-		break;
+		if (*mdoc->meta.msec == '3')
+			break;
+		if (*mdoc->meta.msec == '9')
+			break;
+		return(mdoc_nwarn(mdoc, mdoc->last, EWRONGMSEC));
 	default:
 		break;
 	}
Index: mdoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.h,v
retrieving revision 1.78
retrieving revision 1.79
diff -Lmdoc.h -Lmdoc.h -u -p -r1.78 -r1.79
--- mdoc.h
+++ mdoc.h
@@ -223,7 +223,7 @@ enum	mdoc_sec {
 
 /* Information from prologue. */
 struct	mdoc_meta {
-	int		  msec;
+	char		 *msec;
 	char		 *vol;
 	char		 *arch;
 	time_t		  date;
Index: mdoc_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v
retrieving revision 1.123
retrieving revision 1.124
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.123 -r1.124
--- mdoc_term.c
+++ mdoc_term.c
@@ -425,7 +425,7 @@ print_mdoc_head(DECL_ARGS)
 		strlcat(buf, ")", BUFSIZ);
 	}
 
-	snprintf(title, BUFSIZ, "%s(%d)", m->title, m->msec);
+	snprintf(title, BUFSIZ, "%s(%s)", m->title, m->msec);
 
 	p->offset = 0;
 	p->rmargin = (p->maxrmargin - strlen(buf) + 1) / 2;
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-05-15 16:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-15 16:24 mdocml: LIBRARY can also occur in section 9 kristaps

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).