put
This commit is contained in:
parent
85a7e7b9b0
commit
c8aee540ce
37
C/iopreds.c
37
C/iopreds.c
@ -110,8 +110,6 @@ 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_past_eof, (void));
|
||||
STATIC_PROTO (Int p_put, (void));
|
||||
STATIC_PROTO (Int p_put_byte, (void));
|
||||
STATIC_PROTO (Int p_skip, (void));
|
||||
STATIC_PROTO (Int p_write_depth, (void));
|
||||
STATIC_PROTO (Int p_user_file_name, (void));
|
||||
@ -2540,39 +2538,6 @@ p_get0_line_codes (void)
|
||||
return Yap_unify(out,ARG2);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_put (void)
|
||||
{ /* '$put'(Stream,N) */
|
||||
int sno = CheckStream (ARG1, Output_Stream_f, "put/2");
|
||||
if (sno < 0)
|
||||
return (FALSE);
|
||||
if (Stream[sno].status & Binary_Stream_f) {
|
||||
UNLOCK(Stream[sno].streamlock);
|
||||
Yap_Error(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, ARG1, "put/2");
|
||||
return(FALSE);
|
||||
}
|
||||
Stream[sno].stream_wputc (sno, (int) IntegerOfTerm (Deref (ARG2)));
|
||||
UNLOCK(Stream[sno].streamlock);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_put_byte (void)
|
||||
{ /* '$put_byte'(Stream,N) */
|
||||
int sno = CheckStream (ARG1, Output_Stream_f, "put/2");
|
||||
if (sno < 0)
|
||||
return (FALSE);
|
||||
if (!(Stream[sno].status & Binary_Stream_f) &&
|
||||
yap_flags[STRICT_ISO_FLAG]) {
|
||||
UNLOCK(Stream[sno].streamlock);
|
||||
Yap_Error(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, ARG1, "get0/2");
|
||||
return(FALSE);
|
||||
}
|
||||
Stream[sno].stream_putc(sno, (int) IntegerOfTerm (Deref (ARG2)));
|
||||
UNLOCK(Stream[sno].streamlock);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#define FORMAT_MAX_SIZE 256
|
||||
|
||||
typedef struct {
|
||||
@ -4074,8 +4039,6 @@ Yap_InitIOPreds(void)
|
||||
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);
|
||||
Yap_InitCPred ("$put", 2, p_put, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred ("$put_byte", 2, p_put_byte, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred ("$set_read_error_handler", 1, p_set_read_error_handler, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred ("$get_read_error_handler", 1, p_get_read_error_handler, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred ("$read", 6, p_read, SyncPredFlag|HiddenPredFlag|UserCPredFlag);
|
||||
|
18
pl/boot.yap
18
pl/boot.yap
@ -1481,3 +1481,21 @@ peek_code(C) :-
|
||||
swi_peek_code(C).
|
||||
peek_code(Stream, C) :-
|
||||
swi_peek_code(Stream, C).
|
||||
|
||||
put(C) :-
|
||||
swi_put(C).
|
||||
put(Stream, C) :-
|
||||
swi_put(Stream, C).
|
||||
put_byte(C) :-
|
||||
swi_put_byte(C).
|
||||
put_byte(Stream, C) :-
|
||||
swi_put_byte(Stream, C).
|
||||
put_char(C) :-
|
||||
swi_put_char(C).
|
||||
put_char(Stream, C) :-
|
||||
swi_put_char(Stream, C).
|
||||
put_code(C) :-
|
||||
swi_put_code(C).
|
||||
put_code(Stream, C) :-
|
||||
swi_put_code(Stream, C).
|
||||
|
||||
|
67
pl/yio.yap
67
pl/yio.yap
@ -268,9 +268,9 @@ read_term(Stream, T, Options) :-
|
||||
'$add_singleton_if_no_underscore'(Na,V2,NSs,[(Name=V2)|NSs]) :-
|
||||
atom_codes(Name, Na).
|
||||
|
||||
nl(Stream) :- '$put'(Stream,10).
|
||||
nl(Stream) :- put(Stream,10).
|
||||
|
||||
nl :- current_output(Stream), '$put'(Stream,10), fail.
|
||||
nl :- current_output(Stream), put(Stream,10), fail.
|
||||
nl.
|
||||
|
||||
/* meaning of flags for '$write' is
|
||||
@ -410,67 +410,6 @@ format(T) :-
|
||||
|
||||
/* character I/O */
|
||||
|
||||
put_byte(V) :- var(V), !,
|
||||
'$do_error'(instantiation_error,put_byte(V)).
|
||||
put_byte(V) :-
|
||||
(\+ integer(V) ; V < 0 ; V > 256), !,
|
||||
'$do_error'(type_error(byte,V),put_byte(V)).
|
||||
put_byte(V) :-
|
||||
current_output(S),
|
||||
'$put_byte'(S,V).
|
||||
|
||||
|
||||
put_byte(S,V) :- var(V), !,
|
||||
'$do_error'(instantiation_error,put_byte(S,V)).
|
||||
put_byte(S,V) :-
|
||||
(\+ integer(V) ; V < 0 ; V > 256), !,
|
||||
'$do_error'(type_error(byte,V),put_byte(S,V)).
|
||||
put_byte(S,V) :-
|
||||
'$put_byte'(S,V).
|
||||
|
||||
put_char(V) :- var(V), !,
|
||||
'$do_error'(instantiation_error,put_char(V)).
|
||||
put_char(V) :-
|
||||
( atom(V) -> atom_codes(V,[_,_|_]) ; true ), !,
|
||||
'$do_error'(type_error(character,V),put_char(V)).
|
||||
put_char(V) :-
|
||||
current_output(S),
|
||||
atom_codes(V,[I]),
|
||||
'$put'(S,I).
|
||||
|
||||
put_char(S,V) :- var(V), !,
|
||||
'$do_error'(instantiation_error,put_char(S,V)).
|
||||
put_char(S,V) :-
|
||||
( atom(V) -> atom_codes(V,[_,_|_]) ; true ), !,
|
||||
'$do_error'(type_error(character,V),put_char(S,V)).
|
||||
put_char(S,V) :-
|
||||
atom_codes(V,[I]),
|
||||
'$put'(S,I).
|
||||
|
||||
put_code(V) :- var(V), !,
|
||||
'$do_error'(instantiation_error,put_code(V)).
|
||||
put_code(V) :-
|
||||
(\+ integer(V)), !,
|
||||
'$do_error'(type_error(character_code,V),put_code(V)).
|
||||
put_code(V) :-
|
||||
current_output(S),
|
||||
'$put'(S,V).
|
||||
|
||||
|
||||
put_code(S,V) :- var(V), !,
|
||||
'$do_error'(instantiation_error,put_code(S,V)).
|
||||
put_code(S,V) :-
|
||||
(\+ integer(V)), !,
|
||||
'$do_error'(type_error(character_code,V),put_code(S,V)).
|
||||
put_code(S,V) :-
|
||||
'$put'(S,V).
|
||||
|
||||
|
||||
|
||||
put(N) :- current_output(S), N1 is N, '$put'(S,N1).
|
||||
|
||||
put(Stream,N) :- N1 is N, '$put'(Stream,N1).
|
||||
|
||||
skip(N) :- current_input(S), N1 is N, '$skip'(S,N1).
|
||||
|
||||
skip(Stream,N) :- N1 is N, '$skip'(Stream,N1).
|
||||
@ -494,7 +433,7 @@ ttyget0(N) :- get0(user_input,N).
|
||||
|
||||
ttyskip(N) :- N1 is N, '$skip'(user_input,N1).
|
||||
|
||||
ttyput(N) :- N1 is N, '$put'(user_output,N1).
|
||||
ttyput(N) :- N1 is N, put(user_output,N1).
|
||||
|
||||
ttynl :- nl(user_output).
|
||||
|
||||
|
Reference in New Issue
Block a user