delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/08/25/10:41:51

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <6f80c152050825074131fa2732@mail.gmail.com>
Date: Thu, 25 Aug 2005 23:41:40 +0900
From: June Kim <juneaftn AT gmail DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Re: misbehavior of ftell on stdin?
Mime-Version: 1.0
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id j7PEfo5R017189

> On Fri, Aug 19, 2005 at 04:51:12AM +0900, June Kim wrote:
> >I run cygwin on Windows XP through rxvt. When I compile and run the
> >following code:
> >
> >#include <stdio.h>
> >
> >main()
> >{
> >  printf("isatty=%d",isatty(fileno(stdin)));
> >  char *s=(char *)malloc(1024+1);
> >  char *s2=(char *)malloc(1024+1);
> >
> >  fgets(s,1024,stdin);
> >  free(s);
> >  printf("stdio = %ld", ftell(stdin));
> >
> >  fgets(s2,1024,stdin);
> >  free(s2);
> >  printf("stdio = %ld ", ftell(stdin));
> >
> >}
> >
> >I input "abcdefg" followed by a nl and then "abcdefg" followed by a nl.
> >
> >$ gcc test1.c
> >
> >bash ~
> >$ ./a 
> >isatty=1
> >abcdefg
> >stdio = 0
> >abcdefg
> >stdio = 8
> >
> >As you see, the first ftell's result is wrong.  The first fgets is
> >ignored.
> >
> >Interestingly, when I run cygwin without rxvt(just running bash.exe
> >from the dos command line) with CYGWIN=notty, the ftell always returns
> >-1.  If CYGWIN=tty, then ftell behaves as in rxvt ; it returns 0 first
> >and then behaves correct.
> >
> >Am I missing something?
> 
> I've fixed cygwin so that it consistently returns -1 when an ftell is
> attempted on a tty device, which is the correct behavior.
> 
> Thanks for the test case.
> 
> cgf

Thank you but where do I get the patched version?

--
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/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019