Fixed time and space usage in cases where entity references
follow each other (thanks to Ivan Shvedunov for the report). * xml/xml-parse.lisp (P/CONTENT): Removed useless call to append. Use loop instead of tail recursion.
This commit is contained in:
@ -2800,19 +2800,17 @@
|
||||
|
||||
(defun p/content (input)
|
||||
;; [43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*
|
||||
(loop
|
||||
(multiple-value-bind (cat sem) (peek-token input)
|
||||
(case cat
|
||||
((:stag :ztag)
|
||||
(p/element input)
|
||||
(p/content input))
|
||||
(p/element input))
|
||||
((:CDATA)
|
||||
(process-characters input sem)
|
||||
(sax:characters (handler *ctx*) sem)
|
||||
(p/content input))
|
||||
(sax:characters (handler *ctx*) sem))
|
||||
((:ENTITY-REF)
|
||||
(let ((name sem))
|
||||
(consume-token input)
|
||||
(append
|
||||
(recurse-on-entity input name :general
|
||||
(lambda (input)
|
||||
(prog1
|
||||
@ -2821,24 +2819,20 @@
|
||||
(external-entdef (p/ext-parsed-ent input)))
|
||||
(unless (eq (peek-token input) :eof)
|
||||
(wf-error input "Trailing garbage. - ~S"
|
||||
(peek-token input))))))
|
||||
(p/content input))))
|
||||
(peek-token input))))))))
|
||||
((:<!\[)
|
||||
(let ((data (process-cdata-section input)))
|
||||
(sax:start-cdata (handler *ctx*))
|
||||
(sax:characters (handler *ctx*) data)
|
||||
(sax:end-cdata (handler *ctx*)))
|
||||
(p/content input))
|
||||
(sax:end-cdata (handler *ctx*))))
|
||||
((:PI)
|
||||
(consume-token input)
|
||||
(sax:processing-instruction (handler *ctx*) (car sem) (cdr sem))
|
||||
(p/content input))
|
||||
(sax:processing-instruction (handler *ctx*) (car sem) (cdr sem)))
|
||||
((:COMMENT)
|
||||
(consume-token input)
|
||||
(sax:comment (handler *ctx*) sem)
|
||||
(p/content input))
|
||||
(sax:comment (handler *ctx*) sem))
|
||||
(otherwise
|
||||
nil))))
|
||||
(return))))))
|
||||
|
||||
;; [78] extParsedEnt ::= TextDecl? contentw
|
||||
;; [79] extPE ::= TextDecl? extSubsetDecl
|
||||
|
||||
Reference in New Issue
Block a user