Skip to content

Commit

Permalink
Fixed get get0
Browse files Browse the repository at this point in the history
  • Loading branch information
sasagawa888 committed Oct 24, 2024
1 parent ebee700 commit 59108d0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
7 changes: 1 addition & 6 deletions builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,9 +691,6 @@ int b_get0(int arglist, int rest)
else
c = getc(GET_PORT(arg1));

if (c == EOL) {
c = getc(GET_PORT(arg1));
}
if(c==EOF)
return(NO);

Expand Down Expand Up @@ -736,12 +733,10 @@ int b_get(int arglist, int rest)
else
c = getc(GET_PORT(arg1));

if (c == EOL)
c = getc(GET_PORT(arg1));

if(c==EOF)
return(NO);

i = (int) c;
if (c == EOL)
goto exit;
Expand Down
29 changes: 28 additions & 1 deletion tests/bug.pl
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
% 9-queens program



test16 :- between(1,16,X),test1,fail.

test :- queen([1,2,3,4,5,6,7,8,9],X),write(X),nl,fail.
test1 :- queen([1,2,3,4,5,6,7,8,9],X),fail.

queen(Data, Out) :-
queen_2(Data, [], Out).

queen_2([], _, []).
queen_2([H|T], History, [Q|M]) :-
qdelete(Q, H, T, L1),
nodiag(History, Q, 1),
queen_2(L1, [Q|History], M).


qdelete(A, A, L, L).
qdelete(X, A, [H|T], [A|R]) :-
qdelete(X, H, T, R).


nodiag([], _, _).
nodiag([N|L], B, D) :-
D =\= N - B,
D =\= B - N,
D1 is D + 1,
nodiag(L, B, D1).

7 changes: 7 additions & 0 deletions tests/iitaka.pl
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,11 @@
repeat,
while_do(get0(H,C),put(C)),
close(H),!.

copy_file(File_nameX,File_nameY):-
open(H1,File_nameX,r),
create(H2,File_nameY),
repeat,
while_do(get0(H1,C),put(H2,C)),
close(H1),close(H2),!.

0 comments on commit 59108d0

Please sign in to comment.