@@ -326,6 +326,7 @@ evaluate(int argc, VALUE *argv, VALUE self)
326
326
xmlXPathContextPtr ctx ;
327
327
xmlXPathObjectPtr xpath ;
328
328
xmlChar * query ;
329
+ VALUE errors = rb_ary_new ();
329
330
330
331
Data_Get_Struct (self , xmlXPathContext , ctx );
331
332
@@ -341,13 +342,7 @@ evaluate(int argc, VALUE *argv, VALUE self)
341
342
xmlXPathRegisterFuncLookup (ctx , lookup , (void * )xpath_handler );
342
343
}
343
344
344
- xmlResetLastError ();
345
- #ifdef TRUFFLERUBY_NOKOGIRI_SYSTEM_LIBRARIES
346
- VALUE errors = rb_ary_new ();
347
- xmlSetStructuredErrorFunc (errors , Nokogiri_error_array_pusher );
348
- #else
349
- xmlSetStructuredErrorFunc (NULL , Nokogiri_error_raise );
350
- #endif
345
+ xmlSetStructuredErrorFunc ((void * )errors , Nokogiri_error_array_pusher );
351
346
352
347
/* For some reason, xmlXPathEvalExpression will blow up with a generic error */
353
348
/* when there is a non existent function. */
@@ -357,15 +352,8 @@ evaluate(int argc, VALUE *argv, VALUE self)
357
352
xmlSetStructuredErrorFunc (NULL , NULL );
358
353
xmlSetGenericErrorFunc (NULL , NULL );
359
354
360
- #ifdef TRUFFLERUBY_NOKOGIRI_SYSTEM_LIBRARIES
361
- if (RARRAY_LEN (errors ) > 0 ) {
362
- rb_exc_raise (rb_ary_entry (errors , 0 ));
363
- }
364
- #endif
365
-
366
355
if (xpath == NULL ) {
367
- xmlErrorPtr error = xmlGetLastError ();
368
- rb_exc_raise (Nokogiri_wrap_xml_syntax_error (error ));
356
+ rb_exc_raise (rb_ary_entry (errors , 0 ));
369
357
}
370
358
371
359
retval = xpath2ruby (xpath , ctx );
0 commit comments