1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-04 08:02:34 +03:00

trio upgrade and integration

This commit is contained in:
Bjorn Reese
2001-04-21 16:57:29 +00:00
parent 34b1b3a81e
commit 70a9da54eb
36 changed files with 2125 additions and 854 deletions

View File

@ -1,3 +1,18 @@
Sat Apr 21 18:27:51 CEST 2001 Bjorn Reese <breese@users.sourceforge.net>
* libxml.h: new header used only for the compilation of libxml
* HTMLparser.c HTMLtree.c SAX.c debugXML.c encoding.c entities.c
error.c hash.c list.c nanoftp.c nanohttp.c parser.c
parserInternals.c testHTML.c testSAX.c testURI.c testXPath.c
tree.c uri.c valid.c xinclude.c xlink.c xmlIO.c xmllint.c
xmlmemory.c xpath.c xpointer.c: libxml.h integration
* trio.[ch] triop.h strio.[ch]: upgraded to the latest trio
baseline (version 1.2 plus a single patch).
* xpath.c result/XPath/expr/floats test/XPath/expr/floats: parses
scientific notation for numbers. Tests added.
* xpath.c: formatting of numbers changed to use sprintf
(contribution from William Brack)
Sat Apr 21 16:12:59 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Sat Apr 21 16:12:59 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* valid.c: cleanup, more useful debugging * valid.c: cleanup, more useful debugging

View File

@ -6,15 +6,9 @@
* Daniel.Veillard@w3.org * Daniel.Veillard@w3.org
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <libxml/xmlversion.h>
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED
#include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_CTYPE_H #ifdef HAVE_CTYPE_H
#include <ctype.h> #include <ctype.h>

View File

@ -7,16 +7,9 @@
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <libxml/xmlversion.h>
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED
#include <stdio.h>
#include <string.h> /* for memset() only ! */ #include <string.h> /* for memset() only ! */
#ifdef HAVE_CTYPE_H #ifdef HAVE_CTYPE_H

7
SAX.c
View File

@ -7,12 +7,7 @@
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <libxml/xmlmemory.h> #include <libxml/xmlmemory.h>

View File

@ -7,16 +7,9 @@
* Daniel Veillard <Daniel.Veillard@w3.org> * Daniel Veillard <Daniel.Veillard@w3.org>
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <libxml/xmlversion.h>
#ifdef LIBXML_DEBUG_ENABLED #ifdef LIBXML_DEBUG_ENABLED
#include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>

View File

@ -20,13 +20,8 @@
* Daniel.Veillard@w3.org * Daniel.Veillard@w3.org
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_CTYPE_H #ifdef HAVE_CTYPE_H
@ -35,7 +30,6 @@
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>
#endif #endif
#include <libxml/xmlversion.h>
#ifdef LIBXML_ICONV_ENABLED #ifdef LIBXML_ICONV_ENABLED
#ifdef HAVE_ERRNO_H #ifdef HAVE_ERRNO_H
#include <errno.h> #include <errno.h>

View File

@ -6,13 +6,8 @@
* Daniel.Veillard@w3.org * Daniel.Veillard@w3.org
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>

View File

@ -6,13 +6,8 @@
* Daniel Veillard <Daniel.Veillard@w3.org> * Daniel Veillard <Daniel.Veillard@w3.org>
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <libxml/parser.h> #include <libxml/parser.h>
#include <libxml/xmlerror.h> #include <libxml/xmlerror.h>

8
hash.c
View File

@ -14,14 +14,10 @@
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
* *
* Author: bjorn.reese@systematic.dk * Author: breese@users.sourceforge.net
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <string.h> #include <string.h>
#include <libxml/hash.h> #include <libxml/hash.h>

27
libxml.h Normal file
View File

@ -0,0 +1,27 @@
/*
* libxml.h: internal header only used during the compilation of libxml
*
* See COPYRIGHT for the status of this software
*
* Author: breese@users.sourceforge.net
*/
#ifndef __XML_LIBXML_H__
#define __XML_LIBXML_H__
#ifdef WIN32
#include "win32config.h"
#else
#include "config.h"
#endif
#include <libxml/xmlversion.h>
#ifdef WITHOUT_TRIO
#include <stdio.h>
#else
#define TRIO_REPLACE_STDIO
#include "trio.h"
#endif
#endif /* ! __XML_LIBXML_H__ */

