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

Commit dc1e262

Browse files
committed
Updated from archive luaexpat-1.3.0.tar.gz
1 parent 74dcbc0 commit dc1e262

File tree

9 files changed

+206
-117
lines changed

9 files changed

+206
-117
lines changed

README

+10-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ software and uses the same license as Lua 5.1.
88

99
Status
1010

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

1414
Download
1515

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

1919
History
2020

21+
Version 1.3.0 [04/Apr/2014]
22+
23+
* support for the XmlDecl handler
24+
* add parser:getcurrentbytecount() (XML_GetCurrentByteCount)
25+
* ability to disable CharacterData merging
26+
2127
Version 1.2.0 [02/Jun/2011]
2228

2329
* support for the StartDoctypeDecl handler
@@ -47,11 +53,11 @@ LuaExpat implements the SAX API.
4753

4854
Credits
4955

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

54-
LuaExpat development was sponsored by F�brica Digital and FINEP.
60+
LuaExpat development was sponsored by Fábrica Digital and FINEP.
5561

5662
Contact
5763

config

-36
This file was deleted.

doc/us/index.html

+11-3
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ <h2><a name="overview"></a>Overview</h2>
6666

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

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

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

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

8181
<dl class="history">
82+
<dt><strong>Version 1.3.0</strong> [02/Apr/2014]</dt>
83+
<dd>
84+
<ul>
85+
<li>support for the XmlDecl handler</li>
86+
<li>add parser:getcurrentbytecount() (XML_GetCurrentByteCount)</li>
87+
<li>ability to disable CharacterData merging</li>
88+
</ul>
89+
</dd>
90+
8291
<dt><strong>Version 1.2.0</strong> [02/Jun/2011]</dt>
8392
<dd>
8493
<ul>
@@ -156,7 +165,6 @@ <h2><a name="contact"></a>Contact</h2>
156165
<div id="about">
157166
<p><a href="http://validator.w3.org/check?uri=referer">
158167
<img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
159-
<p><small>$Id: index.html,v 1.45 2007/06/05 21:11:29 carregal Exp $</small></p>
160168
</div> <!-- id="about" -->
161169

162170
</div> <!-- id="container" -->

doc/us/manual.html

+23-8
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ <h2><a name="introduction"></a>Introduction</h2>
8585
<h2><a name="building"></a>Building</h2>
8686

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

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

141143
<h4>Methods</h4>
@@ -167,6 +169,12 @@ <h4>Methods</h4>
167169
<dd>Returns three results: the current parsing line, column, and
168170
absolute position.</dd>
169171

172+
<dt><strong>parser:getcurrentbytecount()</strong></dt>
173+
<dd>Return the number of bytes of input corresponding to the current
174+
event. This function can only be called inside a handler, in other
175+
contexts it will return 0. Do not use inside a CharacterData handler
176+
unless CharacterData merging has been disabled (see lxp.new).</dd>
177+
170178
<dt><strong>parser:setbase(base)</strong></dt>
171179
<dd>Sets the <em>base</em> to be used for resolving relative URIs in
172180
system identifiers.</dd>
@@ -205,8 +213,8 @@ <h4>Callbacks</h4>
205213
<em>ExternalEntityRef</em>, <em>NotStandalone</em>,
206214
<em>NotationDecl</em>, <em>ProcessingInstruction</em>,
207215
<em>StartCDataSection</em>, <em>StartElement</em>,
208-
<em>StartNamespaceDecl</em>, <em>UnparsedEntityDecl</em>
209-
and <em>StartDoctypeDecl</em>.</p>
216+
<em>StartNamespaceDecl</em>, <em>UnparsedEntityDecl</em>,
217+
<em>XmlDecl</em> and <em>StartDoctypeDecl</em>.</p>
210218

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

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

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

314+
<dt><strong>callbacks.XmlDecl = function(parser, version, encoding)</strong></dt>
315+
<dd>Called when the <em>parser</em> encounters an XML document declaration (these are
316+
optional, and valid only at the start of the document). The callback receives
317+
the declared XML <em>version</em> and document <em>encoding</em>.</dd>
318+
303319
<dt><strong>callbacks.StartElement = function(parser, elementName, attributes)</strong></dt>
304320
<dd>Called when the <em>parser</em> detects the begining of an XML
305321
element with <em>elementName</em>.<br/>
@@ -371,7 +387,6 @@ <h4><a name="separator"></a>The separator character</h4>
371387
<div id="about">
372388
<p><a href="http://validator.w3.org/check?uri=referer">
373389
<img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
374-
<p><small>$Id: manual.html,v 1.27 2007/06/05 20:03:12 carregal Exp $</small></p>
375390
</div> <!-- id="about" -->
376391

377392
</div> <!-- id="container" -->

makefile

