www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - broken stream.readLine in dmd 0.89

reply "Ivan Senji" <ivan.senji public.srce.hr> writes:
When using readLine i get Error: Access Violation
This started with 0.89 and everything works ok in 0.88

Example code:
<CODE file="testreadLine.d">
import std.c.stdio;
import std.stream;

int main (char [] [] args )
{
 File file = new File("testreadLine.d");

 char[] line;

 do
 {
  line = file.readLine();
  printf("Line: %.*s",line);
 }while(!file.eof);
}

 getch();
 return 1;
}
</CODE>

All my code uses readLine so now nothing of that code works
and i don't like having to use files from different versions!
May 19 2004
next sibling parent reply "Ben Hinkle" <bhinkle mathworks.com> writes:
I don't see any difference in the output. Can you post the results you get?

Line: import std.c.stdio;Line: import std.stream;Line: Line: int main()
{Line: F
ile file = new File("rt.d");Line: Line:  char[] line;Line: Line:  doLine:
{Line
:   line = file.readLine();Line:   printf("Line:
.*s",line);Line:  }while(!file
.eof);Line: Line: getch();Line: return 0;Line: }

The std.stream.readLine did change to call
 char[] readLine(char[] buffer)
which will fill the supplied buffer if the line fits so that there is less
memory allocation.
-Ben


"Ivan Senji" <ivan.senji public.srce.hr> wrote in message
news:c8gk70$das$1 digitaldaemon.com...
 When using readLine i get Error: Access Violation
 This started with 0.89 and everything works ok in 0.88

 Example code:
 <CODE file="testreadLine.d">
 import std.c.stdio;
 import std.stream;

 int main (char [] [] args )
 {
  File file = new File("testreadLine.d");

  char[] line;

  do
  {
   line = file.readLine();
   printf("Line: %.*s",line);
  }while(!file.eof);
 }

  getch();
  return 1;
 }
 </CODE>

 All my code uses readLine so now nothing of that code works
 and i don't like having to use files from different versions!

May 19 2004
parent reply "Ivan Senji" <ivan.senji public.srce.hr> writes:
"Ben Hinkle" <bhinkle mathworks.com> wrote in message
news:c8gm40$m06$1 digitaldaemon.com...
 I don't see any difference in the output. Can you post the results you

Very strange! The difference is with the new stream.d version i don't get any output! I get "Error: Access Violation" the first time readLine() is called. I tried "printf("%.*s",file.toString());" and this prints the entire file but it isn't what i need. I don't know why is it working for you? I tested four of my projects that use FIle.readLine() an none of them work and they all crash at readLine()!
 Line: import std.c.stdio;Line: import std.stream;Line: Line: int main()
 {Line: F
 ile file = new File("rt.d");Line: Line:  char[] line;Line: Line:  doLine:
 {Line
 :   line = file.readLine();Line:   printf("Line:
 .*s",line);Line:  }while(!file
 .eof);Line: Line: getch();Line: return 0;Line: }

 The std.stream.readLine did change to call
  char[] readLine(char[] buffer)
 which will fill the supplied buffer if the line fits so that there is less
 memory allocation.
 -Ben


 "Ivan Senji" <ivan.senji public.srce.hr> wrote in message
 news:c8gk70$das$1 digitaldaemon.com...
 When using readLine i get Error: Access Violation
 This started with 0.89 and everything works ok in 0.88

 Example code:
 <CODE file="testreadLine.d">
 import std.c.stdio;
 import std.stream;

 int main (char [] [] args )
 {
  File file = new File("testreadLine.d");

  char[] line;

  do
  {
   line = file.readLine();
   printf("Line: %.*s",line);
  }while(!file.eof);
 }

  getch();
  return 1;
 }
 </CODE>

 All my code uses readLine so now nothing of that code works
 and i don't like having to use files from different versions!


May 20 2004
parent reply Ben Hinkle <bhinkle4 juno.com> writes:
Ivan Senji wrote:

 "Ben Hinkle" <bhinkle mathworks.com> wrote in message
 news:c8gm40$m06$1 digitaldaemon.com...
 I don't see any difference in the output. Can you post the results you

