Exported ASCII-DECODER-ENABLED-P; Added :start and :end parameters to receive-text.

Pascal J. Bourguignon [2021-05-17 14:11]
Exported ASCII-DECODER-ENABLED-P; Added :start and :end parameters to receive-text.
Filename
common-lisp/telnet/package.lisp
common-lisp/telnet/telnet.lisp
common-lisp/telnet/test.lisp
diff --git a/common-lisp/telnet/package.lisp b/common-lisp/telnet/package.lisp
index c0dd41f..fe581f3 100644
--- a/common-lisp/telnet/package.lisp
+++ b/common-lisp/telnet/package.lisp
@@ -57,6 +57,7 @@
    "OPTION" "OPTION-CODE" "OPTION-NAME"
    ;; Up interface (from up):
    "SEND-BINARY" "SEND-TEXT" "SEND-CONTROL"
+   "ASCII-DECODER-ENABLED-P"
    ;; Up interface (to up):
    "WANT-OPTION-P" "RECEIVE-BINARY" "RECEIVE-TEXT" "RECEIVE-CONTROL"
    ;; Down interface (to down):
diff --git a/common-lisp/telnet/telnet.lisp b/common-lisp/telnet/telnet.lisp
index 92255a2..e928595 100644
--- a/common-lisp/telnet/telnet.lisp
+++ b/common-lisp/telnet/telnet.lisp
@@ -407,7 +407,7 @@ BYTE:       a VECTOR of (UNSIGNED-BYTE 8).
 START, END: bounding index designators of sequence.
             The defaults are for START 0 and for END nil."))

-(defgeneric receive-text    (up-sender text)
+(defgeneric receive-text    (up-sender text &key start end)
   (:documentation "Receive some ASCII text.
 TEXT: If (ASCII-DECODER-ENABLED-P nvt)
       then a string containing only printable ASCII characters and #\newline,
@@ -1606,10 +1606,9 @@ RETURN: the length of bytes processed.
                                        :end2 end))
                             (return (- (+ processed (- end newend)) start)))
                            ((:text)
-                            (receive-text (up-sender nvt)
-                                          (if (ascii-decoder-enabled-p nvt)
-                                              (ascii-string bytes :newline :crlf :start processed :end newend)
-                                              (nsubseq bytes processed newend))))
+                            (if (ascii-decoder-enabled-p nvt)
+                                (receive-text (up-sender nvt) (ascii-string bytes :newline :crlf :start processed :end newend))
+                                (receive-text (up-sender nvt) bytes :start processed :end  newend)))
                            ((:control)
                             (let ((control (convert-control code)))
                               (when control
diff --git a/common-lisp/telnet/test.lisp b/common-lisp/telnet/test.lisp
index 2b03975..b039f28 100644
--- a/common-lisp/telnet/test.lisp
+++ b/common-lisp/telnet/test.lisp
@@ -124,11 +124,11 @@
 (defparameter *dlc*    (make-instance 'down-layer :name "Client DOWN"))
 (defparameter *dls*    (make-instance 'down-layer :name "Server DOWN"))
 (defparameter *client* (make-instance 'network-virtual-terminal
-                           :name "CLIENT NVT" :client t
-                           :up-sender *ulc* :down-sender  *dlc*))
+                                      :name "CLIENT NVT" :client t
+                                      :up-sender *ulc* :down-sender  *dlc*))
 (defparameter *server* (make-instance 'network-virtual-terminal
-                           :name "SERVER NVT" :client nil
-                           :up-sender *uls* :down-sender  *dls*))
+                                      :name "SERVER NVT" :client nil
+                                      :up-sender *uls* :down-sender  *dls*))

 (setf (layer-nvt *ulc*) *client*
       (layer-nvt *dlc*) *client*
ViewGit