nokolexbor 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/nokolexbor/extconf.rb +12 -6
- data/ext/nokolexbor/libxml/SAX2.h +4 -4
- data/ext/nokolexbor/libxml/chvalid.h +21 -21
- data/ext/nokolexbor/libxml/dict.h +13 -13
- data/ext/nokolexbor/libxml/globals.h +202 -202
- data/ext/nokolexbor/libxml/hash.h +25 -25
- data/ext/nokolexbor/libxml/parser.h +5 -5
- data/ext/nokolexbor/libxml/parserInternals.h +4 -4
- data/ext/nokolexbor/libxml/pattern.h +14 -14
- data/ext/nokolexbor/libxml/threads.h +15 -15
- data/ext/nokolexbor/libxml/tree.h +5 -5
- data/ext/nokolexbor/libxml/xmlerror.h +5 -5
- data/ext/nokolexbor/libxml/xmlmemory.h +16 -16
- data/ext/nokolexbor/libxml/xmlstring.h +30 -30
- data/ext/nokolexbor/libxml/xpath.h +43 -43
- data/ext/nokolexbor/libxml/xpathInternals.h +128 -128
- data/ext/nokolexbor/memory.c +7 -0
- data/ext/nokolexbor/nl_document.c +11 -1
- data/ext/nokolexbor/nl_node.c +37 -16
- data/ext/nokolexbor/nl_node_set.c +23 -9
- data/ext/nokolexbor/nl_xpath_context.c +19 -14
- data/ext/nokolexbor/private/buf.h +1 -1
- data/ext/nokolexbor/private/error.h +3 -3
- data/ext/nokolexbor/xml_SAX2.c +8 -8
- data/ext/nokolexbor/xml_buf.c +19 -19
- data/ext/nokolexbor/xml_chvalid.c +25 -25
- data/ext/nokolexbor/xml_dict.c +69 -69
- data/ext/nokolexbor/xml_encoding.c +2 -2
- data/ext/nokolexbor/xml_error.c +51 -51
- data/ext/nokolexbor/xml_globals.c +329 -329
- data/ext/nokolexbor/xml_hash.c +131 -131
- data/ext/nokolexbor/xml_memory.c +25 -25
- data/ext/nokolexbor/xml_parser.c +3 -3
- data/ext/nokolexbor/xml_parserInternals.c +15 -15
- data/ext/nokolexbor/xml_pattern.c +103 -103
- data/ext/nokolexbor/xml_string.c +93 -93
- data/ext/nokolexbor/xml_threads.c +61 -61
- data/ext/nokolexbor/xml_tree.c +12 -12
- data/ext/nokolexbor/xml_xpath.c +1194 -1203
- data/lib/nokolexbor/version.rb +1 -1
- data/patches/0003-lexbor-attach-template-content-to-self.patch +13 -0
- metadata +2 -2
data/ext/nokolexbor/nl_node.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#include "nokolexbor.h"
|
2
2
|
|
3
|
-
#define SORT_NAME
|
3
|
+
#define SORT_NAME nl_css_result
|
4
4
|
#define SORT_TYPE lxb_dom_node_t *
|
5
5
|
#define SORT_CMP(x, y) (x->user >= y->user ? (x->user == y->user ? 0 : 1) : -1)
|
6
6
|
#include "timsort.h"
|
@@ -199,7 +199,7 @@ nl_node_css_callback(lxb_dom_node_t *node, lxb_css_selector_specificity_t *spec,
|
|
199
199
|
return LXB_STATUS_OK;
|
200
200
|
}
|
201
201
|
|
202
|
-
|
202
|
+
lxb_status_t
|
203
203
|
nl_node_find(VALUE self, VALUE selector, lxb_selectors_cb_f cb, void *ctx)
|
204
204
|
{
|
205
205
|
const char *selector_c = StringValuePtr(selector);
|
@@ -207,37 +207,44 @@ nl_node_find(VALUE self, VALUE selector, lxb_selectors_cb_f cb, void *ctx)
|
|
207
207
|
|
208
208
|
lxb_dom_node_t *node = nl_rb_node_unwrap(self);
|
209
209
|
|
210
|
+
lxb_status_t status;
|
211
|
+
lxb_css_parser_t *parser = NULL;
|
212
|
+
lxb_selectors_t *selectors = NULL;
|
213
|
+
lxb_css_selector_list_t *list = NULL;
|
214
|
+
|
210
215
|
/* Create CSS parser. */
|
211
|
-
|
212
|
-
|
216
|
+
parser = lxb_css_parser_create();
|
217
|
+
status = lxb_css_parser_init(parser, NULL, NULL);
|
213
218
|
if (status != LXB_STATUS_OK)
|
214
219
|
{
|
215
|
-
|
220
|
+
goto cleanup;
|
216
221
|
}
|
217
222
|
|
218
223
|
/* Selectors. */
|
219
|
-
|
224
|
+
selectors = lxb_selectors_create();
|
220
225
|
status = lxb_selectors_init(selectors);
|
221
226
|
if (status != LXB_STATUS_OK)
|
222
227
|
{
|
223
|
-
|
228
|
+
goto cleanup;
|
224
229
|
}
|
225
230
|
|
226
231
|
/* Parse and get the log. */
|
227
232
|
// TODO: Cache the list for reuse, improves performance
|
228
|
-
|
233
|
+
list = lxb_css_selectors_parse_relative_list(parser, (const lxb_char_t *)selector_c, selector_len);
|
229
234
|
if (parser->status != LXB_STATUS_OK)
|
230
235
|
{
|
231
|
-
|
236
|
+
status = parser->status;
|
237
|
+
goto cleanup;
|
232
238
|
}
|
233
239
|
|
234
240
|
/* Find HTML nodes by CSS Selectors. */
|
235
241
|
status = lxb_selectors_find(selectors, node, list, cb, ctx);
|
236
242
|
if (status != LXB_STATUS_OK)
|
237
243
|
{
|
238
|
-
|
244
|
+
goto cleanup;
|
239
245
|
}
|
240
246
|
|
247
|
+
cleanup:
|
241
248
|
/* Destroy Selectors object. */
|
242
249
|
(void)lxb_selectors_destroy(selectors, true);
|
243
250
|
|
@@ -246,6 +253,8 @@ nl_node_find(VALUE self, VALUE selector, lxb_selectors_cb_f cb, void *ctx)
|
|
246
253
|
|
247
254
|
/* Destroy all object for all CSS Selector List. */
|
248
255
|
lxb_css_selector_list_destroy_memory(list);
|
256
|
+
|
257
|
+
return status;
|
249
258
|
}
|
250
259
|
|
251
260
|
static void
|
@@ -281,7 +290,7 @@ mark_node_orders(lxb_dom_node_t *root)
|
|
281
290
|
}
|
282
291
|
|
283
292
|
// Sort nodes in document traversal order (the same as Nokorigi)
|
284
|
-
void
|
293
|
+
void nl_sort_nodes_if_necessary(VALUE selector, lxb_dom_document_t *doc, lexbor_array_t *array)
|
285
294
|
{
|
286
295
|
// No need to sort if there's only one selector, the results are natually in document traversal order
|
287
296
|
if (strchr(RSTRING_PTR(selector), ',') != NULL)
|
@@ -301,7 +310,7 @@ void sort_nodes_if_necessary(VALUE selector, lxb_dom_document_t *doc, lexbor_arr
|
|
301
310
|
{
|
302
311
|
mark_node_orders(&doc->node);
|
303
312
|
}
|
304
|
-
|
313
|
+
nl_css_result_tim_sort((lxb_dom_node_t **)&array->list[0], array->length);
|
305
314
|
}
|
306
315
|
}
|
307
316
|
|
@@ -311,14 +320,21 @@ nl_node_at_css(VALUE self, VALUE selector)
|
|
311
320
|
lxb_dom_node_t *node = nl_rb_node_unwrap(self);
|
312
321
|
lexbor_array_t *array = lexbor_array_create();
|
313
322
|
|
314
|
-
nl_node_find(self, selector, nl_node_at_css_callback, array);
|
323
|
+
lxb_status_t status = nl_node_find(self, selector, nl_node_at_css_callback, array);
|
324
|
+
|
325
|
+
if (status != LXB_STATUS_OK)
|
326
|
+
{
|
327
|
+
lexbor_array_destroy(array, true);
|
328
|
+
nl_raise_lexbor_error(status);
|
329
|
+
}
|
315
330
|
|
316
331
|
if (array->length == 0)
|
317
332
|
{
|
333
|
+
lexbor_array_destroy(array, true);
|
318
334
|
return Qnil;
|
319
335
|
}
|
320
336
|
|
321
|
-
|
337
|
+
nl_sort_nodes_if_necessary(selector, node->owner_document, array);
|
322
338
|
|
323
339
|
VALUE ret = nl_rb_node_create(array->list[0], nl_rb_document_get(self));
|
324
340
|
|
@@ -333,9 +349,14 @@ nl_node_css(VALUE self, VALUE selector)
|
|
333
349
|
lxb_dom_node_t *node = nl_rb_node_unwrap(self);
|
334
350
|
lexbor_array_t *array = lexbor_array_create();
|
335
351
|
|
336
|
-
nl_node_find(self, selector, nl_node_css_callback, array);
|
352
|
+
lxb_status_t status = nl_node_find(self, selector, nl_node_css_callback, array);
|
353
|
+
if (status != LXB_STATUS_OK)
|
354
|
+
{
|
355
|
+
lexbor_array_destroy(array, true);
|
356
|
+
nl_raise_lexbor_error(status);
|
357
|
+
}
|
337
358
|
|
338
|
-
|
359
|
+
nl_sort_nodes_if_necessary(selector, node->owner_document, array);
|
339
360
|
|
340
361
|
return nl_rb_node_set_create_with_data(array, nl_rb_document_get(self));
|
341
362
|
}
|
@@ -5,8 +5,8 @@ extern VALUE cNokolexborNode;
|
|
5
5
|
VALUE cNokolexborNodeSet;
|
6
6
|
extern rb_data_type_t nl_document_type;
|
7
7
|
|
8
|
-
|
9
|
-
void
|
8
|
+
lxb_status_t nl_node_find(VALUE self, VALUE selector, lxb_selectors_cb_f cb, void *ctx);
|
9
|
+
void nl_sort_nodes_if_necessary(VALUE selector, lxb_dom_document_t *doc, lexbor_array_t *array);
|
10
10
|
lxb_status_t nl_node_at_css_callback(lxb_dom_node_t *node, lxb_css_selector_specificity_t *spec, void *ctx);
|
11
11
|
lxb_status_t nl_node_css_callback(lxb_dom_node_t *node, lxb_css_selector_specificity_t *spec, void *ctx);
|
12
12
|
|
@@ -275,8 +275,8 @@ nl_node_set_union(VALUE self, VALUE other)
|
|
275
275
|
return nl_rb_node_set_create_with_data(new_array, nl_rb_document_get(self));
|
276
276
|
}
|
277
277
|
|
278
|
-
static
|
279
|
-
nl_node_set_find(VALUE self, VALUE selector, lxb_selectors_cb_f cb, void*
|
278
|
+
static lxb_status_t
|
279
|
+
nl_node_set_find(VALUE self, VALUE selector, lxb_selectors_cb_f cb, void *ctx)
|
280
280
|
{
|
281
281
|
lxb_dom_document_t *doc = nl_rb_document_unwrap(nl_rb_document_get(self));
|
282
282
|
if (doc == NULL)
|
@@ -319,7 +319,7 @@ nl_node_set_find(VALUE self, VALUE selector, lxb_selectors_cb_f cb, void* ctx)
|
|
319
319
|
}
|
320
320
|
VALUE rb_frag = nl_rb_node_create(&frag->node, nl_rb_document_get(self));
|
321
321
|
|
322
|
-
nl_node_find(rb_frag, selector, cb, ctx);
|
322
|
+
lxb_status_t status = nl_node_find(rb_frag, selector, cb, ctx);
|
323
323
|
|
324
324
|
lxb_dom_document_fragment_interface_destroy(frag);
|
325
325
|
// Restore original node data
|
@@ -329,6 +329,8 @@ nl_node_set_find(VALUE self, VALUE selector, lxb_selectors_cb_f cb, void* ctx)
|
|
329
329
|
free(backup_array->list[i]);
|
330
330
|
}
|
331
331
|
lexbor_array_destroy(backup_array, true);
|
332
|
+
|
333
|
+
return status;
|
332
334
|
}
|
333
335
|
|
334
336
|
static VALUE
|
@@ -337,14 +339,21 @@ nl_node_set_at_css(VALUE self, VALUE selector)
|
|
337
339
|
lexbor_array_t *array = lexbor_array_create();
|
338
340
|
lxb_dom_document_t *doc = nl_rb_document_unwrap(nl_rb_document_get(self));
|
339
341
|
|
340
|
-
nl_node_set_find(self, selector, nl_node_at_css_callback, array);
|
342
|
+
lxb_status_t status = nl_node_set_find(self, selector, nl_node_at_css_callback, array);
|
343
|
+
|
344
|
+
if (status != LXB_STATUS_OK)
|
345
|
+
{
|
346
|
+
lexbor_array_destroy(array, true);
|
347
|
+
nl_raise_lexbor_error(status);
|
348
|
+
}
|
341
349
|
|
342
350
|
if (array->length == 0)
|
343
351
|
{
|
352
|
+
lexbor_array_destroy(array, true);
|
344
353
|
return Qnil;
|
345
354
|
}
|
346
355
|
|
347
|
-
|
356
|
+
nl_sort_nodes_if_necessary(selector, doc, array);
|
348
357
|
|
349
358
|
VALUE ret = nl_rb_node_create(array->list[0], nl_rb_document_get(self));
|
350
359
|
|
@@ -359,9 +368,14 @@ nl_node_set_css(VALUE self, VALUE selector)
|
|
359
368
|
lexbor_array_t *array = lexbor_array_create();
|
360
369
|
lxb_dom_document_t *doc = nl_rb_document_unwrap(nl_rb_document_get(self));
|
361
370
|
|
362
|
-
nl_node_set_find(self, selector, nl_node_css_callback, array);
|
371
|
+
lxb_status_t status = nl_node_set_find(self, selector, nl_node_css_callback, array);
|
372
|
+
if (status != LXB_STATUS_OK)
|
373
|
+
{
|
374
|
+
lexbor_array_destroy(array, true);
|
375
|
+
nl_raise_lexbor_error(status);
|
376
|
+
}
|
363
377
|
|
364
|
-
|
378
|
+
nl_sort_nodes_if_necessary(selector, doc, array);
|
365
379
|
|
366
380
|
return nl_rb_node_set_create_with_data(array, nl_rb_document_get(self));
|
367
381
|
}
|
@@ -18,7 +18,7 @@ VALUE cNokolexborXpathSyntaxError;
|
|
18
18
|
static void
|
19
19
|
free_xml_xpath_context(xmlXPathContextPtr ctx)
|
20
20
|
{
|
21
|
-
|
21
|
+
nl_xmlXPathFreeContext(ctx);
|
22
22
|
}
|
23
23
|
|
24
24
|
/*
|
@@ -33,7 +33,7 @@ nl_xpath_context_register_ns(VALUE self, VALUE prefix, VALUE uri)
|
|
33
33
|
xmlXPathContextPtr ctx;
|
34
34
|
Data_Get_Struct(self, xmlXPathContext, ctx);
|
35
35
|
|
36
|
-
|
36
|
+
nl_xmlXPathRegisterNs(ctx,
|
37
37
|
(const xmlChar *)StringValueCStr(prefix),
|
38
38
|
(const xmlChar *)StringValueCStr(uri));
|
39
39
|
return self;
|
@@ -52,9 +52,9 @@ nl_xpath_context_register_variable(VALUE self, VALUE name, VALUE value)
|
|
52
52
|
xmlXPathObjectPtr xmlValue;
|
53
53
|
Data_Get_Struct(self, xmlXPathContext, ctx);
|
54
54
|
|
55
|
-
xmlValue =
|
55
|
+
xmlValue = nl_xmlXPathNewCString(StringValueCStr(value));
|
56
56
|
|
57
|
-
|
57
|
+
nl_xmlXPathRegisterVariable(ctx,
|
58
58
|
(const xmlChar *)StringValueCStr(name),
|
59
59
|
xmlValue);
|
60
60
|
|
@@ -74,7 +74,7 @@ xpath2ruby(xmlXPathObjectPtr c_xpath_object, xmlXPathContextPtr ctx, VALUE rb_do
|
|
74
74
|
{
|
75
75
|
case XPATH_STRING:
|
76
76
|
rb_retval = rb_utf8_str_new_cstr((const char *)c_xpath_object->stringval);
|
77
|
-
|
77
|
+
nl_xmlFree(c_xpath_object->stringval);
|
78
78
|
return rb_retval;
|
79
79
|
|
80
80
|
case XPATH_NODESET:
|
@@ -192,19 +192,20 @@ nl_xpath_context_evaluate(int argc, VALUE *argv, VALUE self)
|
|
192
192
|
// if (Qnil != xpath_handler) {
|
193
193
|
// /* FIXME: not sure if this is the correct place to shove private data. */
|
194
194
|
// ctx->userData = (void *)xpath_handler;
|
195
|
-
//
|
195
|
+
// nl_xmlXPathRegisterFuncLookup(ctx, handler_lookup, (void *)xpath_handler);
|
196
196
|
// }
|
197
197
|
|
198
|
-
|
199
|
-
|
198
|
+
nl_xmlSetStructuredErrorFunc((void *)errors, nl_xpath_error_array_pusher);
|
199
|
+
nl_xmlSetGenericErrorFunc((void *)errors, nl_xpath_generic_exception_pusher);
|
200
200
|
|
201
|
-
xpath =
|
201
|
+
xpath = nl_xmlXPathEvalExpression(query, ctx);
|
202
202
|
|
203
|
-
|
204
|
-
|
203
|
+
nl_xmlSetStructuredErrorFunc(NULL, NULL);
|
204
|
+
nl_xmlSetGenericErrorFunc(NULL, NULL);
|
205
205
|
|
206
206
|
if (xpath == NULL)
|
207
207
|
{
|
208
|
+
nl_xmlXPathFreeObject(xpath);
|
208
209
|
rb_exc_raise(rb_ary_entry(errors, 0));
|
209
210
|
}
|
210
211
|
|
@@ -214,7 +215,7 @@ nl_xpath_context_evaluate(int argc, VALUE *argv, VALUE self)
|
|
214
215
|
retval = rb_funcall(cNokolexborNodeSet, rb_intern("new"), 1, rb_ary_new());
|
215
216
|
}
|
216
217
|
|
217
|
-
|
218
|
+
nl_xmlXPathFreeObject(xpath);
|
218
219
|
|
219
220
|
return retval;
|
220
221
|
}
|
@@ -233,7 +234,7 @@ nl_xpath_context_new(VALUE klass, VALUE rb_node)
|
|
233
234
|
|
234
235
|
lxb_dom_node_t *node = nl_rb_node_unwrap(rb_node);
|
235
236
|
|
236
|
-
ctx =
|
237
|
+
ctx = nl_xmlXPathNewContext(node->owner_document);
|
237
238
|
ctx->node = node;
|
238
239
|
|
239
240
|
self = Data_Wrap_Struct(klass, 0, free_xml_xpath_context, ctx);
|
@@ -244,7 +245,11 @@ nl_xpath_context_new(VALUE klass, VALUE rb_node)
|
|
244
245
|
|
245
246
|
void Init_nl_xpath_context(void)
|
246
247
|
{
|
247
|
-
|
248
|
+
#ifndef NOKOLEXBOR_ASAN
|
249
|
+
nl_xmlMemSetup((xmlFreeFunc)ruby_xfree, (xmlMallocFunc)ruby_xmalloc, (xmlReallocFunc)ruby_xrealloc, ruby_strdup);
|
250
|
+
#else
|
251
|
+
nl_xmlMemSetup((xmlFreeFunc)free, (xmlMallocFunc)malloc, (xmlReallocFunc)realloc, strdup);
|
252
|
+
#endif
|
248
253
|
|
249
254
|
cNokolexborXpathContext = rb_define_class_under(mNokolexbor, "XPathContext", rb_cObject);
|
250
255
|
mNokolexborXpath = rb_define_module_under(mNokolexbor, "XPath");
|
@@ -43,7 +43,7 @@ xmlBufIsEmpty(const xmlBufPtr buf);
|
|
43
43
|
XML_HIDDEN int
|
44
44
|
xmlBufAddLen(xmlBufPtr buf, size_t len);
|
45
45
|
|
46
|
-
/* const xmlChar *
|
46
|
+
/* const xmlChar * nl_xmlBufContent(const xmlBuf *buf); */
|
47
47
|
/* const xmlChar * xmlBufEnd(xmlBufPtr buf); */
|
48
48
|
|
49
49
|
XML_HIDDEN xmlChar *
|
@@ -5,17 +5,17 @@
|
|
5
5
|
#include "libxml/xmlversion.h"
|
6
6
|
|
7
7
|
XML_HIDDEN void
|
8
|
-
|
8
|
+
__nl_xmlRaiseError(xmlStructuredErrorFunc schannel,
|
9
9
|
xmlGenericErrorFunc channel, void *data, void *ctx,
|
10
10
|
void *nod, int domain, int code, xmlErrorLevel level,
|
11
11
|
const char *file, int line, const char *str1,
|
12
12
|
const char *str2, const char *str3, int int1, int col,
|
13
13
|
const char *msg, ...) LIBXML_ATTR_FORMAT(16,17);
|
14
14
|
XML_HIDDEN void
|
15
|
-
|
15
|
+
__nl_xmlSimpleError(int domain, int code, lxb_dom_node_t_ptr node,
|
16
16
|
const char *msg, const char *extra) LIBXML_ATTR_FORMAT(4,0);
|
17
17
|
XML_HIDDEN void
|
18
|
-
|
18
|
+
nl_xmlGenericErrorDefaultFunc(void *ctx, const char *msg,
|
19
19
|
...) LIBXML_ATTR_FORMAT(2,3);
|
20
20
|
|
21
21
|
#endif /* XML_ERROR_H_PRIVATE__ */
|
data/ext/nokolexbor/xml_SAX2.c
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
#include "libxml/globals.h"
|
17
17
|
|
18
18
|
/**
|
19
|
-
*
|
19
|
+
* nl_xmlSAX2GetPublicId:
|
20
20
|
* @ctx: the user data (XML parser context)
|
21
21
|
*
|
22
22
|
* Provides the public ID e.g. "-//SGMLSOURCE//DTD DEMO//EN"
|
@@ -24,14 +24,14 @@
|
|
24
24
|
* Returns a xmlChar *
|
25
25
|
*/
|
26
26
|
const xmlChar *
|
27
|
-
|
27
|
+
nl_xmlSAX2GetPublicId(void *ctx ATTRIBUTE_UNUSED)
|
28
28
|
{
|
29
29
|
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
|
30
30
|
return(NULL);
|
31
31
|
}
|
32
32
|
|
33
33
|
/**
|
34
|
-
*
|
34
|
+
* nl_xmlSAX2GetSystemId:
|
35
35
|
* @ctx: the user data (XML parser context)
|
36
36
|
*
|
37
37
|
* Provides the system ID, basically URL or filename e.g.
|
@@ -40,7 +40,7 @@ xmlSAX2GetPublicId(void *ctx ATTRIBUTE_UNUSED)
|
|
40
40
|
* Returns a xmlChar *
|
41
41
|
*/
|
42
42
|
const xmlChar *
|
43
|
-
|
43
|
+
nl_xmlSAX2GetSystemId(void *ctx)
|
44
44
|
{
|
45
45
|
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
46
46
|
if ((ctx == NULL) || (ctxt->input == NULL)) return(NULL);
|
@@ -48,7 +48,7 @@ xmlSAX2GetSystemId(void *ctx)
|
|
48
48
|
}
|
49
49
|
|
50
50
|
/**
|
51
|
-
*
|
51
|
+
* nl_xmlSAX2GetLineNumber:
|
52
52
|
* @ctx: the user data (XML parser context)
|
53
53
|
*
|
54
54
|
* Provide the line number of the current parsing point.
|
@@ -56,7 +56,7 @@ xmlSAX2GetSystemId(void *ctx)
|
|
56
56
|
* Returns an int
|
57
57
|
*/
|
58
58
|
int
|
59
|
-
|
59
|
+
nl_xmlSAX2GetLineNumber(void *ctx)
|
60
60
|
{
|
61
61
|
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
62
62
|
if ((ctx == NULL) || (ctxt->input == NULL)) return(0);
|
@@ -64,7 +64,7 @@ xmlSAX2GetLineNumber(void *ctx)
|
|
64
64
|
}
|
65
65
|
|
66
66
|
/**
|
67
|
-
*
|
67
|
+
* nl_xmlSAX2GetColumnNumber:
|
68
68
|
* @ctx: the user data (XML parser context)
|
69
69
|
*
|
70
70
|
* Provide the column number of the current parsing point.
|
@@ -72,7 +72,7 @@ xmlSAX2GetLineNumber(void *ctx)
|
|
72
72
|
* Returns an int
|
73
73
|
*/
|
74
74
|
int
|
75
|
-
|
75
|
+
nl_xmlSAX2GetColumnNumber(void *ctx)
|
76
76
|
{
|
77
77
|
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
78
78
|
if ((ctx == NULL) || (ctxt->input == NULL)) return(0);
|
data/ext/nokolexbor/xml_buf.c
CHANGED
@@ -92,7 +92,7 @@ struct _xmlBuf {
|
|
92
92
|
static void
|
93
93
|
xmlBufMemoryError(xmlBufPtr buf, const char *extra)
|
94
94
|
{
|
95
|
-
|
95
|
+
__nl_xmlSimpleError(XML_FROM_BUFFER, XML_ERR_NO_MEMORY, NULL, NULL, extra);
|
96
96
|
if ((buf) && (buf->error == 0))
|
97
97
|
buf->error = XML_ERR_NO_MEMORY;
|
98
98
|
}
|
@@ -107,7 +107,7 @@ xmlBufPtr
|
|
107
107
|
xmlBufCreate(void) {
|
108
108
|
xmlBufPtr ret;
|
109
109
|
|
110
|
-
ret = (xmlBufPtr)
|
110
|
+
ret = (xmlBufPtr) nl_xmlMalloc(sizeof(xmlBuf));
|
111
111
|
if (ret == NULL) {
|
112
112
|
xmlBufMemoryError(NULL, "creating buffer");
|
113
113
|
return(NULL);
|
@@ -115,13 +115,13 @@ xmlBufCreate(void) {
|
|
115
115
|
ret->use = 0;
|
116
116
|
ret->error = 0;
|
117
117
|
ret->buffer = NULL;
|
118
|
-
ret->size =
|
118
|
+
ret->size = nl_xmlDefaultBufferSize;
|
119
119
|
UPDATE_COMPAT(ret);
|
120
|
-
ret->alloc =
|
121
|
-
ret->content = (xmlChar *)
|
120
|
+
ret->alloc = nl_xmlBufferAllocScheme;
|
121
|
+
ret->content = (xmlChar *) nl_xmlMallocAtomic(ret->size);
|
122
122
|
if (ret->content == NULL) {
|
123
123
|
xmlBufMemoryError(ret, "creating buffer");
|
124
|
-
|
124
|
+
nl_xmlFree(ret);
|
125
125
|
return(NULL);
|
126
126
|
}
|
127
127
|
ret->content[0] = 0;
|
@@ -140,7 +140,7 @@ void
|
|
140
140
|
xmlBufFree(xmlBufPtr buf) {
|
141
141
|
if (buf == NULL) {
|
142
142
|
#ifdef DEBUG_BUFFER
|
143
|
-
|
143
|
+
nl_xmlGenericError(nl_xmlGenericErrorContext,
|
144
144
|
"xmlBufFree: buf == NULL\n");
|
145
145
|
#endif
|
146
146
|
return;
|
@@ -148,15 +148,15 @@ xmlBufFree(xmlBufPtr buf) {
|
|
148
148
|
|
149
149
|
if ((buf->alloc == XML_BUFFER_ALLOC_IO) &&
|
150
150
|
(buf->contentIO != NULL)) {
|
151
|
-
|
151
|
+
nl_xmlFree(buf->contentIO);
|
152
152
|
} else if (buf->content != NULL) {
|
153
|
-
|
153
|
+
nl_xmlFree(buf->content);
|
154
154
|
}
|
155
|
-
|
155
|
+
nl_xmlFree(buf);
|
156
156
|
}
|
157
157
|
|
158
158
|
/**
|
159
|
-
*
|
159
|
+
* nl_xmlBufContent:
|
160
160
|
* @buf: the buffer
|
161
161
|
*
|
162
162
|
* Function to extract the content of a buffer
|
@@ -165,7 +165,7 @@ xmlBufFree(xmlBufPtr buf) {
|
|
165
165
|
*/
|
166
166
|
|
167
167
|
xmlChar *
|
168
|
-
|
168
|
+
nl_xmlBufContent(const xmlBuf *buf)
|
169
169
|
{
|
170
170
|
if ((!buf) || (buf->error))
|
171
171
|
return NULL;
|
@@ -258,7 +258,7 @@ xmlBufResize(xmlBufPtr buf, size_t size)
|
|
258
258
|
buf->content[buf->use] = 0;
|
259
259
|
buf->size += start_buf;
|
260
260
|
} else {
|
261
|
-
rebuf = (xmlChar *)
|
261
|
+
rebuf = (xmlChar *) nl_xmlRealloc(buf->contentIO, start_buf + newSize);
|
262
262
|
if (rebuf == NULL) {
|
263
263
|
xmlBufMemoryError(buf, "growing buffer");
|
264
264
|
return 0;
|
@@ -268,21 +268,21 @@ xmlBufResize(xmlBufPtr buf, size_t size)
|
|
268
268
|
}
|
269
269
|
} else {
|
270
270
|
if (buf->content == NULL) {
|
271
|
-
rebuf = (xmlChar *)
|
271
|
+
rebuf = (xmlChar *) nl_xmlMallocAtomic(newSize);
|
272
272
|
buf->use = 0;
|
273
273
|
rebuf[buf->use] = 0;
|
274
274
|
} else if (buf->size - buf->use < 100) {
|
275
|
-
rebuf = (xmlChar *)
|
275
|
+
rebuf = (xmlChar *) nl_xmlRealloc(buf->content, newSize);
|
276
276
|
} else {
|
277
277
|
/*
|
278
278
|
* if we are reallocating a buffer far from being full, it's
|
279
279
|
* better to make a new allocation and copy only the used range
|
280
280
|
* and free the old one.
|
281
281
|
*/
|
282
|
-
rebuf = (xmlChar *)
|
282
|
+
rebuf = (xmlChar *) nl_xmlMallocAtomic(newSize);
|
283
283
|
if (rebuf != NULL) {
|
284
284
|
memcpy(rebuf, buf->content, buf->use);
|
285
|
-
|
285
|
+
nl_xmlFree(buf->content);
|
286
286
|
rebuf[buf->use] = 0;
|
287
287
|
}
|
288
288
|
}
|
@@ -320,7 +320,7 @@ xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len) {
|
|
320
320
|
|
321
321
|
if (len < -1) {
|
322
322
|
#ifdef DEBUG_BUFFER
|
323
|
-
|
323
|
+
nl_xmlGenericError(nl_xmlGenericErrorContext,
|
324
324
|
"xmlBufAdd: len < 0\n");
|
325
325
|
#endif
|
326
326
|
return -1;
|
@@ -328,7 +328,7 @@ xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len) {
|
|
328
328
|
if (len == 0) return 0;
|
329
329
|
|
330
330
|
if (len < 0)
|
331
|
-
len =
|
331
|
+
len = nl_xmlStrlen(str);
|
332
332
|
|
333
333
|
if (len < 0) return -1;
|
334
334
|
if (len == 0) return 0;
|