Very strange! The difference is with the new stream.d version i don't get any output! I get "Error: Access Violation" the first time readLine() is called. I tried "printf("%.*s",file.toString());" and this prints the entire file but it isn't what i need. I don't know why is it working for you? I tested four of my projects that use FIle.readLine() an none of them work and they all crash at readLine()!

are you on Windows or Linux? I've tested on RedHat 9 and Windows XP. -Ben
May 20 2004
next sibling parent "Ivan Senji" <ivan.senji public.srce.hr> writes:
"Ben Hinkle" <bhinkle4 juno.com> wrote in message
news:c8i048$2o8e$1 digitaldaemon.com...
 Ivan Senji wrote:

 "Ben Hinkle" <bhinkle mathworks.com> wrote in message
 news:c8gm40$m06$1 digitaldaemon.com...
 I don't see any difference in the output. Can you post the results you

Very strange! The difference is with the new stream.d version i don't get any output! I get "Error: Access Violation" the first time


 is called.

 I tried "printf("%.*s",file.toString());" and this prints the entire


 but
 it isn't what i need. I don't know why is it working for you?

 I tested four of my projects that use FIle.readLine() an none of
 them work and they all crash at readLine()!

are you on Windows or Linux? I've tested on RedHat 9 and Windows XP.

Windows XP. Later i'll test it on an other computer, and let you know how that turns out. Thanks for testing this, it seams that it only doesn't work on my computer.
 -Ben

May 20 2004
prev sibling parent "Ivan Senji" <ivan.senji public.srce.hr> writes:
"Ben Hinkle" <bhinkle4 juno.com> wrote in message
news:c8i048$2o8e$1 digitaldaemon.com...
 Ivan Senji wrote:

 "Ben Hinkle" <bhinkle mathworks.com> wrote in message
 news:c8gm40$m06$1 digitaldaemon.com...
 I don't see any difference in the output. Can you post the results you

Very strange! The difference is with the new stream.d version i don't get any output! I get "Error: Access Violation" the first time


 is called.

 I tried "printf("%.*s",file.toString());" and this prints the entire


 but
 it isn't what i need. I don't know why is it working for you?

 I tested four of my projects that use FIle.readLine() an none of
 them work and they all crash at readLine()!

are you on Windows or Linux? I've tested on RedHat 9 and Windows XP.

I just tested it on the other computer (WinXP) and i get the same error.
 -Ben

May 20 2004
prev sibling next sibling parent reply J C Calvarese <jcc7 cox.net> writes:
Ivan Senji wrote:
 When using readLine i get Error: Access Violation
 This started with 0.89 and everything works ok in 0.88

After I removed an extraneous "}" from your example, it worked fine for me on (DMD 0.89/WinXP HE). I don't know why you're getting an Access Violation. (I also added an "\n" to make the output more readable.) import std.c.stdio; import std.stream; int main (char [] [] args ) { File file = new File("testreadLine.d"); char[] line; do { line = file.readLine(); printf("Line: %.*s\n",line); }while(!file.eof); getch(); return 1; } Output... Line: import std.c.stdio; Line: import std.stream; Line: Line: int main (char [] [] args ) Line: { Line: File file = new File("testreadLine.d"); Line: Line: char[] line; Line: Line: do Line: { Line: line = file.readLine(); Line: printf("Line: %.*s\n",line); Line: }while(!file.eof); Line: Line: Line: getch(); Line: return 1; Line: }
 
 Example code:
 <CODE file="testreadLine.d">
 import std.c.stdio;
 import std.stream;
 
 int main (char [] [] args )
 {
  File file = new File("testreadLine.d");
 
  char[] line;
 
  do
  {
   line = file.readLine();
   printf("Line: %.*s",line);
  }while(!file.eof);
 }
 
  getch();
  return 1;
 }
 </CODE>
 
 All my code uses readLine so now nothing of that code works
 and i don't like having to use files from different versions!
 
 
 
 

-- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
May 19 2004
parent reply "Ivan Senji" <ivan.senji public.srce.hr> writes:
"J C Calvarese" <jcc7 cox.net> wrote in message
news:c8gq41$v3u$1 digitaldaemon.com...
 Ivan Senji wrote:
 When using readLine i get Error: Access Violation
 This started with 0.89 and everything works ok in 0.88

After I removed an extraneous "}" from your example, it worked fine for me on (DMD 0.89/WinXP HE). I don't know why you're getting an Access Violation. (I also added an "\n" to make the output more readable.)

I would have also added \n if i got any output at all :) I gues i will temporarilly have to go back to the old stream.d :(
 import std.c.stdio;
 import std.stream;

 int main (char [] [] args )
 {
   File file = new File("testreadLine.d");

   char[] line;

   do
   {
    line = file.readLine();
    printf("Line: %.*s\n",line);
   }while(!file.eof);


   getch();
   return 1;
 }


 Output...
 Line: import std.c.stdio;
 Line: import std.stream;
 Line:
 Line: int main (char [] [] args )
 Line: {
 Line:  File file = new File("testreadLine.d");
 Line:
 Line:  char[] line;
 Line:
 Line:  do
 Line:  {
 Line:   line = file.readLine();
 Line:   printf("Line: %.*s\n",line);
 Line:  }while(!file.eof);
 Line:
 Line:
 Line:  getch();
 Line:  return 1;
 Line: }

 Example code:
 <CODE file="testreadLine.d">
 import std.c.stdio;
 import std.stream;

 int main (char [] [] args )
 {
  File file = new File("testreadLine.d");

  char[] line;

  do
  {
   line = file.readLine();
   printf("Line: %.*s",line);
  }while(!file.eof);
 }

  getch();
  return 1;
 }
 </CODE>

 All my code uses readLine so now nothing of that code works
 and i don't like having to use files from different versions!

-- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/

May 20 2004
parent Andrew Edwards <ridimz_at yahoo.dot.com> writes:
Ivan Senji wrote:
 "J C Calvarese" <jcc7 cox.net> wrote in message
 news:c8gq41$v3u$1 digitaldaemon.com...
 
Ivan Senji wrote:

When using readLine i get Error: Access Violation
This started with 0.89 and everything works ok in 0.88

After I removed an extraneous "}" from your example, it worked fine for me on (DMD 0.89/WinXP HE). I don't know why you're getting an Access Violation. (I also added an "\n" to make the output more readable.)

I would have also added \n if i got any output at all :) I gues i will temporarilly have to go back to the old stream.d :(

No Access Violation here (DMD v0.89/WinXP): the only thing wrong with it is the extra '}'. Remove it and the program works fine. F:\>dmd testreadLine f:\dmd\bin\..\..\dm\bin\link.exe testreadLine,,,user32+kernel32/noi; F:\>testreadLine Line: import std.c.stdio; Line: import std.stream; Line: Line: int main (char [] [] args ) Line: { Line: File file = new File("testreadLine.d"); Line: Line: char[] line; Line: Line: do Line: { Line: line = file.readLine(); Line: printf("Line: %.*s\n",line); // added \n Line: }while(!file.eof); Line: //} <== remove this and recompile! Line: Line: getch(); Line: return 1; Line: }
May 20 2004
prev sibling parent "Ivan Senji" <ivan.senji public.srce.hr> writes:
"Ivan Senji" <ivan.senji public.srce.hr> wrote in message
news:c8gk70$das$1 digitaldaemon.com...
 When using readLine i get Error: Access Violation
 This started with 0.89 and everything works ok in 0.88

 Example code:
 <CODE file="testreadLine.d">
 import std.c.stdio;
 import std.stream;

 int main (char [] [] args )
 {
  File file = new File("testreadLine.d");

  char[] line;

  do
  {
   line = file.readLine();
   printf("Line: %.*s",line);
  }while(!file.eof);
 }

  getch();
  return 1;
 }
 </CODE>

 All my code uses readLine so now nothing of that code works
 and i don't like having to use files from different versions!

I am very happy to say this works now in 0.90 :)
May 21 2004