Re: Pop's Device, was Re: Some Newb Problem with "int", please help.

From: Alex Monjushko (monjushko_at_hotmail.com)
Date: 09/23/04


Date: 23 Sep 2004 17:59:08 GMT

Arthur J. O'Dwyer <ajo@nospam.andrew.cmu.edu> wrote:

> On Wed, 22 Sep 2004, Dan Pop wrote:
>>
>> "Arthur J. O'Dwyer" <ajo@nospam.andrew.cmu.edu> writes:
>>> There may be problems (and usually are, IME), however, when you
>>> compile pete's code on a Unix or Linux implementation and then try to
>>> feed it a text file generated on a DOS or Windows system.
>>
>> You're invoking undefined behaviour in this case: you're opening in text
>> mode a file which is not a text file (on the platform opening it).

> True. That doesn't mean we should never try to do something reasonable
> with it, though. (I'm not saying one should /always/ catch weird
> newlines, but for programs that need maximum robustness and
> user-friendliness I do think it's one of the first things to do.)

How can you do something reasonable after invoking undefined behavior?

If your file is not formatted to be a text file on the system you are on
then, by definition, it is not a text file and you should not be treating
it as such. On the other hand, if you are absolutely certain of the exact
format variations of the files that you are going to be working with, then
you can attempt to detect and correctly handle these formats in binary mode.

-- 
Alex Monjushko (monjushko@hotmail.com)


Relevant Pages

  • Re: oldbie -- format help
    ... even e format would be accepted. ... Sounds to me like you want list-directed input. ... arbitrary spacing and mostly ignoring "newlines". ... This can cause confusing symptoms as subsequent reads ...
    (comp.lang.fortran)
  • Re: Pops Device, was Re: Some Newb Problem with "int", please help.
    ... >> mode a file which is not a text file (on the platform opening it). ... conversions. ... utilities for converting one text file format ... Dan Pop ...
    (comp.lang.c)
  • Re: Gantt Bar Date Format
    ... Arthur the pest wrote: ... The Canadian goverment uses the format year/month/day. ... lived in the US, but outside the USA, the American method of displaying dates ... can cause great confusion, and may end up with the confusion costing you real ...
    (microsoft.public.project)
  • Re: WRITE + new line
    ... > glen herrmannsfeldt wrote: ... completely independent of format processing; ... The processor choice in question is for additional newlines during the ... data transfer; the initial one is not at the processor's option. ...
    (comp.lang.fortran)
  • Re: Importing FastCAD files
    ... the files to be exported in another format, ... for Arthur. ... Depending on how ancient Fastcad was there's a tiny possibility ...
    (comp.sys.acorn.apps)