SCCS-vsn: usr.bin/find/find.c 4.35
SCCS-vsn: usr.bin/find/find.h 5.3
SCCS-vsn: usr.bin/find/function.c 5.11
SCCS-vsn: usr.bin/find/misc.c 5.5
SCCS-vsn: usr.bin/find/operator.c 5.2
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)find.c 4.34 (Berkeley) %G%";
+static char sccsid[] = "@(#)find.c 4.35 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
char **argv;
{
PLAN *plan, *tail, *new;
char **argv;
{
PLAN *plan, *tail, *new;
- PLAN *c_print(), *find_create(), *find_squish_not(), *find_squish_or();
- PLAN *find_squish_paren();
+ PLAN *c_print(), *find_create(), *not_squish(), *or_squish();
+ PLAN *paren_squish();
/*
* for each argument in the command line, determine what kind of node
/*
* for each argument in the command line, determine what kind of node
* operators are handled in order of precedence.
*/
* operators are handled in order of precedence.
*/
- plan = find_squish_paren(plan); /* ()'s */
- plan = find_squish_not(plan); /* !'s */
- plan = find_squish_or(plan); /* -o's */
+ plan = paren_squish(plan); /* ()'s */
+ plan = not_squish(plan); /* !'s */
+ plan = or_squish(plan); /* -o's */
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)find.h 5.2 (Berkeley) %G%
+ * @(#)find.h 5.3 (Berkeley) %G%
extern int ftsoptions;
extern int isdeprecated, isdepth, isoutput, isrelative, isstopdnx;
extern int ftsoptions;
extern int isdeprecated, isdepth, isoutput, isrelative, isstopdnx;
-static char sccsid[] = "@(#)function.c 5.10 (Berkeley) %G%";
+static char sccsid[] = "@(#)function.c 5.11 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
register int cnt;
union wait pstat;
pid_t pid, waitpid();
register int cnt;
union wait pstat;
pid_t pid, waitpid();
for (cnt = 0; plan->e_argv[cnt]; ++cnt)
if (plan->e_len[cnt])
for (cnt = 0; plan->e_argv[cnt]; ++cnt)
if (plan->e_len[cnt])
- find_subst(plan->e_orig[cnt], &plan->e_argv[cnt],
+ brace_subst(plan->e_orig[cnt], &plan->e_argv[cnt],
entry->fts_accpath, plan->e_len[cnt]);
entry->fts_accpath, plan->e_len[cnt]);
- if (plan->flags && !find_queryuser(plan->e_argv))
+ if (plan->flags && !queryuser(plan->e_argv))
return(0);
switch(pid = vfork()) {
return(0);
switch(pid = vfork()) {
ftsoptions &= ~FTS_NOSTAT;
NEW(T_LINKS, f_links);
ftsoptions &= ~FTS_NOSTAT;
NEW(T_LINKS, f_links);
- new->l_data = find_parsenum(new, "-links", arg, (char *)NULL);
+ new->l_data = (nlink_t)find_parsenum(new, "-links", arg, (char *)NULL);
-static char sccsid[] = "@(#)misc.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)misc.c 5.5 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
#include <sys/errno.h>
#include <stdio.h>
#include "find.h"
#include <sys/errno.h>
#include <stdio.h>
#include "find.h"
+#include <stdlib.h>
+#include <string.h>
* Replace occurrences of {} in s1 with s2 and return the result string.
*/
* Replace occurrences of {} in s1 with s2 and return the result string.
*/
-find_subst(orig, store, path, len)
+void
+brace_subst(orig, store, path, len)
char *orig, **store, *path;
int len;
{
register int plen;
register char ch, *p;
char *orig, **store, *path;
int len;
{
register int plen;
register char ch, *p;
- char *realloc(), *strerror();
plen = strlen(path);
for (p = *store; ch = *orig; ++orig)
plen = strlen(path);
for (p = *store; ch = *orig; ++orig)
* print a message to standard error and then read input from standard
* input. If the input is 'y' then 1 is returned.
*/
* print a message to standard error and then read input from standard
* input. If the input is 'y' then 1 is returned.
*/
(void)fprintf(stderr, "\"%s", *argv);
while (*++argv)
(void)fprintf(stderr, " %s", *argv);
(void)fprintf(stderr, "\"? ");
(void)fflush(stderr);
(void)fprintf(stderr, "\"%s", *argv);
while (*++argv)
(void)fprintf(stderr, " %s", *argv);
(void)fprintf(stderr, "\"? ");
(void)fflush(stderr);
- return(!fgets(buf, sizeof(buf), stdin) || buf[0] != 'y' ? 0 : 1);
+
+ first = ch = getchar();
+ for (nl = 0;;) {
+ if (ch == '\n') {
+ nl = 1;
+ break;
+ }
+ if (ch == EOF)
+ break;
+ ch = getchar();
+ }
+
+ if (!nl) {
+ (void)fprintf(stderr, "\n");
+ (void)fflush(stderr);
+ }
+ return(first == 'y');
* emalloc --
* malloc with error checking.
*/
* emalloc --
* malloc with error checking.
*/
emalloc(len)
u_int len;
{
emalloc(len)
u_int len;
{
- char *p, *malloc(), *strerror();
if (!(p = malloc(len))) {
(void)fprintf(stderr, "find: %s.\n", strerror(errno));
if (!(p = malloc(len))) {
(void)fprintf(stderr, "find: %s.\n", strerror(errno));
-static char sccsid[] = "@(#)operator.c 5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)operator.c 5.2 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#include <stdio.h>
#include "find.h"
#endif /* not lint */
#include <sys/types.h>
#include <stdio.h>
#include "find.h"
* destructively removes the top from the plan
*/
PLAN *
* destructively removes the top from the plan
*/
PLAN *
PLAN **planp; /* pointer to top of plan (modified) */
{
PLAN *node; /* top node removed from the plan */
PLAN **planp; /* pointer to top of plan (modified) */
{
PLAN *node; /* top node removed from the plan */
* Removes one expression from the plan. This is used mainly by
* Removes one expression from the plan. This is used mainly by
- * find_squish_paren. In comments below, an expression is either
- * a simple node or a T_EXPR node containing a list of simple nodes.
+ * paren_squish. In comments below, an expression is either a
+ * simple node or a T_EXPR node containing a list of simple nodes.
PLAN **planp; /* pointer to top of plan (modified) */
{
register PLAN *next; /* temp node holding subexpression results */
PLAN **planp; /* pointer to top of plan (modified) */
{
register PLAN *next; /* temp node holding subexpression results */
int f_expr();
/* first pull the top node from the plan */
int f_expr();
/* first pull the top node from the plan */
- if ((node = find_yanknode(planp)) == NULL)
+ if ((node = yanknode(planp)) == NULL)
*/
if (node->type == T_OPENPAREN)
for (tail = subplan = NULL;;) {
*/
if (node->type == T_OPENPAREN)
for (tail = subplan = NULL;;) {
- if ((next = find_yankexpr(planp)) == NULL)
+ if ((next = yankexpr(planp)) == NULL)
bad_arg("(", "missing closing ')'");
/*
* If we find a closing ')' we store the collected
bad_arg("(", "missing closing ')'");
/*
* If we find a closing ')' we store the collected
* replaces "parentheisized" plans in our search plan with "expr" nodes.
*/
PLAN *
* replaces "parentheisized" plans in our search plan with "expr" nodes.
*/
PLAN *
PLAN *plan; /* plan with ( ) nodes */
{
register PLAN *expr; /* pointer to next expression */
PLAN *plan; /* plan with ( ) nodes */
{
register PLAN *expr; /* pointer to next expression */
- * the basic idea is to have find_yankexpr do all our work and just
+ * the basic idea is to have yankexpr do all our work and just
* collect it's results together.
*/
* collect it's results together.
*/
- while ((expr = find_yankexpr(&plan)) != NULL) {
+ while ((expr = yankexpr(&plan)) != NULL) {
/*
* if we find an unclaimed ')' it means there is a missing
* '(' someplace.
/*
* if we find an unclaimed ')' it means there is a missing
* '(' someplace.
* compresses "!" expressions in our search plan.
*/
PLAN *
* compresses "!" expressions in our search plan.
*/
PLAN *
PLAN *plan; /* plan to process */
{
register PLAN *next; /* next node being processed */
PLAN *plan; /* plan to process */
{
register PLAN *next; /* next node being processed */
tail = result = next = NULL;
tail = result = next = NULL;
- while ((next = find_yanknode(&plan)) != NULL) {
+ while ((next = yanknode(&plan)) != NULL) {
/*
* if we encounter a ( expression ) then look for nots in
* the expr subplan.
*/
if (next->type == T_EXPR)
/*
* if we encounter a ( expression ) then look for nots in
* the expr subplan.
*/
if (next->type == T_EXPR)
- next->p_data[0] = find_squish_not(next->p_data[0]);
+ next->p_data[0] = not_squish(next->p_data[0]);
/*
* if we encounter a not, then snag the next node and place
/*
* if we encounter a not, then snag the next node and place
if (next->type == T_NOT) {
int notlevel = 1;
if (next->type == T_NOT) {
int notlevel = 1;
- node = find_yanknode(&plan);
+ node = yanknode(&plan);
while (node->type == T_NOT) {
++notlevel;
while (node->type == T_NOT) {
++notlevel;
- node = find_yanknode(&plan);
+ node = yanknode(&plan);
}
if (node == NULL)
bad_arg("!", "no following expression");
}
if (node == NULL)
bad_arg("!", "no following expression");
* compresses -o expressions in our search plan.
*/
PLAN *
* compresses -o expressions in our search plan.
*/
PLAN *
PLAN *plan; /* plan with ors to be squished */
{
register PLAN *next; /* next node being processed */
PLAN *plan; /* plan with ors to be squished */
{
register PLAN *next; /* next node being processed */
tail = result = next = NULL;
tail = result = next = NULL;
- while ((next = find_yanknode(&plan)) != NULL) {
+ while ((next = yanknode(&plan)) != NULL) {
/*
* if we encounter a ( expression ) then look for or's in
* the expr subplan.
*/
if (next->type == T_EXPR)
/*
* if we encounter a ( expression ) then look for or's in
* the expr subplan.
*/
if (next->type == T_EXPR)
- next->p_data[0] = find_squish_or(next->p_data[0]);
+ next->p_data[0] = or_squish(next->p_data[0]);
/* if we encounter a not then look for not's in the subplan */
if (next->type == T_NOT)
/* if we encounter a not then look for not's in the subplan */
if (next->type == T_NOT)
- next->p_data[0] = find_squish_or(next->p_data[0]);
+ next->p_data[0] = or_squish(next->p_data[0]);
/*
* if we encounter an or, then place our collected plan in the
/*
* if we encounter an or, then place our collected plan in the
if (result == NULL)
bad_arg("-o", "no expression before -o");
next->p_data[0] = result;
if (result == NULL)
bad_arg("-o", "no expression before -o");
next->p_data[0] = result;
- next->p_data[1] = find_squish_or(plan);
+ next->p_data[1] = or_squish(plan);
if (next->p_data[1] == NULL)
bad_arg("-o", "no expression after -o");
return(next);
if (next->p_data[1] == NULL)
bad_arg("-o", "no expression after -o");
return(next);