discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
* using "bits" comparison in manpage_compare()
@ 2018-10-29 22:41 Yuri Pankov
  2018-11-21 15:17 ` Yuri Pankov
  2018-11-22 12:11 ` Ingo Schwarze
  0 siblings, 2 replies; 3+ messages in thread
From: Yuri Pankov @ 2018-10-29 22:41 UTC (permalink / raw)
  To: discuss

Hi,

It looks like using "bits" comparison in manpage_compare() leads to
somewhat inconsistent output sorting for apropos(1), reported as
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=227408.

So I've proposed the change below as a "fix", any thoughts on it?

Index: contrib/mandoc/mansearch.c
===================================================================
--- contrib/mandoc/mansearch.c
+++ contrib/mandoc/mansearch.c
@@ -412,8 +412,7 @@

 	mp1 = vp1;
 	mp2 = vp2;
-	if ((diff = mp2->bits - mp1->bits) ||
-	    (diff = mp1->sec - mp2->sec))
+	if ((diff = mp1->sec - mp2->sec) != 0)
 		return diff;

 	/* Fall back to alphabetic ordering of names. */
--
 To unsubscribe send an email to discuss+unsubscribe@mandoc.bsd.lv

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: using "bits" comparison in manpage_compare()
  2018-10-29 22:41 using "bits" comparison in manpage_compare() Yuri Pankov
@ 2018-11-21 15:17 ` Yuri Pankov
  2018-11-22 12:11 ` Ingo Schwarze
  1 sibling, 0 replies; 3+ messages in thread
From: Yuri Pankov @ 2018-11-21 15:17 UTC (permalink / raw)
  To: discuss


[-- Attachment #1.1: Type: text/plain, Size: 773 bytes --]

Yuri Pankov wrote:
> Hi,
> 
> It looks like using "bits" comparison in manpage_compare() leads to
> somewhat inconsistent output sorting for apropos(1), reported as
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=227408.
> 
> So I've proposed the change below as a "fix", any thoughts on it?
> 
> Index: contrib/mandoc/mansearch.c
> ===================================================================
> --- contrib/mandoc/mansearch.c
> +++ contrib/mandoc/mansearch.c
> @@ -412,8 +412,7 @@
> 
>  	mp1 = vp1;
>  	mp2 = vp2;
> -	if ((diff = mp2->bits - mp1->bits) ||
> -	    (diff = mp1->sec - mp2->sec))
> +	if ((diff = mp1->sec - mp2->sec) != 0)
>  		return diff;
> 
>  	/* Fall back to alphabetic ordering of names. */

Any thoughts on this?


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: using "bits" comparison in manpage_compare()
  2018-10-29 22:41 using "bits" comparison in manpage_compare() Yuri Pankov
  2018-11-21 15:17 ` Yuri Pankov
@ 2018-11-22 12:11 ` Ingo Schwarze
  1 sibling, 0 replies; 3+ messages in thread
From: Ingo Schwarze @ 2018-11-22 12:11 UTC (permalink / raw)
  To: Yuri Pankov; +Cc: discuss, Edward Tomasz Napierala

Hi Yuri, hi Edward,

Yuri Pankov wrote on Tue, Oct 30, 2018 at 01:41:23AM +0300:

> It looks like using "bits" comparison in manpage_compare() leads to
> somewhat inconsistent output sorting for apropos(1), reported as
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=227408.
> 
> So I've proposed the change below as a "fix", any thoughts on it?

I think you are right, the feature wasn't even documented.
Besides, i have been trying to gradually reduce the importance
of the .Nm bits magic over the years, it is less useful than we
originally thought, and it tends to cause confusion.

Thanks for the suggestion,
  Ingo


Log Message:
-----------
In apropos(1) output, stop sorting .Nm search results by name 
priorities (bits).  The obscure feature wasn't documented and merely 
confused people - for example Edward Tomasz Napierala <trasz at
FreeBSD>, see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=227408.

Smaller patch provided by Yuri Pankov <yuripv at FreeBSD>, but i'm 
also retiring the now unused "bits" member from struct manpage.
Simplification is good.

Modified Files:
--------------
    mandoc:
        main.c
        mansearch.c
        mansearch.h

Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/main.c,v
retrieving revision 1.309
retrieving revision 1.310
diff -Lmain.c -Lmain.c -u -p -r1.309 -r1.310
--- main.c
+++ main.c
@@ -405,7 +405,6 @@ main(int argc, char *argv[])
 				res[sz].names = NULL;
 				res[sz].output = NULL;
 				res[sz].ipath = SIZE_MAX;
-				res[sz].bits = 0;
 				res[sz].sec = 10;
 				res[sz].form = FORM_SRC;
 				sz++;
@@ -754,7 +753,6 @@ found:
 	page->names = NULL;
 	page->output = NULL;
 	page->ipath = ipath;
-	page->bits = NAME_FILE & NAME_MASK;
 	page->sec = (*sec >= '1' && *sec <= '9') ? *sec - '1' + 1 : 10;
 	page->form = form;
 	return 1;
Index: mansearch.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mansearch.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -Lmansearch.c -Lmansearch.c -u -p -r1.78 -r1.79
--- mansearch.c
+++ mansearch.c
@@ -201,7 +201,6 @@ mansearch(const struct mansearch *search
 			mpage->names = buildnames(page);
 			mpage->output = buildoutput(outkey, page);
 			mpage->ipath = i;
-			mpage->bits = rp->bits;
 			mpage->sec = *page->sect - '0';
 			if (mpage->sec < 0 || mpage->sec > 9)
 				mpage->sec = 10;
@@ -296,10 +295,8 @@ manmerge_term(struct expr *e, struct oha
 				break;
 			slot = ohash_lookup_memory(htab,
 			    (char *)&res, sizeof(res.page), res.page);
-			if ((rp = ohash_find(htab, slot)) != NULL) {
-				rp->bits |= res.bits;
+			if ((rp = ohash_find(htab, slot)) != NULL)
 				continue;
-			}
 			rp = mandoc_malloc(sizeof(*rp));
 			*rp = res;
 			ohash_insert(htab, slot, rp);
@@ -412,8 +409,7 @@ manpage_compare(const void *vp1, const v
 
 	mp1 = vp1;
 	mp2 = vp2;
-	if ((diff = mp2->bits - mp1->bits) ||
-	    (diff = mp1->sec - mp2->sec))
+	if ((diff = mp1->sec - mp2->sec))
 		return diff;
 
 	/* Fall back to alphabetic ordering of names. */
Index: mansearch.h
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mansearch.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -Lmansearch.h -Lmansearch.h -u -p -r1.28 -r1.29
--- mansearch.h
+++ mansearch.h
@@ -93,7 +93,6 @@ struct	manpage {
 	char		*names; /* a list of names with sections */
 	char		*output; /* user-defined additional output */
 	size_t		 ipath; /* number of the manpath */
-	uint64_t	 bits; /* name type mask */
 	int		 sec; /* section number, 10 means invalid */
 	enum form	 form;
 };
--
 To unsubscribe send an email to discuss+unsubscribe@mandoc.bsd.lv

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-22 12:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-29 22:41 using "bits" comparison in manpage_compare() Yuri Pankov
2018-11-21 15:17 ` Yuri Pankov
2018-11-22 12:11 ` Ingo 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).