equal
deleted
inserted
replaced
644 |
644 |
645 |answerStream char wasBinary available "{ Class:SmallInteger }"| |
645 |answerStream char wasBinary available "{ Class:SmallInteger }"| |
646 |
646 |
647 answerStream := WriteStream on:(String uninitializedNew:80). |
647 answerStream := WriteStream on:(String uninitializedNew:80). |
648 [ |
648 [ |
|
649 "#atEnd waits for new data or EOF" |
|
650 self atEnd ifTrue:[ |
|
651 answerStream size == 0 ifTrue:[ |
|
652 ^ self pastEndRead. |
|
653 ]. |
|
654 ^ answerStream contents. |
|
655 ]. |
649 available := self numAvailableForRead. |
656 available := self numAvailableForRead. |
|
657 available == 0 ifTrue:[ |
|
658 "so #atEnd didn't wait above, but no data is present - check for error" |
|
659 self peek. |
|
660 available := self numAvailableForRead. |
|
661 ]. |
|
662 |
650 wasBinary := binary. "temporarily set to text mode" |
663 wasBinary := binary. "temporarily set to text mode" |
651 binary := false. |
664 binary := false. |
652 available timesRepeat:[ |
665 available timesRepeat:[ |
653 char := super nextOrNil. "don't wait - we know that there is data" |
666 char := super nextOrNil. "don't wait - we know that there is data" |
654 char == Character cr ifTrue:[ |
667 char == Character cr ifTrue:[ |
661 char notNil ifTrue:[ |
674 char notNil ifTrue:[ |
662 answerStream nextPut:char. |
675 answerStream nextPut:char. |
663 ]. |
676 ]. |
664 ]. |
677 ]. |
665 binary := wasBinary. "restore saved mode" |
678 binary := wasBinary. "restore saved mode" |
666 |
|
667 "#atEnd waits for new data or EOF" |
|
668 self atEnd ifTrue:[ |
|
669 answerStream size == 0 ifTrue:[ |
|
670 ^ self pastEndRead. |
|
671 ]. |
|
672 ^ answerStream contents. |
|
673 ]. |
|
674 ] loop. |
679 ] loop. |
675 |
680 |
676 "not reached" |
681 "not reached" |
677 ! |
682 ! |
678 |
683 |
724 and also positions behind it, but DOES include it in the returned value." |
729 and also positions behind it, but DOES include it in the returned value." |
725 |
730 |
726 |element available "{ Class:SmallInteger }"| |
731 |element available "{ Class:SmallInteger }"| |
727 |
732 |
728 [ |
733 [ |
|
734 "#atEnd waits for new data or EOF" |
|
735 self atEnd ifTrue:[ |
|
736 ^ self. |
|
737 ]. |
729 available := self numAvailableForRead. |
738 available := self numAvailableForRead. |
|
739 available == 0 ifTrue:[ |
|
740 "so #atEnd didn't wait above, but no data is present - check for error" |
|
741 self peek. |
|
742 available := self numAvailableForRead. |
|
743 ]. |
|
744 |
730 available timesRepeat:[ |
745 available timesRepeat:[ |
731 element := super next. "we know that there is data" |
746 element := super next. "we know that there is data" |
732 element = anObject ifTrue:[ |
747 element = anObject ifTrue:[ |
733 ^ self. |
748 ^ self. |
734 ]. |
749 ]. |
735 aStream nextPut:element. |
750 aStream nextPut:element. |
736 ]. |
751 ]. |
737 "#atEnd waits for new data or EOF" |
|
738 self atEnd ifTrue:[ |
|
739 ^ self. |
|
740 ]. |
|
741 ] loop. |
752 ] loop. |
742 |
753 |
743 "not reached" |
754 "not reached" |
744 ! ! |
755 ! ! |
745 |
756 |