Path: utzoo!mnetor!uunet!vsi!friedl From: friedl@vsi.UUCP (Stephen J. Friedl) Newsgroups: comp.lang.c Subject: a couple of random questions Message-ID: <530@vsi.UUCP> Date: 13 Apr 88 03:57:05 GMT Distribution: comp Organization: V-Systems, Inc. -- Santa Ana, CA Lines: 42 Hiho there, Two random questions. First, the word "entry" used to be a reserved keyword in C but appears to never have been used. Does anybody know the direction it might have taken had its use been implemented? I recall vaguely about a similar keyword in FORTRAN but wonder if anybody has any stories from long ago in days of old. Second, what is the portable way to rewind a Unix file descriptor? On almost every machine I have ever used: lseek(fd, (off_t)0, SEEK_SET); works because the offset is a byte count, but it is inevitable that on some machine, off_t is the pointer to some kind of struct, or at least is *not* simply a byte count. What other machines might work this way? I know that the good old BDS C compiler for the Z-80 measured its offset in records, but nevertheless a zero arg did the trick. Related to this, how about a portable way to back up one record? On the assumption that doing math on an off_t is not portable, I basically save the offset just before a read: #define tell(fd) lseek(fd, (off_t)0, SEEK_CUR) extern off_t lseek( /* int fd, off_t offset, int whence */ ); { off_t off; while (off = tell(fd), read(fd, buf, SIZE) == SIZE) if (some.condition->here) lseek(fd, off, SEEK_SET); /* back up */ Note that this is largely an academic exercise, and I know that using dpANS buffered I/O resolves these issues, but I'm just curious... -- Steve Friedl V-Systems, Inc. "Yes, I'm jeff@unh's brother" friedl@vsi.com {backbones}!vsi.com!friedl attmail!vsi!friedl