6
list.c
View File

@ -15,11 +15,7 @@
* Author: Gary.Pennington@uk.sun.com * Author: Gary.Pennington@uk.sun.com
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@ -12,19 +12,19 @@
#define HAVE_NETINET_IN_H #define HAVE_NETINET_IN_H
#define HAVE_NETDB_H #define HAVE_NETDB_H
#define HAVE_SYS_TIME_H #define HAVE_SYS_TIME_H
#else /* STANDALONE */ #include <libxml/xmlversion.h>
#ifdef WIN32 #ifdef WITHOUT_TRIO
#define INCLUDE_WINSOCK #include <stdio.h>
#include "win32config.h"
#else #else
#include "config.h" #define TRIO_REPLACE_STDIO
#include "trio.h"
#endif #endif
#else /* STANDALONE */
#include "libxml.h"
#endif /* STANDALONE */ #endif /* STANDALONE */
#include <libxml/xmlversion.h>
#ifdef LIBXML_FTP_ENABLED #ifdef LIBXML_FTP_ENABLED
#include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H

View File

@ -14,17 +14,9 @@
/* TODO add compression support, Send the Accept- , and decompress on the /* TODO add compression support, Send the Accept- , and decompress on the
fly with ZLIB if found at compile-time */ fly with ZLIB if found at compile-time */
#ifdef WIN32 #include "libxml.h"
#define INCLUDE_WINSOCK
#include "win32config.h"
#else
#include "config.h"
#endif
#include <libxml/xmlversion.h>
#ifdef LIBXML_HTTP_ENABLED #ifdef LIBXML_HTTP_ENABLED
#include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H

View File

@ -33,15 +33,14 @@
* and xmlDoValidityCheckingDefaultValue for VMS * and xmlDoValidityCheckingDefaultValue for VMS
*/ */
#include "libxml.h"
#ifdef WIN32 #ifdef WIN32
#include "win32config.h"
#define XML_DIR_SEP '\\' #define XML_DIR_SEP '\\'
#else #else
#include "config.h"
#define XML_DIR_SEP '/' #define XML_DIR_SEP '/'
#endif #endif
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <libxml/xmlmemory.h> #include <libxml/xmlmemory.h>

View File

@ -7,15 +7,14 @@
* Daniel.Veillard@w3.org * Daniel.Veillard@w3.org
*/ */
#include "libxml.h"
#ifdef WIN32 #ifdef WIN32
#include "win32config.h"
#define XML_DIR_SEP '\\' #define XML_DIR_SEP '\\'
#else #else
#include "config.h"
#define XML_DIR_SEP '/' #define XML_DIR_SEP '/'
#endif #endif
#include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_CTYPE_H #ifdef HAVE_CTYPE_H
#include <ctype.h> #include <ctype.h>

View File

@ -15,6 +15,14 @@ Object is a number : 1.23
Expression: 0.123 Expression: 0.123
Object is a number : 0.123 Object is a number : 0.123
========================
Expression: 1.23e3
Object is a number : 1230
========================
Expression: 1.23e-3
Object is a number : 0.00123
======================== ========================
Expression: 1 div 0 Expression: 1 div 0
Object is a number : inf Object is a number : inf

16
strio.c
View File

