public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: takach@ece.iit.edu (Andres Takach)
To: gnu-win32@cygnus.com
Subject: bug report
Date: Wed, 12 Feb 1997 16:36:00 -0000	[thread overview]
Message-ID: <9702121936.AA02046@mar> (raw)

There seems to be a problem in the read() (getc etc.) when
reading binary files. A character 1A can confuse the read
to think that it has found the end of file.

This problem also happens when using the gnu-win92 "od" program.
In fact it also happens on the perl implementation for win 95/NT.
The perl problem happens on even NT machines. 

I have included below a simple c program that exposes the problem.

Andres Takach


#include <stdio.h>
#include <stdlib.h>

/* this program illustrates the fact that if the character 1A is
  present in a binary file, getc() will return an EOF at that point
  (same can be said about read() etc.)  The output of this program
  should be 13 (13 chars in file "temp") but instead it is 2.
  Program "od" will also quit early and same can be said about
  perl for windows 95/NT.
*/

main(){
  FILE *fp;
  int ch;
  int count = 0;
  int i;
  fp = fopen("temp","w");

/* Write two random chars to "temp"*/
  putc(255,fp); 
  putc('a',fp);
  
/* Write offending char 26 (Hex 1A) to "temp" */
  putc(26,fp);    

/* Write 10 more 'a's to file "temp"  and close file */
  for(i=0; i < 10; i++) putc('a',fp);  /* 10 more bytes */
  fclose(fp);

/* Attempt to count # of bytes in "temp" */
  fp = fopen("temp","r");
  while( getc(fp)!= EOF) count++;
  /* should be 13 bytes */
  printf("Number of bytes: %d\n",count);
}

             reply	other threads:[~1997-02-12 16:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-12 16:36 Andres Takach [this message]
1997-02-13  1:21 Sergey Okhapkin
1997-02-16 22:10 Sean McNeil
1997-02-17  8:27 p.a.c.tavares
     [not found] <19980630141709.614.rocketmail@send101.yahoomail.com>
1998-07-01  8:02 ` Bug Report Ronald Pijnacker
     [not found] ` <199807010655.IAA00527.cygnus.gnu-win32@surgery1.best.ms.philips.com>
1998-07-02  9:53   ` Christopher G. Faylor
2001-06-06 22:21 Bug report David L Wiltshire
2003-05-05 16:21 Kern Sibbald
2003-05-05 16:38 ` Igor Pechtchanski
2003-05-05 17:14   ` Kern Sibbald
2003-05-05 17:30     ` Igor Pechtchanski
2003-05-05 17:33       ` Igor Pechtchanski
2003-05-05 16:40 ` Christopher Faylor
2022-02-08 22:01 Bug Report julie77793
2022-02-09  6:29 ` Ernie Rael
2022-02-09 16:24 ` Bill Stewart
     [not found] <CAJVfQ_gj3N5+j+NpJytcYqMnMVMj-_p=EuLKsZ7BwnYWNRMgJg@mail.gmail.com>
2023-09-06 22:20 ` bug report Asad Ali
2023-09-08  5:09   ` Brian Inglis

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=9702121936.AA02046@mar \
    --to=takach@ece.iit.edu \
    --cc=gnu-win32@cygnus.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).