[PYTHONMAC-SIG] UNIX files
Jon Stevens
jon@aggroup.com
Wed, 9 Oct 1996 14:07:46 -0800
> I'm not Jack, but I think there's only one or two places where modules
> are opened. I wonder if we could open the file in binary mode and if
> we detect a CR in the first 512 bytes, reopen it in text mode... The
> same hack should work for Windows! On Unix, don't do this at all.
>
> --Guido van Rossum (home page: http://www.python.org/~guido/)
not really knowing how python reads in the files...would something
like this work for you guys?
--just trying to be slightly helpful..:)
// this function gets one line from a file regardless of unix/mac/dos
int getline ( char *s, FILE *in )
{
int c, i =3D 0;
while ( MAXLINE >=3D i ) {
c =3D fgetc(in);
if ( c =3D=3D EOF ) return 0;
if ( c =3D=3D '\r' || c =3D=3D '\n' ) {
s[i] =3D '\0';
return ( 1 );
}
s[i] =3D c;
i++;
}
return ( 0 );
}
-jon
Jon (no h) S. Stevens kid@latchkey.com
ClearInk WebMagus http://www.clearink.com/
finger pgp@sparc.clearink.com for pgp pub key
people in cars cause accidents
accidents in cars cause people
=================
PYTHONMAC-SIG - SIG on Python for the Apple Macintosh
send messages to: pythonmac-sig@python.org
administrivia to: pythonmac-sig-request@python.org
=================