Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Nov 20, 2020. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patherror.c
More file actions
Latest commit
130 lines (123 loc) · 3.09 KB
/
Copy patherror.c
File metadata and controls
130 lines (123 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include"lua.h"
#include"lauxlib.h"
#include"libxml/xmlerror.h"
/* TODO: wrap the error object so user code can retrieve and query the last
* error */
/* Mostly ripped from code in parser.c and error.c in libxml. Not ideal, but
* it seems impossible to hook into libxml's error string generation */
intxml_push_error(lua_State*L, xmlErrorPtrerr)
{
if (err==NULL)
luaL_error(L, "a NULL error was raised. Should not happen");
char*file=err->file;
intline=err->line;
/* int code = err->code; */
intdomain=err->domain;
xmlErrorLevellevel=err->level;
constxmlChar*name=NULL;
xmlNodePtrnode=err->node;
luaL_Bufferbuf;
luaL_buffinit(L, &buf);
luaL_Buffer*B=&buf;
if ((node!=NULL) && (node->type==XML_ELEMENT_NODE))
name=node->name;
if (file!=NULL)
{
lua_pushfstring(L, "%s:%d: ", file, line);
luaL_addvalue(B);
}
elseif ((line!=0) && (domain==XML_FROM_PARSER))
{
lua_pushfstring(L, "Entity: line %d: ", line);
luaL_addvalue(B);
}
if (name!=NULL)
{
lua_pushfstring(L, "element %s: ", name);
luaL_addvalue(B);
}
switch (domain)
{
caseXML_FROM_PARSER:
luaL_addstring(B, "parser ");
break;
caseXML_FROM_NAMESPACE:
luaL_addstring(B, "namespace ");
break;
caseXML_FROM_DTD:
caseXML_FROM_VALID:
luaL_addstring(B, "validity ");
break;
caseXML_FROM_HTML:
luaL_addstring(B, "HTML parser ");
break;
caseXML_FROM_MEMORY:
luaL_addstring(B, "memory ");
break;
caseXML_FROM_OUTPUT:
luaL_addstring(B, "output ");
break;
caseXML_FROM_IO:
luaL_addstring(B, "I/O ");
break;
caseXML_FROM_XINCLUDE:
luaL_addstring(B, "XInclude ");
break;
caseXML_FROM_XPATH:
luaL_addstring(B, "XPath ");
break;
caseXML_FROM_XPOINTER:
luaL_addstring(B, "parser ");
break;
caseXML_FROM_REGEXP:
luaL_addstring(B, "regexp ");
break;
caseXML_FROM_MODULE:
luaL_addstring(B, "module ");
break;
caseXML_FROM_SCHEMASV:
luaL_addstring(B, "Schemas validity ");
break;
caseXML_FROM_SCHEMASP:
luaL_addstring(B, "Schemas parser ");
break;
caseXML_FROM_RELAXNGP:
luaL_addstring(B, "Relax-NG parser ");
break;
caseXML_FROM_RELAXNGV:
luaL_addstring(B, "Relax-NG validity ");
break;
caseXML_FROM_CATALOG:
luaL_addstring(B, "Catalog ");
break;
caseXML_FROM_C14N:
luaL_addstring(B, "C14N ");
break;
caseXML_FROM_XSLT:
luaL_addstring(B, "XSLT ");
break;
caseXML_FROM_I18N:
luaL_addstring(B, "encoding ");
break;
default:
break;
}
switch (level) {
caseXML_ERR_NONE:
luaL_addstring(B, ": ");
break;
caseXML_ERR_WARNING:
luaL_addstring(B, "warning : ");
break;
caseXML_ERR_ERROR:
luaL_addstring(B, "error : ");
break;
caseXML_ERR_FATAL:
luaL_addstring(B, "error : ");
break;
}
if (err->message)
luaL_addstring(B, err->message);
luaL_pushresult(B);
return1;
}