13 if (arg[1].arg_type & A_DONT) {
14 if (arg[1].arg_ptr.arg_stab == defstab) {
16 stio = stab_io(statstab);
23 statstab = arg[1].arg_ptr.arg_stab;
25 stio = stab_io(statstab);
27 if (stio && stio->ifp) {
28 #if defined(STDSTDIO) || defined(atarist) /* this will work with atariST */
29 fstat(fileno(stio->ifp),&statcache);
30 if (S_ISDIR(statcache.st_mode)) /* handle NFS glitch */
31 return arg->arg_type == O_FTTEXT ? &str_no : &str_yes;
32 if (stio->ifp->_cnt <= 0) {
35 (void)ungetc(i,stio->ifp);
37 if (stio->ifp->_cnt <= 0) /* null file is anything */
39 len = stio->ifp->_cnt + (stio->ifp->_ptr - stio->ifp->_base);
42 fatal("-T and -B not implemented on filehandles");
47 warn("Test on unopened file <%s>",
48 stab_ename(arg[1].arg_ptr.arg_stab));
55 str_set(statname,str_get(TARG));
57 i = open(str_get(TARG),0);
59 if (dowarn && index(str_get(TARG), '\n'))
60 warn(warn_nl, "open");
64 len = read(i,tbuf,512);
67 if (S_ISDIR(statcache.st_mode) && arg->arg_type == O_FTTEXT)
68 return &str_no; /* special case NFS directories */
69 return &str_yes; /* null file is anything */
74 /* now scan s to look for textiness */
76 for (i = 0; i < len; i++,s++) {
77 if (!*s) { /* null never allowed in text */
84 *s != '\n' && *s != '\r' && *s != '\b' &&
85 *s != '\t' && *s != '\f' && *s != 27)
89 if ((odd * 10 > len) == (arg->arg_type == O_FTTEXT)) /* allow 10% odd */