ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Strange crash when using lxp library
@ 2012-05-11 15:39 Procházka Lukáš Ing. - Pontex s. r. o.
  0 siblings, 0 replies; only message in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2012-05-11 15:39 UTC (permalink / raw)
  To: ConTeXt

[-- Attachment #1: Type: text/plain, Size: 1590 bytes --]

Hello,

I have a strange problem.

I tried to prepare the simplest example.

Let's have a table utility in 'Table-U_.lua' (to be placed to LUA_PATH):

----
table.fromExcelXML = function(fn)
...
           tabs[true] = true -- Comment this line to make it work(?!) [1]
...
end

if not context then
   require "lxp"

   print("\n777777")
   table.fromExcelXML("InzSiteLitom_Nove.xml")
   print("\n888888")
end
----

When you call it from the command line, it works fine:

----
C:\Lukas\ConTeXt\TestDDv>lua -e require'table-u_'

777777

888888
----

When used in a context file:

----
\mainlanguage[cz]
\enableregime[cp1250]

\startluacode
   require "lxp"
   require "Table-U_"

   print("\n111111")
   table.fromExcelXML("InzSiteLitom_Nove.xml")
   print("\n222222")
\stopluacode

\starttext
   AAA
\stoptext
----

it crashes with an exception in luatex:

"
Exception "unknown software exception" 0xc000000d" at 0x1028e4c3.
...
"

Would anyone have an idea what causes the program crash?

I also observed that commenting a line [1] in the "Table-U_.lua" makes context work;
but the place seems "innocent", so I have no idea what can cause ctx crashing.

Could anyone test the code, respectively give a hint how to make the [simplified] code work?

All ideas are welcome.

Thank you in advance.

Best regards,

Lukas


-- 
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o.      [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

[-- Attachment #2: Text.mkiv --]
[-- Type: application/octet-stream, Size: 219 bytes --]

\mainlanguage[cz]
\enableregime[cp1250]

\startluacode
  require "lxp"
  require "Table-U_"

  print("\n111111")
  table.fromExcelXML("1.xml")
  print("\n222222")
\stopluacode

\starttext
  AAA
\stoptext

[-- Attachment #3: Text.log --]
[-- Type: application/octet-stream, Size: 1755 bytes --]

(C:/Lukas/ConTeXt/TestDDv/Text.mkiv

ConTeXt  ver: 2012.04.26 22:27 MKIV  fmt: 2012.4.30  int: english/english

system          > cont-new.mkiv loaded
(c:/ConTeXt/tex/texmf-context/tex/context/base/cont-new.mkiv
system          > beware: some patches loaded from cont-new.mkiv
)
system          > Text.top loaded

system          > options > start used options

used options    > % runtime options files (command line driven)
used options    > \unprotect
used options    > % feedback and basic job control
used options    > \nonstopmode
used options    > % handy for special styles
used options    > \startluacode
used options    > document = document or { }
used options    > document.arguments={
used options    >  ["FILE"]="Text.mkiv",
used options    >  ["halt-on-error"]=true,
used options    >  ["mode"]="Text",
used options    >  ["nonstopmode"]=true,
used options    > }
used options    > document.files={
used options    >  "C:/Lukas/ConTeXt/TestDDv/Text.mkiv",
used options    > }
used options    > \stopluacode
used options    > % process info
used options    > \setupsystem[inputfile=C:/Lukas/ConTeXt/TestDDv/Text.mkiv]
used options    > \setupsystem[\c!n=1,\c!m=1]
used options    > % modes
used options    > \enablemode[Text]
used options    > % options (not that important)
used options    > \startsetups *runtime:options
used options    > \stopsetups
used options    > % styles and modules
used options    > \startsetups *runtime:modules
used options    > \stopsetups
used options    > % done
used options    > \protect \endinput

system          > options > stop used options

(Text.top
)
fonts           > latin modern fonts are not preloaded
languages       > language en is active
regimes         > loading > vector 'cp1250' is loaded

[-- Attachment #4: Table-U_.lua --]
[-- Type: application/octet-stream, Size: 616 bytes --]

table.fromExcelXML = function(fn)
  local fh = assert(io.open(fn, "r"))
  local tabs = {}

  local callbacks =
    { StartElement = function(parser, name)
        if name == "Worksheet" then
          tabs[true] = true -- Comment this line to make it work(?!)
        end
      end,
    }

  local parser = lxp.new(callbacks)

  for ln in fh:lines() do
    parser:parse(ln)
    parser:parse("\n")
  end

  fh:close()

  parser:parse()
  parser:close()
end

if not context then
  require "lxp"

  print("\n777777")
  table.fromExcelXML("InzSiteLitom_Nove.xml")
  print("\n888888")
end

[-- Attachment #5: InzSiteLitom_Nove.zip --]
[-- Type: application/zip, Size: 11233 bytes --]

[-- Attachment #6: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-05-11 15:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-11 15:39 Strange crash when using lxp library Procházka Lukáš Ing. - Pontex s. r. o.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).