public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Volker Quetschke <quetschke@scytek.de>
To: cygwin@cygwin.com
Subject: Re: bash-3.1-7^[$B!!^[(BBUG
Date: Thu, 14 Sep 2006 16:58:00 -0000	[thread overview]
Message-ID: <45098A3B.4060105@scytek.de> (raw)
In-Reply-To: <45093972.7080606@byu.net>

[-- Attachment #1: Type: text/plain, Size: 4466 bytes --]

Hi!

Eric Blake wrote:
> According to Christopher Faylor on 9/13/2006 8:07 PM:
>>> I doubt that Eric will want to deal with the fallout of having bash not
>>> understand \r\n line endings but, if he does, it would be his decision
>>> and, again, I would support it 100%.  I am very eager to see things like
>>> configure scripts work faster and if we have to drop a few scared or
>>> lazy people along the way to accomplish that goal, that's fine with me.
>>> I have no problem at all with being a part of a smaller community which
>>> doesn't need to use notepad to edit their bash scripts.
Hey, don't shoot at me, I'm only voicing my opinion and am perfectly fine
with your decision. Maybe I'm lacking some coffee, but this ...

> Here's the difference between 3.1-7 and 3.1-8:
> 
(snip)
> +#ifdef __CYGWIN__
> +  /* lseek'ing on text files is problematic; lseek reports the true
> +     file offset, but read collapses \r\n and returns a character
> +     count.  We cannot reliably seek backwards if nr is smaller than
> +     the seek offset encountered during the read, and must instead
> +     treat the stream as unbuffered.  */
> +  if ((bp->b_flag & (B_TEXT | B_UNBUFF)) == B_TEXT)
------------------------^^^^^^^^^^^^^^^^^      ^^^^^^
part of the patch looks suspicious to me. You probably just want to test
if the LHS expression is true.

  Volker

> +    {
> +      off_t offset = lseek (bp->b_fd, 0, SEEK_CUR);
> +      nr = zread (bp->b_fd, bp->b_buffer, bp->b_size);
> +      if (nr > 0 && nr < lseek (bp->b_fd, 0, SEEK_CUR) - offset)
> +       {
> +         lseek (bp->b_fd, offset, SEEK_SET);
> +         bp->b_flag |= B_UNBUFF;
> +         nr = zread (bp->b_fd, bp->b_buffer, bp->b_size = 1);
> +       }
> +    }
> +  else
> +#endif
>    nr = zread (bp->b_fd, bp->b_buffer, bp->b_size);
>    if (nr <= 0)
>      {
> @@ -454,15 +477,6 @@
>        return (EOF);
>      }
> 
> -#if defined (__CYGWIN__)
> -  /* If on cygwin, translate \r\n to \n. */
> -  if (nr >= 2 && bp->b_buffer[nr - 2] == '\r' && bp->b_buffer[nr - 1] ==
> '\n')
> -    {
> -      bp->b_buffer[nr - 2] = '\n';
> -      nr--;
> -    }
> -#endif
> -
>    bp->b_used = nr;
>    bp->b_inputp = 0;
>    return (bp->b_buffer[bp->b_inputp++] & 0xFF);
> only in patch2:
> unchanged:
> --- bash-3.1-orig/input.h       2002-01-30 07:11:47.000000000 -0700
> +++ bash-3.1/input.h    2006-09-14 03:29:05.484375000 -0600
> @@ -47,6 +47,7 @@
>  #define B_ERROR                0x02
>  #define B_UNBUFF       0x04
>  #define B_WASBASHINPUT 0x08
> +#define B_TEXT         0x10 /* Text stream, when O_BINARY is nonzero */
> 
>  /* A buffered stream.  Like a FILE *, but with our own buffering and
>     synchronization.  Look in input.c for the implementation. */
> 
> 
> My thoughts on the matter are that if you use binary mounts (and I highly
> recommend them), then every character in your file is important.  Since
> bash on Linux does not ignore \r, and POSIX does not allow bash to ignore
> \r by default (although you can set IFS to include \r as a whitespace
> character to ignore), then neither should bash on a binary cygwin file.
> If you use text mounts, then this patch is smart enough to buffer data up
> until the point that an \r\n pair is converted by the text mode file into
> a single character, at which point the lseek optimization breaks down and
> the text mode file is subsequently processed a byte at a time.  If you
> need DOS line endings, use a text mount.  If you need speed, use UNIX line
> endings on a binary mount, although even UNIX line endings on a text mount
> will be faster than DOS line endings.  Case closed, since I'm the
> maintainer, and I really don't want to bother with anything larger than
> the above patch (and also plan on submitting the above patch upstream,
> where it is less likely to be accepted if it is larger).
> 
> --
> Life is short - so eat dessert first!
> 
> Eric Blake             ebb9@byu.net

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


-- 
= http://wiki.services.openoffice.org/wiki/Debug_Build_Problems  =
PGP/GPG key  (ID: 0x9F8A785D)  available  from  wwwkeys.de.pgp.net
key-fingerprint 550D F17E B082 A3E9 F913  9E53 3D35 C9BA 9F8A 785D


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

  reply	other threads:[~2006-09-14 16:58 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-13  4:38 bash-3.1-7^[$B!!^[(BBUG Eric Blake
2006-09-13  5:25 ` bash-3.1-7^[$B!!^[(BBUG Christopher Faylor
2006-09-13 14:33   ` bash-3.1-7^[$B!!^[(BBUG Eric Blake
2006-09-13 20:07     ` bash-3.1-7^[$B!!^[(BBUG Shankar Unni
2006-09-13 20:37       ` bash-3.1-7^[$B!!^[(BBUG mwoehlke
2006-09-13 21:48         ` bash-3.1-7^[$B!!^[(BBUG Eric Blake
2006-09-13 22:08           ` bash-3.1-7^[$B!!^[(BBUG mwoehlke
2006-09-13 23:46             ` bash-3.1-7^[$B!!^[(BBUG Volker Quetschke
2006-09-13 23:58               ` bash-3.1-7^[$B!!^[(BBUG David Rothenberger
2006-09-14  0:30                 ` bash-3.1-7^[$B!!^[(BBUG Larry Hall (Cygwin)
2006-09-18  2:48                   ` bash-3.1-7^[$B!!^[(BBUG Carlo Florendo
2006-09-18  2:54                     ` bash-3.1-7^[$B!!^[(BBUG Carlo Florendo
2006-09-14  0:19               ` bash-3.1-7^[$B!!^[(BBUG Christopher Faylor
2006-09-14  1:09                 ` bash-3.1-7^[$B!!^[(BBUG Volker Quetschke
2006-09-14  2:07                   ` bash-3.1-7^[$B!!^[(BBUG Christopher Faylor
2006-09-14 11:13                     ` bash-3.1-7^[$B!!^[(BBUG Eric Blake
2006-09-14 16:58                       ` Volker Quetschke [this message]
2006-09-14 17:15                         ` bash-3.1-7^[$B!!^[(BBUG Dave Korn
2006-09-14 17:22                           ` bash-3.1-7^[$B!!^[(BBUG Volker Quetschke
2006-09-14 17:26                         ` bash-3.1-7^[$B!!^[(BBUG Eric Blake
2006-09-21  3:50                         ` bash-3.1-7^[$B!!^[(BBUG Christopher Layne
2006-09-14 15:21                     ` bash-3.1-7 bug mwoehlke
2006-09-21  3:48                     ` bash-3.1-7^[$B!!^[(BBUG Christopher Layne
2006-09-21  3:37                 ` bash-3.1-7^[$B!!^[(BBUG Christopher Layne
  -- strict thread matches above, loose matches on Subject: below --
2006-09-13  4:13 bash-3.1-7^[$B!!^[(BBUG Eric Blake

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=45098A3B.4060105@scytek.de \
    --to=quetschke@scytek.de \
    --cc=cygwin@cygwin.com \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).