zsh-workers
 help / color / mirror / code / Atom feed
From: JohnW@bops.com
To: zsh-workers@sunsite.dk
Subject: RE: PATCH: fix for autoloading and compiling under Cygwin
Date: Tue, 18 Dec 2001 13:34:48 -0600	[thread overview]
Message-ID: <A148C710488FD411BC4000508BD922D859F309@aussrv001.austin.bops.com> (raw)

When bash reads whole files, it uses fstat to find out how much memory to
allocate to store the file and then takes the result of read to be the
actual length of the file. All the error checks on read just make sure the
result isn't negative, except one case that tries to read a single
character. That case makes sure read returns 1.

Regarding O_BINARY, bash does something similar to what you suggest. Here's
the actual code:

/* If we're compiling for __EMX__ (OS/2) or __CYGWIN__ (cygwin32 environment
   on win 95/98/nt), we want to open files with O_BINARY mode so that there
   is no \n -> \r\n conversion performed.  On other systems, we don't want
to
   mess around with O_BINARY at all, so we ensure that it's defined to 0. */
#if defined (__EMX__) || defined (__CYGWIN__)
#  ifndef O_BINARY
#    define O_BINARY 0
#  endif
#else /* !__EMX__ && !__CYGWIN__ */
#  undef O_BINARY
#  define O_BINARY 0
#endif /* !__EMX__ && !__CYGWIN__ */

-----Original Message-----
From: Borsenkow Andrej [mailto:Andrej.Borsenkow@mow.siemens.ru]
Sent: Tuesday, December 18, 2001 2:11 AM
To: JohnW@bops.com; zsh-workers@sunsite.dk
Subject: RE: PATCH: fix for autoloading and compiling under Cygwin



> 
> I was actually overlooking writing of zwc files in my first fix.
Here's a
> new patch that really fixes the problem, with a test case, too. I've
done
> two things here:
> 
> * I added the O_BINARY flag to all calls to 'open' on zwc files.

That is needed in any case and is not harmful at all. Any system that
does not support this flag? Should probably add

#ifndef O_BINARY
#define O_BINARY 0
#endif

somewhere in ... zsh.h?

> * For text files, I changed the code to treat the result of 'seek' as
an
> upper bound on the length of the file. For the actual length, the
return
> value of 'read' is used. Checks that 'seek' and 'read' return the same
thing
> have been changed to check that 'seek' and 'read' both return
nonnegative
> values.
> 

I have mixed feelings about it. It needed to be under #ifdef __CYGWIN__
in the first place. It also defeats error checking completely.

Have you looked how bash on Cygwin does it?

-andrej


             reply	other threads:[~2001-12-18 19:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-18 19:34 JohnW [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-12-17 21:15 JohnW
2001-12-18  8:10 ` Borsenkow Andrej
2001-12-18 10:36   ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A148C710488FD411BC4000508BD922D859F309@aussrv001.austin.bops.com \
    --to=johnw@bops.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).