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_Reno release
[unix-history]
/
usr
/
src
/
usr.bin
/
file
/
file.c
diff --git
a/usr/src/usr.bin/file/file.c
b/usr/src/usr.bin/file/file.c
index
4842095
..
a14c39b
100644
(file)
--- a/
usr/src/usr.bin/file/file.c
+++ b/
usr/src/usr.bin/file/file.c
@@
-1,5
+1,5
@@
#ifndef lint
#ifndef lint
-static char sccsid[] = "@(#)file.c 4.1
0 (Berkeley) %G%
";
+static char sccsid[] = "@(#)file.c 4.1
7 (Berkeley) 7/1/90
";
#endif
/*
* file - determine type of file
#endif
/*
* file - determine type of file
@@
-7,12
+7,13
@@
static char sccsid[] = "@(#)file.c 4.10 (Berkeley) %G%";
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/stat.h>
+#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <a.out.h>
#include <stdio.h>
#include <ctype.h>
#include <a.out.h>
-int errno;
-
int sys_nerr
;
-char *sys_errlist[];
+
+
extern int errno
;
+
int in;
int i = 0;
char buf[BUFSIZ];
int in;
int i = 0;
char buf[BUFSIZ];
@@
-41,7
+42,6
@@
char **argv;
FILE *fl;
register char *p;
char ap[MAXPATHLEN + 1];
FILE *fl;
register char *p;
char ap[MAXPATHLEN + 1];
- extern char _sobuf[];
if (argc < 2) {
fprintf(stderr, "usage: %s file ...\n", argv[0]);
if (argc < 2) {
fprintf(stderr, "usage: %s file ...\n", argv[0]);
@@
-57,7
+57,6
@@
char **argv;
int l = strlen(p);
if (l>0)
p[l-1] = '\0';
int l = strlen(p);
if (l>0)
p[l-1] = '\0';
- printf("%s: ", p);
type(p);
if (ifile>=0)
close(ifile);
type(p);
if (ifile>=0)
close(ifile);
@@
-65,7
+64,6
@@
char **argv;
exit(1);
}
while(argc > 1) {
exit(1);
}
while(argc > 1) {
- printf("%s: ", argv[1]);
type(argv[1]);
fflush(stdout);
argc--;
type(argv[1]);
fflush(stdout);
argc--;
@@
-86,10
+84,10
@@
char *file;
ifile = -1;
if (lstat(file, &mbuf) < 0) {
ifile = -1;
if (lstat(file, &mbuf) < 0) {
- printf("%s\n",
- (unsigned)errno < sys_nerr? sys_errlist[errno]: "Cannot stat");
+ fprintf(stderr, "file: %s: %s\n", file, strerror(errno));
return;
}
return;
}
+ printf("%s:\t", file);
switch (mbuf.st_mode & S_IFMT) {
case S_IFLNK:
switch (mbuf.st_mode & S_IFMT) {
case S_IFLNK:
@@
-111,8
+109,8
@@
char *file;
case S_IFCHR:
case S_IFBLK:
printf("%s special (%d/%d)\n",
case S_IFCHR:
case S_IFBLK:
printf("%s special (%d/%d)\n",
-
mbuf.st_mode&S_IFMT
== S_IFCHR ? "character" : "block",
-
major(mbuf.st_rdev), minor(mbuf.st_rdev));
+
(mbuf.st_mode&S_IFMT)
== S_IFCHR ? "character" : "block",
+ major(mbuf.st_rdev), minor(mbuf.st_rdev));
return;
case S_IFSOCK:
return;
case S_IFSOCK:
@@
-122,8
+120,7
@@
char *file;
ifile = open(file, 0);
if(ifile < 0) {
ifile = open(file, 0);
if(ifile < 0) {
- printf("%s\n",
- (unsigned)errno < sys_nerr? sys_errlist[errno]: "Cannot read");
+ fprintf(stderr, "file: %s: %s\n", file, strerror(errno));
return;
}
in = read(ifile, buf, BUFSIZ);
return;
}
in = read(ifile, buf, BUFSIZ);
@@
-176,6
+173,12
@@
exec:
if (buf[0] == '#' && buf[1] == '!' && shellscript(buf+2, &mbuf))
return;
if (buf[0] == '#' && buf[1] == '!' && shellscript(buf+2, &mbuf))
return;
+ if (buf[0] == '\037' && buf[1] == '\235') {
+ if (buf[2]&0x80)
+ printf("block ");
+ printf("compressed %d bit code data\n", buf[2]&0x1f);
+ return;
+ }
if(strncmp(buf, "!<arch>\n__.SYMDEF", 17) == 0 ) {
printf("archive random library\n");
return;
if(strncmp(buf, "!<arch>\n__.SYMDEF", 17) == 0 ) {
printf("archive random library\n");
return;
@@
-414,7
+417,7
@@
char *bp;
ct[j]=0;
for(j=0; j<n; j++)
{
ct[j]=0;
for(j=0; j<n; j++)
{
- if (bp[j]<NASC)
+ if (
(u_char)
bp[j]<NASC)
ct[bp[j]|040]++;
switch (bp[j])
{
ct[bp[j]|040]++;
switch (bp[j])
{