diff options
author | nate <nate@FreeBSD.org> | 1996-12-03 21:56:15 +0000 |
---|---|---|
committer | nate <nate@FreeBSD.org> | 1996-12-03 21:56:15 +0000 |
commit | 2596f6cfcadce74d72c67c1edafafe2a4a0214ce (patch) | |
tree | cc698233b7c99a5d4f5ee226fe4c0c0a23f19f52 /gnu/usr.bin/perl | |
parent | 8620fc8544ff62f29a19ab194cb21a092e314a97 (diff) | |
download | FreeBSD-src-2596f6cfcadce74d72c67c1edafafe2a4a0214ce.zip FreeBSD-src-2596f6cfcadce74d72c67c1edafafe2a4a0214ce.tar.gz |
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>
Diffstat (limited to 'gnu/usr.bin/perl')
-rw-r--r-- | gnu/usr.bin/perl/perl/doio.c | 22 | ||||
-rw-r--r-- | gnu/usr.bin/perl/perl/tdoio.c | 23 |
2 files changed, 43 insertions, 2 deletions
diff --git a/gnu/usr.bin/perl/perl/doio.c b/gnu/usr.bin/perl/perl/doio.c index 9c0731f..0ace377 100644 --- a/gnu/usr.bin/perl/perl/doio.c +++ b/gnu/usr.bin/perl/perl/doio.c @@ -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 @@ -1221,8 +1224,25 @@ STR *str; 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 { if (dowarn) diff --git a/gnu/usr.bin/perl/perl/tdoio.c b/gnu/usr.bin/perl/perl/tdoio.c index 1cd6269..cd5d480 100644 --- a/gnu/usr.bin/perl/perl/tdoio.c +++ b/gnu/usr.bin/perl/perl/tdoio.c @@ -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 * @@ -1214,8 +1217,26 @@ STR *str; 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 { if (dowarn) |