+01-07-2008
+ * fix a problem caused by removing the last unnecessary alloc
+ * strip leading-, and trailing spaces from the string before comparing
+ * fix a problem where trailing spaces weren't removed
+
30-06-2008:
- * some small changes; fix some typo's en fix a small memory leak
+ * some small changes; fix some typo's and fix a small memory leak
* update the documentation in README
* remove the last unnecessary alloc
* add a README file with short examples of various functions
27-06-2008:
- * removed some memorly allocation in xmlGetNode and XMLGetNextElement
- * use the filesize for mmap and remove the root node from the xml-id
- * rearange xmlGetNode to work with complicated xml files
+ * removed some memory allocation in xmlGetNode and XMLGetNextElement
+ * use the file-size for mmap and remove the root node from the xml-id
+ * rearrange xmlGetNode to work with complicated xml files
* add the xmlMarkId function to save the id before using xmlGetNextElement
* speed up xmlGetNextId
if (xid && xid->len && s && (strlen(s) > 0))
{
- ret = strncasecmp(xid->start, s, xid->len);
+ char *ps, *pe;
+
+ ps = xid->start;
+ pe = ps + xid->len;
+ pe--;
+
+ while ((ps<pe) && isspace(*ps)) ps++;
+ while ((pe>ps) && isspace(*pe)) pe--;
+ pe++;
+
+ ret = strncasecmp(ps, s, pe-ps);
}
return ret;
if (xid && xid->len && path && s && (strlen(s) > 0))
{
+ char *str, *ps, *pe;
size_t rlen;
- char *str;
rlen = strlen(path);
str = __xmlGetNode(xid->start, xid->len, path, &rlen);
- if (str) ret = strncasecmp(str, s, rlen);
+
+ ps = str;
+ pe = ps + rlen;
+ pe--;
+
+ while ((ps<pe) && isspace(*ps)) ps++;
+ while ((pe>ps) && isspace(*pe)) pe--;
+ pe++;
+
+ if (str) ret = strncasecmp(pe, s, pe-ps);
}
return ret;
str = __xmlCopyNode(xid->start, xid->len, path);
if (str)
{
- char *ps, *pe, *pem;
+ char *ps, *pe, *pend;
int slen;
slen = strlen(str);
ps = str;
- pe = pem = ps+slen;
+ pend = ps+slen;
+ pe = pend-1;
while ((ps<pe) && isspace(*ps)) ps++;
while ((pe>ps) && isspace(*pe)) pe--;
- if (pe<pem) *++pe = 0;
+ *++pe = 0;
slen = (pe-ps);
- if ((ps>str) && slen) memmove(str, ps, slen+1);
+ if (slen && (ps>str)) memmove(str, ps, slen);
else if (!slen) *str = 0;
}
}
str = malloc(xid->len+1);
if (str)
{
- char *ps, *pe, *pem;
+ char *ps, *pe, *pend;
int slen;
slen = xid->len;
memcpy(str, xid->start, slen);
- *(str+slen) = 0;
ps = str;
- pe = pem = ps+slen;
+ pend = ps+slen;
+ pe = pend-1;
+ *pend = 0;
while ((ps<pe) && isspace(*ps)) ps++;
while ((pe>ps) && isspace(*pe)) pe--;
- if (pe<pem) *++pe = 0;
+ if (pe<pend) *++pe = 0;
slen = (pe-ps);
if ((ps>str) && slen) memmove(str, ps, slen+1);
else if (!slen) *str = 0;
{
unsigned int clen;
char *p, *pathname;
- char *pname, *nname;
+ char *nname;
pathname = (char *)path;
if (*path == '/') pathname++;
if (nname)
{
clen = nname-pathname;
- p = __xmlGetNode(xid->start, xid->len, path, &clen);
+ p = __xmlGetNode(xid->start, xid->len, pathname, &clen);
}
else
{
{
char *ret = 0;
- if (len)
+ if (len && rlen && *rlen)
{
char last_node = 0;
char *ptr, *name;
- int plen;
+ size_t plen, slen;
+ slen = *rlen;
name = (char *)path;
- if (*name == '/') name++; /* skip the leading '/' character */
+ if (*name == '/')
+ {
+ name++; /* skip the leading '/' character */
+ slen--;
+ }
ptr = strchr(name, '/');
if (!ptr)
{
last_node = 1;
- ptr = name + *rlen;
+ plen = slen;
+ }
+ else
+ {
+ plen = ptr++ - name;
+ slen -= (ptr - name);
}
- plen = ptr - name;
if (plen)
{
}
else
{
- ret = __xmlGetNode(cur, len, ptr+1, rlen);
+ *rlen = slen;
+ ret = __xmlGetNode(cur, len, ptr, rlen);
}
}
}