@ -15,12 +15,9 @@
* *
************************************************************************/ ************************************************************************/
/* DV for libxml */ /*
#include <libxml/xmlversion.h> * TODO
#ifdef WITH_TRIO * - StrToLongDouble
/* FIXME
* StrToLongDouble
*/ */
static const char rcsid[] = "@(#)$Id$"; static const char rcsid[] = "@(#)$Id$";
@ -389,9 +386,9 @@ char *StrSubstringMax(const char *string, size_t max, const char *find)
assert(VALID(find)); assert(VALID(find));
size = StrLength(find); size = StrLength(find);
if (size >= max) if (size <= max)
{ {
for (count = 0; count > max - size; count++) for (count = 0; count <= max - size; count++)
{ {
if (StrEqualMax(find, size, &string[count])) if (StrEqualMax(find, size, &string[count]))
{ {
@ -563,6 +560,3 @@ int StrToUpper(char *target)
} }
return i; return i;
} }
/* DV for libxml */
#endif /* WITH_TRIO */

13
strio.h
View File

@ -15,13 +15,16 @@
* *
************************************************************************/ ************************************************************************/
#ifndef H_STRIO #ifndef TRIO_STRIO_H
#define H_STRIO #define TRIO_STRIO_H
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include "assert.h" #ifndef DEBUG
# define NDEBUG
#endif
#include <assert.h>
/* /*
* StrAppend(target, source) * StrAppend(target, source)
@ -122,7 +125,7 @@
enum { enum {
STRIO_HASH_NONE = 0, STRIO_HASH_NONE = 0,
STRIO_HASH_PLAIN, STRIO_HASH_PLAIN,
STRIO_HASH_TWOSIGNED STRIO_HASH_TWOSIGNED,
}; };
#if !defined(DEBUG) || defined(__DECC) #if !defined(DEBUG) || defined(__DECC)
@ -213,4 +216,4 @@ float StrToFloat(const char *source, const char **target);
double StrToDouble(const char *source, const char **target); double StrToDouble(const char *source, const char **target);
int StrToUpper(char *target); int StrToUpper(char *target);
#endif /* H_STRIO */ #endif /* TRIO_STRIO_H */

View File

@ -2,6 +2,8 @@
123 123
1.23 1.23
0.123 0.123
1.23e3
1.23e-3
1 div 0 1 div 0
-1 div 0 -1 div 0
0 div 0 0 div 0

View File

@ -6,17 +6,14 @@
* Daniel.Veillard@w3.org * Daniel.Veillard@w3.org
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#undef LIBXML_DLL_IMPORT
#else
#include "config.h"
#endif
#include <libxml/xmlversion.h>
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED
#include <stdio.h> #ifdef WIN32
#undef LIBXML_DLL_IMPORT
#endif
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>

View File

@ -6,14 +6,12 @@
* Daniel.Veillard@w3.org * Daniel.Veillard@w3.org
*/ */
#include "libxml.h"
#ifdef WIN32 #ifdef WIN32
#include "win32config.h"
#undef LIBXML_DLL_IMPORT #undef LIBXML_DLL_IMPORT
#else
#include "config.h"
#endif #endif
#include <stdio.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>

View File

@ -6,18 +6,12 @@
* Daniel.Veillard@w3.org * Daniel.Veillard@w3.org
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <stdio.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <libxml/xmlversion.h>
#include <libxml/xmlmemory.h> #include <libxml/xmlmemory.h>
#include <libxml/uri.h> #include <libxml/uri.h>

View File

@ -6,16 +6,9 @@
* Daniel.Veillard@w3.org * Daniel.Veillard@w3.org
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <libxml/xmlversion.h>
#if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_DEBUG_ENABLED) #if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_DEBUG_ENABLED)
#include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H

7
tree.c
View File

@ -11,13 +11,8 @@
* *
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <stdio.h>
#include <string.h> /* for memset() only ! */ #include <string.h> /* for memset() only ! */
#ifdef HAVE_CTYPE_H #ifdef HAVE_CTYPE_H

2230
trio.c

File diff suppressed because it is too large Load Diff

104
trio.h
View File

@ -15,13 +15,23 @@
* *
************************************************************************/ ************************************************************************/
#ifndef H_TRIO #ifndef TRIO_TRIO_H
#define H_TRIO #define TRIO_TRIO_H
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
/*
* Use autoconf defines if present. Packages using trio must define
* HAVE_CONFIG_H as a compiler option themselves.
*/
#if defined(HAVE_CONFIG_H)
# include <config.h>
#endif
#if !defined(WITHOUT_TRIO)
/* /*
* Error codes. * Error codes.
* *
@ -34,7 +44,7 @@ enum {
TRIO_EDBLREF = 4, TRIO_EDBLREF = 4,
TRIO_EGAP = 5, TRIO_EGAP = 5,
TRIO_ENOMEM = 6, TRIO_ENOMEM = 6,
TRIO_ERANGE = 7 TRIO_ERANGE = 7,
}; };
/* Error macros */ /* Error macros */
@ -42,61 +52,117 @@ enum {
#define TRIO_ERROR_POSITION(x) ((-(x)) >> 8) #define TRIO_ERROR_POSITION(x) ((-(x)) >> 8)
#define TRIO_ERROR_NAME(x) trio_strerror(x) #define TRIO_ERROR_NAME(x) trio_strerror(x)
/* const char *trio_strerror(int);
* trio_sprintf(target, format, ...)
/*************************************************************************
* Print Functions
*/
int trio_printf(const char *format, ...);
int trio_vprintf(const char *format, va_list args);
int trio_printfv(const char *format, void **args);
int trio_fprintf(FILE *file, const char *format, ...);
int trio_vfprintf(FILE *file, const char *format, va_list args);
int trio_fprintfv(FILE *file, const char *format, void **args);
int trio_dprintf(int fd, const char *format, ...);
int trio_vdprintf(int fd, const char *format, va_list args);
int trio_dprintfv(int fd, const char *format, void **args);
/* trio_sprintf(target, format, ...)
* trio_snprintf(target, maxsize, format, ...) * trio_snprintf(target, maxsize, format, ...)
* *
* Build 'target' according to 'format' and succesive * Build 'target' according to 'format' and succesive
* arguments. This is equal to the sprintf() and * arguments. This is equal to the sprintf() and
* snprintf() functions. * snprintf() functions.
*/ */
int trio_printf(const char *format, ...);
int trio_vprintf(const char *format, va_list args);
int trio_fprintf(FILE *file, const char *format, ...);
int trio_vfprintf(FILE *file, const char *format, va_list args);
int trio_dprintf(int fd, const char *format, ...);
int trio_vdprintf(int fd, const char *format, va_list args);
int trio_sprintf(char *buffer, const char *format, ...); int trio_sprintf(char *buffer, const char *format, ...);
int trio_snprintf(char *buffer, size_t max, const char *format, ...);
int trio_snprintfcat(char *buffer, size_t max, const char *format, ...);
int trio_vsprintf(char *buffer, const char *format, va_list args); int trio_vsprintf(char *buffer, const char *format, va_list args);
int trio_sprintfv(char *buffer, const char *format, void **args);
int trio_snprintf(char *buffer, size_t max, const char *format, ...);
int trio_vsnprintf(char *buffer, size_t bufferSize, const char *format, int trio_vsnprintf(char *buffer, size_t bufferSize, const char *format,
va_list args); va_list args);
int trio_snprintfv(char *buffer, size_t bufferSize, const char *format,
void **args);
int trio_snprintfcat(char *buffer, size_t max, const char *format, ...);
int trio_vsnprintfcat(char *buffer, size_t bufferSize, const char *format, int trio_vsnprintfcat(char *buffer, size_t bufferSize, const char *format,
va_list args); va_list args);
char *trio_aprintf(const char *format, ...); char *trio_aprintf(const char *format, ...);
char *trio_vaprintf(const char *format, va_list args); char *trio_vaprintf(const char *format, va_list args);
int trio_asprintf(char **ret, const char *format, ...); int trio_asprintf(char **ret, const char *format, ...);
int trio_vasprintf(char **ret, const char *format, va_list args); int trio_vasprintf(char **ret, const char *format, va_list args);
/*************************************************************************
* Scan Functions
*/
int trio_scanf(const char *format, ...); int trio_scanf(const char *format, ...);
int trio_vscanf(const char *format, va_list args); int trio_vscanf(const char *format, va_list args);
int trio_scanfv(const char *format, void **args);
int trio_fscanf(FILE *file, const char *format, ...); int trio_fscanf(FILE *file, const char *format, ...);
int trio_vfscanf(FILE *file, const char *format, va_list args); int trio_vfscanf(FILE *file, const char *format, va_list args);
int trio_fscanfv(FILE *file, const char *format, void **args);
int trio_dscanf(int fd, const char *format, ...); int trio_dscanf(int fd, const char *format, ...);
int trio_vdscanf(int fd, const char *format, va_list args); int trio_vdscanf(int fd, const char *format, va_list args);
int trio_dscanfv(int fd, const char *format, void **args);
int trio_sscanf(const char *buffer, const char *format, ...); int trio_sscanf(const char *buffer, const char *format, ...);
int trio_vsscanf(const char *buffer, const char *format, va_list args); int trio_vsscanf(const char *buffer, const char *format, va_list args);
int trio_sscanfv(const char *buffer, const char *format, void **args);
const char *trio_strerror(int); /*************************************************************************
* Renaming
*/
#ifdef TRIO_REPLACE_STDIO #ifdef TRIO_REPLACE_STDIO
/* Replace the <stdio.h> functions */ /* Replace the <stdio.h> functions */
#ifndef HAVE_PRINTF
# define printf trio_printf # define printf trio_printf
#endif
#ifndef HAVE_VPRINTF
# define vprintf trio_vprintf # define vprintf trio_vprintf
#endif
#ifndef HAVE_FPRINTF
# define fprintf trio_fprintf # define fprintf trio_fprintf
#endif
#ifndef HAVE_VFPRINTF
# define vfprintf trio_vfprintf # define vfprintf trio_vfprintf
#endif
#ifndef HAVE_SPRINTF
# define sprintf trio_sprintf # define sprintf trio_sprintf
#endif
#ifndef HAVE_VSPRINTF
# define vsprintf trio_vsprintf # define vsprintf trio_vsprintf
#endif
#ifndef HAVE_SNPRINTF
# define snprintf trio_snprintf # define snprintf trio_snprintf
#endif
#ifndef HAVE_VSNPRINTF
# define vsnprintf trio_vsnprintf # define vsnprintf trio_vsnprintf
#endif
#ifndef HAVE_SCANF
# define scanf trio_scanf # define scanf trio_scanf
#endif
#ifndef HAVE_VSCANF
# define vscanf trio_vscanf # define vscanf trio_vscanf
#endif
#ifndef HAVE_FSCANF
# define fscanf trio_fscanf # define fscanf trio_fscanf
#endif
#ifndef HAVE_VFSCANF
# define vfscanf trio_vfscanf # define vfscanf trio_vfscanf
#endif
#ifndef HAVE_SSCANF
# define sscanf trio_sscanf # define sscanf trio_sscanf
#endif
#ifndef HAVE_VSSCANF
# define vsscanf trio_vsscanf # define vsscanf trio_vsscanf
#endif
/* These aren't stdio functions, but we make them look similar */ /* These aren't stdio functions, but we make them look similar */
#define dprintf trio_dprintf #define dprintf trio_dprintf
#define vdprintf trio_vdprintf #define vdprintf trio_vdprintf
@ -109,10 +175,12 @@ const char *trio_strerror(int);
#endif #endif
/* strio compatible names */ /* strio compatible names */
#define StrScan sscanf /* FIXME: must be trio_sscanf */ #define StrScan trio_sscanf
#define StrFormat trio_sprintf #define StrFormat trio_sprintf
#define StrFormatMax trio_snprintf #define StrFormatMax trio_snprintf
#define StrFormatAlloc trio_aprintf #define StrFormatAlloc trio_aprintf
#define StrFormatAppendMax trio_snprintfcat #define StrFormatAppendMax trio_snprintfcat
#endif /* H_TRIO */ #endif /* TRIO_IGNORE */
#endif /* TRIO_TRIO_H */

101
triop.h Normal file
View File

@ -0,0 +1,101 @@
/*************************************************************************
*
* $Id$
*
* Copyright (C) 2000 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.
*
************************************************************************
*
* Private functions, types, etc. used for callback functions.
*
* The ref pointer is an opaque type and should remain as such.
* Private data must only be accessible through the getter and
* setter functions.
*
************************************************************************/
#ifndef TRIO_TRIOP_H
#define TRIO_TRIOP_H
#if defined(__STDC__) && (__STDC_VERSION__ >= 199901L)
# define TRIO_C99
#endif
#define TRIO_BSD
#define TRIO_GNU
#define TRIO_MISC
#define TRIO_UNIX98
#define TRIO_EXTENSION
#define TRIO_ERRORS
typedef int (*trio_callback_t)(void *ref);
void *trio_register(trio_callback_t callback, const char *name);
void trio_unregister(void *handle);
const char *trio_get_format(void *ref);
void *trio_get_argument(void *ref);
/* Modifiers */
int trio_get_width(void *ref);
void trio_set_width(void *ref, int width);
int trio_get_precision(void *ref);
void trio_set_precision(void *ref, int precision);
int trio_get_base(void *ref);
void trio_set_base(void *ref, int base);
int trio_get_padding(void *ref);
void trio_set_padding(void *ref, int is_padding);
int trio_get_short(void *ref); /* h */
void trio_set_shortshort(void *ref, int is_shortshort);
int trio_get_shortshort(void *ref); /* hh */
void trio_set_short(void *ref, int is_short);
int trio_get_long(void *ref); /* l */
void trio_set_long(void *ref, int is_long);
int trio_get_longlong(void *ref); /* ll */
void trio_set_longlong(void *ref, int is_longlong);
int trio_get_longdouble(void *ref); /* L */
void trio_set_longdouble(void *ref, int is_longdouble);
int trio_get_alternative(void *ref); /* # */
void trio_set_alternative(void *ref, int is_alternative);
int trio_get_alignment(void *ref); /* - */
void trio_set_alignment(void *ref, int is_leftaligned);
int trio_get_spacing(void *ref); /* (space) */
void trio_set_spacing(void *ref, int is_space);
int trio_get_sign(void *ref); /* + */
void trio_set_sign(void *ref, int is_showsign);
int trio_get_quote(void *ref); /* ' */
void trio_set_quote(void *ref, int is_quote);
int trio_get_upper(void *ref);
void trio_set_upper(void *ref, int is_upper);
#if defined(TRIO_C99)
int trio_get_largest(void *ref); /* j */
void trio_set_largest(void *ref, int is_largest);
int trio_get_ptrdiff(void *ref); /* t */
void trio_set_ptrdiff(void *ref, int is_ptrdiff);
int trio_get_size(void *ref); /* z / Z */
void trio_set_size(void *ref, int is_size);
#endif
/* Printing */
int trio_print_ref(void *ref, const char *format, ...);
int trio_vprint_ref(void *ref, const char *format, va_list args);
int trio_printv_ref(void *ref, const char *format, void **args);
void trio_print_int(void *ref, int number);
void trio_print_uint(void *ref, unsigned int number);
/* void trio_print_long(void *ref, long number); */
/* void trio_print_ulong(void *ref, unsigned long number); */
void trio_print_double(void *ref, double number);
void trio_print_string(void *ref, char *string);
void trio_print_pointer(void *ref, void *pointer);
#endif /* TRIO_TRIOP_H */

6
uri.c
View File

@ -8,14 +8,12 @@
* Daniel.Veillard@w3.org * Daniel.Veillard@w3.org
*/ */
#include "libxml.h"
#ifdef WIN32 #ifdef WIN32
#define INCLUDE_WINSOCK #define INCLUDE_WINSOCK
#include "win32config.h"
#else
#include "config.h"
#endif #endif
#include <stdio.h>
#include <string.h> #include <string.h>
#include <libxml/xmlmemory.h> #include <libxml/xmlmemory.h>

View File

@ -7,13 +7,8 @@
* Daniel.Veillard@w3.org * Daniel.Veillard@w3.org
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H

View File

@ -13,13 +13,8 @@
* TODO: compute XPointers nodesets * TODO: compute XPointers nodesets
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <stdio.h>
#include <string.h> #include <string.h>
#include <libxml/xmlmemory.h> #include <libxml/xmlmemory.h>
#include <libxml/tree.h> #include <libxml/tree.h>

View File

@ -8,13 +8,8 @@
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <stdio.h>
#include <string.h> /* for memset() only */ #include <string.h> /* for memset() only */
#ifdef HAVE_CTYPE_H #ifdef HAVE_CTYPE_H
#include <ctype.h> #include <ctype.h>

View File

@ -8,13 +8,8 @@
* 14 Nov 2000 ht - for VMS, truncated name of long functions to under 32 char * 14 Nov 2000 ht - for VMS, truncated name of long functions to under 32 char
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <stdio.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>

View File

@ -6,15 +6,9 @@
* Daniel.Veillard@w3.org * Daniel.Veillard@w3.org
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <stdio.h>
#include <string.h> #include <string.h>
#include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#ifdef _WIN32 #ifdef _WIN32
#ifdef _MSC_VER #ifdef _MSC_VER

View File

@ -4,13 +4,8 @@
* Daniel.Veillard@w3.org * Daniel.Veillard@w3.org
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H

185
xpath.c
View File

@ -16,16 +16,9 @@
* for VMS * for VMS
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
#include <libxml/xmlversion.h>
#ifdef LIBXML_XPATH_ENABLED #ifdef LIBXML_XPATH_ENABLED
#include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H
@ -935,112 +928,57 @@ xmlXPathFormatNumber(double number, char buffer[], int buffersize)
if (buffersize > (int)sizeof("NaN")) if (buffersize > (int)sizeof("NaN"))
sprintf(buffer, "NaN"); sprintf(buffer, "NaN");
} else { } else {
char work[INTEGER_DIGITS + FRACTION_DIGITS + EXPONENT_DIGITS + 1]; /* 3 is sign, decimal point, and terminating zero */
char *pointer; char work[DBL_DIG + EXPONENT_DIGITS + 3];
char *start; int integer_place, fraction_place;
int i; char *ptr;
int digits; char *after_fraction;
int is_negative; double absolute_value;
int use_scientific; int size;
int exponent;
int indx;
int count;
double n;
i = digits = 0; absolute_value = fabs(number);
is_negative = (number < 0.0);
if (is_negative)
number = -number;
/* Scale number */ /*
n = log10(number); * First choose format - scientific or regular floating point.
exponent = (isinf(n) == -1) ? 0 : (int)n; * In either case, result is in work, and after_fraction points
use_scientific = (((number <= LOWER_DOUBLE) || * just past the fractional part.
(number > UPPER_DOUBLE)) && */
(number != 0)); if ( ((absolute_value > UPPER_DOUBLE) ||
if (use_scientific) { (absolute_value < LOWER_DOUBLE)) &&
number /= pow(10.0, (double)exponent); (absolute_value != 0.0) ) {
while (number < 1.0) { /* Use scientific notation */
number *= 10.0; integer_place = DBL_DIG + EXPONENT_DIGITS + 1;
exponent--; fraction_place = DBL_DIG - 1;
snprintf(work, sizeof(work),"%*.*e",
integer_place, fraction_place, number);
after_fraction = strchr(work + DBL_DIG, 'e');
} }
else {
/* Use regular notation */
integer_place = 1 + (int)log10(absolute_value);
fraction_place = (integer_place > 0)
? DBL_DIG - integer_place
: DBL_DIG;
size = snprintf(work, sizeof(work), "%0.*f",
fraction_place, number);
after_fraction = work + size;
} }
/* Integer part is build from back */ /* Remove fractional trailing zeroes */
pointer = &work[INTEGER_DIGITS + 1]; ptr = after_fraction;
if (number < 1.0) { while (*(--ptr) == '0')
*(--pointer) = '0'; ;
digits++; if (*ptr != '.')
} else { ptr++;
n = number; strcpy(ptr, after_fraction);
for (i = 1; i < INTEGER_DIGITS - 1; i++) {
indx = (int)n % 10;
*(--pointer) = "0123456789"[indx];
n /= 10.0;
if (n < 1.0)
break;
}
digits += i;
}
if (is_negative) {
*(--pointer) = '-';
digits++;
}
start = pointer;
/* Fraction part is build from front */ /* Finally copy result back to caller */
i = 0; size = strlen(work) + 1;
pointer = &work[INTEGER_DIGITS + 1]; if (size > buffersize) {
if (number - floor(number) > DBL_EPSILON) { work[buffersize - 1] = 0;
*(pointer++) = '.'; size = buffersize;
i++;
n = number;
count = 0;
while (i < FRACTION_DIGITS) {
n -= floor(n);
n *= 10.0;
indx = (int)n % 10;
*(pointer++) = "0123456789"[indx];
i++;
if ((indx != 0) || (count > 0))
count++;
if ((n > 10.0) || (count > FRACTION_DIGITS / 2))
break;
} }
} memcpy(buffer, work, size);
/* Remove trailing zeroes */
while ((pointer[-1] == '0') && (i > 0)) {
pointer--;
i--;
}
digits += i;
if (use_scientific) {
*(pointer++) = 'e';
digits++;
if (exponent < 0) {
*(pointer++) = '-';
exponent = -exponent;
} else {
*(pointer++) = '+';
}
digits++;
if (exponent >= 100)
pointer += 2;
else if (exponent >= 10)
pointer += 1;
while (exponent >= 1) {
*(pointer--) = "0123456789"[exponent % 10];
exponent /= 10;
digits++;
}
}
if (digits >= buffersize)
digits = buffersize - 1;
memcpy(buffer, start, digits);
buffer[digits] = 0;
} }
break; break;
} }
@ -5200,6 +5138,8 @@ xmlXPathParseName(xmlXPathParserContextPtr ctxt) {
* xmlXPathStringEvalNumber: * xmlXPathStringEvalNumber:
* @str: A string to scan * @str: A string to scan
* *
* [30a] Float ::= Number ('e' Digits?)?
*
* [30] Number ::= Digits ('.' Digits?)? * [30] Number ::= Digits ('.' Digits?)?
* | '.' Digits * | '.' Digits
* [31] Digits ::= [0-9]+ * [31] Digits ::= [0-9]+
@ -5217,6 +5157,8 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
double mult = 1; double mult = 1;
int ok = 0; int ok = 0;
int isneg = 0; int isneg = 0;
int exponent = 0;
int is_exponent_negative = 0;
while (IS_BLANK(*cur)) cur++; while (IS_BLANK(*cur)) cur++;
if ((*cur != '.') && ((*cur < '0') || (*cur > '9')) && (*cur != '-')) { if ((*cur != '.') && ((*cur < '0') || (*cur > '9')) && (*cur != '-')) {
@ -5242,9 +5184,22 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
cur++; cur++;
} }
} }
if ((*cur == 'e') || (*cur == 'E')) {
cur++;
if (*cur == '-') {
is_exponent_negative = 1;
cur++;
}
while ((*cur >= '0') && (*cur <= '9')) {
exponent = exponent * 10 + (*cur - '0');
cur++;
}
}
while (IS_BLANK(*cur)) cur++; while (IS_BLANK(*cur)) cur++;
if (*cur != 0) return(xmlXPathNAN); if (*cur != 0) return(xmlXPathNAN);
if (isneg) ret = -ret; if (isneg) ret = -ret;
if (is_exponent_negative) exponent = -exponent;
ret *= pow(10.0, (double)exponent);
return(ret); return(ret);
} }
@ -5264,6 +5219,8 @@ xmlXPathCompNumber(xmlXPathParserContextPtr ctxt) {
double ret = 0.0; double ret = 0.0;
double mult = 1; double mult = 1;
int ok = 0; int ok = 0;
int exponent = 0;
int is_exponent_negative = 0;
CHECK_ERROR; CHECK_ERROR;
if ((CUR != '.') && ((CUR < '0') || (CUR > '9'))) { if ((CUR != '.') && ((CUR < '0') || (CUR > '9'))) {
@ -5285,6 +5242,20 @@ xmlXPathCompNumber(xmlXPathParserContextPtr ctxt) {
NEXT; NEXT;
} }
} }
if ((CUR == 'e') || (CUR == 'E')) {
NEXT;
if (CUR == '-') {
is_exponent_negative = 1;
NEXT;
}
while ((CUR >= '0') && (CUR <= '9')) {
exponent = exponent * 10 + (CUR - '0');
NEXT;
}
}
if (is_exponent_negative)
exponent = -exponent;
ret *= pow(10.0, (double)exponent);
PUSH_LONG_EXPR(XPATH_OP_VALUE, XPATH_NUMBER, 0, 0, PUSH_LONG_EXPR(XPATH_OP_VALUE, XPATH_NUMBER, 0, 0,
xmlXPathNewFloat(ret), NULL); xmlXPathNewFloat(ret), NULL);
} }

View File

@ -9,11 +9,7 @@
* Daniel.Veillard@w3.org * Daniel.Veillard@w3.org
*/ */
#ifdef WIN32 #include "libxml.h"
#include "win32config.h"
#else
#include "config.h"
#endif
/** /**
* TODO: better handling of error cases, the full expression should * TODO: better handling of error cases, the full expression should
@ -23,7 +19,6 @@
* parent is the endity declaration, not the ref. * parent is the endity declaration, not the ref.
*/ */
#include <stdio.h>
#include <string.h> #include <string.h>
#include <libxml/xpointer.h> #include <libxml/xpointer.h>
#include <libxml/xmlmemory.h> #include <libxml/xmlmemory.h>