Skip to content

Commit

Permalink
Fix some ansi-test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
yitzchak committed Dec 18, 2023
1 parent 517c249 commit 617751d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
10 changes: 6 additions & 4 deletions include/clasp/core/lispStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ class StringInputStream_O : public StringStream_O {
void unread_char(claspCharacter c);
claspCharacter peek_char();
int listen();
void clear_input();

bool input_p() const;
T_sp element_type() const;
Expand Down Expand Up @@ -739,7 +740,7 @@ class SynonymStream_O : public AnsiStream_O {
T_sp length();
T_sp position();
T_sp set_position(T_sp pos);
int column();
int column() const;
int set_column(int column);

int input_handle();
Expand Down Expand Up @@ -794,7 +795,7 @@ class TwoWayStream_O : public AnsiStream_O {
T_sp element_type() const;

T_sp position();
int column();
int column() const;
int set_column(int column);

int input_handle();
Expand Down Expand Up @@ -841,7 +842,7 @@ class BroadcastStream_O : public AnsiStream_O {
T_sp position();
T_sp set_position(T_sp pos);
T_sp string_length(T_sp string);
int column();
int column() const;
int set_column(int column);
T_sp close(T_sp abort);
}; // BroadcastStream class
Expand Down Expand Up @@ -872,6 +873,7 @@ class ConcatenatedStream_O : public AnsiStream_O {
claspCharacter read_char();
void unread_char(claspCharacter c);
int listen();
void clear_input();

bool input_p() const;
T_sp element_type() const;
Expand Down Expand Up @@ -923,7 +925,7 @@ class EchoStream_O : public AnsiStream_O {
T_sp element_type() const;

T_sp position();
int column();
int column() const;
int set_column(int column);

int input_handle();
Expand Down
27 changes: 23 additions & 4 deletions src/core/lispStream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,8 @@ claspCharacter StringInputStream_O::peek_char() {

int StringInputStream_O::listen() { return (_InputPosition < _InputLimit) ? CLASP_LISTEN_AVAILABLE : CLASP_LISTEN_EOF; }

void StringInputStream_O::clear_input() {}

T_sp StringInputStream_O::element_type() const { return _Contents->element_type(); }

T_sp StringInputStream_O::position() { return Integer_O::create((gc::Fixnum)_InputPosition); }
Expand Down Expand Up @@ -1385,7 +1387,7 @@ T_sp TwoWayStream_O::element_type() const { return stream_element_type(_In); }

T_sp TwoWayStream_O::position() { return nil<T_O>(); }

int TwoWayStream_O::column() { return stream_column(_Out); }
int TwoWayStream_O::column() const { return stream_column(_Out); }

int TwoWayStream_O::set_column(int column) { return stream_set_column(_Out, column); }

Expand Down Expand Up @@ -1513,7 +1515,7 @@ T_sp BroadcastStream_O::string_length(T_sp string) {
: stream_string_length(oCar(cl__last(_Streams, clasp_make_fixnum(1))), string);
}

int BroadcastStream_O::column() { return _Streams.nilp() ? -1 : stream_column(oCar(_Streams)); }
int BroadcastStream_O::column() const { return _Streams.nilp() ? -1 : stream_column(oCar(_Streams)); }

int BroadcastStream_O::set_column(int column) {
for (T_sp cur = _Streams; cur.consp(); cur = gc::As_unsafe<Cons_sp>(cur)->cdr()) {
Expand Down Expand Up @@ -1638,7 +1640,7 @@ T_sp EchoStream_O::element_type() const { return stream_element_type(_In); }

T_sp EchoStream_O::position() { return nil<T_O>(); }

int EchoStream_O::column() { return stream_column(_Out); }
int EchoStream_O::column() const { return stream_column(_Out); }

int EchoStream_O::set_column(int column) { return stream_set_column(_Out, column); }

Expand Down Expand Up @@ -1700,6 +1702,8 @@ CL_DEFUN T_sp cl__echo_stream_output_stream(T_sp strm) {
*/

cl_index ConcatenatedStream_O::read_byte8(unsigned char* c, cl_index n) {
check_open();

cl_index out = 0;
while (out < n && !_List.nilp()) {
cl_index delta = stream_read_byte8(oCar(_List), c + out, n - out);
Expand All @@ -1712,6 +1716,8 @@ cl_index ConcatenatedStream_O::read_byte8(unsigned char* c, cl_index n) {
}

T_sp ConcatenatedStream_O::read_byte() {
check_open();

T_sp l = _List;
T_sp c = nil<T_O>();
while (!l.nilp()) {
Expand All @@ -1731,6 +1737,8 @@ bool ConcatenatedStream_O::input_p() const { return true; }
T_sp ConcatenatedStream_O::element_type() const { return _List.nilp() ? _lisp->_true() : stream_element_type(oCar(_List)); }

claspCharacter ConcatenatedStream_O::read_char() {
check_open();

T_sp l = _List;
claspCharacter c = EOF;
while (!l.nilp()) {
Expand All @@ -1743,11 +1751,15 @@ claspCharacter ConcatenatedStream_O::read_char() {
}

void ConcatenatedStream_O::unread_char(claspCharacter c) {
check_open();

unlikely_if(_List.nilp()) unread_error(asSmartPtr());
stream_unread_char(oCar(_List), c);
}

int ConcatenatedStream_O::listen() {
check_open();

while (!_List.nilp()) {
int f = stream_listen(oCar(_List));
if (f != CLASP_LISTEN_EOF) {
Expand All @@ -1758,6 +1770,13 @@ int ConcatenatedStream_O::listen() {
return CLASP_LISTEN_EOF;
}

void ConcatenatedStream_O::clear_input() {
check_open();

if (_List.notnilp())
stream_clear_input(oCar(_List));
}

T_sp ConcatenatedStream_O::position() { return nil<T_O>(); }

T_sp ConcatenatedStream_O::close(T_sp abort) {
Expand Down Expand Up @@ -1868,7 +1887,7 @@ T_sp SynonymStream_O::position() { return stream_position(stream()); }

T_sp SynonymStream_O::set_position(T_sp pos) { return stream_set_position(stream(), pos); }

int SynonymStream_O::column() { return stream_column(stream()); }
int SynonymStream_O::column() const { return stream_column(stream()); }

int SynonymStream_O::set_column(int column) { return stream_set_column(stream(), column); }

Expand Down

0 comments on commit 617751d

Please sign in to comment.