[2062] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

-B FILE in linux perl not implemented? or why my stdio ain't std

daemon@ATHENA.MIT.EDU (Calvin Clark)
Thu Jul 1 16:40:46 1993

Date: Thu, 6 May 93 16:59 EDT
From: Calvin Clark <ckclark@mit.edu>
To: perl-users@athena.mit.edu

[ Pardon me if this is a FAQ, but there is no FAQ for comp.lang.perl on
the new pit-manager, bloom-picayune. ]

When I try to use -B on a filehandle to determine whether or not the
file is a binary file, I get the error:

	-T and -B not implemented on filehandles

I have only seen this on the linux box (quiche), but it should occur on
any system with "stdio that's not quite std," because of the following
lines in doio.c:

  1192  #if defined(STDSTDIO) || defined(atarist) /* this will work with atariST
  1193              fstat(fileno(stio->ifp),&statcache);
  1194              if (S_ISDIR(statcache.st_mode))     /* handle NFS glitch */
  1195                  return arg->arg_type == O_FTTEXT ? &str_no : &str_yes;
  1196              if (stio->ifp->_cnt <= 0) {
  1197                  i = getc(stio->ifp);
  1198                  if (i != EOF)
  1199                      (void)ungetc(i,stio->ifp);
  1200              }
  1201              if (stio->ifp->_cnt <= 0)   /* null file is anything */
  1202                  return &str_yes;
  1203              len = stio->ifp->_cnt + (stio->ifp->_ptr - stio->ifp->_base)
  1204              s = stio->ifp->_base;
  1205  #else
  1206              fatal("-T and -B not implemented on filehandles");
  1207  #endif

(Configure looks for _cnt in <stdio.h> to determine whether or not it can
get away with this code.  If you don't have it, then your stdio isn't
very std, I guess.)

Ahem.  Has any complained about this yet?

Perl version is 4.035.

-Calvin

home help back first fref pref prev next nref lref last post