[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #62725] "help fputs" has unclear reference to
From: |
Michael Leitner |
Subject: |
[Octave-bug-tracker] [bug #62725] "help fputs" has unclear reference to EOF |
Date: |
Fri, 8 Jul 2022 17:04:02 -0400 (EDT) |
Follow-up Comment #1, bug #62725 (project octave):
Triggering is not hard: open an existing file foo for reading and try to print
a string to it:
++
fid=fopen("foo","r");
a=fputs(fid,"bar")
--
On my system, a is indeed the double -1. Yes, your suggestion solves the
documentation bug (it is indeed a bug, because the octave interpreter does not
know EOF, different from, for example, SEEK_CUR), but I would even say that
fputs should not just pass through the return value from the internally used C
function, but rather check this return value and itself return 0 for success
and -1 for error, as it probably does already on the vast majority of
installations, and it should also be documented like that. In C, this would be
just a
++
return -(r<0)
--
where r is the return value of the system function, which takes practically
zero additional time compared to what fputs itself costs.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?62725>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/