Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
Updated from archive luaexpat-1.3.0.tar.gz
Browse files Browse the repository at this point in the history
  • Loading branch information
drahosp committed Jun 16, 2014
1 parent 74dcbc0 commit dc1e262
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 117 deletions.
14 changes: 10 additions & 4 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ software and uses the same license as Lua 5.1.

Status

Current version is 1.2.0. It was developed for both Lua 5.0 and Lua 5.1,
and has been tested on Linux, Windows (2000/XP) and MacOS X with Expat 2.0.0.
Current version is 1.3.0. It was developed for both Lua 5.1 and Lua 5.2,
and has been tested on Linux, Windows (XP) and MacOS X with Expat 2.1.0.

Download

Expand All @@ -18,6 +18,12 @@ LuaBinaries a Windows binary version of LuaExpat can be found at the LuaForge pa

History

Version 1.3.0 [04/Apr/2014]

* support for the XmlDecl handler
* add parser:getcurrentbytecount() (XML_GetCurrentByteCount)
* ability to disable CharacterData merging

Version 1.2.0 [02/Jun/2011]

* support for the StartDoctypeDecl handler
Expand Down Expand Up @@ -47,11 +53,11 @@ LuaExpat implements the SAX API.

Credits

Version 1.0 was designed by Roberto Ierusalimschy, Andr� Carregal and Tom�s Guisasola
Version 1.0 was designed by Roberto Ierusalimschy, André Carregal and Tomás Guisasola
as part of the Kepler Project which holds its copyright. The implementation was coded
by Roberto Ierusalimschy, based on a previous design by Jay Carlson.

LuaExpat development was sponsored by F�brica Digital and FINEP.
LuaExpat development was sponsored by Fábrica Digital and FINEP.

Contact

Expand Down
36 changes: 0 additions & 36 deletions config

This file was deleted.

14 changes: 11 additions & 3 deletions doc/us/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ <h2><a name="overview"></a>Overview</h2>

<h2><a name="status"></a>Status</h2>

<p>Current version is 1.2.0. It was developed for both Lua 5.0 and Lua 5.1, and has been tested on
Linux, Windows (2000/XP) and MacOS X with Expat 2.0.0.</p>
<p>Current version is 1.3.0. It was developed for both Lua 5.1 and Lua 5.2, and has been tested on
Linux, Windows (XP) and MacOS X with Expat 2.1.0.</p>

<h2><a name="download"></a>Download</h2>

Expand All @@ -79,6 +79,15 @@ <h2><a name="download"></a>Download</h2>
<h2><a name="history"></a>History</h2>

<dl class="history">
<dt><strong>Version 1.3.0</strong> [02/Apr/2014]</dt>
<dd>
<ul>
<li>support for the XmlDecl handler</li>
<li>add parser:getcurrentbytecount() (XML_GetCurrentByteCount)</li>
<li>ability to disable CharacterData merging</li>
</ul>
</dd>

<dt><strong>Version 1.2.0</strong> [02/Jun/2011]</dt>
<dd>
<ul>
Expand Down Expand Up @@ -156,7 +165,6 @@ <h2><a name="contact"></a>Contact</h2>
<div id="about">
<p><a href="http://validator.w3.org/check?uri=referer">
<img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
<p><small>$Id: index.html,v 1.45 2007/06/05 21:11:29 carregal Exp $</small></p>
</div> <!-- id="about" -->

</div> <!-- id="container" -->
Expand Down
31 changes: 23 additions & 8 deletions doc/us/manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ <h2><a name="introduction"></a>Introduction</h2>
<h2><a name="building"></a>Building</h2>

<p>
LuaExpat could be built to Lua 5.0 or to Lua 5.1.
LuaExpat could be built to Lua 5.1 or to Lua 5.2.
In both cases,
the language library and headers files for the desired version
must be installed properly.
LuaExpat also depends on Expat 2.0.0 which should also be installed.
LuaExpat also depends on Expat 2.0.0+ which should also be installed.
</p>
<p>
LuaExpat offers a Makefile and a separate configuration file,
Expand Down Expand Up @@ -131,11 +131,13 @@ <h2><a name="parser"></a>Parser objects</h2>
<h4>Constructor</h4>

