bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#63196: sxml or guile bug?


From: Christopher Lam
Subject: bug#63196: sxml or guile bug?
Date: Mon, 1 May 2023 10:32:26 +0800

Hi, we've identified an unusual behaviour in writing a test in gnucash. Can anyone reproduce and confirmit?

I paste a simple .scm file, and its input test-file.html. Now, in sxml-bug.scm, modify the <tr> index - from -1 to -2 i.e. access the last/penultimate row etc.

Odd negative indices work, even negative indices lead to error. Odd (haha) bug. See report for (tr -2) for example, pasted below.

==== sxml-bug.scm =====
(use-modules (sxml simple))
(use-modules (sxml xpath))
(use-modules (ice-9 textual-ports))
(define html (call-with-input-file "/tmp/test-file.html" get-string-all))
(define sx (xml->sxml html))

;; note this path: try different indices for the tr tag:
;; odd numbers -1 -3 -5 are ok
;; even numbers -2 -4 -6 will fail
(define path '(// (table 1) // (tr -1)))

(format #t "html=[~s]\n" html)
(format #t "sxpath is [~s]\n" path)
(format #t "result is [~s]\n" ((sxpath path) sx))
====

And the backtrace with -2

=====
Backtrace:
In ice-9/boot-9.scm:
  1752:10 18 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
          17 (apply-smob/0 #<thunk 7f7fd530d2e0>)
In ice-9/boot-9.scm:
    724:2 16 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
In ice-9/eval.scm:
    619:8 15 (_ #(#(#<directory (guile-user) 7f7fd5312c80>)))
In ice-9/boot-9.scm:
   2836:4 14 (save-module-excursion _)
  4388:12 13 (_)
In /home/user/sources/sxml-bug.scm:
    20:30 12 (_)
In sxml/xpath.scm:
   254:18 11 (map-union #<procedure 7f7fd18e8280 at sxml/xpath.scm:…> …)
   254:18 10 (map-union #<procedure 7f7fd18e8280 at sxml/xpath.scm:…> …)
   254:18  9 (map-union #<procedure 7f7fd18e8280 at sxml/xpath.scm:…> …)
   254:18  8 (map-union #<procedure 7f7fd18e8280 at sxml/xpath.scm:…> …)
   254:18  7 (map-union #<procedure 7f7fd18e8280 at sxml/xpath.scm:…> …)
   252:22  6 (map-union #<procedure 7f7fd18e8280 at sxml/xpath.scm:…> …)
   252:22  5 (map-union #<procedure 7f7fd18f2ea0 at sxml/xpath.scm:…> …)
   254:18  4 (map-union #<procedure 7f7fd1901420 at sxml/xpath.scm:…> …)
   254:18  3 (map-union #<procedure 7f7fd1901420 at sxml/xpath.scm:…> …)
   252:22  2 (map-union #<procedure 7f7fd1901420 at sxml/xpath.scm:…> …)
   484:19  1 (loop _ ((tr -6)))
   181:24  0 (_ _)

sxml/xpath.scm:181:24: yikes!
=====


read rows from the bottom

From 01/01/23 to 12/31/23

Sorting / Add indenting columns : Disabled
Sorting / Secondary Key : none
Sorting / Primary Subtotal : Disabled
Sorting / Primary Subtotal for Date Key : none
General / Add options summary : always
General / Table for Exporting : Enabled
Display / Totals : Disabled
Display / Amount : single
Display / Other Account Name : Disabled
Display / Account Name : Enabled
Display / Notes : Disabled
Display / Memo : Disabled
Display / Num : Disabled
Accounts / Accounts : Bank
Date Description Account Amount
01/03/23 $103 income Root.Asset.Bank $103.00
01/09/23 $109 income Root.Asset.Bank $109.00
01/15/23 $22 expense Root.Asset.Bank -$22.00
02/03/23 $103 income Root.Asset.Bank $103.00
02/09/23 $109 income Root.Asset.Bank $109.00
02/15/23 $22 expense Root.Asset.Bank -$22.00
03/03/23 $103 income Root.Asset.Bank $103.00
03/09/23 $109 income Root.Asset.Bank $109.00
03/15/23 $22 expense Root.Asset.Bank -$22.00
04/03/23 $103 income Root.Asset.Bank $103.00
04/09/23 $109 income Root.Asset.Bank $109.00
04/15/23 $22 expense Root.Asset.Bank -$22.00
05/03/23 $103 income Root.Asset.Bank $103.00
05/09/23 $109 income Root.Asset.Bank $109.00
05/15/23 $22 expense Root.Asset.Bank -$22.00
06/03/23 $103 income Root.Asset.Bank $103.00
06/09/23 $109 income Root.Asset.Bank $109.00
06/15/23 $22 expense Root.Asset.Bank -$22.00
07/03/23 $103 income Root.Asset.Bank $103.00
07/09/23 $109 income Root.Asset.Bank $109.00
07/15/23 $22 expense Root.Asset.Bank -$22.00
08/03/23 $103 income Root.Asset.Bank $103.00
08/09/23 $109 income Root.Asset.Bank $109.00
08/15/23 $22 expense Root.Asset.Bank -$22.00
09/03/23 $103 income Root.Asset.Bank $103.00
09/09/23 $109 income Root.Asset.Bank $109.00
09/15/23 $22 expense Root.Asset.Bank -$22.00
10/03/23 $103 income Root.Asset.Bank $103.00
10/09/23 $109 income Root.Asset.Bank $109.00
10/15/23 $22 expense Root.Asset.Bank -$22.00
11/03/23 $103 income Root.Asset.Bank $103.00
11/09/23 $109 income Root.Asset.Bank $109.00
11/15/23 $22 expense Root.Asset.Bank -$22.00
12/03/23 $103 income Root.Asset.Bank $103.00
12/09/23 $109 income Root.Asset.Bank $109.00
12/15/23 $22 expense Root.Asset.Bank -$22.00

reply via email to

[Prev in Thread] Current Thread [Next in Thread]