From: Earnie Boyd <earnie_boyd@yahoo.com>
To: cygwin users <cygwin@sourceware.cygnus.com>
Subject: [bug] Crazy I/O.
Date: Wed, 31 Mar 1999 19:45:00 -0000 [thread overview]
Message-ID: <19990308164440.28717.rocketmail@send106.yahoomail.com> (raw)
Message-ID: <19990331194500.HtzJFOX4uV93YBezXgjCaJ1SRBLFrnNYxGvbBnMvoCQ@z> (raw)
[-- Attachment #1: Type: text/plain, Size: 938 bytes --]
This bug has to do with getting back to the beginning of a file. I was trying to test what happens with O_TEXT and O_BINARY based upon the CYGWIN variable and the [no]binmode value. I'm using the 1998-12-3 release of the cygwin1.dll on NT4SP3. I haven't tested with a recent snapshot but the list needs to know about this for the distributed version.
I've included a test case. You must save the file as text.tst.c, gcc -o text text.tst.c, and have your working directory set to the source code.
==
- \\||//
-------------------o0O0--Earnie--0O0o-------------------
-- earnie_boyd@yahoo.com --
-- http://www.freeyellow.com/members5/gw32/index.html --
----------------------ooo0O--O0ooo----------------------
PS: Newbie's, you should visit my page.
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
[-- Attachment #2: text.tst.c --]
[-- Type: text/x-c, Size: 1055 bytes --]
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <io.h>
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);
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] );
}
}
close( fh1 );
fh1 = open( "text.tst.c", O_RDONLY | O_BINARY );
lseek( fh1, 0, SEEK_SET ); /* added to try to get the pointer back to the
the beginning of the file. Which doesn't help.
*/
dup2(fh1, 0);
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] );
}
}
close( fh1 );
}
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-08 8:44 Earnie Boyd [this message]
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 11:45 Earnie Boyd
1999-03-31 19:45 ` Earnie Boyd
1999-03-08 12:25 Michael V. Nikolaev
1999-03-31 19:45 ` Michael V. Nikolaev
1999-03-09 6:24 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=19990308164440.28717.rocketmail@send106.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).