autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Portability of fopen (foo, "wb") (Was: bug in AC_COMPUTE_INT)


From: Earnie Boyd
Subject: Re: Portability of fopen (foo, "wb") (Was: bug in AC_COMPUTE_INT)
Date: Thu, 16 Nov 2000 10:56:22 -0800 (PST)

--- Akim Demaille <address@hidden> wrote:
> >>>>> "Earnie" == Earnie Boyd <address@hidden> writes:
> 
> Earnie> Lars, just to satisfy my curiosity please send me the output
> Earnie> of `cygcheck -s -r -v'.  
> 
> What's this?  

It is a tool developed by the Cygwin team to report on the users Cygwin
environment.  With the output, those with experience can determine if a
reported problem is due to something within the environment.  I asked to see
the report from Lars' system because I suspected that he had a mix of default
[text|binary] mode mounts.

Cygwin contains a pseudo mount point loving known as /cygdrive that also has a
default processing mode and unless your aware of it could pose text/binary
confusion.  Also, until recently, Cygwin's setup would leave this /cygdrive
mount point to default process in text mode even if you chose to have binary
mode mount points.  Also, until recently, the mount command itself would not
tell you what mode your /cygdrive was processing in, so unless you were aware
you wouldn't know that your /cygdrive was processing in text mode.

When looking at Lars' setup, he indeed had all mount points processing in
binary mode except for /cygdrive.  If for some reason /cygdrive is used to open
a file it would process in text mode and write \r\n line endings.  If Lars had
had his /cygdrive in binary mode I suspect that this thread wouldn't have taken
place.

If you wish more details, just ask.

> I'm looking for all the possible uname and the like
> which we could include in the config.log.  Currently, you have:
> 
> This file contains any messages produced by compilers while
> running configure, to aid debugging if configure makes a mistake.
> 
> It was created by  (Autoconf 2.49b) 2.49b, executed with
>  > ./configure --no-create --no-recursion
> 
> on nostromo:
> 
> uname -m = i686
> uname -r = 2.2.17
> uname -s = Linux
> uname -v = #1 Sat Sep 9 12:42:22 EST 2000
> 
> /usr/bin/uname -p = 
> /bin/uname -X     = 
> 
> hostinfo               = 
> /bin/universe          = 
> /usr/bin/arch -k       = 
> /bin/arch              = i686
> /usr/bin/oslevel       = 
> /usr/convex/getsysinfo = 
> 
> I'm really looking for all the means to enrich our knowledge of the
> user's system.
> 

I'm not sure how you could incorporate the cygcheck output, perhaps an autoconf
derived syscheck could be in order.

> Earnie> I'm researching fopen using google.com and I find that the
> Earnie> "Single UNIX Specification Version 2" from The Open Group
> Earnie> supports wb.  I've checked several man pages and all except
> Earnie> those related to PHP supports the 'b' option.  It is also
> Earnie> required for conformity by IEEE STDSt (``POSIX'')-ansiC
> Earnie> standard according to
> Earnie> http://www.ajk.tele.fi/libc/stdio/fopen.3.html.
> 
> Yep, I seem to remember it's in the K&R book first edition, so it
> should be quite safe.
> 

Good.  That means it doesn't have to be conditionally used and that if a file
is know to contain binary data that it should always be used for portability. 
If it is possible for a file to be created by a human using some form of a text
editor then the 'b' should never be used.  Writing text data with the 'b'
option specified is fine too as it will only output \n line endings and the
read function handles both line endings.  When processing in text mode and the
file contains \r\n line endings then fseek and ftell won't do what's expected
either because the read function will return a count of 1 less than what was
actually read because the function removes the \r and decrements the count.

Cheers,

=====
Earnie Boyd
mailto:address@hidden

---         <http://earniesystems.safeshopper.com>         ---
--- Cygwin: POSIX on Windows <http://gw32.freeyellow.com/> ---
---   Minimalist GNU for Windows <http://www.mingw.org/>   ---

__________________________________________________
Do You Yahoo!?
Yahoo! Calendar - Get organized for the holidays!
http://calendar.yahoo.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]