Path: utzoo!attcan!uunet!dino!uxc.cso.uiuc.edu!garcon!uicsrd.csrd.uiuc.edu!mcdaniel From: mcdaniel@uicsrd.csrd.uiuc.edu (Tim McDaniel) Newsgroups: comp.std.c Subject: Re: struct comparison Message-ID: <1611@garcon.cso.uiuc.edu> Date: 29 Jul 89 05:39:45 GMT References: <167@ssp1.idca.tds.philips.nl> <12040019@hpfcdc.HP.COM> <2288@auspex.auspex.com> Sender: news@garcon.cso.uiuc.edu Reply-To: mcdaniel@uicsrd.csrd.uiuc.edu (Tim McDaniel) Organization: Center for Supercomputing R&D (Cedar), U. of Ill. Lines: 40 In article <2288@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes: >OK, what if I want to see if one file offset is larger than, or smaller >than, another? ... >Perhaps add and subtract aren't as common as other operators, but I'd >still be a bit annoyed if I couldn't add and subtract file offsets; >unlike structure comparison, I've used addition of file offsets on a >number of occasions. The BSD 4.3 man page for fseek(3S) and ftell(3S) says: _Ftell_ returns the current value of the offset relative to the beginning of the file associated with the named _stream_. It is measured in bytes on UNIX; on some other systems it is a magic cookie, and the only foolproof way to obtain an _offset_ for _fseek_. K&R 2, 1st edition, p. 248, says (for fseek): For a binary file, the position is set to _offset_ characters from _origin_, which may be SEEK_SET (beginning), SEEK_CUR (current postion), or SEEK_END (end of file). For a text stream, _offset_ must be zero, or a value returned by _ftell_ (in which case _origin_ must be SEEK_SET). Thus, in pANS C, a *text* stream offset may indeed be a "magic cookie", for which comparison and arithmetic is undefined. Binary mode requires an actual character number. (Personally, I see no point in having the distinction; I'd like to see all _offset_s be magic cookies. It's too late, now that X3J11 has acted.) -- "Let me control a planet's oxygen supply, and I don't care who makes the laws." - GREAT CTHUHLU'S STARRY WISDOM BAND (via Roger Leroux) __ \ Tim, the Bizarre and Oddly-Dressed Enchanter \ mcdaniel@uicsrd.csrd.uiuc.edu /\ mcdaniel%uicsrd@{uxc.cso.uiuc.edu,uiuc.csnet} _/ \_ {uunet,convex,pur-ee}!uiucuxc!uicsrd!mcdaniel