Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/find Obey preceding - and + on -user when a numeric ...



details:   https://anonhg.NetBSD.org/src/rev/62b249612d4c
branches:  trunk
changeset: 542475:62b249612d4c
user:      jhawk <jhawk%NetBSD.org@localhost>
date:      Thu Jan 30 10:49:05 2003 +0000

description:
Obey preceding - and + on -user when a numeric uid is specified (only).
Our behavior is now consistent with Solaris, and more useful than previous.

Unfortunately we end up strtol()-ing twice (once via atoi()) to avoid
changing find_parsenum().

diffstat:

 usr.bin/find/function.c |  18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diffs (51 lines):

diff -r 7e002050f058 -r 62b249612d4c usr.bin/find/function.c
--- a/usr.bin/find/function.c   Thu Jan 30 07:46:28 2003 +0000
+++ b/usr.bin/find/function.c   Thu Jan 30 10:49:05 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: function.c,v 1.42 2003/01/26 07:07:31 matt Exp $       */
+/*     $NetBSD: function.c,v 1.43 2003/01/30 10:49:05 jhawk Exp $      */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "from: @(#)function.c   8.10 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: function.c,v 1.42 2003/01/26 07:07:31 matt Exp $");
+__RCSID("$NetBSD: function.c,v 1.43 2003/01/30 10:49:05 jhawk Exp $");
 #endif
 #endif /* not lint */
 
@@ -1552,7 +1552,7 @@
        FTSENT *entry;
 {
 
-       return (entry->fts_statp->st_uid == plan->u_data);
+       COMPARE(entry->fts_statp->st_uid, plan->u_data);
 }
  
 PLAN *
@@ -1568,15 +1568,19 @@
        (*argvp)++;
        ftsoptions &= ~FTS_NOSTAT;
 
+       new = palloc(N_USER, f_user);
        p = getpwnam(username);
        if (p == NULL) {
-               uid = atoi(username);
-               if (uid == 0 && username[0] != '0')
+               if (atoi(username) == 0 && username[0] != '0' &&
+                   strcmp(username, "+0") && strcmp(username, "-0"))
                        errx(1, "-user: %s: no such user", username);
-       } else
+               uid = find_parsenum(new, "-user", username, NULL);
+
+       } else {
+               new->flags = F_EQUAL;
                uid = p->pw_uid;
+       }
 
-       new = palloc(N_USER, f_user);
        new->u_data = uid;
        return (new);
 }



Home | Main Index | Thread Index | Old Index