source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: No longer use names that only occur in the SYNOPSIS section as
@ 2017-08-02 13:29 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2017-08-02 13:29 UTC (permalink / raw)
  To: source

Log Message:
-----------
No longer use names that only occur in the SYNOPSIS section as names 
for man(1) lookup.  For OpenBSD base and Xenocara, that functionality
was never intended to be required, and i just fixed the last handful
of offenders using it - not counting the horribly ill-designed
interfaces engine(3) and lh_new(3) which are impossible to properly
document in the first place.

Of course, apropos(1) and whatis(1) continue to use SYNOPSIS .Nm, 
.Fn, and .Fo macros, so "man -k ENGINE_get_load_privkey_function"
still works.

This change also gets rid of a few bogus warnings "cross reference
to self" which actually are *not* to self, like in yp(8).

This former functionality was intended to help third-party software
in the ports tree and on non-OpenBSD systems containing manual pages
with incomplete or corrupt NAME sections.  But it turned out it did
more harm than good, and caused more confusion than relief, 
specifically for third party manuals and for maintainers of
mandoc-portable on other operating systems.  So kill it.
Problems reported, among others, by Yuri Pankov (illumos).

OK jmc@

Modified Files:
--------------
    mandoc:
        mansearch.c
        mdoc_validate.c

Revision Data
-------------
Index: mdoc_validate.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_validate.c,v
retrieving revision 1.351
retrieving revision 1.352
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.351 -r1.352
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -1137,8 +1137,6 @@ post_fname(POST_ARGS)
 	if ( ! (cp[0] == '\0' || (cp[0] == '(' && cp[1] == '*')))
 		mandoc_msg(MANDOCERR_FN_PAREN, mdoc->parse,
 		    n->line, n->pos + pos, n->string);
-	if (n->sec == SEC_SYNOPSIS && mdoc->meta.msec != NULL)
-		mandoc_xr_add(mdoc->meta.msec, n->string, -1, -1);
 }
 
 static void
@@ -1205,9 +1203,8 @@ post_nm(POST_ARGS)
 
 	n = mdoc->last;
 
-	if ((n->sec == SEC_NAME || n->sec == SEC_SYNOPSIS) &&
-	    n->child != NULL && n->child->type == ROFFT_TEXT &&
-	    mdoc->meta.msec != NULL)
+	if (n->sec == SEC_NAME && n->child != NULL &&
+	    n->child->type == ROFFT_TEXT && mdoc->meta.msec != NULL)
 		mandoc_xr_add(mdoc->meta.msec, n->child->string, -1, -1);
 
 	if (n->last != NULL &&
Index: mansearch.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mansearch.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -Lmansearch.c -Lmansearch.c -u -p -r1.75 -r1.76
--- mansearch.c
+++ mansearch.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: mansearch.c,v 1.50 2016/07/09 15:23:36 schwarze Exp $ */
+/*	$Id$ */
 /*
  * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2013-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -171,7 +171,9 @@ mansearch(const struct mansearch *search
 			page = dbm_page_get(rp->page);
 
 			if (lstmatch(search->sec, page->sect) == 0 ||
-			    lstmatch(search->arch, page->arch) == 0)
+			    lstmatch(search->arch, page->arch) == 0 ||
+			    (search->argmode == ARG_NAME &&
+			     rp->bits <= (int32_t)(NAME_SYN & NAME_MASK)))
 				continue;
 
 			if (res == NULL) {
@@ -452,14 +454,28 @@ lstlen(const char *cp, size_t sep)
 {
 	size_t	 sz;
 
-	for (sz = 0;; sz++) {
-		if (cp[0] == '\0') {
-			if (cp[1] == '\0')
-				break;
-			sz += sep - 1;
-		} else if (cp[0] < ' ')
-			sz--;
-		cp++;
+	for (sz = 0; *cp != '\0'; cp++) {
+
+		/* Skip names appearing only in the SYNOPSIS. */
+		if (*cp <= (char)(NAME_SYN & NAME_MASK)) {
+			while (*cp != '\0')
+				cp++;
+			continue;
+		}
+
+		/* Skip name class markers. */
+		if (*cp < ' ')
+			cp++;
+
+		/* Print a separator before each but the first string. */
+		if (sz)
+			sz += sep;
+
+		/* Copy one string. */
+		while (*cp != '\0') {
+			sz++;
+			cp++;
+		}
 	}
 	return sz;
 }
@@ -471,19 +487,34 @@ lstlen(const char *cp, size_t sep)
 static void
 lstcat(char *buf, size_t *i, const char *cp, const char *sep)
 {
-	const char *s;
+	const char	*s;
+	size_t		 i_start;
 
-	for (;;) {
-		if (cp[0] == '\0') {
-			if (cp[1] == '\0')
-				break;
+	for (i_start = *i; *cp != '\0'; cp++) {
+
+		/* Skip names appearing only in the SYNOPSIS. */
+		if (*cp <= (char)(NAME_SYN & NAME_MASK)) {
+			while (*cp != '\0')
+				cp++;
+			continue;
+		}
+
+		/* Skip name class markers. */
+		if (*cp < ' ')
+			cp++;
+
+		/* Print a separator before each but the first string. */
+		if (*i > i_start) {
 			s = sep;
 			while (*s != '\0')
 				buf[(*i)++] = *s++;
-		} else if (cp[0] >= ' ')
-			buf[(*i)++] = cp[0];
-		cp++;
+		}
+
+		/* Copy one string. */
+		while (*cp != '\0')
+			buf[(*i)++] = *cp++;
 	}
+
 }
 
 /*
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

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

only message in thread, other threads:[~2017-08-02 13:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-02 13:29 mandoc: No longer use names that only occur in the SYNOPSIS section as schwarze

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).