Commit 71b656e0 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

- added xmlRemoveID() and xmlRemoveRef()

- added check and handling when possibly removing an ID
- fixed some entities problems
- added xmlParseTryOrFinish()
- changed the way struct aredeclared to allow gtk-doc to expose those
- closed #4960
- fixes to libs detection from Albert Chin-A-Young
- preparing 1.8.3 release
Daniel
parent 437b87b8
Wed Jan 5 17:08:43 CET 2000 Daniel Veillard <Daniel.Veillard@w3.org>
* acconfig.h: readline and history patch
* valid.[ch]: added xmlRemoveID() and xmlRemoveRef()
* tree.c: added check and handling when possibly removing an ID
* tree.c, HTMLparser.h, HTMLtree.h: fixed entities parsing
and saving.
* test/HTML/entities.html result/HTML/entities.html* : test for
various entities reference cases
* result/HTML/* : as a result output of some testcase have
changed
* HTMLparser.c, parser.c: fixed a bug in the push mode triggered
by previous example. added xmlParseTryOrFinish().
* xpath.h tree.h parser.h valid.h xmlIO.h xlink.h encoding.h
entities.h debugXML.h HTMLparser.h: changed the way struct are
declared to allow gtk-doc to expose those
* parser.c: closed bug #4960
* Makefile.am configure.in: Applied patch from
Albert Chin-A-Young <china@thewrittenword.com> for better zlib
and math/socket libs detection
Mon Jan 3 18:29:43 CET 2000 Daniel Veillard <Daniel.Veillard@w3.org>
* configure.in, Makefile.am: link tester against readline
......
......@@ -1391,6 +1391,7 @@ htmlParseName(htmlParserCtxtPtr ctxt) {
xmlChar *
htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
#if 0
xmlChar buf[HTML_MAX_NAMELEN];
int len = 0;
......@@ -1410,6 +1411,84 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
}
}
return(xmlStrndup(buf, len));
#else
xmlChar *buffer = NULL;
int buffer_size = 0;
xmlChar *out = NULL;
xmlChar *name = NULL;
xmlChar *cur = NULL;
htmlEntityDescPtr ent;
/*
* allocate a translation buffer.
*/
buffer_size = HTML_PARSER_BIG_BUFFER_SIZE;
buffer = (xmlChar *) xmlMalloc(buffer_size * sizeof(xmlChar));
if (buffer == NULL) {
perror("htmlParseHTMLAttribute: malloc failed");
return(NULL);
}
out = buffer;
/*
* Ok loop until we reach one of the ending chars
*/
while ((CUR != 0) && (CUR != stop) && (CUR != '>')) {
if ((stop == 0) && (IS_BLANK(CUR))) break;
if (CUR == '&') {
if (NXT(1) == '#') {
int val = htmlParseCharRef(ctxt);
*out++ = val;
} else {
ent = htmlParseEntityRef(ctxt, &name);
if (name == NULL) {
*out++ = '&';
if (out - buffer > buffer_size - 100) {
int index = out - buffer;
growBuffer(buffer);
out = &buffer[index];
}
} else if ((ent == NULL) || (ent->value <= 0) ||
(ent->value >= 255)) {
*out++ = '&';
cur = name;
while (*cur != 0) {
if (out - buffer > buffer_size - 100) {
int index = out - buffer;
growBuffer(buffer);
out = &buffer[index];
}
*out++ = *cur++;
}
xmlFree(name);
} else {
*out++ = ent->value;
if (out - buffer > buffer_size - 100) {
int index = out - buffer;
growBuffer(buffer);
out = &buffer[index];
}
xmlFree(name);
}
}
} else {
*out++ = CUR;
if (out - buffer > buffer_size - 100) {
int index = out - buffer;
growBuffer(buffer);
out = &buffer[index];
}
NEXT;
}
}
*out++ = 0;
return(buffer);
#endif
}
/**
......@@ -1477,23 +1556,19 @@ htmlParseEntityRef(htmlParserCtxtPtr ctxt, xmlChar **str) {
} else {
GROW;
if (CUR == ';') {
NEXT;
*str = name;
/*
* Lookup the entity in the table.
*/
ent = htmlEntityLookup(name);
if (ent != NULL) /* OK that's ugly !!! */
NEXT;
} else {
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
ctxt->sax->error(ctxt->userData,
"htmlParseEntityRef: expecting ';'\n");
ctxt->wellFormed = 0;
if (ctxt->sax->characters != NULL) {
ctxt->sax->characters(ctxt->userData, BAD_CAST "&", 1);
ctxt->sax->characters(ctxt->userData, name, xmlStrlen(name));
}
xmlFree(name);
*str = name;
}
}
}
......@@ -2321,12 +2396,15 @@ htmlParseReference(htmlParserCtxtPtr ctxt) {
ctxt->sax->characters(ctxt->userData, out, 1);
} else {
ent = htmlParseEntityRef(ctxt, &name);
if (name == NULL) return; /* Shall we output & anyway ? */
if (name == NULL) {
ctxt->sax->characters(ctxt->userData, BAD_CAST "&", 1);
return;
}
if ((ent == NULL) || (ent->value <= 0) || (ent->value >= 255)) {
if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL)) {
ctxt->sax->characters(ctxt->userData, BAD_CAST "&", 1);
ctxt->sax->characters(ctxt->userData, name, xmlStrlen(name));
ctxt->sax->characters(ctxt->userData, BAD_CAST ";", 1);
/* ctxt->sax->characters(ctxt->userData, BAD_CAST ";", 1); */
}
} else {
/* invalid for UTF-8 variable encoding !!!!! */
......@@ -2903,15 +2981,16 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
}
/**
* htmlParseTry:
* htmlParseTryOrFinish:
* @ctxt: an HTML parser context
* @terminate: last chunk indicator
*
* Try to progress on parsing
*
* Returns zero if no parsing was possible
*/
int
htmlParseTry(htmlParserCtxtPtr ctxt) {
htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
int ret = 0;
htmlParserInputPtr in;
int avail;
......@@ -2990,7 +3069,8 @@ htmlParseTry(htmlParserCtxtPtr ctxt) {
(UPP(4) == 'C') && (UPP(5) == 'T') &&
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
(UPP(8) == 'E')) {
if (htmlParseLookupSequence(ctxt, '>', 0, 0) < 0)
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, '>', 0, 0) < 0))
goto done;
#ifdef DEBUG_PUSH
fprintf(stderr, "HPP: Parsing internal subset\n");
......@@ -3020,7 +3100,8 @@ htmlParseTry(htmlParserCtxtPtr ctxt) {
next = in->cur[1];
if ((cur == '<') && (next == '!') &&
(in->cur[2] == '-') && (in->cur[3] == '-')) {
if (htmlParseLookupSequence(ctxt, '-', '-', '>') < 0)
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
goto done;
#ifdef DEBUG_PUSH
fprintf(stderr, "HPP: Parsing Comment\n");
......@@ -3032,7 +3113,8 @@ htmlParseTry(htmlParserCtxtPtr ctxt) {
(UPP(4) == 'C') && (UPP(5) == 'T') &&
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
(UPP(8) == 'E')) {
if (htmlParseLookupSequence(ctxt, '>', 0, 0) < 0)
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, '>', 0, 0) < 0))
goto done;
#ifdef DEBUG_PUSH
fprintf(stderr, "HPP: Parsing internal subset\n");
......@@ -3064,7 +3146,8 @@ htmlParseTry(htmlParserCtxtPtr ctxt) {
next = in->cur[1];
if ((cur == '<') && (next == '!') &&
(in->cur[2] == '-') && (in->cur[3] == '-')) {
if (htmlParseLookupSequence(ctxt, '-', '-', '>') < 0)
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
goto done;
#ifdef DEBUG_PUSH
fprintf(stderr, "HPP: Parsing Comment\n");
......@@ -3093,7 +3176,8 @@ htmlParseTry(htmlParserCtxtPtr ctxt) {
next = in->cur[1];
if ((cur == '<') && (next == '!') &&
(in->cur[2] == '-') && (in->cur[3] == '-')) {
if (htmlParseLookupSequence(ctxt, '-', '-', '>') < 0)
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
goto done;
#ifdef DEBUG_PUSH
fprintf(stderr, "HPP: Parsing Comment\n");
......@@ -3133,7 +3217,8 @@ htmlParseTry(htmlParserCtxtPtr ctxt) {
#endif
break;
}
if (htmlParseLookupSequence(ctxt, '>', 0, 0) < 0)
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, '>', 0, 0) < 0))
goto done;
oldname = xmlStrdup(ctxt->name);
......@@ -3268,7 +3353,8 @@ htmlParseTry(htmlParserCtxtPtr ctxt) {
next = in->cur[1];
if ((cur == '<') && (next == '!') &&
(in->cur[2] == '-') && (in->cur[3] == '-')) {
if (htmlParseLookupSequence(ctxt, '-', '-', '>') < 0)
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
goto done;
#ifdef DEBUG_PUSH
fprintf(stderr, "HPP: Parsing Comment\n");
......@@ -3292,7 +3378,8 @@ htmlParseTry(htmlParserCtxtPtr ctxt) {
#endif
break;
} else if (cur == '&') {
if (htmlParseLookupSequence(ctxt, ';', 0, 0) < 0)
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, ';', 0, 0) < 0))
goto done;
#ifdef DEBUG_PUSH
fprintf(stderr, "HPP: Parsing Reference\n");
......@@ -3308,7 +3395,8 @@ htmlParseTry(htmlParserCtxtPtr ctxt) {
*/
if ((ctxt->inputNr == 1) &&
(avail < HTML_PARSER_BIG_BUFFER_SIZE)) {
if (htmlParseLookupSequence(ctxt, '<', 0, 0) < 0)
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, '<', 0, 0) < 0))
goto done;
}
ctxt->checkIndex = 0;
......@@ -3321,7 +3409,8 @@ htmlParseTry(htmlParserCtxtPtr ctxt) {
case XML_PARSER_END_TAG:
if (avail < 2)
goto done;
if (htmlParseLookupSequence(ctxt, '>', 0, 0) < 0)
if ((!terminate) &&
(htmlParseLookupSequence(ctxt, '>', 0, 0) < 0))
goto done;
htmlParseEndTag(ctxt);
if (ctxt->nameNr == 0) {
......@@ -3399,6 +3488,19 @@ done:
return(ret);
}
/**
* htmlParseTry:
* @ctxt: an HTML parser context
*
* Try to progress on parsing
*
* Returns zero if no parsing was possible
*/
int
htmlParseTry(htmlParserCtxtPtr ctxt) {
return(htmlParseTryOrFinish(ctxt, 0));
}
/**
* htmlParseChunk:
* @ctxt: an XML parser context
......@@ -3425,9 +3527,9 @@ htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
fprintf(stderr, "HPP: pushed %d\n", size);
#endif
htmlParseTry(ctxt);
htmlParseTryOrFinish(ctxt, terminate);
} else if (ctxt->instate != XML_PARSER_EOF)
htmlParseTry(ctxt);
htmlParseTryOrFinish(ctxt, terminate);
if (terminate) {
if ((ctxt->instate != XML_PARSER_EOF) &&
(ctxt->instate != XML_PARSER_EPILOG) &&
......
......@@ -30,7 +30,9 @@ typedef xmlNodePtr htmlNodePtr;
/*
* Internal description of an HTML element
*/
typedef struct htmlElemDesc {
typedef struct _htmlElemDesc htmlElemDesc;
typedef htmlElemDesc *htmlElemDescPtr;
struct _htmlElemDesc {
const char *name; /* The tag name */
int startTag; /* Whether the start tag can be implied */
int endTag; /* Whether the end tag can be implied */
......@@ -38,16 +40,18 @@ typedef struct htmlElemDesc {
int depr; /* Is this a deprecated element ? */
int dtd; /* 1: only in Loose DTD, 2: only Frameset one */
const char *desc; /* the description */
} htmlElemDesc, *htmlElemDescPtr;
};
/*
* Internal description of an HTML entity
*/
typedef struct htmlEntityDesc {
typedef struct _htmlEntityDesc htmlEntityDesc;
typedef htmlEntityDesc *htmlEntityDescPtr;
struct _htmlEntityDesc {
int value; /* the UNICODE value for the character */
const char *name; /* The entity name */
const char *desc; /* the description */
} htmlEntityDesc, *htmlEntityDescPtr;
};
/*
* There is only few public functions.
......
......@@ -2,7 +2,7 @@
SUBDIRS = doc
INCLUDES = -I@srcdir@ @CORBA_CFLAGS@ $(VERSION_FLAGS)
INCLUDES = -I@srcdir@ @Z_CFLAGS@ @CORBA_CFLAGS@ $(VERSION_FLAGS)
VERSION_FLAGS = -DLIBXML_VERSION=\"@LIBXML_VERSION@\"
......
......@@ -4,3 +4,5 @@
#undef HAVE_LIBM
#undef HAVE_ISINF
#undef HAVE_ISNAN
#undef HAVE_LIBHISTORY
#undef HAVE_LIBREADLINE
......@@ -12,6 +12,8 @@
#undef HAVE_LIBM
#undef HAVE_ISINF
#undef HAVE_ISNAN
#undef HAVE_LIBHISTORY
#undef HAVE_LIBREADLINE
/* Define if you have the class function. */
#undef HAVE_CLASS
......@@ -25,12 +27,6 @@
/* Define if you have the fpclass function. */
#undef HAVE_FPCLASS
/* Define if you have the isinf function. */
#undef HAVE_ISINF
/* Define if you have the isnan function. */
#undef HAVE_ISNAN
/* Define if you have the isnand function. */
#undef HAVE_ISNAND
......@@ -127,21 +123,12 @@
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define if you have the <zlib.h> header file. */
#undef HAVE_ZLIB_H
/* Define if you have the history library (-lhistory). */
#undef HAVE_LIBHISTORY
/* Define if you have the inet library (-linet). */
#undef HAVE_LIBINET
/* Define if you have the nsl library (-lnsl). */
#undef HAVE_LIBNSL
/* Define if you have the readline library (-lreadline). */
#undef HAVE_LIBREADLINE
/* Define if you have the socket library (-lsocket). */
#undef HAVE_LIBSOCKET
......
......@@ -5,7 +5,7 @@ AM_CONFIG_HEADER(config.h)
LIBXML_MAJOR_VERSION=1
LIBXML_MINOR_VERSION=8
LIBXML_MICRO_VERSION=2
LIBXML_MICRO_VERSION=3
LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION
LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION
......@@ -33,18 +33,39 @@ AM_PROG_LIBTOOL
AM_MAINTAINER_MODE
dnl Checks for libraries.
Z_LIBS=
AC_CHECK_LIB(z, inflate,
AC_CHECK_HEADER(zlib.h,
Z_LIBS="-lz"; AC_DEFINE(HAVE_LIBZ)))
dnl Checks for zlib library.
_cppflags="${CPPFLAGS}"
_ldflags="${LDFLAGS}"
AC_ARG_WITH(zlib,
[ --with-zlib[=DIR] use libz in DIR],[
if test "$withval" != "no"; then
Z_DIR=$withval
CPPFLAGS="${CPPFLAGS} -I$withval/include"
LDFLAGS="${LDFLAGS} -L$withval/lib"
fi
])
AC_CHECK_HEADER(zlib.h,
AC_CHECK_LIB(z, gzread,[
AC_DEFINE(HAVE_LIBZ)
if test "x${Z_DIR}" != "x"; then
Z_CFLAGS="-I${Z_DIR}/include"
Z_LIBS="-L${Z_DIR}/lib -lz"
else
Z_LIBS="-lz"
fi]))
AC_SUBST(Z_CFLAGS)
AC_SUBST(Z_LIBS)
CPPFLAGS=${_cppflags}
LDFLAGS=${_ldflags}
dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h unistd.h ctype.h dirent.h errno.h malloc.h)
AC_CHECK_HEADERS(stdarg.h sys/stat.h sys/types.h time.h zlib.h)
AC_CHECK_HEADERS(stdarg.h sys/stat.h sys/types.h time.h)
AC_CHECK_HEADERS(ieeefp.h nan.h math.h fp_class.h float.h)
AC_CHECK_HEADERS(stdlib.h sys/socket.h netinet/in.h arpa/inet.h)
AC_CHECK_HEADERS(netdb.h sys/time.h sys/select.h)
......@@ -71,33 +92,20 @@ AC_SUBST(CORBA_CFLAGS)
dnl Checks for library functions.
AC_FUNC_STRFTIME
AC_CHECK_FUNCS(strdup strndup strerror snprintf)
AC_CHECK_FUNCS(finite isinf isnan isnand fp_class class fpclass finite)
AC_CHECK_FUNCS(finite isnand fp_class class fpclass)
AC_CHECK_FUNCS(strftime localtime)
dnl Checks for inet libraries:
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(inet, connect)
AC_CHECK_LIB(nsl, t_accept)
AC_CHECK_FUNC(gethostent, , AC_CHECK_LIB(nsl, gethostent))
AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
AC_CHECK_FUNC(connect, , AC_CHECK_LIB(inet, connect))
dnl Checks for isnan in libm if not in libc
M_LIBS=
if test "$ac_cv_func_isnan" != "yes"
then
AC_CHECK_LIB(m, isnan,
M_LIBS="-lm"; AC_DEFINE(HAVE_ISNAN))
fi
AC_CHECK_FUNC(isnan, , AC_CHECK_LIB(m, isnan,
[M_LIBS="-lm"; AC_DEFINE(HAVE_ISNAN)]))
dnl Checks for isinf in libm if not in libc
if test "$ac_cv_func_isinf" != "yes"
then
M2_LIBS=""
AC_CHECK_LIB(m, isinf,
M2_LIBS="-lm"; AC_DEFINE(HAVE_ISINF))
if test "$M2_LIBS" != ""
then
M_LIBS="$M2_LIBS"
fi
fi
AC_CHECK_FUNC(isinf, , AC_CHECK_LIB(m, isinf,
[M_LIBS="-lm"; AC_DEFINE(HAVE_ISINF)]))
XML_LIBDIR='-L${libdir}'
XML_INCLUDEDIR='-I${includedir}/gnome-xml'
......@@ -149,7 +157,6 @@ AC_SUBST(HTML_DIR)
AC_SUBST(HAVE_ISNAN)
AC_SUBST(HAVE_ISINF)
AC_SUBST(Z_LIBS)
AC_SUBST(M_LIBS)
AC_SUBST(RDL_LIBS)
AC_OUTPUT(libxml.spec Makefile doc/Makefile example/Makefile xml-config win32config.h)
......
......@@ -64,7 +64,9 @@ typedef char * (* xmlShellReadlineFunc)(char *prompt);
* The shell context itself
* TODO: add the defined function tables.
*/
typedef struct xmlShellCtxt {
typedef struct _xmlShellCtxt xmlShellCtxt;
typedef xmlShellCtxt *xmlShellCtxtPtr;
struct _xmlShellCtxt {
char *filename;
xmlDocPtr doc;
xmlNodePtr node;
......@@ -72,7 +74,7 @@ typedef struct xmlShellCtxt {
int loaded;
FILE *output;
xmlShellReadlineFunc input;
} xmlShellCtxt, *xmlShellCtxtPtr;
};
/**
* xmlShellCmd:
......
......@@ -4,13 +4,16 @@
>Gnome XML Library Reference Manual</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.33"><LINK
CONTENT="Modular DocBook HTML Stylesheet Version 1.44"><LINK
REL="NEXT"
TITLE="Libxml Programming Notes"
HREF="libxml-notes.html"></HEAD
><BODY
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="BOOK"
><DIV
......@@ -46,14 +49,14 @@ CLASS="AFFILIATION"
><DIV
CLASS="ADDRESS"
><P
CLASS="LITERALLAYOUT"
CLASS="ADDRESS"
> &nbsp;&nbsp;&nbsp;&nbsp;Daniel.Veillard@w3.org<br>
&nbsp;&nbsp;</P
></DIV
></DIV
><P
CLASS="COPYRIGHT"
>Copyright 1999 by <SPAN
>Copyright &copy; 1999 by <SPAN
CLASS="HOLDER"
>Daniel Veillard</SPAN
></P
......
......@@ -4,7 +4,7 @@
>entities</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.33"><LINK
CONTENT="Modular DocBook HTML Stylesheet Version 1.44"><LINK
REL="HOME"
TITLE="Gnome XML Library Reference Manual"
HREF="book1.html"><LINK
......@@ -20,6 +20,9 @@ HREF="gnome-xml-valid.html"></HEAD
><BODY
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
......@@ -111,19 +114,22 @@ SIZE="3"
></TABLE
></DIV
><H1
>entities</H1
><A
NAME="GNOME-XML-ENTITIES"
>entities</A
></H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN5768"
NAME="AEN5124"
></A
><H2
>Name</H2
>entities &#8212; </DIV
>entities&nbsp;--&nbsp;</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN5771"
NAME="AEN5127"
></A
><H2
>Synopsis</H2
......@@ -336,11 +342,7 @@ HREF="gnome-xml-tree.html#XMLBUFFERPTR"
<A
HREF="gnome-xml-entities.html#XMLENTITIESTABLEPTR"
>xmlEntitiesTablePtr</A
> table);
void <A
HREF="gnome-xml-entities.html#XMLCLEANUPPREDEFINEDENTITIES"
>xmlCleanupPredefinedEntities</A
> (void);</PRE
> table);</PRE
></TD
></TR
></TABLE
......@@ -348,7 +350,7 @@ HREF="gnome-xml-entities.html#XMLCLEANUPPREDEFINEDENTITIES"
><DIV
CLASS="REFSECT1"
><A
NAME="AEN5829"
NAME="AEN5184"
></A
><H2
>Description</H2
......@@ -358,14 +360,14 @@ NAME="AEN5829"
><DIV
CLASS="REFSECT1"
><A
NAME="AEN5832"
NAME="AEN5187"
></A
><H2
>Details</H2
><DIV
CLASS="REFSECT2"