Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/find Add new primaries -asince, -csince, and -since ...



details:   https://anonhg.NetBSD.org/src/rev/daa796a9cf7b
branches:  trunk
changeset: 345881:daa796a9cf7b
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Mon Jun 13 00:04:40 2016 +0000

description:
Add new primaries -asince, -csince, and -since to compare file's
attributes against a user-specified timestamp (rather than the
attributes of a reference file).

Update the parse routines so they have access to the name of the
option being parsed.  This enables accurate error reporting for
"aliases" of primaries.

Now that aliases work, introduce some aliases for consistency with
Gnu findutils.

diffstat:

 usr.bin/find/extern.h   |   99 +++++++++--------
 usr.bin/find/find.1     |   42 +++++++-
 usr.bin/find/find.c     |   12 +-
 usr.bin/find/find.h     |   18 +-
 usr.bin/find/function.c |  263 ++++++++++++++++++++++++++++++++++-------------
 usr.bin/find/option.c   |   49 +++++++-
 6 files changed, 337 insertions(+), 146 deletions(-)

diffs (truncated from 1208 to 300 lines):

diff -r 52b0720e7616 -r daa796a9cf7b usr.bin/find/extern.h
--- a/usr.bin/find/extern.h     Sun Jun 12 22:25:13 2016 +0000
+++ b/usr.bin/find/extern.h     Mon Jun 13 00:04:40 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.28 2007/07/19 07:49:30 daniel Exp $       */
+/*     $NetBSD: extern.h,v 1.29 2016/06/13 00:04:40 pgoyette Exp $     */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -47,53 +47,56 @@
 int     queryuser(char **);
 void    show_path(int);
 
-PLAN   *c_amin(char ***, int);
-PLAN   *c_anewer(char ***, int);
-PLAN   *c_atime(char ***, int);
-PLAN   *c_cmin(char ***, int);
-PLAN   *c_cnewer(char ***, int);
-PLAN   *c_ctime(char ***, int);
-PLAN   *c_delete(char ***, int);
-PLAN   *c_depth(char ***, int);
-PLAN   *c_empty(char ***, int);
-PLAN   *c_exec(char ***, int);
-PLAN   *c_execdir(char ***, int);
-PLAN   *c_exit(char ***, int);
-PLAN   *c_false(char ***, int);
-PLAN   *c_flags(char ***, int);
-PLAN   *c_follow(char ***, int);
-PLAN   *c_fprint(char ***, int);
-PLAN   *c_fstype(char ***, int);
-PLAN   *c_group(char ***, int);
-PLAN   *c_iname(char ***, int);
-PLAN   *c_inum(char ***, int);
-PLAN   *c_iregex(char ***, int);
-PLAN   *c_links(char ***, int);
-PLAN   *c_ls(char ***, int);
-PLAN   *c_maxdepth(char ***, int);
-PLAN   *c_mindepth(char ***, int);
-PLAN   *c_mmin(char ***, int);
-PLAN   *c_mtime(char ***, int);
-PLAN   *c_name(char ***, int);
-PLAN   *c_newer(char ***, int);
-PLAN   *c_nogroup(char ***, int);
-PLAN   *c_nouser(char ***, int);
-PLAN   *c_path(char ***, int);
-PLAN   *c_perm(char ***, int);
-PLAN   *c_print(char ***, int);
-PLAN   *c_print0(char ***, int);
-PLAN   *c_printx(char ***, int);
-PLAN   *c_prune(char ***, int);
-PLAN   *c_regex(char ***, int);
-PLAN   *c_size(char ***, int);
-PLAN   *c_type(char ***, int);
-PLAN   *c_user(char ***, int);
-PLAN   *c_xdev(char ***, int);
-PLAN   *c_openparen(char ***, int);
-PLAN   *c_closeparen(char ***, int);
-PLAN   *c_not(char ***, int);
-PLAN   *c_or(char ***, int);
-PLAN   *c_null(char ***, int);
+PLAN   *c_amin(char ***, int, char *);
+PLAN   *c_anewer(char ***, int, char *);
+PLAN   *c_asince(char ***, int, char *);
+PLAN   *c_atime(char ***, int, char *);
+PLAN   *c_cmin(char ***, int, char *);
+PLAN   *c_cnewer(char ***, int, char *);
+PLAN   *c_csince(char ***, int, char *);
+PLAN   *c_ctime(char ***, int, char *);
+PLAN   *c_delete(char ***, int, char *);
+PLAN   *c_depth(char ***, int, char *);
+PLAN   *c_empty(char ***, int, char *);
+PLAN   *c_exec(char ***, int, char *);
+PLAN   *c_execdir(char ***, int, char *);
+PLAN   *c_exit(char ***, int, char *);
+PLAN   *c_false(char ***, int, char *);
+PLAN   *c_flags(char ***, int, char *);
+PLAN   *c_follow(char ***, int, char *);
+PLAN   *c_fprint(char ***, int, char *);
+PLAN   *c_fstype(char ***, int, char *);
+PLAN   *c_group(char ***, int, char *);
+PLAN   *c_iname(char ***, int, char *);
+PLAN   *c_inum(char ***, int, char *);
+PLAN   *c_iregex(char ***, int, char *);
+PLAN   *c_links(char ***, int, char *);
+PLAN   *c_ls(char ***, int, char *);
+PLAN   *c_maxdepth(char ***, int, char *);
+PLAN   *c_mindepth(char ***, int, char *);
+PLAN   *c_mmin(char ***, int, char *);
+PLAN   *c_mtime(char ***, int, char *);
+PLAN   *c_name(char ***, int, char *);
+PLAN   *c_newer(char ***, int, char *);
+PLAN   *c_nogroup(char ***, int, char *);
+PLAN   *c_nouser(char ***, int, char *);
+PLAN   *c_path(char ***, int, char *);
+PLAN   *c_perm(char ***, int, char *);
+PLAN   *c_print(char ***, int, char *);
+PLAN   *c_print0(char ***, int, char *);
+PLAN   *c_printx(char ***, int, char *);
+PLAN   *c_prune(char ***, int, char *);
+PLAN   *c_regex(char ***, int, char *);
+PLAN   *c_since(char ***, int, char *);
+PLAN   *c_size(char ***, int, char *);
+PLAN   *c_type(char ***, int, char *);
+PLAN   *c_user(char ***, int, char *);
+PLAN   *c_xdev(char ***, int, char *);
+PLAN   *c_openparen(char ***, int, char *);
+PLAN   *c_closeparen(char ***, int, char *);
+PLAN   *c_not(char ***, int, char *);
+PLAN   *c_or(char ***, int, char *);
+PLAN   *c_null(char ***, int, char *);
 
 extern int ftsoptions, isdeprecated, isdepth, isoutput, issort, isxargs,
        regcomp_flags;
