diff options
| author | Mark A. Hershberger | 2005-06-10 15:37:37 +0000 |
|---|---|---|
| committer | Mark A. Hershberger | 2005-06-10 15:37:37 +0000 |
| commit | 23d519e49c597f10b0a778cc340e233d74127c3d (patch) | |
| tree | 2e82f64456a150867b76ffd3e47997d09a840f09 | |
| parent | 578c1340ea0f4d6a6aa9d86ff5d89bdf690e8fbb (diff) | |
| download | emacs-23d519e49c597f10b0a778cc340e233d74127c3d.tar.gz emacs-23d519e49c597f10b0a778cc340e233d74127c3d.zip | |
eliminate use of inefficient match-data
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/xml.el | 60 |
2 files changed, 54 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 09ce2a4e50a..724d86a95b6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2005-06-10 Mark A. Hershberger <mah@everybody.org> | ||
| 2 | |||
| 3 | * xml.el (start-chars, xml-parse-dtd): Add the ability to skip | ||
| 4 | ATTLIST portions of included DTDs. | ||
| 5 | (xml-parse-dtd): Eliminate use of inefficient match-data. | ||
| 6 | |||
| 1 | 2005-06-10 Miles Bader <miles@gnu.org> | 7 | 2005-06-10 Miles Bader <miles@gnu.org> |
| 2 | 8 | ||
| 3 | * play/mpuz.el (mpuz-unsolved, mpuz-solved, mpuz-trivial) | 9 | * play/mpuz.el (mpuz-unsolved, mpuz-solved, mpuz-trivial) |
diff --git a/lisp/xml.el b/lisp/xml.el index f9527a276b1..f4300817836 100644 --- a/lisp/xml.el +++ b/lisp/xml.el | |||
| @@ -211,6 +211,35 @@ If PARSE-NS is non-nil, then QNAMES are expanded." | |||
| 211 | (defvar xml-pe-reference-re (concat "%" xml-name-re ";")) | 211 | (defvar xml-pe-reference-re (concat "%" xml-name-re ";")) |
| 212 | ;;[67] Reference ::= EntityRef | CharRef | 212 | ;;[67] Reference ::= EntityRef | CharRef |
| 213 | (defvar xml-reference-re (concat "\\(?:" xml-entity-ref "\\|" xml-char-ref-re "\\)")) | 213 | (defvar xml-reference-re (concat "\\(?:" xml-entity-ref "\\|" xml-char-ref-re "\\)")) |
| 214 | ;;[10] AttValue ::= '"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'" | ||
| 215 | (defvar xml-att-value-re (concat "\\(?:\"\\(?:[^&\"]\\|" xml-reference-re "\\)*\"\\|" | ||
| 216 | "'\\(?:[^&']\\|" xml-reference-re "\\)*'\\)")) | ||
| 217 | ;;[56] TokenizedType ::= 'ID' [VC: ID] [VC: One ID per Element Type] [VC: ID Attribute Default] | ||
| 218 | ;; | 'IDREF' [VC: IDREF] | ||
| 219 | ;; | 'IDREFS' [VC: IDREF] | ||
| 220 | ;; | 'ENTITY' [VC: Entity Name] | ||
| 221 | ;; | 'ENTITIES' [VC: Entity Name] | ||
| 222 | ;; | 'NMTOKEN' [VC: Name Token] | ||
| 223 | ;; | 'NMTOKENS' [VC: Name Token] | ||
| 224 | (defvar xml-tokenized-type-re "\\(?:ID\\|IDREF\\|IDREFS\\|ENTITY\\|ENTITIES\\|NMTOKEN\\|NMTOKENS\\)") | ||
| 225 | ;;[58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')' | ||
| 226 | (defvar xml-notation-type-re (concat "\\(?:NOTATION" whitespace "(" whitespace "*" xml-name-re | ||
| 227 | "\\(?:" whitespace "*|" whitespace "*" xml-name-re "\\)*" whitespace "*)\\)")) | ||
| 228 | ;;[59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')' [VC: Enumeration] [VC: No Duplicate Tokens] | ||
| 229 | (defvar xml-enumeration-re (concat "\\(?:(" whitespace "*" xml-nmtoken-re | ||
| 230 | "\\(?:" whitespace "*|" whitespace "*" xml-nmtoken-re "\\)*" | ||
| 231 | whitespace ")\\)")) | ||
| 232 | ;;[57] EnumeratedType ::= NotationType | Enumeration | ||
| 233 | (defvar xml-enumerated-type-re (concat "\\(?:" xml-notation-type-re "\\|" xml-enumeration-re "\\)")) | ||
| 234 | ;;[54] AttType ::= StringType | TokenizedType | EnumeratedType | ||
| 235 | ;;[55] StringType ::= 'CDATA' | ||
| 236 | (defvar xml-att-type-re (concat "\\(?:CDATA\\|" xml-tokenized-type-re "\\|" xml-notation-type-re"\\|" xml-enumerated-type-re "\\)")) | ||
| 237 | ;;[60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue) | ||
| 238 | (defvar xml-default-decl-re (concat "\\(?:#REQUIRED\\|#IMPLIED\\|\\(?:#FIXED" whitespace "\\)*" xml-att-value-re "\\)")) | ||
| 239 | ;;[53] AttDef ::= S Name S AttType S DefaultDecl | ||
| 240 | (defvar xml-att-def-re (concat "\\(?:" whitespace "*" xml-name-re | ||
| 241 | whitespace "*" xml-att-type-re | ||
| 242 | whitespace "*" xml-default-decl-re "\\)")) | ||
| 214 | ;;[9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"' | 243 | ;;[9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"' |
| 215 | ;; | "'" ([^%&'] | PEReference | Reference)* "'" | 244 | ;; | "'" ([^%&'] | PEReference | Reference)* "'" |
| 216 | (defvar xml-entity-value-re (concat "\\(?:\"\\(?:[^%&\"]\\|" xml-pe-reference-re | 245 | (defvar xml-entity-value-re (concat "\\(?:\"\\(?:[^%&\"]\\|" xml-pe-reference-re |
| @@ -580,7 +609,7 @@ This follows the rule [28] in the XML specifications." | |||
| 580 | (error "XML: Bad DTD") | 609 | (error "XML: Bad DTD") |
| 581 | (forward-char) | 610 | (forward-char) |
| 582 | ;; Parse the rest of the DTD | 611 | ;; Parse the rest of the DTD |
| 583 | ;; Fixme: Deal with ATTLIST, NOTATION, PIs. | 612 | ;; Fixme: Deal with NOTATION, PIs. |
| 584 | (while (not (looking-at "\\s-*\\]")) | 613 | (while (not (looking-at "\\s-*\\]")) |
| 585 | (skip-syntax-forward " ") | 614 | (skip-syntax-forward " ") |
| 586 | (cond | 615 | (cond |
| @@ -616,16 +645,24 @@ This follows the rule [28] in the XML specifications." | |||
| 616 | ;; Store the element in the DTD | 645 | ;; Store the element in the DTD |
| 617 | (push (list element type) dtd) | 646 | (push (list element type) dtd) |
| 618 | (goto-char end-pos)) | 647 | (goto-char end-pos)) |
| 648 | |||
| 649 | ;; Translation of rule [52] of XML specifications | ||
| 650 | ((looking-at (concat "<!ATTLIST[ \t\n\r]*\\(" xml-name-re | ||
| 651 | "\\)[ \t\n\r]*\\(" xml-att-def-re | ||
| 652 | "\\)*[ \t\n\r]*>")) | ||
| 653 | |||
| 654 | ;; We don't do anything with ATTLIST currently | ||
| 655 | (goto-char (match-end 0))) | ||
| 656 | |||
| 619 | ((looking-at "<!--") | 657 | ((looking-at "<!--") |
| 620 | (search-forward "-->")) | 658 | (search-forward "-->")) |
| 621 | ((looking-at (concat "<!ENTITY[ \t\n\r]*\\(" xml-name-re | 659 | ((looking-at (concat "<!ENTITY[ \t\n\r]*\\(" xml-name-re |
| 622 | "\\)[ \t\n\r]*\\(" xml-entity-value-re | 660 | "\\)[ \t\n\r]*\\(" xml-entity-value-re |
| 623 | "\\)[ \t\n\r]*>")) | 661 | "\\)[ \t\n\r]*>")) |
| 624 | (let ((name (buffer-substring (nth 2 (match-data)) | 662 | (let ((name (match-string 1)) |
| 625 | (nth 3 (match-data)))) | 663 | (value (substring (match-string 2) 1 |
| 626 | (value (buffer-substring (+ (nth 4 (match-data)) 1) | 664 | (- (length (match-string 2)) 1)))) |
| 627 | (- (nth 5 (match-data)) 1)))) | 665 | (goto-char (match-end 0)) |
| 628 | (goto-char (nth 1 (match-data))) | ||
| 629 | (setq xml-entity-alist | 666 | (setq xml-entity-alist |
| 630 | (append xml-entity-alist | 667 | (append xml-entity-alist |
| 631 | (list (cons name | 668 | (list (cons name |
| @@ -644,11 +681,10 @@ This follows the rule [28] in the XML specifications." | |||
| 644 | "\\|'[- \r\na-zA-Z0-9()+,./:=?;!*#@$_%]*'" | 681 | "\\|'[- \r\na-zA-Z0-9()+,./:=?;!*#@$_%]*'" |
| 645 | "[ \t\n\r]+\\(\"[^\"]*\"\\|'[^']*'\\)" | 682 | "[ \t\n\r]+\\(\"[^\"]*\"\\|'[^']*'\\)" |
| 646 | "[ \t\n\r]*>"))) | 683 | "[ \t\n\r]*>"))) |
| 647 | (let ((name (buffer-substring (nth 2 (match-data)) | 684 | (let ((name (match-string 1)) |
| 648 | (nth 3 (match-data)))) | 685 | (file (substring (match-string 2) 1 |
| 649 | (file (buffer-substring (+ (nth 4 (match-data)) 1) | 686 | (- (length (match-string 2)) 1)))) |
| 650 | (- (nth 5 (match-data)) 1)))) | 687 | (goto-char (match-end 0)) |
| 651 | (goto-char (nth 1 (match-data))) | ||
| 652 | (setq xml-entity-alist | 688 | (setq xml-entity-alist |
| 653 | (append xml-entity-alist | 689 | (append xml-entity-alist |
| 654 | (list (cons name (with-temp-buffer | 690 | (list (cons name (with-temp-buffer |
| @@ -677,7 +713,7 @@ This follows the rule [28] in the XML specifications." | |||
| 677 | (when xml-validating-parser | 713 | (when xml-validating-parser |
| 678 | (error "XML: (Validity) Invalid DTD item")))))) | 714 | (error "XML: (Validity) Invalid DTD item")))))) |
| 679 | (if (looking-at "\\s-*]>") | 715 | (if (looking-at "\\s-*]>") |
| 680 | (goto-char (nth 1 (match-data))))) | 716 | (goto-char (match-end 0)))) |
| 681 | (nreverse dtd))) | 717 | (nreverse dtd))) |
| 682 | 718 | ||
| 683 | (defun xml-parse-elem-type (string) | 719 | (defun xml-parse-elem-type (string) |