<dl class="reference">
<dt><strong>lxp.new(<em>callbacks [, separator]</em>)</strong></dt>
<dt><strong>lxp.new(<em>callbacks [, separator[, merge_character_data]]</em>)</strong></dt>
<dd>The parser is created by a call to the function <strong>lxp.new</strong>,
which returns the created parser or raises a Lua error. It
receives the callbacks table and optionally the parser <a href="#separator">
separator character</a> used in the namespace expanded element names.</dd>
separator character</a> used in the namespace expanded element names.
If <em>merge_character_data</em> is false then LuaExpat will not combine multiple
CharacterData calls into one. For more info on this behaviour see CharacterData below.</dd>
</dl>

<h4>Methods</h4>
Expand Down Expand Up @@ -167,6 +169,12 @@ <h4>Methods</h4>
<dd>Returns three results: the current parsing line, column, and
absolute position.</dd>

<dt><strong>parser:getcurrentbytecount()</strong></dt>
<dd>Return the number of bytes of input corresponding to the current
event. This function can only be called inside a handler, in other
contexts it will return 0. Do not use inside a CharacterData handler
unless CharacterData merging has been disabled (see lxp.new).</dd>

<dt><strong>parser:setbase(base)</strong></dt>
<dd>Sets the <em>base</em> to be used for resolving relative URIs in
system identifiers.</dd>
Expand Down Expand Up @@ -205,8 +213,8 @@ <h4>Callbacks</h4>
<em>ExternalEntityRef</em>, <em>NotStandalone</em>,
<em>NotationDecl</em>, <em>ProcessingInstruction</em>,
<em>StartCDataSection</em>, <em>StartElement</em>,
<em>StartNamespaceDecl</em>, <em>UnparsedEntityDecl</em>
and <em>StartDoctypeDecl</em>.</p>
<em>StartNamespaceDecl</em>, <em>UnparsedEntityDecl</em>,
<em>XmlDecl</em> and <em>StartDoctypeDecl</em>.</p>

<p>These indices can be references to functions with
specific signatures, as seen below. The parser constructor also
Expand All @@ -226,7 +234,10 @@ <h4>Callbacks</h4>

<dl class="reference">
<dt><strong>callbacks.CharacterData = function(parser, string)</strong></dt>
<dd>Called when the <em>parser</em> recognizes an XML CDATA <em>string</em>.</dd>
<dd>Called when the <em>parser</em> recognizes an XML CDATA <em>string</em>.
Note that LuaExpat automatically combines multiple CharacterData events
from Expat into a single call to this handler, unless <em>merge_character_data</em>
is set to false when calling lxp.new().</dd>

<dt><strong>callbacks.Comment = function(parser, string)</strong></dt>
<dd>Called when the <em>parser</em> recognizes an XML comment
Expand Down Expand Up @@ -300,6 +311,11 @@ <h4>Callbacks</h4>
<dd>Called when the <em>parser</em> detects the begining of an XML
CDATA section.</dd>

<dt><strong>callbacks.XmlDecl = function(parser, version, encoding)</strong></dt>
<dd>Called when the <em>parser</em> encounters an XML document declaration (these are
optional, and valid only at the start of the document). The callback receives
the declared XML <em>version</em> and document <em>encoding</em>.</dd>

<dt><strong>callbacks.StartElement = function(parser, elementName, attributes)</strong></dt>
<dd>Called when the <em>parser</em> detects the begining of an XML
element with <em>elementName</em>.<br/>
Expand Down Expand Up @@ -371,7 +387,6 @@ <h4><a name="separator"></a>The separator character</h4>
<div id="about">
<p><a href="http://validator.w3.org/check?uri=referer">
<img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
<p><small>$Id: manual.html,v 1.27 2007/06/05 20:03:12 carregal Exp $</small></p>
</div> <!-- id="about" -->

</div> <!-- id="container" -->
Expand Down
50 changes: 27 additions & 23 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
T= lxp
V= 1.2.0
CONFIG= ./config
CC ?= cc
RM ?= rm -rf
INSTALL ?= install
INSTALL_PROGRAM ?= $(INSTALL)
INSTALL_DATA ?= $(INSTALL) -m 644
LUA_V ?= 5.1
LUA_LDIR ?= /usr/share/lua/$(LUA_V)
LUA_CDIR ?= /usr/lib/lua/$(LUA_V)
T = lxp
LIBNAME = $(T).so

