ox: Fix stack overflow in equal error

* lisp/ox.el (org-export-table-cell-width): Modify key (now an
  element) and value structure (now a vector) of cache so it can use
  `eq' as test. Elements are circular lists so `equal' cannot apply on
  them.

Reported-by: Jambunathan K <kjambunathan@gmail.com>
This commit is contained in:
Nicolas Goaziou 2013-08-29 10:00:24 +02:00
parent 9e51049b22
commit 2baa2c3afa
1 changed files with 9 additions and 7 deletions

View File

@ -4475,19 +4475,21 @@ Return value is the width given by the last width cookie in the
same column as TABLE-CELL, or nil." same column as TABLE-CELL, or nil."
(let* ((row (org-export-get-parent table-cell)) (let* ((row (org-export-get-parent table-cell))
(table (org-export-get-parent row)) (table (org-export-get-parent row))
(column (let ((cells (org-element-contents row))) (cells (org-element-contents row))
(- (length cells) (length (memq table-cell cells))))) (columns (length cells))
(column (- columns (length (memq table-cell cells))))
(cache (or (plist-get info :table-cell-width-cache) (cache (or (plist-get info :table-cell-width-cache)
(plist-get (setq info (plist-get (setq info
(plist-put info :table-cell-width-cache (plist-put info :table-cell-width-cache
(make-hash-table :test 'equal))) (make-hash-table :test 'eq)))
:table-cell-width-cache))) :table-cell-width-cache)))
(key (cons table column)) (width-vector (or (gethash table cache)
(value (gethash key cache 'no-result))) (puthash table (make-vector columns 'empty) cache)))
(if (not (eq value 'no-result)) value (value (aref width-vector column)))
(if (not (eq value 'empty)) value
(let (cookie-width) (let (cookie-width)
(dolist (row (org-element-contents table) (dolist (row (org-element-contents table)
(puthash key cookie-width cache)) (aset width-vector column cookie-width))
(when (org-export-table-row-is-special-p row info) (when (org-export-table-row-is-special-p row info)
;; In a special row, try to find a width cookie at COLUMN. ;; In a special row, try to find a width cookie at COLUMN.
(let* ((value (org-element-contents (let* ((value (org-element-contents