source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: Improve POSIX compliance by making case-insensitive extended
Date: Mon, 19 Nov 2018 14:28:07 -0500 (EST)	[thread overview]
Message-ID: <381d4c0a272e80a6@fantadrom.bsd.lv> (raw)

Log Message:
-----------
Improve POSIX compliance by making case-insensitive extended 
regular expressions the default in man(1) -k searches, also matching 
what the man-db package used by many Linux distributions does.

Originally requested by Wolfram Schneider <wosch at FreeBSD> 
via Yuri Pankov <yuripv at FreeBSD>.

Feedback and OK cheloha@, and no objections when shown on tech@.

Thanks to cheloha@ for pointing out that POSIX requires this behaviour
and for the suggestion to explicitly say that *extended* regular
expressions are used here.

While here, unify spelling of case-[in]sensitive, fix a typo,
update the EXAMPLES, and add a STANDARDS section.

Modified Files:
--------------
    mandoc:
        apropos.1
        mansearch.c

Revision Data
-------------
Index: apropos.1
===================================================================
RCS file: /home/cvs/mandoc/mandoc/apropos.1,v
retrieving revision 1.47
retrieving revision 1.48
diff -Lapropos.1 -Lapropos.1 -u -p -r1.47 -r1.48
--- apropos.1
+++ apropos.1
@@ -1,7 +1,7 @@
 .\"	$Id$
 .\"
 .\" Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
-.\" Copyright (c) 2011, 2012, 2014, 2017 Ingo Schwarze <schwarze@openbsd.org>
+.\" Copyright (c) 2011,2012,2014,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
 .\"
 .\" Permission to use, copy, modify, and distribute this software for any
 .\" purpose with or without fee is hereby granted, provided that the above
@@ -51,8 +51,7 @@ searches for
 .Xr makewhatis 8
 databases in the default paths stipulated by
 .Xr man 1
-and uses case-insensitive substring matching
-.Pq the Cm = No operator
+and uses case-insensitive extended regular expression matching
 over manual names and descriptions
 .Pq the Li \&Nm No and Li \&Nd No macro keys .
 Multiple terms imply pairwise
@@ -93,7 +92,7 @@ format.
 Search for all words in
 .Ar expression
 in manual page names only.
-The search is case insensitive and matches whole words only.
+The search is case-insensitive and matches whole words only.
 In this mode, macro keys, comparison operators, and logical operators
 are not available.
 .It Fl k
@@ -123,7 +122,7 @@ Restrict the search to pages for the spe
 .Xr machine 1
 architecture.
 .Ar arch
-is case insensitive.
+is case-insensitive.
 By default, pages for all architectures are shown.
 .It Fl s Ar section
 Restrict the search to the specified section of the manual.
@@ -199,7 +198,7 @@ Operator
 .Cm =
 evaluates a substring, while
 .Cm \(ti
-evaluates a regular expression.
+evaluates a case-sensitive extended regular expression.
 .It Fl i Ar term
 If
 .Ar term
@@ -339,7 +338,7 @@ function arguments appearing on
 .Ic \&Fn
 lines
 .It Li \&Fn
-fuction names marked up with
+function names marked up with
 .Ic \&Fo
 macros
 .It Li \&In
@@ -407,7 +406,7 @@ Search for
 .Qq .cf
 as a substring of manual names and descriptions:
 .Pp
-.Dl $ apropos .cf
+.Dl $ apropos =.cf
 .Pp
 Include matches for
 .Qq .cnf
@@ -415,9 +414,9 @@ and
 .Qq .conf
 as well:
 .Pp
-.Dl $ apropos .cf .cnf .conf
+.Dl $ apropos =.cf =.cnf =.conf
 .Pp
-Search in names and descriptions using a regular expression:
+Search in names and descriptions using a case-sensitive regular expression:
 .Pp
 .Dl $ apropos \(aq\(tiset.?[ug]id\(aq
 .Pp
@@ -448,6 +447,24 @@ The following two invocations are equiva
 .Xr man 1 ,
 .Xr re_format 7 ,
 .Xr makewhatis 8
+.Sh STANDARDS
+The
+.Nm
+utility is compliant with the
+.St -p1003.1-2008
+specification of
+.Xr man 1
+.Fl k .
+.Pp
+All options, the
+.Nm whatis
+command, support for logical operators, macro keys,
+substring matching, sorting of results, the environment variables
+.Ev MANPAGER
+and
+.Ev MANPATH ,
+the database format, and the configuration file
+are extensions to that specification.
 .Sh HISTORY
 Part of the functionality of
 .Nm whatis
Index: mansearch.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mansearch.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -Lmansearch.c -Lmansearch.c -u -p -r1.77 -r1.78
--- mansearch.c
+++ mansearch.c
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2013-2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013-2018 Ingo Schwarze <schwarze@openbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -774,8 +774,9 @@ exprterm(const struct mansearch *search,
 		cs = 0;
 	} else if ((val = strpbrk(argv[*argi], "=~")) == NULL) {
 		e->bits = TYPE_Nm | TYPE_Nd;
-		e->match.type = DBM_SUB;
-		e->match.str = argv[*argi];
+		e->match.type = DBM_REGEX;
+		val = argv[*argi];
+		cs = 0;
 	} else {
 		if (val == argv[*argi])
 			e->bits = TYPE_Nm | TYPE_Nd;
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

                 reply	other threads:[~2018-11-19 19:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=381d4c0a272e80a6@fantadrom.bsd.lv \
    --to=schwarze@mandoc.bsd.lv \
    --cc=source@mandoc.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).