COMMON_CFLAGS = -g -pedantic -Wall -O2 -fPIC -DPIC -ansi
LUA_INC ?= -I/usr/include/lua$(LUA_V)
EXPAT_INC ?= -I/usr/include
CF = $(LUA_INC) $(EXPAT_INC) $(COMMON_CFLAGS) $(CFLAGS)

EXPAT_LIB = -lexpat
COMMON_LDFLAGS = -shared
LF = $(COMMON_LDFLAGS) $(EXPAT_LIB) $(LDFLAGS)

OBJS = src/lxplib.o

include $(CONFIG)

ifeq "$(LUA_VERSION_NUM)" "500"
COMPAT_O= $(COMPAT_DIR)/compat-5.1.o
endif

OBJS= src/lxplib.o $(COMPAT_O)
lib: src/$(LIBNAME)

src/$(LIBNAME) : $(OBJS)
export MACOSX_DEPLOYMENT_TARGET="10.3"; $(CC) -o src/$(LIBNAME) $(LIB_OPTION) $(OBJS) -lexpat

$(COMPAT_DIR)/compat-5.1.o: $(COMPAT_DIR)/compat-5.1.c
$(CC) -c $(CFLAGS) -o $@ $(COMPAT_DIR)/compat-5.1.c
src/$(LIBNAME):
export MACOSX_DEPLOYMENT_TARGET="10.3";
$(CC) $(CF) -o $@ src/$(T)lib.c $(LF)

install:
mkdir -p $(LUA_LIBDIR)
cp src/$(LIBNAME) $(LUA_LIBDIR)
cd $(LUA_LIBDIR); ln -f -s $(LIBNAME) $T.so
mkdir -p $(LUA_DIR)/$T
cp src/$T/lom.lua $(LUA_DIR)/$T
$(INSTALL_PROGRAM) -D src/$(LIBNAME) $(DESTDIR)$(LUA_CDIR)/$(LIBNAME)
$(INSTALL_PROGRAM) -D src/$T/lom.lua $(DESTDIR)$(LUA_LDIR)/$T/lom.lua

clean:
rm -f src/$(LIBNAME) $(OBJS)

# $Id: makefile,v 1.33 2006/06/08 20:41:48 tomas Exp $
$(RM) src/$(LIBNAME) $(OBJS)
17 changes: 8 additions & 9 deletions src/lxp/lom.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
-- See Copyright Notice in license.html
-- $Id: lom.lua,v 1.6 2005/06/09 19:18:40 tuler Exp $

require "lxp"
local lxp = require "lxp"

local tinsert, tremove, getn = table.insert, table.remove, table.getn
local tinsert, tremove = table.insert, table.remove
local assert, type, print = assert, type, print
local lxp = lxp

module ("lxp.lom")

local function starttag (p, tag, attr)
local stack = p:getcallbacks().stack
Expand All @@ -19,22 +17,22 @@ local function endtag (p, tag)
local stack = p:getcallbacks().stack
local element = tremove(stack)
assert(element.tag == tag)
local level = getn(stack)
local level = #stack
tinsert(stack[level], element)
end

local function text (p, txt)
local stack = p:getcallbacks().stack
local element = stack[getn(stack)]
local n = getn(element)
local element = stack[#stack]
local n = #element
if type(element[n]) == "string" then
element[n] = element[n] .. txt
else
tinsert(element, txt)
end
end

function parse (o)
local function parse (o)
local c = { StartElement = starttag,
EndElement = endtag,
CharacterData = text,
Expand All @@ -47,7 +45,7 @@ function parse (o)
status, err = p:parse(o)
if not status then return nil, err end
else
for l in o do
for l in pairs(o) do
status, err = p:parse(l)
if not status then return nil, err end
end
Expand All @@ -58,3 +56,4 @@ function parse (o)
return c.stack[1][1]
end

return { parse = parse }
Loading

0 comments on commit dc1e262

Please sign in to comment.