projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
BSD 4_3_Tahoe release
[unix-history]
/
usr
/
src
/
usr.bin
/
find
/
find.c
diff --git
a/usr/src/usr.bin/find/find.c
b/usr/src/usr.bin/find/find.c
index
d8eab78
..
1c17130
100644
(file)
--- a/
usr/src/usr.bin/find/find.c
+++ b/
usr/src/usr.bin/find/find.c
@@
-1,12
+1,11
@@
#ifndef lint
#ifndef lint
-static char *sccsid = "@(#)find.c 4.2
3 (Berkeley) %G%
";
+static char *sccsid = "@(#)find.c 4.2
0 (Berkeley) 9/28/87
";
#endif
#endif
+#include <stdio.h>
#include <sys/param.h>
#include <sys/dir.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/dir.h>
#include <sys/stat.h>
-#include <stdio.h>
-#include "pathnames.h"
#define A_DAY 86400L /* a day full of seconds */
#define EQ(x, y) (strcmp(x, y)==0)
#define A_DAY 86400L /* a day full of seconds */
#define EQ(x, y) (strcmp(x, y)==0)
@@
-53,8
+52,8
@@
char *rindex();
char *sbrk();
/*
char *sbrk();
/*
- * SEE ALSO:
code.c, updatedb, bigram
.c
- * Usenix ;login:,
Vol 8, No 1,
February/March, 1983, p. 8.
+ * SEE ALSO:
updatedb, bigram.c, code
.c
+ * Usenix ;login:, February/March, 1983, p. 8.
*
* REVISIONS: James A. Woods, Informatics General Corporation,
* NASA Ames Research Center, 6/81.
*
* REVISIONS: James A. Woods, Informatics General Corporation,
* NASA Ames Research Center, 6/81.
@@
-96,8
+95,6
@@
main(argc, argv)
}
#endif
time(&Now);
}
#endif
time(&Now);
- setpassent(1);
- setgroupent(1);
#ifdef SUID_PWD
pwd = popen("pwd", "r");
fgets(Home, sizeof Home, pwd);
#ifdef SUID_PWD
pwd = popen("pwd", "r");
fgets(Home, sizeof Home, pwd);
@@
-794,7
+791,7
@@
chgreel(x, fl)
again:
fprintf(stderr, "If you want to go on, type device/file name %s\n",
"when ready");
again:
fprintf(stderr, "If you want to go on, type device/file name %s\n",
"when ready");
- devtty = fopen(
_PATH_TTY
, "r");
+ devtty = fopen(
"/dev/tty"
, "r");
fgets(str, 20, devtty);
str[strlen(str) - 1] = '\0';
if(!*str)
fgets(str, 20, devtty);
str[strlen(str) - 1] = '\0';
if(!*str)
@@
-817,9
+814,9
@@
again:
* The codes are:
*
* 0-28 likeliest differential counts + offset to make nonnegative
* The codes are:
*
* 0-28 likeliest differential counts + offset to make nonnegative
- * 30
switch
code for out-of-range count to follow in next word
- * 128-255 bigram codes (128 most common, as determined by 'updatedb')
- * 32-127 single character (printable) ascii residue
(ie, literal)
+ * 30
escape
code for out-of-range count to follow in next word
+ * 128-255 bigram codes
,
(128 most common, as determined by 'updatedb')
+ * 32-127 single character (printable) ascii residue
*
* A novel two-tiered string search technique is employed:
*
*
* A novel two-tiered string search technique is employed:
*
@@
-833,10
+830,11
@@
again:
* provided in the standard 'find'.
*/
* provided in the standard 'find'.
*/
-#include "find.h"
-
+#define FCODES "/usr/lib/find/find.codes"
#define YES 1
#define NO 0
#define YES 1
#define NO 0
+#define OFFSET 14
+#define ESCCODE 30
fastfind ( pathpart )
char pathpart[];
fastfind ( pathpart )
char pathpart[];
@@
-844,36
+842,38
@@
fastfind ( pathpart )
register char *p, *s;
register int c;
char *q, *index(), *patprep();
register char *p, *s;
register int c;
char *q, *index(), *patprep();
- int
count = 0, found = NO
, globflag;
+ int
i, count = 0
, globflag;
FILE *fp, *fopen();
char *patend, *cutoff;
FILE *fp, *fopen();
char *patend, *cutoff;
- char path[MAXPATHLEN];
- char bigram1[NBG], bigram2[NBG];
+ char path[1024];
+ char bigram1[128], bigram2[128];
+ int found = NO;
- if ( (fp = fopen (
_PATH_
FCODES, "r" )) == NULL ) {
-
perror( _PATH_
FCODES );
+ if ( (fp = fopen ( FCODES, "r" )) == NULL ) {
+
fprintf ( stderr, "find: can't open %s\n",
FCODES );
exit ( 1 );
}
exit ( 1 );
}
- for (
c = 0, p = bigram1, s = bigram2; c < NBG; c
++ )
-
p[c] = getc ( fp ), s[c
] = getc ( fp );
+ for (
i = 0; i < 128; i
++ )
+
bigram1[i] = getc ( fp ), bigram2[i
] = getc ( fp );
- p = pathpart;
-
globflag = index ( p, '*' ) || index ( p, '?' ) || index ( p
, '[' );
- patend = patprep ( p );
+ globflag = index ( pathpart, '*' ) || index ( pathpart, '?' ) ||
+
index ( pathpart
, '[' );
+ patend = patprep ( p
athpart
);
- for ( c = getc ( fp ); c != EOF; ) {
+ c = getc ( fp );
+ for ( ; ; ) {
- count += ( (c ==
SWITCH
) ? getw ( fp ) : c ) - OFFSET;
+ count += ( (c ==
ESCCODE
) ? getw ( fp ) : c ) - OFFSET;
- for ( p = path + count; (c = getc ( fp )) >
SWITCH; )
/* overlay old path */
- if ( c <
PARITY )
+ for ( p = path + count; (c = getc ( fp )) >
ESCCODE; )
/* overlay old path */
+ if ( c <
0200 )
*p++ = c;
*p++ = c;
- else
{
/* bigrams are parity-marked */
-
c &= PARITY-1
;
- *p++ = bigram1[c], *p++ = bigram2[c];
- }
+ else /* bigrams are parity-marked */
+
*p++ = bigram1[c & 0177], *p++ = bigram2[c & 0177]
;
+ if ( c == EOF )
+ break;
*p-- = NULL;
*p-- = NULL;
- cutoff = ( found ? path : path + count
);
+ cutoff = ( found ? path : path + count);
for ( found = NO, s = p; s >= cutoff; s-- )
if ( *s == *patend ) { /* fast first char check */
for ( found = NO, s = p; s >= cutoff; s-- )
if ( *s == *patend ) { /* fast first char check */
@@
-973,6
+973,9
@@
getname(uid)
register struct passwd *pw;
struct passwd *getpwent();
register int cp;
register struct passwd *pw;
struct passwd *getpwent();
register int cp;
+ extern int _pw_stayopen;
+
+ _pw_stayopen = 1;
#if (((NUID) & ((NUID) - 1)) != 0)
cp = uid % (NUID);
#if (((NUID) & ((NUID) - 1)) != 0)
cp = uid % (NUID);
@@
-1043,6
+1046,11
@@
getuid(username)
{
register struct passwd *pw;
struct passwd *getpwnam();
{
register struct passwd *pw;
struct passwd *getpwnam();
+#ifndef NO_PW_STAYOPEN
+ extern int _pw_stayopen;
+
+ _pw_stayopen = 1;
+#endif
pw = getpwnam(username);
if (pw != NULL)
pw = getpwnam(username);
if (pw != NULL)