public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* DOS-EOL bug in "fgets"
@ 2000-05-24  8:02 Sergey R. Grigoriev
  0 siblings, 0 replies; 3+ messages in thread
From: Sergey R. Grigoriev @ 2000-05-24  8:02 UTC (permalink / raw)
  To: cygwin

Hallo!

I've found, that for DOS-EOL (\n\r) 
fgets returns the string terminated by \r
(for UNIX-EOL (\n) is all OK).
By this way I can't use any makefile generated
by "bash ./configure" under W32 without converting it into
unix-EOL.

It was some DOS-EOL problem with sed.exe and I recompiled it with
CYGNUS on W32 

To configure "sed" without right working "sed" I used sed-replacement
script:

#! bash
! d2u_s $1 $2 $3 $4
! sed_org "$@"

and wrote small d2u_s.c (MUST be compiled with CYGNUS!) to convert "-f
filename" file from DOS-EOL to UNIX-EOL.

If you interesting I can sent you sed-binaries :-)

Serge



*********d2u_s.c*********
#include <stdio.h>

void d2u(char * arg)
{
  FILE* in;
  FILE* tmp;
  FILE* out;
  int c;

  in=fopen(arg,"rb");
  tmp=fopen("d2u_tmp_","wb");
  while((c=fgetc(in)) != EOF)
  {
    fprintf(tmp,"%c",(char)c);
  }
  fclose(tmp);
  fclose(in);

  tmp=fopen("d2u_tmp_","rb");
  out=fopen(arg,"wb");
  while((c=fgetc(tmp)) != EOF)
  {
    if(c!=0x0D) fprintf(out,"%c",(char)c);
  }
  fclose(out);
  fclose(tmp);
}


int main(int argc, char ** argv)
{

  int i;

  for(i=1;i<argc;i++)
  {
    if(argv[i][0]=='-')
    if(argv[i][1]=='f')
    if(argv[i][2]==0x00)
    if((i+1)<argc) d2u(argv[i+1]);
  }
  return 0;
}

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: DOS-EOL bug in "fgets"
@ 2000-05-24  9:09 Earnie Boyd
  0 siblings, 0 replies; 3+ messages in thread
From: Earnie Boyd @ 2000-05-24  9:09 UTC (permalink / raw)
  To: Serguei.Grigoriev; +Cc: cygwin users

--- "Sergey R. Grigoriev" <Serguei.Grigoriev@Physik.Uni-Augsburg.DE> wrote:
> 
> 
> Hello Earnie
> 
> I've reinstalled all-CYGWIN from NET yesterday.
> 
> probably I don't understand EOL and gets() problem correct...
> but I see, that gets() returns "\r\n" as EOL for DOS-Files and
> '\n' for UNIX-Files. But make (see function readline() in read.c from
> make-distribution) can check only '\n' - and parcer will see this
> '\r' later...
> I thank, that CYGWIN-gets() converts 2-byte DOS-EOL into '\n'-Unix EOL
> like it does it in MINGW.
> 
> 

Ok, get the latest dll snapshot from
http://sourceware.cygnus.com/cygwin/snapshots/ and see if that helps.  Yes,
there were patches to fgets to help deal with \r\n and something broke, a fix
was supposedly put into place yesterday.


=====
---
   Earnie Boyd: < mailto:earnie_boyd@yahoo.com >
            __Cygwin: POSIX on Windows__
Cygwin Newbies: < http://www.freeyellow.com/members5/gw32/index.html >
           __Minimalist GNU for Windows__
  Mingw32 List: < http://www.egroups.com/group/mingw32/ >
    Mingw Home: < http://www.mingw.org/ >

__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: DOS-EOL bug in "fgets"
@ 2000-05-24  8:13 Earnie Boyd
  0 siblings, 0 replies; 3+ messages in thread
From: Earnie Boyd @ 2000-05-24  8:13 UTC (permalink / raw)
  To: Serguei.Grigoriev, cygwin

From MSDOS with no cygwin process running.

mkdir c:\cygupdate
c:
cd \cygupdate
[download] ftp://ftp.sunsite.utk.edu/pub/cygwin/latest/setup.exe
          NOTE: put it in c:\cygupdate
setup -u

Cheers,
Earnie

--- "Sergey R. Grigoriev" <Serguei.Grigoriev@Physik.Uni-Augsburg.DE> wrote:
> Hallo!
> 
> I've found, that for DOS-EOL (\n\r) 
> fgets returns the string terminated by \r
> (for UNIX-EOL (\n) is all OK).
> By this way I can't use any makefile generated
> by "bash ./configure" under W32 without converting it into
> unix-EOL.
> 
> It was some DOS-EOL problem with sed.exe and I recompiled it with
> CYGNUS on W32 
> 
> To configure "sed" without right working "sed" I used sed-replacement
> script:
> 
> #! bash
> ! d2u_s $1 $2 $3 $4
> ! sed_org "$@"
> 
> and wrote small d2u_s.c (MUST be compiled with CYGNUS!) to convert "-f
> filename" file from DOS-EOL to UNIX-EOL.
> 
> If you interesting I can sent you sed-binaries :-)
> 
> Serge
> 
> 
> 
> *********d2u_s.c*********
> #include <stdio.h>
> 
> void d2u(char * arg)
> {
>   FILE* in;
>   FILE* tmp;
>   FILE* out;
>   int c;
> 
>   in=fopen(arg,"rb");
>   tmp=fopen("d2u_tmp_","wb");
>   while((c=fgetc(in)) != EOF)
>   {
>     fprintf(tmp,"%c",(char)c);
>   }
>   fclose(tmp);
>   fclose(in);
> 
>   tmp=fopen("d2u_tmp_","rb");
>   out=fopen(arg,"wb");
>   while((c=fgetc(tmp)) != EOF)
>   {
>     if(c!=0x0D) fprintf(out,"%c",(char)c);
>   }
>   fclose(out);
>   fclose(tmp);
> }
> 
> 
> int main(int argc, char ** argv)
> {
> 
>   int i;
> 
>   for(i=1;i<argc;i++)
>   {
>     if(argv[i][0]=='-')
>     if(argv[i][1]=='f')
>     if(argv[i][2]==0x00)
>     if((i+1)<argc) d2u(argv[i+1]);
>   }
>   return 0;
> }
> 
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe@sourceware.cygnus.com
> 


__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-05-24  9:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-24  8:02 DOS-EOL bug in "fgets" Sergey R. Grigoriev
2000-05-24  8:13 Earnie Boyd
2000-05-24  9:09 Earnie Boyd

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).