Commit a48ed3d6 authored by Daniel Veillard's avatar Daniel Veillard

Bjorn sent an update for the TRIO portability layer. Daniel

* trio.c trio.h triodef.h trionan.c trionan.h triop.h triostr.c
  triostr.h: Bjorn sent an update for the TRIO portability layer.
Daniel
parent d6c8650b
Thu Apr 3 17:24:44 CEST 2003 Daniel Veillard <daniel@veillard.com>
* trio.c trio.h triodef.h trionan.c trionan.h triop.h triostr.c
triostr.h: Bjorn sent an update for the TRIO portability layer.
Tue Apr 1 21:57:26 CEST 2003 Igor Zlatkovic <igor@zlatkovic.com>
* win32/libxml2.def.src: exported new functions
......
This diff is collapsed.
......@@ -22,14 +22,6 @@
#ifndef TRIO_TRIO_H
#define TRIO_TRIO_H
#include <stdio.h>
#include <stdlib.h>
#if defined(TRIO_COMPILER_ANCIENT)
# include <varargs.h>
#else
# include <stdarg.h>
#endif
#if !defined(WITHOUT_TRIO)
/*
......@@ -42,6 +34,14 @@
#include "triodef.h"
#include <stdio.h>
#include <stdlib.h>
#if defined(TRIO_COMPILER_ANCIENT)
# include <varargs.h>
#else
# include <stdarg.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
......
......@@ -42,11 +42,17 @@
# define TRIO_COMPILER_BCB
#endif
#if defined(unix) || defined(__unix) || defined(__unix__)
#if defined(VMS) || defined(__VMS)
/*
* VMS is placed first to avoid identifying the platform as Unix
* based on the DECC compiler later on.
*/
# define TRIO_PLATFORM_VMS
#elif defined(unix) || defined(__unix) || defined(__unix__)
# define TRIO_PLATFORM_UNIX
#elif defined(TRIO_COMPILER_XLC) || defined(_AIX)
# define TRIO_PLATFORM_UNIX
#elif ( defined(TRIO_COMPILER_DECC) && !defined(__VMS) ) || defined(__osf__)
#elif defined(TRIO_COMPILER_DECC) || defined(__osf___)
# define TRIO_PLATFORM_UNIX
#elif defined(__NetBSD__)
# define TRIO_PLATFORM_UNIX
......@@ -59,13 +65,23 @@
# define TRIO_PLATFORM_UNIX
#elif defined(TRIO_COMPILER_MSVC) || defined(WIN32) || defined(_WIN32)
# define TRIO_PLATFORM_WIN32
#elif defined(VMS) || defined(__VMS)
# define TRIO_PLATFORM_VMS
#elif defined(mpeix) || defined(__mpexl)
# define TRIO_PLATFORM_MPEIX
#endif
#if defined(__STDC__) || defined(TRIO_COMPILER_MSVC)
#if defined(_AIX)
# define TRIO_PLATFORM_AIX
#elif defined(__hpux)
# define TRIO_PLATFORM_HPUX
#elif defined(sun) || defined(__sun__)
# if defined(__SVR4) || defined(__svr4__)
# define TRIO_PLATFORM_SOLARIS
# else
# define TRIO_PLATFORM_SUNOS
# endif
#endif
#if defined(__STDC__) || defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
# define TRIO_COMPILER_SUPPORTS_C89
# if defined(__STDC_VERSION__)
# define TRIO_COMPILER_SUPPORTS_C90
......@@ -82,18 +98,6 @@
# endif
#endif
#if defined(TRIO_PLATFORM_VMS)
/* The compiler does support C99 but the library still does not have things
* the standard requires (like nan() and strtof()) as of __CRTL_VER 70300022.
*/
# undef TRIO_COMPILER_SUPPORTS_C99
/* Computations done with constants at compile time can trigger these
* even when compiling with IEEE enabled.
*/
# pragma message disable (UNDERFLOW,FLOATOVERFL)
#endif /* TRIO_PLATFORM_VMS */
#if defined(_XOPEN_SOURCE)
# if defined(_XOPEN_SOURCE_EXTENDED)
# define TRIO_COMPILER_SUPPORTS_UNIX95
......@@ -141,7 +145,7 @@ typedef char * trio_pointer_t;
# define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4
# define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5
# define TRIO_VA_DECL va_dcl
# define TRIO_VA_START(x,y) va_start((x))
# define TRIO_VA_START(x,y) va_start(x)
# define TRIO_VA_END(x) va_end(x)
#else /* ANSI C */
# define TRIO_CONST const
......@@ -163,7 +167,7 @@ typedef void * trio_pointer_t;
# define TRIO_VARGS4 TRIO_ARGS4
# define TRIO_VARGS5 TRIO_ARGS5
# define TRIO_VA_DECL ...
# define TRIO_VA_START(x,y) va_start((x),(y))
# define TRIO_VA_START(x,y) va_start(x,y)
# define TRIO_VA_END(x) va_end(x)
#endif
......@@ -179,4 +183,38 @@ typedef void * trio_pointer_t;
# define TRIO_INLINE
#endif
/*************************************************************************
* Workarounds
*/
#if defined(TRIO_PLATFORM_VMS)
/*
* Computations done with constants at compile time can trigger these
* even when compiling with IEEE enabled.
*/
# pragma message disable (UNDERFLOW, FLOATOVERFL)
# if (__CRTL_VER > 80000000)
/*
* Although the compiler supports C99 language constructs, the C
* run-time library does not contain all C99 functions.
*
* This was the case for 70300022. Update the 80000000 value when
* it has been accurately determined what version of the library
* supports C99.
*/
# if defined(TRIO_COMPILER_SUPPORTS_C99)
# undef TRIO_COMPILER_SUPPORTS_C99
# endif
# endif
#endif
/*
* Not all preprocessors supports the LL token.
*/
#if defined(TRIO_COMPILER_BCB)
#else
# define TRIO_COMPILER_SUPPORTS_LL
#endif
#endif /* TRIO_TRIODEF_H */
......@@ -69,7 +69,9 @@
#define TRIO_TRUE (1 == 1)
#define TRIO_FALSE (0 == 1)
/* We must enable IEEE floating-point on Alpha */
/*
* We must enable IEEE floating-point on Alpha
*/
#if defined(__alpha) && !defined(_IEEE_FP)
# if defined(TRIO_COMPILER_DECC)
# if defined(TRIO_PLATFORM_VMS)
......@@ -372,11 +374,12 @@ TRIO_ARGS1((number),
*/
return isnan(number);
#elif defined(TRIO_COMPILER_MSVC)
#elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
/*
* MSVC has an _isnan() function
* Microsoft Visual C++ and Borland C++ Builder have an _isnan()
* function.
*/
return _isnan(number);
return _isnan(number) ? TRIO_TRUE : TRIO_FALSE;
#elif defined(USE_IEEE_754)
/*
......@@ -449,9 +452,10 @@ TRIO_ARGS1((number),
? ((number > 0.0) ? 1 : -1)
: 0;
#elif defined(TRIO_COMPILER_MSVC)
#elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
/*
* MSVC has an _fpclass() function that can be used to detect infinity.
* Microsoft Visual C++ and Borland C++ Builder have an _fpclass()
* function that can be used to detect infinity.
*/
return ((_fpclass(number) == _FPCLASS_PINF)
? 1
......@@ -514,9 +518,9 @@ TRIO_ARGS1((number),
*/
return isfinite(number);
#elif defined(TRIO_COMPILER_MSVC)
#elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
/*
* MSVC uses _finite().
* Microsoft Visual C++ and Borland C++ Builder use _finite().
*/
return _finite(number);
......@@ -538,6 +542,7 @@ TRIO_ARGS1((number),
#endif
}
/*
* The sign of NaN is always false
*/
......@@ -565,124 +570,106 @@ TRIO_ARGS2((number, is_negative),
return TRIO_FP_NORMAL;
}
#elif defined(TRIO_COMPILER_DECC)
#else
# if defined(TRIO_COMPILER_DECC)
/*
* DECC has an fp_class() function.
*/
switch (fp_class(number)) {
case FP_QNAN:
case FP_SNAN:
*is_negative = TRIO_FALSE; /* NaN has no sign */
return TRIO_FP_NAN;
case FP_POS_INF:
*is_negative = TRIO_FALSE;
return TRIO_FP_INFINITE;
case FP_NEG_INF:
*is_negative = TRIO_TRUE;
return TRIO_FP_INFINITE;
case FP_POS_DENORM:
*is_negative = TRIO_FALSE;
return TRIO_FP_SUBNORMAL;
case FP_NEG_DENORM:
*is_negative = TRIO_TRUE;
return TRIO_FP_SUBNORMAL;
case FP_POS_ZERO:
*is_negative = TRIO_FALSE;
return TRIO_FP_ZERO;
case FP_NEG_ZERO:
*is_negative = TRIO_TRUE;
return TRIO_FP_ZERO;
case FP_POS_NORM:
*is_negative = TRIO_FALSE;
return TRIO_FP_NORMAL;
case FP_NEG_NORM:
*is_negative = TRIO_TRUE;
return TRIO_FP_NORMAL;
default:
/* Just in case... */
*is_negative = (number < 0.0);
return TRIO_FP_NORMAL;
}
#elif defined(TRIO_COMPILER_MSVC)
# define TRIO_FPCLASSIFY(n) fp_class(n)
# define TRIO_QUIET_NAN FP_QNAN
# define TRIO_SIGNALLING_NAN FP_SNAN
# define TRIO_POSITIVE_INFINITY FP_POS_INF
# define TRIO_NEGATIVE_INFINITY FP_NEG_INF
# define TRIO_POSITIVE_SUBNORMAL FP_POS_DENORM
# define TRIO_NEGATIVE_SUBNORMAL FP_NEG_DENORM
# define TRIO_POSITIVE_ZERO FP_POS_ZERO
# define TRIO_NEGATIVE_ZERO FP_NEG_ZERO
# define TRIO_POSITIVE_NORMAL FP_POS_NORM
# define TRIO_NEGATIVE_NORMAL FP_NEG_NORM
# elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
/*
* MSVC has an _fpclass() function.
* Microsoft Visual C++ and Borland C++ Builder have an _fpclass()
* function.
*/
switch (_fpclass(number)) {
case _FPCLASS_QNAN:
case _FPCLASS_SNAN:
*is_negative = TRIO_FALSE;
return TRIO_FP_NAN;
case _FPCLASS_PINF:
*is_negative = TRIO_FALSE;
return TRIO_FP_INFINITE;
case _FPCLASS_NINF:
*is_negative = TRIO_TRUE;
return TRIO_FP_INFINITE;
case _FPCLASS_PD:
*is_negative = TRIO_FALSE;
return TRIO_FP_SUBNORMAL;
case _FPCLASS_ND:
*is_negative = TRIO_TRUE;
return TRIO_FP_SUBNORMAL;
case _FPCLASS_PZ:
*is_negative = TRIO_FALSE;
return TRIO_FP_ZERO;
case _FPCLASS_NZ:
*is_negative = TRIO_TRUE;
return TRIO_FP_ZERO;
case _FPCLASS_PN:
*is_negative = TRIO_FALSE;
return TRIO_FP_NORMAL;
case _FPCLASS_NN:
*is_negative = TRIO_TRUE;
return TRIO_FP_NORMAL;
default:
/* Just in case... */
*is_negative = (number < 0.0);
return TRIO_FP_NORMAL;
}
#elif defined(FP_PLUS_NORM) || defined(__hpux)
# define TRIO_FPCLASSIFY(n) _fpclass(n)
# define TRIO_QUIET_NAN _FPCLASS_QNAN
# define TRIO_SIGNALLING_NAN _FPCLASS_SNAN
# define TRIO_POSITIVE_INFINITY _FPCLASS_PINF
# define TRIO_NEGATIVE_INFINITY _FPCLASS_NINF
# define TRIO_POSITIVE_SUBNORMAL _FPCLASS_PD
# define TRIO_NEGATIVE_SUBNORMAL _FPCLASS_ND
# define TRIO_POSITIVE_ZERO _FPCLASS_PZ
# define TRIO_NEGATIVE_ZERO _FPCLASS_NZ
# define TRIO_POSITIVE_NORMAL _FPCLASS_PN
# define TRIO_NEGATIVE_NORMAL _FPCLASS_NN
# elif defined(FP_PLUS_NORM)
/*
* HP-UX 9.x and 10.x have an fpclassify() function, that is different
* from the C99 fpclassify() macro supported on HP-UX 11.x.
*
* AIX has class() for C, and _class() for C++, which returns the
* same values as the HP-UX fpclassify() function.
*/
switch (fpclassify(number)) {
case FP_QNAN:
case FP_SNAN:
*is_negative = TRIO_FALSE;
# if defined(TRIO_PLATFORM_AIX)
# if defined(__cplusplus)
# define TRIO_FPCLASSIFY(n) _class(n)
# else
# define TRIO_FPCLASSIFY(n) class(n)
# endif
# else
# define TRIO_FPCLASSIFY(n) fpclassify(n)
# endif
# define TRIO_QUIET_NAN FP_QNAN
# define TRIO_SIGNALLING_NAN FP_SNAN
# define TRIO_POSITIVE_INFINITY FP_PLUS_INF
# define TRIO_NEGATIVE_INFINITY FP_MINUS_INF
# define TRIO_POSITIVE_SUBNORMAL FP_PLUS_DENORM
# define TRIO_NEGATIVE_SUBNORMAL FP_MINUS_DENORM
# define TRIO_POSITIVE_ZERO FP_PLUS_ZERO
# define TRIO_NEGATIVE_ZERO FP_MINUS_ZERO
# define TRIO_POSITIVE_NORMAL FP_PLUS_NORM
# define TRIO_NEGATIVE_NORMAL FP_MINUS_NORM
# endif
# if defined(TRIO_FPCLASSIFY)
switch (TRIO_FPCLASSIFY(number)) {
case TRIO_QUIET_NAN:
case TRIO_SIGNALLING_NAN:
*is_negative = TRIO_FALSE; /* NaN has no sign */
return TRIO_FP_NAN;
case FP_PLUS_INF:
case TRIO_POSITIVE_INFINITY:
*is_negative = TRIO_FALSE;
return TRIO_FP_INFINITE;
case FP_MINUS_INF:
case TRIO_NEGATIVE_INFINITY:
*is_negative = TRIO_TRUE;
return TRIO_FP_INFINITE;
case FP_PLUS_DENORM:
case TRIO_POSITIVE_SUBNORMAL:
*is_negative = TRIO_FALSE;
return TRIO_FP_SUBNORMAL;
case FP_MINUS_DENORM:
case TRIO_NEGATIVE_SUBNORMAL:
*is_negative = TRIO_TRUE;
return TRIO_FP_SUBNORMAL;
case FP_PLUS_ZERO:
case TRIO_POSITIVE_ZERO:
*is_negative = TRIO_FALSE;
return TRIO_FP_ZERO;
case FP_MINUS_ZERO:
case TRIO_NEGATIVE_ZERO:
*is_negative = TRIO_TRUE;
return TRIO_FP_ZERO;
case FP_PLUS_NORM:
case TRIO_POSITIVE_NORMAL:
*is_negative = TRIO_FALSE;
return TRIO_FP_NORMAL;
case FP_MINUS_NORM:
case TRIO_NEGATIVE_NORMAL:
*is_negative = TRIO_TRUE;
return TRIO_FP_NORMAL;
default:
assert(0);
/* Just in case... */
*is_negative = (number < 0.0);
return TRIO_FP_NORMAL;
}
#else
# else
/*
* Fallback solution.
*/
......@@ -694,11 +681,11 @@ TRIO_ARGS2((number, is_negative),
* have to handle this as a special case by examining the sign bit
* directly.
*/
#if defined(USE_IEEE_754)
# if defined(USE_IEEE_754)
*is_negative = trio_is_negative(number);
#else
# else
*is_negative = TRIO_FALSE; /* FIXME */
#endif
# endif
return TRIO_FP_ZERO;
}
if (trio_isnan(number)) {
......@@ -720,6 +707,7 @@ TRIO_ARGS2((number, is_negative),
*is_negative = (number < 0.0);
return TRIO_FP_NORMAL;
# endif
#endif
}
......@@ -907,7 +895,7 @@ int main(TRIO_NOARGS)
((unsigned char *)&my_ninf)[6],
((unsigned char *)&my_ninf)[7],
trio_isnan(my_ninf), trio_isinf(my_ninf));
return 0;
}
#endif
......@@ -62,7 +62,11 @@
#if defined(TRIO_PLATFORM_UNIX)
# define USE_STRCASECMP
# define USE_STRNCASECMP
# define USE_STRERROR
# if defined(TRIO_PLATFORM_SUNOS)
# define USE_SYS_ERRLIST
# else
# define USE_STRERROR
# endif
# if defined(TRIO_PLATFORM_QNX)
# define strcasecmp(x,y) stricmp(x,y)
# define strncasecmp(x,y,n) strnicmp(x,y,n)
......@@ -72,6 +76,11 @@
# define strcasecmp(x,y) strcmpi(x,y)
#endif
#if !(defined(TRIO_PLATFORM_SUNOS))
# define USE_TOLOWER
# define USE_TOUPPER
#endif
/*************************************************************************
* Structures
*/
......@@ -393,7 +402,7 @@ TRIO_ARGS2((first, second),
#else
while ((*first != NIL) && (*second != NIL))
{
if (toupper(*first) != toupper(*second))
if (trio_to_upper(*first) != trio_to_upper(*second))
{
break;
}
......@@ -518,7 +527,7 @@ TRIO_ARGS3((first, max, second),
size_t cnt = 0;
while ((*first != NIL) && (*second != NIL) && (cnt <= max))
{
if (toupper(*first) != toupper(*second))
if (trio_to_upper(*first) != trio_to_upper(*second))
{
break;
}
......@@ -545,9 +554,22 @@ TRIO_ARGS1((error_number),
int error_number)
{
#if defined(USE_STRERROR)
return strerror(error_number);
#elif defined(USE_SYS_ERRLIST)
extern char *sys_errlist[];
extern int sys_nerr;
return ((error_number < 0) || (error_number >= sys_nerr))
? "unknown"
: sys_errlist[error_number];
#else
return "unknown";
#endif
}
......@@ -679,7 +701,7 @@ TRIO_ARGS1((target),
{
assert(target);
return trio_span_function(target, target, tolower);
return trio_span_function(target, target, trio_to_lower);
}
#endif /* !defined(TRIO_MINIMAL) */
......@@ -713,7 +735,7 @@ TRIO_ARGS2((string, pattern),
{
return (NIL == *pattern);
}
if ((toupper((int)*string) != toupper((int)*pattern))
if ((trio_to_upper((int)*string) != trio_to_upper((int)*pattern))
&& ('?' != *pattern))
{
return FALSE;
......@@ -959,7 +981,7 @@ TRIO_ARGS2((source, endp),
integer *= base;
integer += (isdigit((int)*source)
? (*source - '0')
: 10 + (toupper((int)*source) - 'A'));
: 10 + (trio_to_upper((int)*source) - 'A'));
source++;
}
if (*source == '.')
......@@ -970,7 +992,7 @@ TRIO_ARGS2((source, endp),
fracdiv /= base;
fraction += fracdiv * (isdigit((int)*source)
? (*source - '0')
: 10 + (toupper((int)*source) - 'A'));
: 10 + (trio_to_upper((int)*source) - 'A'));
source++;
}
if ((*source == 'p') || (*source == 'P'))
......@@ -983,12 +1005,14 @@ TRIO_ARGS2((source, endp),
}
while (isdigit((int)*source))
{
exponent *= (int)base;
exponent *= 10;
exponent += (*source - '0');
source++;
}
}
}
/* For later use with exponent */
base = 2.0;
}
else /* Then try normal decimal floats */
{
......@@ -1123,6 +1147,33 @@ TRIO_ARGS3((string, endp, base),
}
#if !defined(TRIO_MINIMAL)
/**
Convert one alphabetic letter to lower-case.
@param source The letter to be converted.
@return The converted letter.
*/
TRIO_STRING_PUBLIC int
trio_to_lower
TRIO_ARGS1((source),
int source)
{
#if defined(USE_TOLOWER)
return tolower(source);
#else
/* Does not handle locales or non-contiguous alphabetic characters */
return ((source >= (int)'A') && (source <= (int)'Z'))
? source - 'A' + 'a'
: source;
#endif
}
#endif /* !defined(TRIO_MINIMAL) */
#if !defined(TRIO_MINIMAL)
/**
Convert string to unsigned integer.
......@@ -1146,6 +1197,31 @@ TRIO_ARGS3((string, endp, base),
#endif /* !defined(TRIO_MINIMAL) */
/**
Convert one alphabetic letter to upper-case.
@param source The letter to be converted.
@return The converted letter.
*/
TRIO_STRING_PUBLIC int
trio_to_upper
TRIO_ARGS1((source),
int source)
{
#if defined(USE_TOUPPER)
return toupper(source);
#else
/* Does not handle locales or non-contiguous alphabetic characters */
return ((source >= (int)'a') && (source <= (int)'z'))
? source - 'a' + 'A'
: source;
#endif
}
#if !defined(TRIO_MINIMAL)
/**
Convert the alphabetic letters in the string to upper-case.
......@@ -1160,7 +1236,7 @@ TRIO_ARGS1((target),
{
assert(target);
return trio_span_function(target, target, toupper);
return trio_span_function(target, target, trio_to_upper);
}
#endif /* !defined(TRIO_MINIMAL) */
......@@ -1229,6 +1305,7 @@ TRIO_ARGS2((self, delta),
}
#if !defined(TRIO_MINIMAL)
/*
* TrioStringGrowTo
*
......@@ -1247,6 +1324,7 @@ TRIO_ARGS2((self, length),
? TrioStringGrow(self, length - self->allocated)
: TRUE;
}
#endif /* !defined(TRIO_MINIMAL) */
#if !defined(TRIO_MINIMAL)
......
......@@ -42,40 +42,47 @@ enum {
* String functions
*/
TRIO_STRING_PUBLIC int trio_append TRIO_PROTO((char *target, const char *source));
TRIO_STRING_PUBLIC int trio_append_max TRIO_PROTO((char *target, size_t max, const char *source));
TRIO_STRING_PUBLIC int trio_contains TRIO_PROTO((const char *string, const char *substring));
TRIO_STRING_PUBLIC int trio_copy TRIO_PROTO((char *target, const char *source));
TRIO_STRING_PUBLIC int trio_copy_max TRIO_PROTO((char *target, size_t max, const char *source));
TRIO_STRING_PUBLIC char *trio_create TRIO_PROTO((size_t size));
TRIO_STRING_PUBLIC void trio_destroy TRIO_PROTO((char *string));
TRIO_STRING_PUBLIC char *trio_duplicate TRIO_PROTO((const char *source));
TRIO_STRING_PUBLIC char *trio_duplicate_max TRIO_PROTO((const char *source, size_t max));
TRIO_STRING_PUBLIC int trio_equal TRIO_PROTO((const char *first, const char *second));
TRIO_STRING_PUBLIC int trio_equal_case TRIO_PROTO((const char *first, const char *second));
TRIO_STRING_PUBLIC int trio_equal_case_max TRIO_PROTO((const char *first, size_t max, const char *second));
TRIO_STRING_PUBLIC int trio_equal_locale TRIO_PROTO((const char *first, const char *second));
TRIO_STRING_PUBLIC int trio_equal_max TRIO_PROTO((const char *first, size_t max, const char *second));
TRIO_STRING_PUBLIC TRIO_CONST char *trio_error TRIO_PROTO((int));
TRIO_STRING_PUBLIC size_t trio_length TRIO_PROTO((const char *string));
TRIO_STRING_PUBLIC double trio_to_double TRIO_PROTO((const char *source, char **endp));
TRIO_STRING_PUBLIC long trio_to_long TRIO_PROTO((const char *source, char **endp, int base));
TRIO_STRING_PUBLIC trio_long_double_t trio_to_long_double TRIO_PROTO((const char *source, char **endp));
TRIO_STRING_PUBLIC int trio_to_upper TRIO_PROTO((int source));
#if !defined(TRIO_MINIMAL)
TRIO_STRING_PUBLIC int trio_append TRIO_PROTO((char *target, const char *source));
TRIO_STRING_PUBLIC int trio_append_max TRIO_PROTO((char *target, size_t max, const char *source));
TRIO_STRING_PUBLIC int trio_contains TRIO_PROTO((const char *string, const char *substring));
TRIO_STRING_PUBLIC int trio_copy TRIO_PROTO((char *target, const char *source));
TRIO_STRING_PUBLIC char *trio_duplicate_max TRIO_PROTO((const char *source, size_t max));
TRIO_STRING_PUBLIC int trio_equal_case_max TRIO_PROTO((const char *first, size_t max, const char *second));
TRIO_STRING_PUBLIC size_t trio_format_date_max TRIO_PROTO((char *target, size_t max, const char *format, const struct tm *datetime));
TRIO_STRING_PUBLIC unsigned long trio_hash TRIO_PROTO((const char *string, int type));
TRIO_STRING_PUBLIC char *trio_index TRIO_PROTO((const char *string, int character));
TRIO_STRING_PUBLIC char *trio_index_last TRIO_PROTO((const char *string, int character));
TRIO_STRING_PUBLIC size_t trio_length TRIO_PROTO((const char *string));
TRIO_STRING_PUBLIC int trio_lower TRIO_PROTO((char *target));
TRIO_STRING_PUBLIC int trio_match TRIO_PROTO((const char *string, const char *pattern));
TRIO_STRING_PUBLIC int trio_match_case TRIO_PROTO((const char *string, const char *pattern));
TRIO_STRING_PUBLIC size_t trio_span_function TRIO_PROTO((char *target, const char *source, int (*Function) TRIO_PROTO((int))));
TRIO_STRING_PUBLIC char *trio_substring TRIO_PROTO((const char *string, const char *substring));
TRIO_STRING_PUBLIC char *trio_substring_max TRIO_PROTO((const char *string, size_t max, const char *substring));
TRIO_STRING_PUBLIC double trio_to_double TRIO_PROTO((const char *source, char **endp));
TRIO_STRING_PUBLIC float trio_to_float TRIO_PROTO((const char *source, char **endp));
TRIO_STRING_PUBLIC trio_long_double_t trio_to_long_double TRIO_PROTO((const char *source, char **endp));
TRIO_STRING_PUBLIC long trio_to_long TRIO_PROTO((const char *source, char **endp, int base));
TRIO_STRING_PUBLIC int trio_to_lower TRIO_PROTO((int source));
TRIO_STRING_PUBLIC unsigned long trio_to_unsigned_long TRIO_PROTO((const char *source, char **endp, int base));
TRIO_STRING_PUBLIC char *trio_tokenize TRIO_PROTO((char *string, const char *delimiters));
TRIO_STRING_PUBLIC int trio_upper TRIO_PROTO((char *target));
#endif /* !defined(TRIO_MINIMAL) */
/*************************************************************************
* Dynamic string functions
*/
......@@ -83,15 +90,21 @@ TRIO_STRING_PUBLIC int trio_upper TRIO_PROTO((char *target));
/*
* Opaque type for dynamic strings
*/
typedef struct _trio_string_t trio_string_t;
TRIO_STRING_PUBLIC trio_string_t *trio_string_create TRIO_PROTO((int initial_size));
TRIO_STRING_PUBLIC void trio_string_destroy TRIO_PROTO((trio_string_t *self));
TRIO_STRING_PUBLIC char *trio_string_get TRIO_PROTO((trio_string_t *self, int offset));
TRIO_STRING_PUBLIC void trio_xstring_set TRIO_PROTO((trio_string_t *self, char *buffer));
TRIO_STRING_PUBLIC char *trio_string_extract TRIO_PROTO((trio_string_t *self));
TRIO_STRING_PUBLIC int trio_string_size TRIO_PROTO((trio_string_t *self));
TRIO_STRING_PUBLIC void trio_string_terminate TRIO_PROTO((trio_string_t *self));
TRIO_STRING_PUBLIC int trio_xstring_append_char TRIO_PROTO((trio_string_t *self, char character));
TRIO_STRING_PUBLIC trio_string_t *trio_xstring_duplicate TRIO_PROTO((const char *other));
#if !defined(TRIO_MINIMAL)
TRIO_STRING_PUBLIC trio_string_t *trio_string_create TRIO_PROTO((int initial_size));
TRIO_STRING_PUBLIC char *trio_string_get TRIO_PROTO((trio_string_t *self, int offset));
TRIO_STRING_PUBLIC void trio_xstring_set TRIO_PROTO((trio_string_t *self, char *buffer));
TRIO_STRING_PUBLIC int trio_string_append TRIO_PROTO((trio_string_t *self, trio_string_t *other));
TRIO_STRING_PUBLIC int trio_string_contains TRIO_PROTO((trio_string_t *self, trio_string_t *other));
......@@ -111,11 +124,9 @@ TRIO_STRING_PUBLIC int trio_string_match_case TRIO_PROTO((trio_string_t *self, t
TRIO_STRING_PUBLIC char *trio_string_substring TRIO_PROTO((trio_string_t *self, trio_string_t *other));
TRIO_STRING_PUBLIC int trio_string_upper TRIO_PROTO((trio_string_t *self));
TRIO_STRING_PUBLIC int trio_xstring_append_char TRIO_PROTO((trio_string_t *self, char character));
TRIO_STRING_PUBLIC int trio_xstring_append TRIO_PROTO((trio_string_t *self, const char *other));
TRIO_STRING_PUBLIC int trio_xstring_contains TRIO_PROTO((trio_string_t *self, const char *other));
TRIO_STRING_PUBLIC int trio_xstring_copy TRIO_PROTO((trio_string_t *self, const char *other));
TRIO_STRING_PUBLIC trio_string_t *trio_xstring_duplicate TRIO_PROTO((const char *other));
TRIO_STRING_PUBLIC int trio_xstring_equal TRIO_PROTO((trio_string_t *self, const char *other));
TRIO_STRING_PUBLIC int trio_xstring_equal_max TRIO_PROTO((trio_string_t *self, size_t max, const char *other));
TRIO_STRING_PUBLIC int trio_xstring_equal_case TRIO_PROTO((trio_string_t *self, const char *other));
......@@ -124,4 +135,6 @@ TRIO_STRING_PUBLIC int trio_xstring_match TRIO_PROTO((trio_string_t *self, const
TRIO_STRING_PUBLIC int trio_xstring_match_case TRIO_PROTO((trio_string_t *self, const char *other));
TRIO_STRING_PUBLIC char *trio_xstring_substring TRIO_PROTO((trio_string_t *self, const char *other));
#endif /* !defined(TRIO_MINIMAL) */
#endif /* TRIO_TRIOSTR_H */
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