=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/find/function.c,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- src/usr.bin/find/function.c 2023/03/08 04:43:10 1.53 +++ src/usr.bin/find/function.c 2023/04/01 05:27:44 1.54 @@ -1,4 +1,4 @@ -/* $OpenBSD: function.c,v 1.53 2023/03/08 04:43:10 guenther Exp $ */ +/* $OpenBSD: function.c,v 1.54 2023/04/01 05:27:44 tb Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -123,7 +123,7 @@ { long long value; char *endchar, *str; /* Pointer to character ending conversion. */ - + /* Determine comparison from leading + or -. */ str = vp; switch (*str) { @@ -139,7 +139,7 @@ plan->flags = F_EQUAL; break; } - + /* * Convert the string with strtoll(). Note, if strtoll() returns * zero and endchar points to the beginning of the string we know @@ -206,7 +206,7 @@ COMPARE((now - entry->fts_statp->st_atime + SECSPERDAY - 1) / SECSPERDAY, plan->sec_data); } - + PLAN * c_atime(char *arg, char ***ignored, int unused) { @@ -261,7 +261,7 @@ COMPARE((now - entry->fts_statp->st_ctime + SECSPERDAY - 1) / SECSPERDAY, plan->sec_data); } - + PLAN * c_ctime(char *arg, char ***ignored, int unused) { @@ -287,7 +287,7 @@ { return (1); } - + PLAN * c_depth(char *ignore, char ***ignored, int unused) { @@ -352,7 +352,7 @@ return (palloc(N_DELETE, f_delete)); } - + /* * -empty functions -- * @@ -491,8 +491,8 @@ plan->ep_bxp[plan->ep_narg] = NULL; /* Don't mix output of command with find output. */ - fflush(stdout); - fflush(stderr); + fflush(stdout); + fflush(stderr); switch (pid = vfork()) { case -1: @@ -528,7 +528,7 @@ if (rval) plan->ep_rval = rval; } - + /* * c_exec -- * build three parallel arrays, one with pointers to the strings passed @@ -552,7 +552,7 @@ errx(1, "%s: cannot open \".\"", isok ? "-ok" : "-exec"); isoutput = 1; - + new = palloc(N_EXEC, f_exec); if (isok) new->flags |= F_NEEDOK; @@ -621,8 +621,8 @@ argv < ap; ++argv, ++cnt) { c += strlen(*argv) + 1; - new->e_argv[cnt] = *argv; - } + new->e_argv[cnt] = *argv; + } if (arg_max < 4 * 1024 + c) errx(1, "-exec: no space left to run child command"); bufsize = arg_max - 4 * 1024 - c; @@ -655,13 +655,13 @@ } } new->e_orig[cnt] = NULL; - } + } new->e_argv[cnt] = NULL; *argvp = argv + 1; return (new); } - + /* * -execdir utility [arg ... ] ; functions -- * @@ -726,7 +726,7 @@ pid = waitpid(pid, &status, 0); return (pid != -1 && WIFEXITED(status) && !WEXITSTATUS(status)); } - + /* * c_execdir -- * build three parallel arrays, one with pointers to the strings passed @@ -743,7 +743,7 @@ ftsoptions &= ~FTS_NOSTAT; isoutput = 1; - + new = palloc(N_EXECDIR, f_execdir); for (ap = argv = *argvp;; ++ap) { @@ -822,7 +822,7 @@ new->fl_mask = flags | notflags; return (new); } - + /* * -follow functions -- * @@ -837,7 +837,7 @@ return (palloc(N_FOLLOW, f_always_true)); } - + /* * -fstype functions -- * @@ -871,8 +871,8 @@ p[0] = '.'; save[1] = p[1]; p[1] = '\0'; - - } else + + } else p = NULL; if (statfs(entry->fts_accpath, &sb)) @@ -894,21 +894,21 @@ } switch (plan->flags) { case F_MTFLAG: - return (val & plan->mt_data); + return (val & plan->mt_data); case F_MTTYPE: return (strncmp(fstype, plan->c_data, MFSNAMELEN) == 0); default: abort(); } } - + PLAN * c_fstype(char *arg, char ***ignored, int unused) { PLAN *new; - + ftsoptions &= ~FTS_NOSTAT; - + new = palloc(N_FSTYPE, f_fstype); switch (*arg) { case 'l': @@ -931,7 +931,7 @@ new->c_data = arg; return (new); } - + /* * -group gname functions -- * @@ -944,13 +944,13 @@ { return (entry->fts_statp->st_gid == plan->g_data); } - + PLAN * c_group(char *gname, char ***ignored, int unused) { PLAN *new; gid_t gid; - + ftsoptions &= ~FTS_NOSTAT; if (gid_from_group(gname, &gid) == -1) { @@ -960,7 +960,7 @@ if (errstr) errx(1, "-group: %s: no such group", gname); } - + new = palloc(N_GROUP, f_group); new->g_data = gid; return (new); @@ -976,15 +976,15 @@ { COMPARE(entry->fts_statp->st_ino, plan->i_data); } - + PLAN * c_inum(char *arg, char ***ignored, int unused) { long long inum; PLAN *new; - + ftsoptions &= ~FTS_NOSTAT; - + new = palloc(N_INUM, f_inum); inum = find_parsenum(new, "-inum", arg, NULL); if (inum != (ino_t)inum) @@ -992,7 +992,7 @@ new->i_data = inum; return (new); } - + /* * -links n functions -- * @@ -1003,15 +1003,15 @@ { COMPARE(entry->fts_statp->st_nlink, plan->l_data); } - + PLAN * c_links(char *arg, char ***ignored, int unused) { PLAN *new; long long nlink; - + ftsoptions &= ~FTS_NOSTAT; - + new = palloc(N_LINKS, f_links); nlink = find_parsenum(new, "-links", arg, NULL); if (nlink != (nlink_t)nlink) @@ -1019,7 +1019,7 @@ new->l_data = nlink; return (new); } - + /* * -ls functions -- * @@ -1031,13 +1031,13 @@ printlong(entry->fts_path, entry->fts_accpath, entry->fts_statp); return (1); } - + PLAN * c_ls(char *ignore, char ***ignored, int unused) { ftsoptions &= ~FTS_NOSTAT; isoutput = 1; - + return (palloc(N_LS, f_ls)); } @@ -1108,7 +1108,7 @@ COMPARE((now - entry->fts_statp->st_mtime + SECSPERDAY - 1) / SECSPERDAY, plan->sec_data); } - + PLAN * c_mtime(char *arg, char ***ignored, int unused) { @@ -1161,7 +1161,7 @@ { return (!fnmatch(plan->c_data, entry->fts_name, 0)); } - + PLAN * c_name(char *pattern, char ***ignored, int unused) { @@ -1176,14 +1176,14 @@ * -iname functions -- * * Similar to -name, but does case insensitive matching - * + * */ int f_iname(PLAN *plan, FTSENT *entry) { return (!fnmatch(plan->c_data, entry->fts_name, FNM_CASEFOLD)); } - + PLAN * c_iname(char *pattern, char ***ignored, int unused) { @@ -1193,7 +1193,7 @@ new->c_data = pattern; return (new); } - + /* * -newer file functions -- * @@ -1209,13 +1209,13 @@ (entry->fts_statp->st_mtimespec.tv_sec == plan->t_data.tv_sec && entry->fts_statp->st_mtimespec.tv_nsec > plan->t_data.tv_nsec)); } - + PLAN * c_newer(char *filename, char ***ignored, int unused) { PLAN *new; struct stat sb; - + ftsoptions &= ~FTS_NOSTAT; if (stat(filename, &sb)) @@ -1224,7 +1224,7 @@ memcpy(&new->t_data, &sb.st_mtimespec, sizeof(struct timespec)); return (new); } - + /* * -anewer file functions -- * @@ -1240,13 +1240,13 @@ (entry->fts_statp->st_atimespec.tv_sec == plan->t_data.tv_sec && entry->fts_statp->st_atimespec.tv_nsec > plan->t_data.tv_nsec)); } - + PLAN * c_anewer(char *filename, char ***ignored, int unused) { PLAN *new; struct stat sb; - + ftsoptions &= ~FTS_NOSTAT; if (stat(filename, &sb)) @@ -1255,7 +1255,7 @@ memcpy(&new->t_data, &sb.st_atimespec, sizeof(struct timespec)); return (new); } - + /* * -cnewer file functions -- * @@ -1271,13 +1271,13 @@ (entry->fts_statp->st_ctimespec.tv_sec == plan->t_data.tv_sec && entry->fts_statp->st_ctimespec.tv_nsec > plan->t_data.tv_nsec)); } - + PLAN * c_cnewer(char *filename, char ***ignored, int unused) { PLAN *new; struct stat sb; - + ftsoptions &= ~FTS_NOSTAT; if (stat(filename, &sb)) @@ -1286,7 +1286,7 @@ memcpy(&new->t_data, &sb.st_ctimespec, sizeof(struct timespec)); return (new); } - + /* * -nogroup functions -- * @@ -1298,7 +1298,7 @@ { return (group_from_gid(entry->fts_statp->st_gid, 1) ? 0 : 1); } - + PLAN * c_nogroup(char *ignore, char ***ignored, int unused) { @@ -1306,7 +1306,7 @@ return (palloc(N_NOGROUP, f_nogroup)); } - + /* * -nouser functions -- * @@ -1318,7 +1318,7 @@ { return (user_from_uid(entry->fts_statp->st_uid, 1) ? 0 : 1); } - + PLAN * c_nouser(char *ignore, char ***ignored, int unused) { @@ -1326,7 +1326,7 @@ return (palloc(N_NOUSER, f_nouser)); } - + /* * -path functions -- * @@ -1338,7 +1338,7 @@ { return (!fnmatch(plan->c_data, entry->fts_path, 0)); } - + PLAN * c_path(char *pattern, char ***ignored, int unused) { @@ -1348,7 +1348,7 @@ new->c_data = pattern; return (new); } - + /* * -perm functions -- * @@ -1369,7 +1369,7 @@ return (mode == plan->m_data); /* NOTREACHED */ } - + PLAN * c_perm(char *perm, char ***ignored, int unused) { @@ -1392,7 +1392,7 @@ free(set); return (new); } - + /* * -print functions -- * @@ -1413,7 +1413,7 @@ (void)fputc('\0', stdout); return(1); } - + PLAN * c_print(char *ignore, char ***ignored, int unused) { @@ -1429,7 +1429,7 @@ return(palloc(N_PRINT0, f_print0)); } - + /* * -prune functions -- * @@ -1443,13 +1443,13 @@ err(1, "%s", entry->fts_path); return (1); } - + PLAN * c_prune(char *ignore, char ***ignored, int unused) { return (palloc(N_PRUNE, f_prune)); } - + /* * -size n[c] functions -- * @@ -1469,13 +1469,13 @@ FIND_SIZE : entry->fts_statp->st_size; COMPARE(size, plan->o_data); } - + PLAN * c_size(char *arg, char ***ignored, int unused) { PLAN *new; char endch; - + ftsoptions &= ~FTS_NOSTAT; new = palloc(N_SIZE, f_size); @@ -1485,7 +1485,7 @@ divsize = 0; return (new); } - + /* * -type c functions -- * @@ -1498,13 +1498,13 @@ { return ((entry->fts_statp->st_mode & S_IFMT) == plan->m_data); } - + PLAN * c_type(char *typestring, char ***ignored, int unused) { PLAN *new; mode_t mask; - + ftsoptions &= ~FTS_NOSTAT; switch (typestring[0]) { @@ -1532,12 +1532,12 @@ default: errx(1, "-type: %s: unknown type", typestring); } - + new = palloc(N_TYPE, f_type); new->m_data = mask; return (new); } - + /* * -user uname functions -- * @@ -1550,13 +1550,13 @@ { return (entry->fts_statp->st_uid == plan->u_data); } - + PLAN * c_user(char *username, char ***ignored, int unused) { PLAN *new; uid_t uid; - + ftsoptions &= ~FTS_NOSTAT; if (uid_from_user(username, &uid) == -1) { @@ -1571,7 +1571,7 @@ new->u_data = uid; return (new); } - + /* * -xdev functions -- * @@ -1601,7 +1601,7 @@ p && (state = (p->eval)(p, entry)); p = p->next); return (state); } - + /* * N_OPENPAREN and N_CLOSEPAREN nodes are temporary place markers. They are * eliminated during phase 2 of find_formplan() --- the '(' node is converted @@ -1612,13 +1612,13 @@ { return (palloc(N_OPENPAREN, (int (*)(PLAN *, FTSENT *))-1)); } - + PLAN * c_closeparen(char *ignore, char ***ignored, int unused) { return (palloc(N_CLOSEPAREN, (int (*)(PLAN *, FTSENT *))-1)); } - + /* * ! expression functions -- * @@ -1634,13 +1634,13 @@ p && (state = (p->eval)(p, entry)); p = p->next); return (!state); } - + PLAN * c_not(char *ignore, char ***ignored, int unused) { return (palloc(N_NOT, f_not)); } - + /* * expression -o expression functions -- * @@ -1677,7 +1677,7 @@ * and if so, clean it up as appropriate. * * At the moment, only N_EXEC has state. Two kinds: 1) - * lists of files to feed to subprocesses 2) State on exit + * lists of files to feed to subprocesses 2) State on exit * status of past subprocesses. */ int