+27-23
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
1-
T= lxp
2-
V= 1.2.0
3-
CONFIG= ./config
1+
CC ?= cc
2+
RM ?= rm -rf
3+
INSTALL ?= install
4+
INSTALL_PROGRAM ?= $(INSTALL)
5+
INSTALL_DATA ?= $(INSTALL) -m 644
6+
LUA_V ?= 5.1
7+
LUA_LDIR ?= /usr/share/lua/$(LUA_V)
8+
LUA_CDIR ?= /usr/lib/lua/$(LUA_V)
9+
T = lxp
10+
LIBNAME = $(T).so
11+
12+
COMMON_CFLAGS = -g -pedantic -Wall -O2 -fPIC -DPIC -ansi
13+
LUA_INC ?= -I/usr/include/lua$(LUA_V)
14+
EXPAT_INC ?= -I/usr/include
15+
CF = $(LUA_INC) $(EXPAT_INC) $(COMMON_CFLAGS) $(CFLAGS)
16+
17+
EXPAT_LIB = -lexpat
18+
COMMON_LDFLAGS = -shared
19+
LF = $(COMMON_LDFLAGS) $(EXPAT_LIB) $(LDFLAGS)
20+
21+
OBJS = src/lxplib.o
422

5-
include $(CONFIG)
6-
7-
ifeq "$(LUA_VERSION_NUM)" "500"
8-
COMPAT_O= $(COMPAT_DIR)/compat-5.1.o
9-
endif
10-
11-
OBJS= src/lxplib.o $(COMPAT_O)
1223
lib: src/$(LIBNAME)
1324

14-
src/$(LIBNAME) : $(OBJS)
15-
export MACOSX_DEPLOYMENT_TARGET="10.3"; $(CC) -o src/$(LIBNAME) $(LIB_OPTION) $(OBJS) -lexpat
16-
17-
$(COMPAT_DIR)/compat-5.1.o: $(COMPAT_DIR)/compat-5.1.c
18-
$(CC) -c $(CFLAGS) -o $@ $(COMPAT_DIR)/compat-5.1.c
25+
src/$(LIBNAME):
26+
export MACOSX_DEPLOYMENT_TARGET="10.3";
27+
$(CC) $(CF) -o $@ src/$(T)lib.c $(LF)
1928

2029
install:
21-
mkdir -p $(LUA_LIBDIR)
22-
cp src/$(LIBNAME) $(LUA_LIBDIR)
23-
cd $(LUA_LIBDIR); ln -f -s $(LIBNAME) $T.so
24-
mkdir -p $(LUA_DIR)/$T
25-
cp src/$T/lom.lua $(LUA_DIR)/$T
30+
$(INSTALL_PROGRAM) -D src/$(LIBNAME) $(DESTDIR)$(LUA_CDIR)/$(LIBNAME)
31+
$(INSTALL_PROGRAM) -D src/$T/lom.lua $(DESTDIR)$(LUA_LDIR)/$T/lom.lua
2632

2733
clean:
28-
rm -f src/$(LIBNAME) $(OBJS)
29-
30-
# $Id: makefile,v 1.33 2006/06/08 20:41:48 tomas Exp $
34+
$(RM) src/$(LIBNAME) $(OBJS)

src/lxp/lom.lua

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
-- See Copyright Notice in license.html
22
-- $Id: lom.lua,v 1.6 2005/06/09 19:18:40 tuler Exp $
33

4-
require "lxp"
4+
local lxp = require "lxp"
55

6-
local tinsert, tremove, getn = table.insert, table.remove, table.getn
6+
local tinsert, tremove = table.insert, table.remove
77
local assert, type, print = assert, type, print
8-
local lxp = lxp
98

10-
module ("lxp.lom")
119

1210
local function starttag (p, tag, attr)
1311
local stack = p:getcallbacks().stack
@@ -19,22 +17,22 @@ local function endtag (p, tag)
1917
local stack = p:getcallbacks().stack
2018
local element = tremove(stack)
2119
assert(element.tag == tag)
22-
local level = getn(stack)
20+
local level = #stack
2321
tinsert(stack[level], element)
2422
end
2523

2624
local function text (p, txt)
2725
local stack = p:getcallbacks().stack
28-
local element = stack[getn(stack)]
29-
local n = getn(element)
26+
local element = stack[#stack]
27+
local n = #element
3028
if type(element[n]) == "string" then
3129
element[n] = element[n] .. txt
3230
else
3331
tinsert(element, txt)
3432
end
3533
end
3634

37-
function parse (o)
35+
local function parse (o)
3836
local c = { StartElement = starttag,
3937
EndElement = endtag,
4038
CharacterData = text,
@@ -47,7 +45,7 @@ function parse (o)
4745
status, err = p:parse(o)
4846
if not status then return nil, err end
4947
else
50-
for l in o do
48+
for l in pairs(o) do
5149
status, err = p:parse(l)
5250
if not status then return nil, err end
5351
end
@@ -58,3 +56,4 @@ function parse (o)
5856
return c.stack[1][1]
5957
end
6058

59+
return { parse = parse }

0 commit comments

Comments
 (0)