get predicates.
This commit is contained in:
parent
67d23051c2
commit
a851c56e3d
47
C/iopreds.c
47
C/iopreds.c
@ -113,9 +113,6 @@ STATIC_PROTO (Int p_write2, (void));
|
||||
STATIC_PROTO (Int p_set_read_error_handler, (void));
|
||||
STATIC_PROTO (Int p_get_read_error_handler, (void));
|
||||
STATIC_PROTO (Int p_read, (void));
|
||||
STATIC_PROTO (Int p_get, (void));
|
||||
STATIC_PROTO (Int p_get0, (void));
|
||||
STATIC_PROTO (Int p_get_byte, (void));
|
||||
STATIC_PROTO (Int p_peek, (void));
|
||||
STATIC_PROTO (Int p_past_eof, (void));
|
||||
STATIC_PROTO (Int p_put, (void));
|
||||
@ -2692,26 +2689,6 @@ p_get (void)
|
||||
return (Yap_unify_constant (ARG2, MkIntegerTerm (ch)));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_get0 (void)
|
||||
{ /* get0(Stream,-N) */
|
||||
int sno = CheckStream (ARG1, Input_Stream_f, "get0/2");
|
||||
Int status;
|
||||
Int out;
|
||||
|
||||
if (sno < 0)
|
||||
return(FALSE);
|
||||
status = Stream[sno].status;
|
||||
if (status & Binary_Stream_f) {
|
||||
UNLOCK(Stream[sno].streamlock);
|
||||
Yap_Error(PERMISSION_ERROR_INPUT_BINARY_STREAM, ARG1, "get0/2");
|
||||
return FALSE;
|
||||
}
|
||||
UNLOCK(Stream[sno].streamlock);
|
||||
out = Stream[sno].stream_wgetc(sno);
|
||||
return (Yap_unify_constant (ARG2, MkIntegerTerm (out)) );
|
||||
}
|
||||
|
||||
static Term
|
||||
read_line(int sno)
|
||||
{
|
||||
@ -2756,27 +2733,6 @@ p_get0_line_codes (void)
|
||||
return Yap_unify(out,ARG2);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_get_byte (void)
|
||||
{ /* '$get_byte'(Stream,-N) */
|
||||
int sno = CheckStream (ARG1, Input_Stream_f, "get_byte/2");
|
||||
Int status;
|
||||
Term out;
|
||||
|
||||
if (sno < 0)
|
||||
return(FALSE);
|
||||
status = Stream[sno].status;
|
||||
if (!(status & Binary_Stream_f) &&
|
||||
yap_flags[STRICT_ISO_FLAG]) {
|
||||
UNLOCK(Stream[sno].streamlock);
|
||||
Yap_Error(PERMISSION_ERROR_INPUT_TEXT_STREAM, ARG1, "get_byte/2");
|
||||
return(FALSE);
|
||||
}
|
||||
out = MkIntTerm(Stream[sno].stream_getc(sno));
|
||||
UNLOCK(Stream[sno].streamlock);
|
||||
return Yap_unify_constant (ARG2, out);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_put (void)
|
||||
{ /* '$put'(Stream,N) */
|
||||
@ -4307,10 +4263,7 @@ Yap_InitIOPreds(void)
|
||||
Stream = (StreamDesc *)Yap_AllocCodeSpace(sizeof(StreamDesc)*MaxStreams);
|
||||
/* here the Input/Output predicates */
|
||||
Yap_InitCPred ("$close", 1, p_close, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred ("get", 2, p_get, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred ("get0", 2, p_get0, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred ("$get0_line_codes", 2, p_get0_line_codes, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred ("$get_byte", 2, p_get_byte, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred ("$access", 1, p_access, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred ("exists_directory", 1, p_exists_directory, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("$file_expansion", 2, p_file_expansion, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
|
20
pl/boot.yap
20
pl/boot.yap
@ -1439,3 +1439,23 @@ ttyflush :-
|
||||
swi_ttyflush.
|
||||
|
||||
|
||||
get(C) :-
|
||||
swi_get(C).
|
||||
get(Stream, C) :-
|
||||
swi_get(Stream, C).
|
||||
get0(C) :-
|
||||
swi_get0(C).
|
||||
get0(Stream, C) :-
|
||||
swi_get0(Stream, C).
|
||||
get_byte(C) :-
|
||||
swi_get_byte(C).
|
||||
get_byte(Stream, C) :-
|
||||
swi_get_byte(Stream, C).
|
||||
get_char(C) :-
|
||||
swi_get_char(C).
|
||||
get_char(Stream, C) :-
|
||||
swi_get_char(Stream, C).
|
||||
get_code(C) :-
|
||||
swi_get_code(C).
|
||||
get_code(Stream, C) :-
|
||||
swi_get_code(Stream, C).
|
||||
|
47
pl/yio.yap
47
pl/yio.yap
@ -416,21 +416,6 @@ format(T) :-
|
||||
|
||||
/* character I/O */
|
||||
|
||||
get(N) :- current_input(S), get(S,N).
|
||||
|
||||
get_byte(V) :-
|
||||
\+ var(V), (\+ integer(V) ; V < -1 ; V > 256), !,
|
||||
'$do_error'(type_error(in_byte,V),get_byte(V)).
|
||||
get_byte(V) :-
|
||||
current_input(S),
|
||||
'$get_byte'(S,V).
|
||||
|
||||
get_byte(S,V) :-
|
||||
\+ var(V), (\+ integer(V) ; V < -1 ; V > 256), !,
|
||||
'$do_error'(type_error(in_byte,V),get_byte(S,V)).
|
||||
get_byte(S,V) :-
|
||||
'$get_byte'(S,V).
|
||||
|
||||
peek_byte(V) :-
|
||||
\+ var(V), (\+ integer(V) ; V < -1 ; V > 256), !,
|
||||
'$do_error'(type_error(in_byte,V),get_byte(V)).
|
||||
@ -444,23 +429,6 @@ peek_byte(S,V) :-
|
||||
peek_byte(S,V) :-
|
||||
'$peek_byte'(S,V).
|
||||
|
||||
get_char(V) :-
|
||||
\+ var(V),
|
||||
( atom(V) -> atom_codes(V,[_,_|_]), V \= end_of_file ; true ), !,
|
||||
'$do_error'(type_error(in_character,V),get_char(V)).
|
||||
get_char(V) :-
|
||||
current_input(S),
|
||||
get0(S,I),
|
||||
( I = -1 -> V = end_of_file ; atom_codes(V,[I])).
|
||||
|
||||
get_char(S,V) :-
|
||||
\+ var(V),
|
||||
( atom(V) -> atom_codes(V,[_,_|_]), V \= end_of_file ; true ), !,
|
||||
'$do_error'(type_error(in_character,V),get_char(S,V)).
|
||||
get_char(S,V) :-
|
||||
get0(S,I),
|
||||
( I = -1 -> V = end_of_file ; atom_codes(V,[I])).
|
||||
|
||||
peek_char(V) :-
|
||||
\+ var(V),
|
||||
( atom(V) -> atom_codes(V,[_,_|_]), V \= end_of_file ; true ), !,
|
||||
@ -478,19 +446,6 @@ peek_char(S,V) :-
|
||||
'$peek'(S,I),
|
||||
( I = -1 -> V = end_of_file ; atom_codes(V,[I])).
|
||||
|
||||
get_code(S,V) :-
|
||||
\+ var(V), (\+ integer(V)), !,
|
||||
'$do_error'(type_error(in_character_code,V),get_code(S,V)).
|
||||
get_code(S,V) :-
|
||||
get0(S,V).
|
||||
|
||||
get_code(V) :-
|
||||
\+ var(V), (\+ integer(V)), !,
|
||||
'$do_error'(type_error(in_character_code,V),get_code(V)).
|
||||
get_code(V) :-
|
||||
current_input(S),
|
||||
get0(S,V).
|
||||
|
||||
peek_code(S,V) :-
|
||||
\+ var(V), (\+ integer(V)), !,
|
||||
'$do_error'(type_error(in_character_code,V),get_code(S,V)).
|
||||
@ -561,8 +516,6 @@ put_code(S,V) :-
|
||||
|
||||
|
||||
|
||||
get0(N) :- current_input(S), get0(S,N).
|
||||
|
||||
put(N) :- current_output(S), N1 is N, '$put'(S,N1).
|
||||
|
||||
put(Stream,N) :- N1 is N, '$put'(Stream,N1).
|
||||
|
Reference in New Issue
Block a user