From: Earnie Boyd <earnie_boyd@yahoo.com>
To: cygwin users <cygwin@sourceware.cygnus.com>
Subject: Re: [bug] Crazy I/O
Date: Wed, 31 Mar 1999 19:45:00 -0000 [thread overview]
Message-ID: <19990309142548.4553.rocketmail@send103.yahoomail.com> (raw)
Message-ID: <19990331194500.sN2yf9ocz4q94KaU6ctqLuIqp9fSdX6bMUwDxzl1MwM@z> (raw)
[-- Attachment #1: Type: text/plain, Size: 626 bytes --]
I've modified the text.tst.c test program based on suggestions from the list as noted in the program. Note this demonstrates a bug where the values for the file descriptor are not reset if the same file descriptor is used.
I can also state that the 19990115 snapshot eliminates the WARNING listed in the Users Guide under "the default Cygwin behavior" concerning the processing mode always being binary even if O_TEXT was specified if the default is binary.
Earnie.
P.S. BCC: developers
---
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
[-- Attachment #2: text.tst.c --]
[-- Type: text/x-c, Size: 1633 bytes --]
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <io.h>
/*
text.tst.c
Version 2
*/
int
main (void)
{
int fh1, fh2;
unsigned int nbytes = 60000, bytesread;
char fh1_IN[60000];
fh1 = open( "text.tst.c", O_RDONLY | O_TEXT );
dup2(fh1, 0);
close( fh1 );
gets( fh1_IN );
bytesread = strlen(fh1_IN);
printf( "read %u bytes from file\n", bytesread );
{
unsigned int i;
for (i=0; i< bytesread; i++) {
printf( "char value: %i\t\t%c\n", fh1_IN[i], fh1_IN[i] );
}
}
fh1 = open( "text.tst.c", O_RDONLY | O_BINARY );
dup2(fh1, 0);
close( fh1 );
/*
** I first tried: lseek( 0, 0, SEEK_SET ) but that didn't help.
** Michael V. Nikolaev <mvn@gu.kiev.ua> suggested using fseek which does
** reset the file descriptor and stream. Note, without this the change
** from O_TEXT to O_BINARY doesn't take effect either. If you remove the
** fseek then the file descriptor doesn't get reset to the beginning of the
** file as it should and the processing mode remains in O_TEXT.
**
** The fseek shouldn't be needed but works around a bug.
**
** I tried adding the close( 0 ) and fclose( stdin ) but that caused the
** fseek function not to work obviously because the stream was closed.
**
*/
fseek( stdin, 0L, SEEK_SET );
gets( fh1_IN );
bytesread = strlen(fh1_IN);
printf( "read %u bytes from file\n", bytesread );
{
unsigned int i;
for (i=0; i< bytesread; i++) {
printf( "char value: %i\t\t%c\n", fh1_IN[i], fh1_IN[i] );
}
}
}
next reply other threads:[~1999-03-31 19:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-03-09 6:24 Earnie Boyd [this message]
1999-03-31 19:45 ` Earnie Boyd
-- strict thread matches above, loose matches on Subject: below --
1999-03-08 12:25 Michael V. Nikolaev
1999-03-31 19:45 ` Michael V. Nikolaev
1999-03-08 11:45 Earnie Boyd
1999-03-31 19:45 ` Earnie Boyd
1999-03-08 11:32 Michael V. Nikolaev
1999-03-31 19:45 ` Michael V. Nikolaev
1999-03-08 8:44 Earnie Boyd
1999-03-31 19:45 ` Earnie Boyd
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=19990309142548.4553.rocketmail@send103.yahoomail.com \
--to=earnie_boyd@yahoo.com \
--cc=cygwin@sourceware.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).