mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-18 10:35:55 +00:00
Added support for '-T' and '-B' (text and binary) file recognition by
peeking inside of Chris Torek's stdio library internals. This is similar to the code used for other systems, but didn't work on CT's new implementation. Submitted by: Gary Kline <kline@tera.com>
This commit is contained in:
parent
680026d67a
commit
e744d38673
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=20121
@ -1,4 +1,4 @@
|
||||
/* $RCSfile: doio.c,v $$Revision: 1.2 $$Date: 1994/09/11 03:17:32 $
|
||||
/* $RCSfile: doio.c,v $$Revision: 1.3 $$Date: 1995/05/30 05:03:00 $
|
||||
*
|
||||
* Copyright (c) 1991, Larry Wall
|
||||
*
|
||||
@ -6,6 +6,9 @@
|
||||
* License or the Artistic License, as specified in the README file.
|
||||
*
|
||||
* $Log: doio.c,v $
|
||||
* Revision 1.3 1995/05/30 05:03:00 rgrimes
|
||||
* Remove trailing whitespace.
|
||||
*
|
||||
* Revision 1.2 1994/09/11 03:17:32 gclarkii
|
||||
* Changed AF_LOCAL to AF_LOCAL_XX so as not to conflict with 4.4 socket.h
|
||||
* Added casts to shutup warnings in doio.c
|
||||
@ -1220,8 +1223,25 @@ STR *str;
|
||||
return &str_yes;
|
||||
len = stio->ifp->_cnt + (stio->ifp->_ptr - stio->ifp->_base);
|
||||
s = stio->ifp->_base;
|
||||
#else
|
||||
#if (defined(BSD) && (BSD >= 199103))
|
||||
fstat(fileno(stio->ifp),&statcache);
|
||||
if (S_ISDIR(statcache.st_mode)) /* handle NFS glitch */
|
||||
return arg->arg_type == O_FTTEXT ? &str_no : &str_yes;
|
||||
|
||||
if (stio->ifp->_bf._size <= 0) {
|
||||
i = getc(stio->ifp);
|
||||
if (i != EOF)
|
||||
(void)ungetc(i,stio->ifp);
|
||||
}
|
||||
|
||||
if (stio->ifp->_bf._size <= 0)
|
||||
return &str_yes;
|
||||
len = stio->ifp->_bf._size+(stio->ifp->_p - stio->ifp->_bf._base);
|
||||
s = stio->ifp->_bf._base;
|
||||
#else
|
||||
fatal("-T and -B not implemented on filehandles");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $RCSfile: tdoio.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:36 $
|
||||
/* $RCSfile: tdoio.c,v $$Revision: 1.2 $$Date: 1995/05/30 05:03:23 $
|
||||
*
|
||||
* Copyright (c) 1991, Larry Wall
|
||||
*
|
||||
@ -6,6 +6,9 @@
|
||||
* License or the Artistic License, as specified in the README file.
|
||||
*
|
||||
* $Log: tdoio.c,v $
|
||||
* Revision 1.2 1995/05/30 05:03:23 rgrimes
|
||||
* Remove trailing whitespace.
|
||||
*
|
||||
* Revision 1.1.1.1 1994/09/10 06:27:36 gclarkii
|
||||
* Initial import of Perl 4.046 bmaked
|
||||
*
|
||||
@ -1213,8 +1216,26 @@ STR *str;
|
||||
return &str_yes;
|
||||
len = stio->ifp->_cnt + (stio->ifp->_ptr - stio->ifp->_base);
|
||||
s = stio->ifp->_base;
|
||||
#else
|
||||
#if (defined(BSD) && (BSD >= 199103))
|
||||
s = stio->ifp->_base;
|
||||
fstat(fileno(stio->ifp),&statcache);
|
||||
if (S_ISDIR(statcache.st_mode)) /* handle NFS glitch */
|
||||
return arg->arg_type == O_FTTEXT ? &str_no : &str_yes;
|
||||
|
||||
if (stio->ifp->_bf._size <= 0) {
|
||||
i = getc(stio->ifp);
|
||||
if (i != EOF)
|
||||
(void)ungetc(i,stio->ifp);
|
||||
}
|
||||
|
||||
if (stio->ifp->_bf._size <= 0)
|
||||
return &str_yes;
|
||||
len = stio->ifp->_bf._size+(stio->ifp->_p - stio->ifp->_bf._base);
|
||||
s = stio->ifp->_bf._base;
|
||||
#else
|
||||
fatal("-T and -B not implemented on filehandles");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user