Commit 30feac13 authored by Michael R Sweet's avatar Michael R Sweet

Add mxml_isspace() local Unicode implementation of isspace() with inlining

when possible (STR #48)
parent b0e38fbc
......@@ -3,6 +3,8 @@ CHANGES - 2007-09-09
CHANGES IN Mini-XML 2.3.1
- Fixed whitespace detection with Unicode characters (STR
#48)
- mxmlWalkNext() and mxmlWalkPrev() did not work correctly
when called with a node with no children as the top node
(STR #53)
......
......@@ -34,6 +34,13 @@
#define MXML_VERSION ""
/*
* Inline function support...
*/
#define inline
/*
* Do we have the snprintf() and vsnprintf() functions?
*/
......
......@@ -1673,7 +1673,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_config_headers="$ac_config_headers config.h"
VERSION=2.3
VERSION=2.3.1
cat >>confdefs.h <<_ACEOF
#define MXML_VERSION "Mini-XML v$VERSION"
......@@ -3446,8 +3446,78 @@ esac
if test "x$use_ansi" != xyes; then
{ echo "$as_me:$LINENO: checking for inline" >&5
echo $ECHO_N "checking for inline... $ECHO_C" >&6; }
if test "${ac_cv_c_inline+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_cv_c_inline=no
for ac_kw in inline __inline__ __inline; do
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#ifndef __cplusplus
typedef int foo_t;
static $ac_kw foo_t static_foo () {return 0; }
$ac_kw foo_t foo () {return 0; }
#endif
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_c_inline=$ac_kw
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
test "$ac_cv_c_inline" != no && break
done
fi
{ echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5
echo "${ECHO_T}$ac_cv_c_inline" >&6; }
case $ac_cv_c_inline in
inline | yes) ;;
*)
case $ac_cv_c_inline in
no) ac_val=;;
*) ac_val=$ac_cv_c_inline;;
esac
cat >>confdefs.h <<_ACEOF
#ifndef __cplusplus
#define inline $ac_val
#endif
_ACEOF
;;
esac
if test "x$use_ansi" != xyes; then
for ac_func in strdup
do
......
......@@ -23,7 +23,7 @@ dnl Set the name of the config header file...
AC_CONFIG_HEADER(config.h)
dnl Version number...
VERSION=2.3
VERSION=2.3.1
AC_SUBST(VERSION)
AC_DEFINE_UNQUOTED(MXML_VERSION, "Mini-XML v$VERSION")
......@@ -94,6 +94,9 @@ esac
AC_SUBST(ARFLAGS)
dnl Inline functions...
AC_C_INLINE
dnl Checks for string functions.
if test "x$use_ansi" != xyes; then
AC_CHECK_FUNCS(strdup)
......
......@@ -2,7 +2,7 @@
<html>
<head>
<title>Documentation</title>
<meta name='creator' content='Mini-XML v2.3'>
<meta name='creator' content='Mini-XML v2.3.1'>
<style type='text/css'><!--
h1, h2, h3, p { font-family: sans-serif; text-align: justify; }
tt, pre a:link, pre a:visited, tt a:link, tt a:visited { font-weight: bold; color: #7f0000; }
......
......@@ -133,6 +133,11 @@ static int mxml_file_putc(int ch, void *p);
static int mxml_get_entity(mxml_node_t *parent, void *p,
int *encoding,
_mxml_getc_cb_t getc_cb);
static inline int mxml_isspace(int ch)
{
return (ch == ' ' || ch == '\t' || ch == '\r' ||
ch == '\n' || ch == '\f' || ch == '\v');
}
static mxml_node_t *mxml_load_data(mxml_node_t *top, void *p,
mxml_load_cb_t cb,
_mxml_getc_cb_t getc_cb,
......@@ -1520,7 +1525,7 @@ mxml_load_data(
while ((ch = (*getc_cb)(p, &encoding)) != EOF)
{
if ((ch == '<' ||
(isspace(ch) && type != MXML_OPAQUE && type != MXML_CUSTOM)) &&
(mxml_isspace(ch) && type != MXML_OPAQUE && type != MXML_CUSTOM)) &&
bufptr > buffer)
{
/*
......@@ -1584,7 +1589,7 @@ mxml_load_data(
}
bufptr = buffer;
whitespace = isspace(ch) && type == MXML_TEXT;
whitespace = mxml_isspace(ch) && type == MXML_TEXT;
if (!node && type != MXML_IGNORE)
{
......@@ -1608,7 +1613,7 @@ mxml_load_data(
if (!first && node)
first = node;
}
else if (isspace(ch) && type == MXML_TEXT)
else if (mxml_isspace(ch) && type == MXML_TEXT)
whitespace = 1;
/*
......@@ -1643,7 +1648,7 @@ mxml_load_data(
bufptr = buffer;
while ((ch = (*getc_cb)(p, &encoding)) != EOF)
if (isspace(ch) || ch == '>' || (ch == '/' && bufptr > buffer))
if (mxml_isspace(ch) || ch == '>' || (ch == '/' && bufptr > buffer))
break;
else if (ch == '<')
{
......@@ -1980,7 +1985,7 @@ mxml_load_data(
goto error;
}
if (isspace(ch))
if (mxml_isspace(ch))
ch = mxml_parse_element(node, p, &encoding, getc_cb);
else if (ch == '/')
{
......@@ -2038,7 +2043,7 @@ mxml_load_data(
if (mxml_add_char(ch, &bufptr, &buffer, &bufsize))
goto error;
}
else if (type == MXML_OPAQUE || type == MXML_CUSTOM || !isspace(ch))
else if (type == MXML_OPAQUE || type == MXML_CUSTOM || !mxml_isspace(ch))
{
/*
* Add character to current buffer...
......@@ -2151,7 +2156,7 @@ mxml_parse_element(
* Skip leading whitespace...
*/
if (isspace(ch))
if (mxml_isspace(ch))
continue;
/*
......@@ -2218,7 +2223,8 @@ mxml_parse_element(
*/
while ((ch = (*getc_cb)(p, encoding)) != EOF)
if (isspace(ch) || ch == '=' || ch == '/' || ch == '>' || ch == '?')
if (mxml_isspace(ch) || ch == '=' || ch == '/' || ch == '>' ||
ch == '?')
break;
else
{
......@@ -2283,7 +2289,7 @@ mxml_parse_element(
ptr = value + 1;
while ((ch = (*getc_cb)(p, encoding)) != EOF)
if (isspace(ch) || ch == '=' || ch == '/' || ch == '>')
if (mxml_isspace(ch) || ch == '=' || ch == '/' || ch == '>')
break;
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment