public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Earnie Boyd <earnie_boyd@yahoo.com>
To: kabal@ECE.McGill.CA
Cc: cygwin users <cygwin@sourceware.cygnus.com>
Subject: Re: Cygwin B20 - fseek under gcc fails to reposition on text files
Date: Tue, 16 Feb 1999 05:27:00 -0000	[thread overview]
Message-ID: <19990216132732.28101.rocketmail@send102.yahoomail.com> (raw)

You need to read the docs about "text mode processing".  This is
exactly the expected behavior.  If you're going to use these functions
then you must process in binary mode.

Regards,
Earnie.

---Peter Kabal <kabal@ECE.McGill.CA> wrote:
>
> Consider a text file (CR/LF line endings).  Read a line, save the
> current position, seek to end-of-file, seek to the saved position,
> read a line.  The second read does not return the second line of
> the file.
> 
> A shell script which tests the problem is included below:
> ---------------------------------------------------------------------
> #!/bin/sh
> #
> # Test fseek bug
> # On Cygwin 20.1, a file is not correctly repositioned after seeking
to the
> # end-of-file on a text file (CR/LF line endings).
> 
> cat > tfrepos.c << EoF
> #include <stdio.h>
> int main (int argc, char *argv[])
> {
>   FILE *fp;
>   long int pos, size;
>   char line[200];
>   char *p;
> 
>   fp = fopen (argv[1], "r");
>   p = fgets (line, 200, fp);
>   printf (" Line: %s", p);
> 
>   pos = ftell (fp);
>   fseek (fp, 0L, SEEK_END);
>   fseek (fp, pos, SEEK_SET);
> 
>   p = fgets (line, 200, fp);
>   printf (" Line: %s", p);
> 
>   return 0;
> }
> EoF
> 
> # Run the test program with the c-program as input
> gcc tfrepos.c -o tfrepos
> ./tfrepos tfrepos.c
> 
> # Clean up
> rm -f tfrepos tfrepos.c
> ---------------------------------------------------------------------
> 
> Peter Kabal  kabal@ECE.McGill.CA
> Dept. Electrical & Computer Eng.
> McGill University 
> 

_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

WARNING: multiple messages have this Message-ID
From: Earnie Boyd <earnie_boyd@yahoo.com>
To: kabal@ECE.McGill.CA
Cc: cygwin users <cygwin@sourceware.cygnus.com>
Subject: Re: Cygwin B20 - fseek under gcc fails to reposition on text files
Date: Sun, 28 Feb 1999 23:02:00 -0000	[thread overview]
Message-ID: <19990216132732.28101.rocketmail@send102.yahoomail.com> (raw)
Message-ID: <19990228230200.O7RYgZRhe9SLLM039FJvjFZU202UJQw9rP9WkhZmeIs@z> (raw)

You need to read the docs about "text mode processing".  This is
exactly the expected behavior.  If you're going to use these functions
then you must process in binary mode.

Regards,
Earnie.

---Peter Kabal <kabal@ECE.McGill.CA> wrote:
>
> Consider a text file (CR/LF line endings).  Read a line, save the
> current position, seek to end-of-file, seek to the saved position,
> read a line.  The second read does not return the second line of
> the file.
> 
> A shell script which tests the problem is included below:
> ---------------------------------------------------------------------
> #!/bin/sh
> #
> # Test fseek bug
> # On Cygwin 20.1, a file is not correctly repositioned after seeking
to the
> # end-of-file on a text file (CR/LF line endings).
> 
> cat > tfrepos.c << EoF
> #include <stdio.h>
> int main (int argc, char *argv[])
> {
>   FILE *fp;
>   long int pos, size;
>   char line[200];
>   char *p;
> 
>   fp = fopen (argv[1], "r");
>   p = fgets (line, 200, fp);
>   printf (" Line: %s", p);
> 
>   pos = ftell (fp);
>   fseek (fp, 0L, SEEK_END);
>   fseek (fp, pos, SEEK_SET);
> 
>   p = fgets (line, 200, fp);
>   printf (" Line: %s", p);
> 
>   return 0;
> }
> EoF
> 
> # Run the test program with the c-program as input
> gcc tfrepos.c -o tfrepos
> ./tfrepos tfrepos.c
> 
> # Clean up
> rm -f tfrepos tfrepos.c
> ---------------------------------------------------------------------
> 
> Peter Kabal  kabal@ECE.McGill.CA
> Dept. Electrical & Computer Eng.
> McGill University 
> 

_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com


             reply	other threads:[~1999-02-16  5:27 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-16  5:27 Earnie Boyd [this message]
1999-02-28 23:02 ` Earnie Boyd
  -- strict thread matches above, loose matches on Subject: below --
1999-02-22 14:28 Earnie Boyd
1999-02-28 23:02 ` Earnie Boyd
1999-02-19  7:00 setera
     [not found] ` < 8525671D.00525F37.00@D51MTA10.pok.ibm.com >
1999-02-19 17:21   ` Christopher Faylor
1999-02-22 13:40     ` Corinna Vinschen
1999-02-28 23:02       ` Corinna Vinschen
1999-02-28 23:02     ` Christopher Faylor
1999-02-28 23:02 ` setera
1999-02-16  7:41 Earnie Boyd
     [not found] ` < 19990216154134.3413.rocketmail@send104.yahoomail.com >
1999-02-16 17:52   ` Christopher Faylor
     [not found]     ` < 19990216205243.L16511@cygnus.com >
1999-02-16 18:18       ` DJ Delorie
1999-02-28 23:02         ` DJ Delorie
1999-02-17  2:01     ` Corinna Vinschen
1999-02-17  9:36       ` Re[2]: " Paul Sokolovsky
     [not found]         ` < 17817.990217@is.lg.ua >
1999-02-17 10:07           ` DJ Delorie
     [not found]             ` < 199902171807.NAA16764@envy.delorie.com >
1999-02-17 19:16               ` Larry Hall
     [not found]                 ` < 3.0.5.32.19990217221306.0162b070@pop.ma.ultranet.com >
1999-02-17 19:19                   ` DJ Delorie
     [not found]                     ` < 199902180318.WAA20394@envy.delorie.com >
1999-02-17 20:13                       ` Larry Hall
1999-02-28 23:02                         ` Larry Hall
1999-02-28 23:02                     ` DJ Delorie
1999-02-28 23:02                 ` Larry Hall
1999-02-28 23:02             ` DJ Delorie
1999-02-17 13:37         ` Corinna Vinschen
1999-02-19  2:30           ` Re[2]: " Paul Sokolovsky
     [not found]             ` < 17776.990218@is.lg.ua >
1999-02-19  6:36               ` Christopher Faylor
1999-02-28 23:02                 ` Christopher Faylor
1999-02-28 23:02           ` Corinna Vinschen
     [not found]       ` < 36CA92B5.844635AA@cityweb.de >
1999-02-17  8:07         ` DJ Delorie
1999-02-28 23:02           ` DJ Delorie
1999-02-17 13:46         ` J. J. Farrell
1999-02-28 23:02           ` J. J. Farrell
1999-02-28 23:02       ` Corinna Vinschen
1999-02-28 23:02     ` Christopher Faylor
1999-02-28 23:02 ` Earnie Boyd
1999-02-16  4:24 Peter Kabal
1999-02-28 23:02 ` Peter Kabal

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=19990216132732.28101.rocketmail@send102.yahoomail.com \
    --to=earnie_boyd@yahoo.com \
    --cc=cygwin@sourceware.cygnus.com \
    --cc=kabal@ECE.McGill.CA \
    /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).