source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Make `-i' only apply to regular expressions.
@ 2011-11-29 10:53 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2011-11-29 10:53 UTC (permalink / raw)
  To: source

Log Message:
-----------
Make `-i' only apply to regular expressions.  For the equality operator
(and thus the default), always use strcasestr().  Discussed on tech@
with schwarze@.  While here, fix the apropos.c usage() message to be
consistent with apropos(1) and clean up the EXAMPLES in apropos(1).

Modified Files:
--------------
    mdocml:
        apropos.1
        apropos_db.c
        apropos.c

Revision Data
-------------
Index: apropos_db.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/apropos_db.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -Lapropos_db.c -Lapropos_db.c -u -p -r1.15 -r1.16
--- apropos_db.c
+++ apropos_db.c
@@ -52,7 +52,6 @@ struct	expr {
 	int		 regex; /* is regex? */
 	int		 index; /* index in match array */
 	uint64_t 	 mask; /* type-mask */
-	int		 cs; /* is case-sensitive? */
 	int		 and; /* is rhs of logical AND? */
 	char		*v; /* search value */
 	regex_t	 	 re; /* compiled re, if regex */
@@ -694,7 +693,6 @@ exprexpr(int argc, char *argv[], int *po
 			++(*pos);
 			++(*lvl);
 			next = mandoc_calloc(1, sizeof(struct expr));
-			next->cs = 1;
 			next->subexpr = exprexpr(argc, argv, pos, lvl, tt);
 			if (NULL == next->subexpr) {
 				free(next);
@@ -745,8 +743,6 @@ exprterm(char *buf, int cs)
 
 	memset(&e, 0, sizeof(struct expr));
 
-	e.cs = cs;
-
 	/* Choose regex or substring match. */
 
 	if (NULL == (e.v = strpbrk(buf, "=~"))) {
@@ -818,13 +814,8 @@ exprmark(const struct expr *p, const cha
 		if (p->regex) {
 			if (regexec(&p->re, cp, 0, NULL, 0))
 				continue;
-		} else if (p->cs) {
-			if (NULL == strstr(cp, p->v))
-				continue;
-		} else {
-			if (NULL == strcasestr(cp, p->v))
-				continue;
-		}
+		} else if (NULL == strcasestr(cp, p->v))
+			continue;
 
 		if (NULL == ms)
 			return(1);
Index: apropos.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/apropos.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -Lapropos.c -Lapropos.c -u -p -r1.21 -r1.22
--- apropos.c
+++ apropos.c
@@ -142,8 +142,8 @@ usage(void)
 {
 
 	fprintf(stderr, "usage: %s "
-			"[-M path] "
-			"[-m path] "
+			"[-M manpath] "
+			"[-m manpath] "
 			"[-S arch] "
 			"[-s section] "
 			"expression...\n",
Index: apropos.1
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/apropos.1,v
retrieving revision 1.10
retrieving revision 1.11
diff -Lapropos.1 -Lapropos.1 -u -p -r1.10 -r1.11
--- apropos.1
+++ apropos.1
@@ -112,11 +112,11 @@ evaluates a substring, while
 .Li \&~
 evaluates a regular expression.
 .It Fl i Ar term
-Same as
-.Ar term ,
-but
+If
 .Ar term
+is a regular expression, it
 is evaluated case-insensitively.
+Has no effect on substring terms.
 .El
 .Pp
 By default,
@@ -125,7 +125,7 @@ searches for
 .Xr mandocdb 8
 databases in the default paths stipulated by
 .Xr man 1 ,
-parses terms as case-insensitive regular expressions
+parses terms as case-sensitive regular expressions
 .Pq the Li \&~ operator
 over manual names and descriptions
 .Pq the Li \&Nm No and Li \&Nd No macro keys .
@@ -238,25 +238,25 @@ Invalid paths, or paths without manual d
 Overridden by
 .Fl M .
 .El
-.\" .Sh FILES
 .Sh EXIT STATUS
 .Ex -std
 .Sh EXAMPLES
 Search for
 .Qq mdoc
-within the manual name and description:
+as a substring and regular expression 
+within each manual name and description:
 .Pp
 .Dl $ apropos mdoc
+.Dl $ apropos ~^mdoc$
 .Pp
-Two variants of searching for
-.Qq mdoc ,
-.Qq roff ,
-or
+Include matches for
+.Qq roff
+and
 .Qq man
-within manual names and descriptions:
+for the regular expression case:
 .Pp
-.Dl $ apropos mdoc roff man
-.Dl $ apropos mdoc \-o roff \-o man
+.Dl $ apropos ~^mdoc$ roff man
+.Dl $ apropos ~^mdoc$ \-o roff \-o man
 .Pp
 Search for
 .Qq optind
@@ -264,17 +264,11 @@ and
 .Qq optarg
 as variable names in the library category:
 .Pp
-.Dl $ apropos \-s 3 \(dqVa~^optind$\(dq -a \(dqVa~^optarg$\(dq
-.Pp
-Search for all manuals referencing
-.Qq POSIX
-in any letter case:
-.Pp
-.Dl $ apropos \-\- \-i posix
+.Dl $ apropos \-s 3 Va~^optind \-a Va~^optarg$
 .Sh SEE ALSO
 .Xr man 1 ,
-.Xr mandoc 1 ,
-.Xr re_format 7
+.Xr re_format 7 ,
+.Xr mandocdb 8
 .Sh AUTHORS
 The
 .Nm
--
 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:[~2011-11-29 10:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-29 10:53 mdocml: Make `-i' only apply to regular expressions 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).