diff -r 52b0720e7616 -r daa796a9cf7b usr.bin/find/find.1
--- a/usr.bin/find/find.1       Sun Jun 12 22:25:13 2016 +0000
+++ b/usr.bin/find/find.1       Mon Jun 13 00:04:40 2016 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: find.1,v 1.85 2016/06/12 22:25:13 pgoyette Exp $
+.\"    $NetBSD: find.1,v 1.86 2016/06/13 00:04:40 pgoyette Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"    from: @(#)find.1        8.7 (Berkeley) 5/9/95
 .\"
-.Dd June 12, 2016
+.Dd June 13, 2016
 .Dt FIND 1
 .Os
 .Sh NAME
@@ -178,6 +178,12 @@
 are similarly treated if the value is numeric and does not correspond to a
 valid user or group name.)
 .Pp
+For primaries which take a
+.Ar timestamp
+argument, the argument must be valid input to
+.Xr parsedate 3 .
+If the argument contains multiple words, enclose the argument in quotes.
+.Pp
 .Bl -tag -width Ds -compact
 .It Ic -amin Ar n
 True if the difference between the file last access time and the time
@@ -190,6 +196,10 @@
 True if the current file has a more recent last access time than
 .Ar file .
 .Pp
+.It Ic -asince Ar "timestamp"
+True if the file last access time is greater than the specified
+.Ar timestamp .
+.Pp
 .It Ic -atime Ar n
 True if the difference between the file last access time and the time
 .Nm
@@ -209,6 +219,10 @@
 True if the current file has a more recent last change time than
 .Ar file .
 .Pp
+.It Ic -csince Ar "timestamp"
+True if the file last status change time is greater than the specified
+.Ar timestamp .
+.Pp
 .It Ic -ctime Ar n
 True if the difference between the time of last change of file status
 information and the time
@@ -532,6 +546,21 @@
 True if the current file has a more recent last modification time than
 .Ar file .
 .Pp
+.It Ic -newerXY Ar reference
+For compatability with Gnu findutils.
+.Bl -column -offset indent ".Sy findutils" ".Sy equivalent"
+.It Sy findutils Ta Sy find
+.It Sy option Ta Sy equivalent
+.It -neweraa Ta -anewer
+.It -newerat Ta -asince
+.It -newercc Ta -cnewer
+.It -newerct Ta -csince
+.It -newermm Ta -newer
+.It -newermt Ta -since
+.El
+.Pp
+Other option variants from findutils are not implemented.
+.Pp
 .It Ic -nouser
 True if the file belongs to an unknown user.
 .Pp
@@ -644,6 +673,10 @@
 This is a match on the whole path, not a search for the regular expression
 within the path.
 .Pp
+.It Ic -since Ar "timestamp"
+True if the file last modification time is more recent than
+.Ar timestamp .
+.Pp
 .It Ic -size Ar n Ns Op Cm c
 True if the file's size, rounded up, in 512-byte blocks is
 .Ar n .
