[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [BusyBox] -not support in find
From: Andrew Dixon <andrew.dixon () seranoa ! com>
Date: 2001-12-28 0:04:23
[Download RAW message or body]
Hi All,
The following patch gives find in bb-60.2 support for the "-not" flag.
This behaves a bit differently than -not on gnu find. My patch negates
the entire output where gnu find gives you the granularity to negate
only one option.
I also checked out the latest code from CVS. I noticed that the build
system has changed significantly. I'll submit a patch for the code in
CVS once I get it figured out (I haven't really had a chance to look at
it yet so if anyone point me in the right direction that'd be helpful.)
later,
Andy
--
Andrew Dixon
Software Engineer
Seranoa Networks
978.897.3434 x231
["mychanges.patch" (text/plain)]
--- find.c Mon Nov 19 18:34:17 2001
+++ /home/dixon/find.c Thu Dec 27 17:49:01 2001
@@ -3,8 +3,8 @@
* Mini find implementation for busybox
*
*
- * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
- * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+ * Copyright (C) 1999,2000,2001 by Lineo, inc.
+ * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Reworked by David Douthitt <n9ubh@callsign.net> and
* Matt Kraai <kraai@alumni.carnegiemellon.edu>.
*
@@ -37,6 +37,10 @@
static char *pattern;
+#ifdef BB_FEATURE_FIND_NOT
+static int negate = 1;
+#endif /*BB_FEATURE_FIND_NOT*/
+
#ifdef BB_FEATURE_FIND_TYPE
static int type_mask = 0;
#endif
@@ -60,12 +64,20 @@
tmp = fileName;
else
tmp++;
- if (!(fnmatch(pattern, tmp, FNM_PERIOD) == 0))
+ if (!(fnmatch(pattern, tmp, FNM_PERIOD) == 0)
+#ifdef BB_FEATURE_FIND_NOT
+ == negate
+#endif /*BB_FEATURE_FIND_NOT*/
+)
goto no_match;
}
#ifdef BB_FEATURE_FIND_TYPE
if (type_mask != 0) {
- if (!((statbuf->st_mode & S_IFMT) == type_mask))
+ if (!((statbuf->st_mode & S_IFMT) == type_mask)
+#ifdef BB_FEATURE_FIND_NOT
+ == negate
+#endif /*BB_FEATURE_FIND_NOT*/
+)
goto no_match;
}
#endif
@@ -73,7 +85,11 @@
if (perm_mask != 0) {
if (!((isdigit(perm_char) && (statbuf->st_mode & 07777) == perm_mask) ||
(perm_char == '-' && (statbuf->st_mode & perm_mask) == perm_mask) ||
- (perm_char == '+' && (statbuf->st_mode & perm_mask) != 0)))
+ (perm_char == '+' && (statbuf->st_mode & perm_mask) != 0))
+#ifdef BB_FEATURE_FIND_NOT
+ == negate
+#endif /*BB_FEATURE_FIND_NOT*/
+)
goto no_match;
}
#endif
@@ -84,7 +100,11 @@
if (!((isdigit(mtime_char) && mtime_secs >= file_age &&
mtime_secs < file_age + 24 * 60 * 60) ||
(mtime_char == '+' && mtime_secs >= file_age) ||
- (mtime_char == '-' && mtime_secs < file_age)))
+ (mtime_char == '-' && mtime_secs < file_age))
+#ifdef BB_FEATURE_FIND_NOT
+ == negate
+#endif /*BB_FEATURE_FIND_NOT*/
+)
goto no_match;
}
#endif
@@ -150,6 +170,13 @@
if (++i == argc)
error_msg_and_die("option `-name' requires an argument");
pattern = argv[i];
+#ifdef BB_FEATURE_FIND_NOT
+ } else if (strcmp(argv[i], "-not") == 0){
+ if (++i == argc)
+ error_msg_and_die("option '-not' requires an expression");
+ --i;
+ negate = 0;
+#endif /*BB_FEATURE_FIND_NOT*/
#ifdef BB_FEATURE_FIND_TYPE
} else if (strcmp(argv[i], "-type") == 0) {
if (++i == argc)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic