Skip to contentSkip to conversation

whereis: remove find()

PATCH Applied Davidlohr Bueso 2 participants 2 messages Jul 24, 2011 – Jul 26, 2011 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 whereis: remove find()

From: Davidlohr Bueso <[email protected]>
Date: Sun, 24 Jul 2011 10:59:25 -0400

Because findv() can do the same job find() does, we can simply remove it and call findv() with the size of each array.

---
 misc-utils/whereis.c |   14 +++-----------
 1 files changed, 3 insertions(+), 11 deletions(-)
misc-utils/whereis.c +3 -11
index 4f841f9..a331f45 100644
@@ -55,7 +55,6 @@ void looksrc(char *);
 void lookbin(char *);
 void lookman(char *);
 void findv(char **, int, char *);
-void find(char **, char *);
 void findin(char *, char *);
 int itsit(char *, char *);
 
@@ -321,7 +320,7 @@ void
 looksrc(char *cp)
 {
 	if (Sflag == 0)
-		find(srcdirs, cp);
+		findv(srcdirs, ARRAY_SIZE(srcdirs)-1, cp);
 	else
 		findv(Sflag, Scnt, cp);
 }
@@ -330,7 +329,7 @@ void
 lookbin(char *cp)
 {
 	if (Bflag == 0)
-		find(bindirs, cp);
+		findv(bindirs, ARRAY_SIZE(bindirs)-1, cp);
 	else
 		findv(Bflag, Bcnt, cp);
 }
@@ -339,7 +338,7 @@ void
 lookman(char *cp)
 {
 	if (Mflag == 0)
-		find(mandirs, cp);
+		findv(mandirs, ARRAY_SIZE(mandirs)-1, cp);
 	else
 		findv(Mflag, Mcnt, cp);
 }
@@ -352,13 +351,6 @@ findv(char **dirv, int dirc, char *cp)
 }
 
 void
-find(char **dirs, char *cp)
-{
-	while (*dirs)
-		findin(*dirs++, cp);
-}
-
-void
 findin(char *dir, char *cp)
 {
 	DIR *dirp;
Signature · 1 line
1.7.4.1
maintainer Applied
#1 lore raw
Quoted 2 lines · Davidlohr Bueso
 misc-utils/whereis.c |   14 +++-----------
 1 files changed, 3 insertions(+), 11 deletions(-)

Applied, thanks.

misc-utils/whereis.c void · line 323

Quoted 1 line
misc-utils/whereis.c +1 -0
+		findv(srcdirs, ARRAY_SIZE(srcdirs)-1, cp);

Please, use space around operators

        findv(srcdirs, ARRAY_SIZE(srcdirs) - 1, cp);

:-)

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com