bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-apl] Return value of fgets ignored in lib_file _io. (Was: Re: is t


From: Kacper Gutowski
Subject: [Bug-apl] Return value of fgets ignored in lib_file _io. (Was: Re: is there a )copy ⎕fns like ⎕ex is )erase)
Date: Sat, 26 Apr 2014 15:43:31 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

On 2014-04-26 07:13:21, address@hidden wrote:
> btw if you can take a look at the FILE_IO code in 
> http://lists.gnu.org/archive/html/bug-apl/2014-04/msg00269.html
> and give me an idea why the difference between c popen and apl popen - null 
> vs no '10' at end of data still returned - i'd appreciate it

The difference is that there is a bug in lib_file_io.
When FILE_IO[8] is called dyadically, return value of fgets(3) is silently 
ignored and garbage is returned.

-k



Index: src/native/file_io.cc
===================================================================
--- src/native/file_io.cc (revision 224)
+++ src/native/file_io.cc (working copy)
@@ -796,7 +796,7 @@
                    buffer = del = new char[bytes + 1];
 
                 const char * s = fgets(buffer, bytes, fe.fe_file);
-                const int len = strlen(buffer);
+                const int len = s ? strlen(s) : 0;
                 Value_P Z(new Value(len, LOC));
                 new (&Z->get_ravel(0)) IntCell(0);   // prototype
                 loop(z, len)   new (&Z->get_ravel(z)) IntCell(buffer[z] & 
0xFF);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]