1
0
Fork 0

- allowed empty lines in a gopher map (thanks op!).

This commit is contained in:
cage 2024-02-19 20:49:14 +01:00
parent bc8c34f2f6
commit e23ca2c131
3 changed files with 34 additions and 12 deletions

View File

@ -152,6 +152,9 @@
(defmethod gopher-line->text ((line gopher-parser:line-unknown)) (defmethod gopher-line->text ((line gopher-parser:line-unknown))
(%gemline->text-simple line (swconf:config-gopher-line-prefix-unknown))) (%gemline->text-simple line (swconf:config-gopher-line-prefix-unknown)))
(defmethod gopher-line->text ((line gopher-parser:line-empty))
(%gemline->text-simple line ""))
(defun print-response-rows (window gopher-lines) (defun print-response-rows (window gopher-lines)
(flet ((make-rows (lines) (flet ((make-rows (lines)
(mapcar (lambda (line) (mapcar (lambda (line)
@ -179,7 +182,8 @@
(defun not-link-line-p (line) (defun not-link-line-p (line)
(let ((original-object (message-window:extract-original-object line))) (let ((original-object (message-window:extract-original-object line)))
(not (or (gopher-parser:line-type-info-p original-object) (not (or (gopher-parser:line-type-info-p original-object)
(gopher-parser:line-type-error-p original-object))))) (gopher-parser:line-type-error-p original-object)
(gopher-parser:line-type-empty-p original-object)))))
(defun go-to-next-link () (defun go-to-next-link ()
(a:when-let* ((win *gopher-window*) (a:when-let* ((win *gopher-window*)

View File

@ -62,11 +62,13 @@
:line-info :line-info
:line-uri :line-uri
:line-unknown :line-unknown
:line-empty
:line-type-file-p :line-type-file-p
:line-type-info-p :line-type-info-p
:line-type-dir-p :line-type-dir-p
:line-type-cso-p :line-type-cso-p
:line-type-error-p :line-type-error-p
:line-type-empty-p
:line-type-mac-hex-file-p :line-type-mac-hex-file-p
:line-type-dos-archive-file-p :line-type-dos-archive-file-p
:line-type-uuencoded-file-p :line-type-uuencoded-file-p

View File

@ -42,7 +42,8 @@
(gif-image-file "g" "identifier for an image in GIF") (gif-image-file "g" "identifier for an image in GIF")
(image-file "I" "identifier for an image file") (image-file "I" "identifier for an image file")
(info "i" "information line") (info "i" "information line")
(uri "h" "hyperlink"))) (uri "h" "hyperlink")
(empty "" "empty line")))
(a:define-constant +gopher-scheme+ "gopher" :test #'string=) (a:define-constant +gopher-scheme+ "gopher" :test #'string=)
@ -86,6 +87,8 @@
(%gen-check-line-predicate uri +line-type-uri+) (%gen-check-line-predicate uri +line-type-uri+)
(%gen-check-line-predicate empty +line-type-empty+)
(defclass gopher-line () (defclass gopher-line ()
((line-type-id ((line-type-id
:initarg :line-type-id :initarg :line-type-id
@ -160,6 +163,8 @@
(gen-selector-class line-unknown) (gen-selector-class line-unknown)
(gen-selector-class line-empty)
(defun check-line-type (data reference) (defun check-line-type (data reference)
(typep data reference)) (typep data reference))
@ -200,7 +205,9 @@
(gen-check-line-predicate uri 'line-uri) (gen-check-line-predicate uri 'line-uri)
(gen-check-line-predicate unknown 'unknown) (gen-check-line-predicate unknown 'line-unknown)
(gen-check-line-predicate empty 'line-empty)
(defrule line-separator (and #\Return #\Newline) (defrule line-separator (and #\Return #\Newline)
(:constant :line-separator)) (:constant :line-separator))
@ -246,16 +253,23 @@
(defrule port digit-sequence (defrule port digit-sequence
(:function parse-integer)) (:function parse-integer))
(defrule dir-entity (and line-type user-name field-separator (defrule dir-entity (or (and line-type user-name field-separator
selector field-separator selector field-separator
host field-separator host field-separator
port line-separator) port line-separator)
line-separator)
(:function (lambda (line) (:function (lambda (line)
(list :type (first line) (if (listp line)
:user-name (second line) (list :type (first line)
:selector (fourth line) :user-name (second line)
:host (sixth line) :selector (fourth line)
:port (elt line 7))))) :host (sixth line)
:port (elt line 7))
(list :type +line-type-empty+
:user-name ""
:selector ""
:host ""
:port "")))))
(defrule menu (and (* dir-entity) (? last-line)) (defrule menu (and (* dir-entity) (? last-line))
(:function first)) (:function first))
@ -298,6 +312,8 @@
(make-instance 'line-info)) (make-instance 'line-info))
((%line-type-uri-p line-type) ((%line-type-uri-p line-type)
(make-instance 'line-uri)) (make-instance 'line-uri))
((%line-type-empty-p line-type)
(make-instance 'line-empty))
(t (t
(make-instance 'line-unknown))))) (make-instance 'line-unknown)))))
(setf (line-type-id instance) (getf entry :type) (setf (line-type-id instance) (getf entry :type)