Deleted Added
full compact
find.c (41391) find.c (41398)
1/*-
2 * Copyright (c) 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Cimarron D. Taylor of the University of California, Berkeley.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 36 unchanged lines hidden (view full) ---

45#include <errno.h>
46#include <fts.h>
47#include <stdio.h>
48#include <string.h>
49#include <stdlib.h>
50
51#include "find.h"
52
1/*-
2 * Copyright (c) 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Cimarron D. Taylor of the University of California, Berkeley.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 36 unchanged lines hidden (view full) ---

45#include <errno.h>
46#include <fts.h>
47#include <stdio.h>
48#include <string.h>
49#include <stdlib.h>
50
51#include "find.h"
52
53static int find_compare(const FTSENT **s1, const FTSENT **s2);
53static int find_compare __P((const FTSENT **s1, const FTSENT **s2));
54
55/*
54
55/*
56 * find_compare --
57 * tell fts_open() how to order the traversal of the hierarchy.
58 * This variant gives lexicographical order in each directory.
59 */
60static int
61find_compare(s1, s2)
62 const FTSENT **s1, **s2;
63{
64
65 return (strcoll((*s1)->fts_name, (*s2)->fts_name));
66}
67
68/*
56 * find_formplan --
57 * process the command line and create a "plan" corresponding to the
58 * command arguments.
59 */
60PLAN *
61find_formplan(argv)
62 char **argv;
63{

--- 75 unchanged lines hidden (view full) ---

139 plan = not_squish(plan); /* !'s */
140 plan = or_squish(plan); /* -o's */
141 return (plan);
142}
143
144FTS *tree; /* pointer to top of FTS hierarchy */
145
146/*
69 * find_formplan --
70 * process the command line and create a "plan" corresponding to the
71 * command arguments.
72 */
73PLAN *
74find_formplan(argv)
75 char **argv;
76{

--- 75 unchanged lines hidden (view full) ---

152 plan = not_squish(plan); /* !'s */
153 plan = or_squish(plan); /* -o's */
154 return (plan);
155}
156
157FTS *tree; /* pointer to top of FTS hierarchy */
158
159/*
147 * find_compare --
148 * A function which be used in fts_open() to order the
149 * traversal of the hierarchy.
150 * This function give you a lexicographical sorted output.
151 */
152static int find_compare(s1, s2)
153 const FTSENT **s1, **s2;
154{
155 return strcoll( (*s1)->fts_name, (*s2)->fts_name );
156}
157
158/*
159 * find_execute --
160 * take a search plan and an array of search paths and executes the plan
161 * over all FTSENT's returned for the given search paths.
162 */
163int
164find_execute(plan, paths)
165 PLAN *plan; /* search plan */
166 char **paths; /* array of pathnames to traverse */
167{
168 register FTSENT *entry;
169 PLAN *p;
170 int rval;
171
160 * find_execute --
161 * take a search plan and an array of search paths and executes the plan
162 * over all FTSENT's returned for the given search paths.
163 */
164int
165find_execute(plan, paths)
166 PLAN *plan; /* search plan */
167 char **paths; /* array of pathnames to traverse */
168{
169 register FTSENT *entry;
170 PLAN *p;
171 int rval;
172
172 if ((tree = fts_open(paths, ftsoptions,
173 (issort ? find_compare : NULL) )) == NULL)
173 tree = fts_open(paths, ftsoptions, (issort ? find_compare : NULL));
174 if (tree == NULL)
174 err(1, "ftsopen");
175
176 for (rval = 0; (entry = fts_read(tree)) != NULL;) {
177 switch (entry->fts_info) {
178 case FTS_D:
179 if (isdepth)
180 continue;
181 break;

--- 36 unchanged lines hidden ---
175 err(1, "ftsopen");
176
177 for (rval = 0; (entry = fts_read(tree)) != NULL;) {
178 switch (entry->fts_info) {
179 case FTS_D:
180 if (isdepth)
181 continue;
182 break;

--- 36 unchanged lines hidden ---