read_integer causing "user directive failed" in 1.3.0 on x86_64 (Linux)

"Scott L. Burson" <[email protected]>
Newsgroups gmane.comp.gnu.prolog.bugs
Message-ID <[email protected]>
Hi,

I have a simple program that reads an input file containing one integer 
and one atom on each line.  I have two builds of GNU Prolog 1.3.0, one 
on a 32-bit Linux (SuSE 9.3) and the other on a 64-bit Linux (SuSE Linux 
Enterprise Desktop 10).  The program behaves differently in the two 
environments.  The difference seems to come down to what happens when I 
call `read_integer' when the input stream pointer is immediately before 
the newline which is the last character in the file.  On the 32-bit 
machine, the `read_integer' simply fails; on the 64-bit machine, I get 
"warning: ... user directive failed" and the program exits.

I can work around the problem by consuming the newline and testing for 
end_of_file before invoking `read_integer', so I don't need this fixed 
urgently.

I run the test case by doing

  % gplc --no-debugger --no-top-level example.pl
  % example <input.dat

Code and sample input is below.

-- Scott

-------- example.pl
:- initialization(main).

main :-
    read_pairs(Ps),
    print(Ps),
    nl.

read_pairs([P | Ps]) :-
    catch(read_pair(P), _, fail),
    read_pairs(Ps).

read_pairs([]) :-
    at_end_of_stream.

read_pair(pair(I, A)) :-
    peek_char(C),
    read_integer(I),
    read_atom(A).

-------- input.dat
0 a
1 b
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.