* Introduce a root-node that can hold extra information which is necessary
for thread safety under windows * Add xmlErrorGetString, xmlErrorGetLineNo for syntax error detetction * Add xmlErrGetNo for detection of, and clearing the last error
This commit is contained in:
parent
a6563c402c
commit
a21dddeffc
5 changed files with 752 additions and 346 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
18-04-2009
|
||||||
|
* Make the code compiler correctly under windows
|
||||||
|
* Introduce a root-node that can hold extra information which is necessary
|
||||||
|
for thread safety under windows
|
||||||
|
* Add xmlErrorGetString, xmlErrorGetLineNo for syntax error detetction
|
||||||
|
* Add xmlErrGetNo for detection of, and clearing the last error
|
||||||
|
|
||||||
16-04-2008
|
16-04-2008
|
||||||
* Rename xmlGetNode functions to xmlNodeGet for better consistancy
|
* Rename xmlGetNode functions to xmlNodeGet for better consistancy
|
||||||
* likewise for xmlCopyNode en xmlCompareNode
|
* likewise for xmlCopyNode en xmlCompareNode
|
||||||
|
|
|
@ -127,3 +127,15 @@ double xmlAttributeGetDouble(const void *, const char *);
|
||||||
char *xmlAttributeGetString(const void *, const char *);
|
char *xmlAttributeGetString(const void *, const char *);
|
||||||
size_t xmlAttributeCopyString(const void *, const char *, const char *, size_t);
|
size_t xmlAttributeCopyString(const void *, const char *, const char *, size_t);
|
||||||
int xmlAttributeCompareString(const void *, const char *, const char *);
|
int xmlAttributeCompareString(const void *, const char *, const char *);
|
||||||
|
|
||||||
|
#
|
||||||
|
# Error detection and reporting functions
|
||||||
|
#
|
||||||
|
# char *err_str = xmlErrorGetString(id);
|
||||||
|
# size_t err_lineno = xmlErrorGetLineNo(id);
|
||||||
|
# int err = xmlErrorGetNo(id); /* clear last error */
|
||||||
|
# if (err) printf("Error #%i at line #%u: '%s'\n", err, err_lineno, err_str);
|
||||||
|
#
|
||||||
|
int xmlErrorGetNo(const void *);
|
||||||
|
size_t xmlErrorGetLineNo(const void *);
|
||||||
|
const char *xmlErrorGetString(const void *);
|
||||||
|
|
1039
utils/xmlgrep/xml.c
1039
utils/xmlgrep/xml.c
File diff suppressed because it is too large
Load diff
|
@ -223,6 +223,7 @@ char *xmlAttributeGetString(const void *, const char *);
|
||||||
* @param buffer the buffer to copy the string to
|
* @param buffer the buffer to copy the string to
|
||||||
* @param buflen length of the destination buffer
|
* @param buflen length of the destination buffer
|
||||||
* @return the length of the string
|
* @return the length of the string
|
||||||
|
*/
|
||||||
size_t xmlAttributeCopyString(const void *, const char *, const char *, size_t);
|
size_t xmlAttributeCopyString(const void *, const char *, const char *, size_t);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -235,7 +236,6 @@ size_t xmlAttributeCopyString(const void *, const char *, const char *, size_t);
|
||||||
* @return an integer less than, equal to, ro greater than zero if the value
|
* @return an integer less than, equal to, ro greater than zero if the value
|
||||||
* of the node is found, respectively, to be less than, to match, or be greater
|
* of the node is found, respectively, to be less than, to match, or be greater
|
||||||
* than str
|
* than str
|
||||||
*/
|
|
||||||
int xmlAttributeCompareString(const void *, const char *, const char *);
|
int xmlAttributeCompareString(const void *, const char *, const char *);
|
||||||
|
|
||||||
|
|
||||||
|
@ -283,7 +283,6 @@ double xmlGetDouble(const void *);
|
||||||
*/
|
*/
|
||||||
double xmlNodeGetDouble(const void *, const char *);
|
double xmlNodeGetDouble(const void *, const char *);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the double value from the named attribute.
|
* Get the double value from the named attribute.
|
||||||
*
|
*
|
||||||
|
@ -293,5 +292,32 @@ double xmlNodeGetDouble(const void *, const char *);
|
||||||
*/
|
*/
|
||||||
double xmlAttributeGetDouble(const void *, const char *);
|
double xmlAttributeGetDouble(const void *, const char *);
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef XML_NONVALIDATING
|
||||||
|
/**
|
||||||
|
* Get the error number of the last error and clear it.
|
||||||
|
*
|
||||||
|
* @param xid XML-id
|
||||||
|
* @return the numer of the last error, 0 means no error detected.
|
||||||
|
*/
|
||||||
|
int xmlErrorGetNo(const void *);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the line number of the last detected syntax error in the xml file.
|
||||||
|
*
|
||||||
|
* @param xid XML-id
|
||||||
|
* @return the line number of the detected syntax error.
|
||||||
|
*/
|
||||||
|
size_t xmlErrorGetLineNo(const void *);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a string that explains the last error.
|
||||||
|
*
|
||||||
|
* @param xid XML-id
|
||||||
|
* @return a string that explains the last error.
|
||||||
|
*/
|
||||||
|
const char *xmlErrorGetString(const void *);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __XML_CONFIG */
|
#endif /* __XML_CONFIG */
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
|
@ -311,7 +312,16 @@ void grep_file(unsigned num)
|
||||||
if (xid)
|
if (xid)
|
||||||
{
|
{
|
||||||
void *xrid = xmlMarkId(xid);
|
void *xrid = xmlMarkId(xid);
|
||||||
|
size_t n = 0;
|
||||||
|
char *s = 0;
|
||||||
|
int r = 0;
|
||||||
walk_the_tree(num, xrid, _root);
|
walk_the_tree(num, xrid, _root);
|
||||||
|
|
||||||
|
s = xmlErrorGetString(xrid);
|
||||||
|
n = xmlErrorGetLineNo(xrid);
|
||||||
|
r = xmlErrorGetNo(xrid);
|
||||||
|
if (r) printf("Error #%i at line #%u: '%s'\n", r, n, s);
|
||||||
|
|
||||||
free(xrid);
|
free(xrid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue