bug-apl
[Top][All Lists]
Advanced

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

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


From: Juergen Sauermann
Subject: Re: [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 16:08:36 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130330 Thunderbird/17.0.5

Hi Kacper,

very good explanation, thanks. Fixed in SVN 226.

/// Jürgen


On 04/26/2014 03:43 PM, Kacper Gutowski wrote:
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]