src/lxplib.c

changeset 18
90da47758f85
parent 17
7f0e6f8bb8e0
child 19
10c30b63873a
equal deleted inserted replaced
17:7f0e6f8bb8e0 18:90da47758f85
324 lua_pushstring(xpu->L, pubid); 324 lua_pushstring(xpu->L, pubid);
325 lua_pushboolean(xpu->L, has_internal_subset); 325 lua_pushboolean(xpu->L, has_internal_subset);
326 docall(xpu, 4, 0); 326 docall(xpu, 4, 0);
327 } 327 }
328 328
329 static void f_XmlDecl (void *ud, const XML_Char *version,
330 const XML_Char *encoding,
331 int standalone) {
332 lxp_userdata *xpu = (lxp_userdata *)ud;
333 if (getHandle(xpu, XmlDeclKey) == 0) return; /* no handle */
334 lua_pushstring(xpu->L, version);
335 lua_pushstring(xpu->L, encoding);
336 lua_pushboolean(xpu->L, standalone);
337 docall(xpu, 3, 0);
338 }
329 /* }====================================================== */ 339 /* }====================================================== */
330 340
331 341
332 342
333 static int hasfield (lua_State *L, const char *fname) { 343 static int hasfield (lua_State *L, const char *fname) {
344 static const char *const validkeys[] = { 354 static const char *const validkeys[] = {
345 "StartCdataSection", "EndCdataSection", "CharacterData", "Comment", 355 "StartCdataSection", "EndCdataSection", "CharacterData", "Comment",
346 "Default", "DefaultExpand", "StartElement", "EndElement", 356 "Default", "DefaultExpand", "StartElement", "EndElement",
347 "ExternalEntityRef", "StartNamespaceDecl", "EndNamespaceDecl", 357 "ExternalEntityRef", "StartNamespaceDecl", "EndNamespaceDecl",
348 "NotationDecl", "NotStandalone", "ProcessingInstruction", 358 "NotationDecl", "NotStandalone", "ProcessingInstruction",
349 "UnparsedEntityDecl", "StartDoctypeDecl", NULL}; 359 "UnparsedEntityDecl", "StartDoctypeDecl", "XmlDecl", NULL};
350 if (hasfield(L, "_nonstrict")) return; 360 if (hasfield(L, "_nonstrict")) return;
351 lua_pushnil(L); 361 lua_pushnil(L);
352 while (lua_next(L, 1)) { 362 while (lua_next(L, 1)) {
353 lua_pop(L, 1); /* remove value */ 363 lua_pop(L, 1); /* remove value */
354 #if ! defined (LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 364 #if ! defined (LUA_VERSION_NUM) || LUA_VERSION_NUM < 501
399 XML_SetProcessingInstructionHandler(p, f_ProcessingInstruction); 409 XML_SetProcessingInstructionHandler(p, f_ProcessingInstruction);
400 if (hasfield(L, UnparsedEntityDeclKey)) 410 if (hasfield(L, UnparsedEntityDeclKey))
401 XML_SetUnparsedEntityDeclHandler(p, f_UnparsedEntityDecl); 411 XML_SetUnparsedEntityDeclHandler(p, f_UnparsedEntityDecl);
402 if (hasfield(L, StartDoctypeDeclKey)) 412 if (hasfield(L, StartDoctypeDeclKey))
403 XML_SetStartDoctypeDeclHandler(p, f_StartDoctypeDecl); 413 XML_SetStartDoctypeDeclHandler(p, f_StartDoctypeDecl);
414 if (hasfield(L, XmlDeclKey))
415 XML_SetXmlDeclHandler(p, f_XmlDecl);
404 return 1; 416 return 1;
405 } 417 }
406 418
407 419
408 static lxp_userdata *checkparser (lua_State *L, int idx) { 420 static lxp_userdata *checkparser (lua_State *L, int idx) {

mercurial