@@ -816,8 +849,10 @@
 The options and the
 .Ic -amin ,
 .Ic -anewer ,
+.Ic -asince ,
 .Ic -cmin ,
 .Ic -cnewer ,
+.Ic -csince ,
 .Ic -delete ,
 .Ic -empty ,
 .Ic -execdir ,
@@ -835,8 +870,9 @@
 .Ic -print0 ,
 .Ic -printx ,
 .Ic -regex ,
+.Ic -rm ,
 and
-.Ic -rm
+.Ic -since
 primaries are extensions to
 .St -p1003.2 .
 .Pp
diff -r 52b0720e7616 -r daa796a9cf7b usr.bin/find/find.c
--- a/usr.bin/find/find.c       Sun Jun 12 22:25:13 2016 +0000
+++ b/usr.bin/find/find.c       Mon Jun 13 00:04:40 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: find.c,v 1.29 2012/03/20 20:34:57 matt Exp $   */
+/*     $NetBSD: find.c,v 1.30 2016/06/13 00:04:40 pgoyette Exp $       */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "from: @(#)find.c       8.5 (Berkeley) 8/5/94";
 #else
-__RCSID("$NetBSD: find.c,v 1.29 2012/03/20 20:34:57 matt Exp $");
+__RCSID("$NetBSD: find.c,v 1.30 2016/06/13 00:04:40 pgoyette Exp $");
 #endif
 #endif /* not lint */
 
@@ -102,16 +102,16 @@
         */
        if (!isoutput) {
                if (plan == NULL) {
-                       new = c_print(NULL, 0);
+                       new = c_print(NULL, 0, NULL);
                        tail = plan = new;
                } else {
-                       new = c_openparen(NULL, 0);
+                       new = c_openparen(NULL, 0, NULL);
                        new->next = plan;
                        plan = new;
-                       new = c_closeparen(NULL, 0);
+                       new = c_closeparen(NULL, 0, NULL);
                        tail->next = new;
                        tail = new;
-                       new = c_print(NULL, 0);
+                       new = c_print(NULL, 0, NULL);
                        tail->next = new;
                        tail = new;
                }
diff -r 52b0720e7616 -r daa796a9cf7b usr.bin/find/find.h
--- a/usr.bin/find/find.h       Sun Jun 12 22:25:13 2016 +0000
+++ b/usr.bin/find/find.h       Mon Jun 13 00:04:40 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: find.h,v 1.25 2013/05/04 06:29:32 uebayasi Exp $       */
+/*     $NetBSD: find.h,v 1.26 2016/06/13 00:04:40 pgoyette Exp $       */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -40,13 +40,13 @@
 /* node type */
 enum ntype {
        N_AND = 1,                              /* must start > 0 */
-       N_AMIN, N_ANEWER, N_ATIME, N_CLOSEPAREN, N_CMIN, N_CNEWER, N_CTIME,
-       N_DEPTH, N_EMPTY, N_EXEC, N_EXECDIR, N_EXIT, N_EXPR, N_FALSE, N_FLAGS,
-       N_FOLLOW, N_FPRINT, N_FSTYPE, N_GROUP,
+       N_AMIN, N_ANEWER, N_ASINCE, N_ATIME, N_CLOSEPAREN, N_CMIN, N_CNEWER,
+       N_CSINCE, N_CTIME, N_DEPTH, N_EMPTY, N_EXEC, N_EXECDIR, N_EXIT,
+       N_EXPR, N_FALSE, N_FLAGS, N_FOLLOW, N_FPRINT, N_FSTYPE, N_GROUP,
        N_INAME, N_INUM, N_IREGEX, N_LINKS, N_LS, N_MINDEPTH, N_MAXDEPTH,
        N_MMIN, N_MTIME, N_NAME, N_NEWER, N_NOGROUP, N_NOT, N_NOUSER, N_OK,
        N_OPENPAREN, N_OR, N_PATH, N_PERM, N_PRINT, N_PRINT0, N_PRINTX,
-       N_PRUNE, N_REGEX, N_SIZE, N_TYPE, N_USER, N_XDEV, N_DELETE
+       N_PRUNE, N_REGEX, N_SINCE, N_SIZE, N_TYPE, N_USER, N_XDEV, N_DELETE
 };
 
 /* node definition */
@@ -129,10 +129,10 @@
 #define        fprint_file     p_un._fprint_file
 
 typedef struct _option {
-       const char *name;               /* option name */
-       enum ntype token;               /* token type */
-       PLAN *(*create)(char ***, int); /* create function */
-       int arg;                        /* function needs arg */
+       const char *name;                       /* option name */
+       enum ntype token;                       /* token type */
+       PLAN *(*create)(char ***, int, char *); /* create function */
+       int arg;                                /* function needs arg */
 } OPTION;



Home | Main Index | Thread Index | Old Index