Commit 92ad2104 authored by Daniel Veillard's avatar Daniel Veillard

Spring cleanup ...: - configure.in Makefile.am config.h.in

Spring cleanup ...:
- configure.in Makefile.am config.h.in xmlversion.h.in: detect if
  we need string functions
- trio.[ch] strio.[ch]: embedded the Trio-0.23 string functions
  to be able to use them where needed. Applied some changes
  to reduce name linking pollution and compile in only what's
  needed.
- HTMLtree.c debugXML.c entities.c error.c nanoftp.c valid.c
  xlink.c xmlversion.h.in xpath.c: got rid of the #ifdef
  for the string manipulation functions
- xmlmemory.[ch]: removed DEBUG_MEMORY_FREED and added it automatically
  to the free() function of xmlmemory.c
- entities.c HTMLtree.c parserInternals.c tree.c uri.c valid.c
  xinclude.c xmlIO.c xpath.c xpointer.c: removed the MEM_CLEANUP
  usage.
Daniel
parent 2be30641
Tue Mar 27 14:32:06 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* configure.in Makefile.am config.h.in xmlversion.h.in: detect if
we need string functions
* trio.[ch] strio.[ch]: embedded the Trio-0.23 string functions
to be able to use them where needed. Applied some changes
to reduce name linking pollution and compile in only what's
needed.
* HTMLtree.c debugXML.c entities.c error.c nanoftp.c valid.c
xlink.c xmlversion.h.in xpath.c: got rid of the #ifdef
for the string manipulation functions
* xmlmemory.[ch]: removed DEBUG_MEMORY_FREED and added it automatically
to the free() function of xmlmemory.c
* entities.c HTMLtree.c parserInternals.c tree.c uri.c valid.c
xinclude.c xmlIO.c xpath.c xpointer.c: removed the MEM_CLEANUP
usage.
Tue Mar 27 02:30:23 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* error.c: applied the context output patch of the error
......
......@@ -177,12 +177,8 @@ htmlSetMetaEncoding(htmlDocPtr doc, const xmlChar *encoding) {
return(-1);
if (encoding != NULL) {
#ifdef HAVE_SNPRINTF
snprintf(newcontent, sizeof(newcontent), "text/html; charset=%s",
encoding);
#else
sprintf(newcontent, "text/html; charset=%s", encoding);
#endif
newcontent[sizeof(newcontent) - 1] = 0;
}
......@@ -663,7 +659,6 @@ htmlDocDumpMemory(xmlDocPtr cur, xmlChar**mem, int *size) {
htmlDocContentDump(buf, cur);
*mem = buf->content;
*size = buf->use;
MEM_CLEANUP(buf, sizeof(xmlBuffer));
xmlFree(buf);
}
......
......@@ -15,29 +15,11 @@ libxml2_la_LIBADD = @Z_LIBS@ -lm
libxml2_la_LDFLAGS = -version-info @LIBXML_VERSION_INFO@
libxml2_la_SOURCES = \
SAX.c \
entities.c \
encoding.c \
error.c \
parserInternals.c \
parser.c \
tree.c \
hash.c \
list.c \
xmlIO.c \
xmlmemory.c \
uri.c \
valid.c \
xlink.c \
HTMLparser.c \
HTMLtree.c \
debugXML.c \
xpath.c \
xpointer.c \
xinclude.c \
nanohttp.c \
nanoftp.c
libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c \
parser.c tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c \
valid.c xlink.c HTMLparser.c HTMLtree.c debugXML.c xpath.c \
xpointer.c xinclude.c nanohttp.c nanoftp.c \
trio.c strio.c
DEPS = $(top_builddir)/libxml2.la
LDADDS = $(top_builddir)/libxml2.la @Z_LIBS@ -lm
......@@ -428,7 +410,8 @@ EXTRA_DIST = xml2Conf.sh.in libxml.spec.in libxml.spec libxml.m4 \
$(man_MANS) libxml-2.0.pc.in xmlversion.h.in \
win32/README.MSDev win32/Makefile.mingw \
win32/libxml2/libxml2.dsp win32/libxml2/libxml2_so.dsp \
win32/libxml2/libxml2_a.dsp vms/build_libxml.com vms/config.vms
win32/libxml2/libxml2_a.dsp vms/build_libxml.com vms/config.vms \
trio.h strio.h
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libxml-2.0.pc
......
......@@ -31,15 +31,27 @@
/* Define if you have the fpclass function. */
#undef HAVE_FPCLASS
/* Define if you have the fprintf function. */
#undef HAVE_FPRINTF
/* Define if you have the isnand function. */
#undef HAVE_ISNAND
/* Define if you have the localtime function. */
#undef HAVE_LOCALTIME
/* Define if you have the printf function. */
#undef HAVE_PRINTF
/* Define if you have the snprintf function. */
#undef HAVE_SNPRINTF
/* Define if you have the sprintf function. */
#undef HAVE_SPRINTF
/* Define if you have the sscanf function. */
#undef HAVE_SSCANF
/* Define if you have the stat function. */
#undef HAVE_STAT
......@@ -55,9 +67,15 @@
/* Define if you have the strndup function. */
#undef HAVE_STRNDUP
/* Define if you have the vfprintf function. */
#undef HAVE_VFPRINTF
/* Define if you have the vsnprintf function. */
#undef HAVE_VSNPRINTF
/* Define if you have the vsprintf function. */
#undef HAVE_VSPRINTF
/* Define if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H
......
......@@ -100,11 +100,15 @@ AC_SUBST(CORBA_CFLAGS)
dnl Checks for library functions.
AC_FUNC_STRFTIME
AC_CHECK_FUNCS(strdup strndup strerror snprintf vsnprintf)
AC_CHECK_FUNCS(strdup strndup strerror)
AC_CHECK_FUNCS(finite isnand fp_class class fpclass)
AC_CHECK_FUNCS(strftime localtime)
AC_CHECK_FUNCS(stat _stat)
dnl Checking the standard string functions availability
AC_CHECK_FUNCS(printf sprintf fprintf snprintf vfprintf vsprintf vsnprintf sscanf,,
NEED_TRIO=1)
dnl Checks for inet libraries:
AC_CHECK_FUNC(gethostent, , AC_CHECK_LIB(nsl, gethostent))
AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
......@@ -240,6 +244,19 @@ dnl fi
CFLAGS="-Wall -g -O -pedantic -W -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline "
dnl -Wcast-qual -ansi
fi
dnl
dnl Check for trio string functions
dnl
if test "${NEED_TRIO}" = "1" ; then
echo Adding trio library for string functions
WITH_TRIO=1
else
WITH_TRIO=0
fi
AC_SUBST(WITH_TRIO)
dnl
dnl Aloow to disable various pieces
dnl
......
......@@ -1512,18 +1512,10 @@ xmlShellPwd(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED, char *buffer, xmlNodePtr node
next = cur->parent;
}
if (occur == 0)
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "%c%s%s", sep, name, buffer);
#else
sprintf(buf, "%c%s%s", sep, name, buffer);
#endif
else
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "%c%s[%d]%s",
sep, name, occur, buffer);
#else
sprintf(buf, "%c%s[%d]%s", sep, name, occur, buffer);
#endif
buf[sizeof(buf) - 1] = 0;
/*
* This test prevents buffer overflow, because this routine
......@@ -1593,11 +1585,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
if (ctxt->node == (xmlNodePtr) ctxt->doc)
sprintf(prompt, "%s > ", "/");
else if (ctxt->node->name)
#ifdef HAVE_SNPRINTF
snprintf(prompt, sizeof(prompt), "%s > ", ctxt->node->name);
#else
sprintf(prompt, "%s > ", ctxt->node->name);
#endif
else
sprintf(prompt, "? > ");
prompt[sizeof(prompt) - 1] = 0;
......
......@@ -67,7 +67,6 @@ static void xmlFreeEntity(xmlEntityPtr entity) {
xmlFree((char *) entity->content);
if (entity->orig != NULL)
xmlFree((char *) entity->orig);
MEM_CLEANUP(entity, sizeof(xmlEntity));
xmlFree(entity);
}
......@@ -521,11 +520,7 @@ xmlEncodeEntities(xmlDocPtr doc, const xmlChar *input) {
} else if ((sizeof(xmlChar) == 1) && (*cur >= 0x80)) {
char buf[10], *ptr;
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "&#%d;", *cur);
#else
sprintf(buf, "&#%d;", *cur);
#endif
buf[sizeof(buf) - 1] = 0;
ptr = buf;
while (*ptr != 0) *out++ = *ptr++;
......@@ -533,11 +528,7 @@ xmlEncodeEntities(xmlDocPtr doc, const xmlChar *input) {
} else if (IS_CHAR(*cur)) {
char buf[10], *ptr;
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "&#%d;", *cur);
#else
sprintf(buf, "&#%d;", *cur);
#endif
buf[sizeof(buf) - 1] = 0;
ptr = buf;
while (*ptr != 0) *out++ = *ptr++;
......@@ -679,11 +670,7 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
xmlGenericError(xmlGenericErrorContext,
"xmlEncodeEntitiesReentrant : input not UTF-8\n");
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "&#%d;", *cur);
#else
sprintf(buf, "&#%d;", *cur);
#endif
buf[sizeof(buf) - 1] = 0;
ptr = buf;
while (*ptr != 0) *out++ = *ptr++;
......@@ -714,11 +701,7 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
xmlGenericError(xmlGenericErrorContext,
"xmlEncodeEntitiesReentrant : char out of range\n");
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "&#%d;", *cur);
#else
sprintf(buf, "&#%d;", *cur);
#endif
buf[sizeof(buf) - 1] = 0;
ptr = buf;
while (*ptr != 0) *out++ = *ptr++;
......@@ -728,11 +711,7 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
/*
* We could do multiple things here. Just save as a char ref
*/
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "&#x%X;", val);
#else
sprintf(buf, "&#x%X;", val);
#endif
buf[sizeof(buf) - 1] = 0;
ptr = buf;
while (*ptr != 0) *out++ = *ptr++;
......@@ -742,11 +721,7 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
} else if (IS_CHAR(*cur)) {
char buf[10], *ptr;
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "&#%d;", *cur);
#else
sprintf(buf, "&#%d;", *cur);
#endif
buf[sizeof(buf) - 1] = 0;
ptr = buf;
while (*ptr != 0) *out++ = *ptr++;
......
......@@ -163,21 +163,17 @@ xmlGetVarStr(const char * msg, va_list args) {
int chars, left;
char *str, *larger;
str = (char *) xmlMalloc(100);
str = (char *) xmlMalloc(150);
if (str == NULL)
return(NULL);
size = 100;
size = 150;
length = 0;
while (1) {
left = size - length;
/* Try to print in the allocated space. */
#ifdef HAVE_VSNPRINTF
chars = vsnprintf(str + length, left, msg, args);
#else
chars = vsprintf(str + length, msg, args);
#endif
/* If that worked, we're done. */
if ((chars > -1) && (chars < left ))
break;
......
......@@ -26,6 +26,7 @@
#ifdef DEBUG_MEMORY_LOCATION
#define MEM_LIST /* keep a list of all the allocated memory blocks */
#define DEBUG_MEMORY_FREED
#endif
#ifdef DEBUG_MEMORY_FREED
......
......@@ -23,6 +23,15 @@ extern void xmlCheckVersion(int version);
#define LIBXML_VERSION_STRING "@LIBXML_VERSION_NUMBER@"
#define LIBXML_TEST_VERSION xmlCheckVersion(@LIBXML_VERSION_NUMBER@);
/*
* Whether the trio support need to be configured in
*/
#if @WITH_TRIO@
#define WITH_TRIO
#else
#define WITHOUT_TRIO
#endif
/*
* Whether the FTP support is configured in
*/
......
......@@ -761,11 +761,7 @@ xmlNanoFTPSendUser(void *ctx) {
if (ctxt->user == NULL)
sprintf(buf, "USER anonymous\r\n");
else
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "USER %s\r\n", ctxt->user);
#else
sprintf(buf, "USER %s\r\n", ctxt->user);
#endif
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
......@@ -788,17 +784,9 @@ xmlNanoFTPSendPasswd(void *ctx) {
int res;
if (ctxt->passwd == NULL)
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "PASS libxml@%s\r\n", hostname);
#else
sprintf(buf, "PASS libxml@%s\r\n", hostname);
#endif
else
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd);
#else
sprintf(buf, "PASS %s\r\n", ctxt->passwd);
#endif
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
......@@ -947,11 +935,7 @@ xmlNanoFTPConnect(void *ctx) {
/*
* We need proxy auth
*/
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "USER %s\r\n", proxyUser);
#else
sprintf(buf, "USER %s\r\n", proxyUser);
#endif
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
......@@ -970,18 +954,10 @@ xmlNanoFTPConnect(void *ctx) {
break;
case 3:
if (proxyPasswd != NULL)
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "PASS %s\r\n", proxyPasswd);
#else
sprintf(buf, "PASS %s\r\n", proxyPasswd);
#endif
else
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "PASS libxml@%s\r\n",
hostname);
#else
sprintf(buf, "PASS libxml@%s\r\n", hostname);
#endif
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
......@@ -1021,11 +997,7 @@ xmlNanoFTPConnect(void *ctx) {
/* we will try in seqence */
case 1:
/* Using SITE command */
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "SITE %s\r\n", ctxt->hostname);
#else
sprintf(buf, "SITE %s\r\n", ctxt->hostname);
#endif
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
......@@ -1051,20 +1023,11 @@ xmlNanoFTPConnect(void *ctx) {
case 2:
/* USER user@host command */
if (ctxt->user == NULL)
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "USER anonymous@%s\r\n",
ctxt->hostname);
#else
sprintf(buf, "USER anonymous@%s\r\n", ctxt->hostname);
#endif
else
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "USER %s@%s\r\n",
ctxt->user, ctxt->hostname);
#else
sprintf(buf, "USER %s@%s\r\n",
ctxt->user, ctxt->hostname);
#endif
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
......@@ -1083,17 +1046,9 @@ xmlNanoFTPConnect(void *ctx) {
return(0);
}
if (ctxt->passwd == NULL)
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "PASS libxml@%s\r\n", hostname);
#else
sprintf(buf, "PASS libxml@%s\r\n", hostname);
#endif
else
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd);
#else
sprintf(buf, "PASS %s\r\n", ctxt->passwd);
#endif
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
......@@ -1231,11 +1186,7 @@ xmlNanoFTPCwd(void *ctx, char *directory) {
* 250
* 500, 501, 502, 421, 530, 550
*/
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "CWD %s\r\n", directory);
#else
sprintf(buf, "CWD %s\r\n", directory);
#endif
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
......@@ -1349,15 +1300,9 @@ xmlNanoFTPGetConnection(void *ctx) {
}
adp = (unsigned char *) &dataAddr.sin_addr;
portp = (unsigned char *) &dataAddr.sin_port;
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "PORT %d,%d,%d,%d,%d,%d\r\n",
adp[0] & 0xff, adp[1] & 0xff, adp[2] & 0xff, adp[3] & 0xff,
portp[0] & 0xff, portp[1] & 0xff);
#else
sprintf(buf, "PORT %d,%d,%d,%d,%d,%d\r\n",
adp[0] & 0xff, adp[1] & 0xff, adp[2] & 0xff, adp[3] & 0xff,
portp[0] & 0xff, portp[1] & 0xff);
#endif
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
......@@ -1590,11 +1535,7 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
ctxt->dataFd = xmlNanoFTPGetConnection(ctxt);
if (ctxt->dataFd == -1)
return(-1);
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "LIST -L %s\r\n", filename);
#else
sprintf(buf, "LIST -L %s\r\n", filename);
#endif
}
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
......@@ -1706,17 +1647,9 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
return(-res);
}
if (filename == NULL)
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "RETR %s\r\n", ctxt->path);
#else
sprintf(buf, "RETR %s\r\n", ctxt->path);
#endif
else
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf), "RETR %s\r\n", filename);
#else
sprintf(buf, "RETR %s\r\n", filename);
#endif
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
......
......@@ -1877,7 +1877,6 @@ xmlFreeInputStream(xmlParserInputPtr input) {
input->free((xmlChar *) input->base);
if (input->buf != NULL)
xmlFreeParserInputBuffer(input->buf);
MEM_CLEANUP(input, sizeof(xmlParserInput));
xmlFree(input);
}
......
This diff is collapsed.
/*************************************************************************
*
* $Id$
*
* Copyright (C) 1998 Bjorn Reese and Daniel Stenberg.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
*
************************************************************************/
#ifndef H_STRIO
#define H_STRIO
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "assert.h"
/*
* StrAppend(target, source)
* StrAppendMax(target, maxsize, source)
*
* Append 'source' to 'target'
*
* target = StrAlloc(size)
*
* Allocate a new string
*
* StrContains(target, substring)
*
* Find out if the string 'substring' is
* contained in the string 'target'
*
* StrCopy(target, source)
* StrCopyMax(target, maxsize, source)
*
* Copy 'source' to 'target'
*
* target = StrDuplicate(source)
* target = StrDuplicateMax(source, maxsize)
*
* Allocate and copy 'source' to 'target'
*
* StrEqual(first, second)
* StrEqualMax(first, maxsize, second)
*
* Compare if 'first' is equal to 'second'.
* Case-independent.
*
* StrEqualCase(first, second)
* StrEqualCaseMax(first, maxsize, second)
*
* Compare if 'first' is equal to 'second'
* Case-dependent. Please note that the use of the
* word 'case' has the opposite meaning as that of
* strcasecmp().
*
* StrFormat(target, format, ...)
* StrFormatMax(target, maxsize, format, ...)
*
* Build 'target' according to 'format' and succesive
* arguments. This is equal to the sprintf() and
* snprintf() functions.
*
* StrFormatDate(target, format, ...)
*
* StrFree(target)
*
* De-allocates a string
*
* StrHash(string, type)
*
* Calculates the hash value of 'string' based on the
* 'type'.
*
* StrIndex(target, character)
* StrIndexLast(target, character)
*
* Find the first/last occurrence of 'character' in
* 'target'
*
* StrLength(target)
*
* Return the length of 'target'
*
* StrMatch(string, pattern)
* StrMatchCase(string, pattern)
*
* Find 'pattern' within 'string'. 'pattern' may contain
* wildcards such as * (asterics) and ? (question mark)
* which matches zero or more characters and exactly
* on character respectively
*
* StrScan(source, format, ...)
*
* Equal to sscanf()
*
* StrSubstring(target, substring)
*
* Find the first occurrence of the string 'substring'
* within the string 'target'
*
* StrTokenize(target, list)
*
* Split 'target' into the first token delimited by
* one of the characters in 'list'. If 'target' is
* NULL then next token will be returned.
*
* StrToUpper(target)
*
* Convert all lower case characters in 'target' into
* upper case characters.
*/
enum {
STRIO_HASH_NONE = 0,
STRIO_HASH_PLAIN,
STRIO_HASH_TWOSIGNED
};
#if !defined(DEBUG) || defined(__DECC)
#define StrAppend(x,y) strcat((x), (y))
#define StrAlloc(n) ((char *)calloc(1, (n)))
#define StrContains(x,y) (0 != strstr((x), (y)))
#define StrCopy(x,y) strcpy((x), (y))
#define StrFree(x) free((x))
#define StrIndex(x,y) strchr((x), (y))
#define StrIndexLast(x,y) strrchr((x), (y))
#define StrLength(x) strlen((x))
#define StrSubstring(x,y) strstr((x), (y))
#define StrTokenize(x,y) strtok((x), (y))
#define StrToLong(x,y,n) strtol((x), (y), (n))
#define StrToUnsignedLong(x,y,n) strtoul((x), (y), (n))
#else /* DEBUG */
/*
* To be able to use these macros everywhere, including in
* if() sentences, the assertions are put first in a comma
* seperated list.
*
* Unfortunately the DECC compiler does not seem to like this
* so it will use the un-asserted functions above for the
* debugging case too.
*/
#define StrAppend(x,y) \
(assert((x) != NULL),\
assert((y) != NULL),\
strcat((x), (y)))
#define StrAlloc(n) \
(assert((n) > 0),\
((char *)calloc(1, (n))))
#define StrContains(x,y) \
(assert((x) != NULL),\
assert((y) != NULL),\
(0 != strstr((x), (y))))
#define StrCopy(x,y) \
(assert((x) != NULL),\
assert((y) != NULL),\
strcpy((x), (y)))
#define StrIndex(x,c) \
(assert((x) != NULL),\
strchr((x), (c)))
#define StrIndexLast(x,c) \
(assert((x) != NULL),\
strrchr((x), (c)))
#define StrFree(x) \
(assert((x) != NULL),\
free((x)))
#define StrLength(x) \
(assert((x) != NULL),\
strlen((x)))
#define StrSubstring(x,y) \
(assert((x) != NULL),\
assert((y) != NULL),\
strstr((x), (y)))
#define StrTokenize(x,y) \
(assert((y) != NULL),\
strtok((x), (y)))
#define StrToLong(x,y,n) \
(assert((x) != NULL),\
assert((y) != NULL),\
assert((n) >= 2 && (n) <= 36),\
strtol((x), (y), (n)))
#define StrToUnsignedLong(x,y,n) \
(assert((x) != NULL),\
assert((y) != NULL),\
assert((n) >= 2 && (n) <= 36),\
strtoul((x), (y), (n)))
#endif /* DEBUG */
char *StrAppendMax(char *target, size_t max, const char *source);
char *StrCopyMax(char *target, size_t max, const char *source);
char *StrDuplicate(const char *source);
char *StrDuplicateMax(const char *source, size_t max);
int StrEqual(const char *first, const char *second);
int StrEqualCase(const char *first, const char *second);
int StrEqualCaseMax(const char *first, size_t max, const char *second);
int StrEqualMax(const char *first, size_t max, const char *second);
const char *StrError(int);
size_t StrFormatDateMax(char *target, size_t max, const char *format, const struct tm *datetime);
unsigned long StrHash(const char *string, int type);
int StrMatch(char *string, char *pattern);
int StrMatchCase(char *string, char *pattern);
size_t StrSpanFunction(char *source, int (*Function)(int));
char *StrSubstringMax(const char *string, size_t max, const char *find);
float StrToFloat(const char *source, const char **target);
double StrToDouble(const char *source, const char **target);
int StrToUpper(char *target);
#endif /* H_STRIO */
......@@ -213,7 +213,6 @@ xmlFreeNs(xmlNsPtr cur) {
}
if (cur->href != NULL) xmlFree((char *) cur->href);
if (cur->prefix != NULL) xmlFree((char *) cur->prefix);
MEM_CLEANUP(cur, sizeof(xmlNs));
xmlFree(cur);
}
......@@ -446,7 +445,6 @@ xmlFreeDtd(xmlDtdPtr cur) {
if (cur->pentities != NULL)
xmlFreeEntitiesTable((xmlEntitiesTablePtr) cur->pentities);
MEM_CLEANUP(cur, sizeof(xmlDtd));
xmlFree(cur);
}
......@@ -508,7 +506,6 @@ xmlFreeDoc(xmlDocPtr cur) {
if (cur->ids != NULL) xmlFreeIDTable((xmlIDTablePtr) cur->ids);
if (cur->refs != NULL) xmlFreeRefTable((xmlRefTablePtr) cur->refs);
if (cur->URL != NULL) xmlFree((char *) cur->URL);
MEM_CLEANUP(cur, sizeof(xmlDoc));
xmlFree(cur);
}
......@@ -1133,7 +1130,6 @@ xmlFreeProp(xmlAttrPtr cur) {
xmlRemoveID(cur->parent->doc, cur);
if (cur->name != NULL) xmlFree((char *) cur->name);
if (cur->children != NULL) xmlFreeNodeList(cur->children);
MEM_CLEANUP(cur, sizeof(xmlAttr));
xmlFree(cur);
}
......@@ -2329,7 +2325,6 @@ xmlFreeNode(xmlNodePtr cur) {
(cur->name != xmlStringComment))
xmlFree((char *) cur->name);
if (cur->nsDef != NULL) xmlFreeNsList(cur->nsDef);
MEM_CLEANUP(cur, sizeof(xmlNode));
xmlFree(cur);
}
...