From ac3f809c3c10347c110fac3db93af0954eda98bb Mon Sep 17 00:00:00 2001 From: solar Date: Fri, 21 Nov 2003 18:54:25 +0000 Subject: [PATCH] Some cleanup. --- includes/assert.h | 2 +- includes/complex.h | 11 +- includes/ctype.h | 5 +- includes/errno.h | 2 +- includes/fenv.h | 2 +- includes/inttypes.h | 248 +++++++++++++++++++++++++++++- includes/iso646.h | 2 +- includes/limits.h | 2 +- includes/locale.h | 3 +- includes/math.h | 59 +++---- includes/setjmp.h | 2 +- includes/signal.h | 2 +- includes/stdarg.h | 10 +- includes/stdbool.h | 2 +- includes/stddef.h | 2 +- includes/stdint.h | 124 ++++++++++++++- includes/stdio.h | 87 ++++++++++- includes/stdlib.h | 121 ++++++++++++++- includes/string.h | 56 ++++++- includes/tgmath.h | 364 +++++++++++++++++++++++++++++++++++++++++++- includes/time.h | 30 +++- includes/wchar.h | 108 ++++++++++++- includes/wctype.h | 33 +++- 23 files changed, 1213 insertions(+), 64 deletions(-) diff --git a/includes/assert.h b/includes/assert.h index f99ccd7..ebf4d8c 100644 --- a/includes/assert.h +++ b/includes/assert.h @@ -4,7 +4,7 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// Provides the debug macro assert(). +// Diagnostics // ---------------------------------------------------------------------------- #ifndef __ASSERT_H diff --git a/includes/complex.h b/includes/complex.h index 59cb5b2..d4cc9ea 100644 --- a/includes/complex.h +++ b/includes/complex.h @@ -4,8 +4,7 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// Provides the types float _Complex, double _Complex and long double _Complex -// plus math functions on those types. +// Complex arithmetic // ---------------------------------------------------------------------------- #ifndef __COMPLEX_H @@ -18,11 +17,13 @@ #define complex _Complex #endif -#define _Complex_I (float _Complex){0, 1} -#define imaginary _Imaginary // optional +#define _Complex_I ( const float _Complex ) { 0, 1 } + +// TODO: imaginary is only defined if implementation supports _Imaginary. +#define imaginary _Imaginary #ifdef imaginary -#define _Imaginary_I ((float _Imaginary)1) +#define _Imaginary_I ( ( const float _Imaginary ) 1 ) #endif #ifdef imaginary diff --git a/includes/ctype.h b/includes/ctype.h index a9ecc25..86ca13c 100644 --- a/includes/ctype.h +++ b/includes/ctype.h @@ -4,8 +4,7 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// Provides functions for determining the locale-dependent type of a character, -// plus locale-aware uppercase / lowercase conversions. (See also locale.h.) +// Character handling // ---------------------------------------------------------------------------- #ifndef __CTYPE_H @@ -35,7 +34,7 @@ int isgraph( int c ); // returns nonzero if c is a lowercase alphabetic character in the locale. int islower( int c ); -// returns nonzero if c is a printable character ( isgraph( ) or isblank( ) ) in +// returns nonzero if c is a printable character ( isgraph() or isblank() ) in // the locale. int isprint( int c ); diff --git a/includes/errno.h b/includes/errno.h index 873166a..0569284 100644 --- a/includes/errno.h +++ b/includes/errno.h @@ -4,7 +4,7 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// Provides 'errno', the auxiliary error handling of the standard library. +// Errors // ---------------------------------------------------------------------------- #ifndef __ERRNO_H diff --git a/includes/fenv.h b/includes/fenv.h index 09e770c..33e8bea 100644 --- a/includes/fenv.h +++ b/includes/fenv.h @@ -4,7 +4,7 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// TODO +// Floating-point environment // ---------------------------------------------------------------------------- #ifndef __FENV_H diff --git a/includes/inttypes.h b/includes/inttypes.h index 620a2f4..bb52ea9 100644 --- a/includes/inttypes.h +++ b/includes/inttypes.h @@ -4,12 +4,256 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// TODO +// Format conversion of integer types // ---------------------------------------------------------------------------- #ifndef __INTTYPES_H #define __INTTYPES_H __INTTYPES_H -// TODO +// ---------------------------------------------------------------------------- +// TYPEDEFS + +typedef struct +{ + intmax_t quotient, + intmax_t remainder; +} +imaxdiv_t; + +// ---------------------------------------------------------------------------- +// FUNCTIONS + +intmax_t imaxabs( intmax_t i ); +intmax_t abs( intmax_t i ); [C++ only] + +imaxdiv_t imaxdiv( intmax_t numer, intmax_t denom ); +imaxdiv_t div( intmax_t numer, intmax_t denom ); [C++ only] + +intmax_t strtoimax( const char * restrict s, char * * restrict endptr, int base ); +uintmax_t strtoumax( const char * restrict s, char * * restrict endptr, int base ); +intmax_t wcstoimax( const wchar_t * restrict s, wchar_t * * restrict endptr, int base ); +uintmax_t wcstoumax( const wchar_t * restrict s, wchar_t * * restrict endptr, int base ); + +// ---------------------------------------------------------------------------- +// MACROS (PRINT) + +#define PRId8 +#define PRId16 +#define PRId32 +#define PRId64 + +#define PRIdFAST8 +#define PRIdFAST16 +#define PRIdFAST32 +#define PRIdFAST64 + +#define PRIdLEAST8 +#define PRIdLEAST16 +#define PRIdLEAST32 +#define PRIdLEAST64 + +#define PRIdMAX +#define PRIdPTR + +#define PRIi8 +#define PRIi16 +#define PRIi32 +#define PRIi64 + +#define PRIiFAST8 +#define PRIiFAST16 +#define PRIiFAST32 +#define PRIiFAST64 + +#define PRIiLEAST8 +#define PRIiLEAST16 +#define PRIiLEAST32 +#define PRIiLEAST64 + +#define PRIiMAX +#define PRIiPTR + +#define PRIo8 +#define PRIo16 +#define PRIo32 +#define PRIo64 + +#define PRIoFAST8 +#define PRIoFAST16 +#define PRIoFAST32 +#define PRIoFAST64 + +#define PRIoLEAST8 +#define PRIoLEAST16 +#define PRIoLEAST32 +#define PRIoLEAST64 + +#define PRIoMAX +#define PRIoPTR + +#define PRIu8 +#define PRIu16 +#define PRIu32 +#define PRIu64 + +#define PRIuFAST8 +#define PRIuFAST16 +#define PRIuFAST32 +#define PRIuFAST64 + +#define PRIuLEAST8 +#define PRIuLEAST16 +#define PRIuLEAST32 +#define PRIuLEAST64 + +#define PRIuMAX +#define PRIuPTR + +#define PRIx8 +#define PRIx16 +#define PRIx32 +#define PRIx64 + +#define PRIxFAST8 +#define PRIxFAST16 +#define PRIxFAST32 +#define PRIxFAST64 + +#define PRIxLEAST8 +#define PRIxLEAST16 +#define PRIxLEAST32 +#define PRIxLEAST64 + +#define PRIxMAX +#define PRIxPTR + +#define PRIX8 +#define PRIX16 +#define PRIX32 +#define PRIX64 + +#define PRIXFAST8 +#define PRIXFAST16 +#define PRIXFAST32 +#define PRIXFAST64 + +#define PRIXLEAST8 +#define PRIXLEAST16 +#define PRIXLEAST32 +#define PRIXLEAST64 + +#define PRIXMAX +#define PRIXPTR + +// ---------------------------------------------------------------------------- +// MACROS (SCAN) + +#define SCNd8 +#define SCNd16 +#define SCNd32 +#define SCNd64 + +#define SCNdFAST8 +#define SCNdFAST16 +#define SCNdFAST32 +#define SCNdFAST64 + +#define SCNdLEAST8 +#define SCNdLEAST16 +#define SCNdLEAST32 +#define SCNdLEAST64 + +#define SCNdMAX +#define SCNdPTR + +#define SCNi8 +#define SCNi16 +#define SCNi32 +#define SCNi64 + +#define SCNiFAST8 +#define SCNiFAST16 +#define SCNiFAST32 +#define SCNiFAST64 + +#define SCNiLEAST8 +#define SCNiLEAST16 +#define SCNiLEAST32 +#define SCNiLEAST64 + +#define SCNiMAX +#define SCNiPTR + +#define SCNo8 +#define SCNo16 +#define SCNo32 +#define SCNo64 + +#define SCNoFAST8 +#define SCNoFAST16 +#define SCNoFAST32 +#define SCNoFAST64 + +#define SCNoLEAST8 +#define SCNoLEAST16 +#define SCNoLEAST32 +#define SCNoLEAST64 + +#define SCNoMAX +#define SCNoPTR + +#define SCNu8 +#define SCNu16 +#define SCNu32 +#define SCNu64 + +#define SCNuFAST8 +#define SCNuFAST16 +#define SCNuFAST32 +#define SCNuFAST64 + +#define SCNuLEAST8 +#define SCNuLEAST16 +#define SCNuLEAST32 +#define SCNuLEAST64 + +#define SCNuMAX +#define SCNuPTR + +#define SCNx8 +#define SCNx16 +#define SCNx32 +#define SCNx64 + +#define SCNxFAST8 +#define SCNxFAST16 +#define SCNxFAST32 +#define SCNxFAST64 + +#define SCNxLEAST8 +#define SCNxLEAST16 +#define SCNxLEAST32 +#define SCNxLEAST64 + +#define SCNxMAX +#define SCNxPTR + +#define SCNX8 +#define SCNX16 +#define SCNX32 +#define SCNX64 + +#define SCNXFAST8 +#define SCNXFAST16 +#define SCNXFAST32 +#define SCNXFAST64 + +#define SCNXLEAST8 +#define SCNXLEAST16 +#define SCNXLEAST32 +#define SCNXLEAST64 + +#define SCNXMAX +#define SCNXPTR #endif // __INTTYPES_H diff --git a/includes/iso646.h b/includes/iso646.h index cc8be74..7dd19ca 100644 --- a/includes/iso646.h +++ b/includes/iso646.h @@ -4,7 +4,7 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// Provides "readable" aliases for bit operators. +// Alternative spellings // ---------------------------------------------------------------------------- #ifndef __ISO646_H diff --git a/includes/limits.h b/includes/limits.h index e8cc909..302eb3a 100644 --- a/includes/limits.h +++ b/includes/limits.h @@ -4,7 +4,7 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// TODO +// Sizes of integer types // ---------------------------------------------------------------------------- #ifndef __LIMITS_H diff --git a/includes/locale.h b/includes/locale.h index e16b075..59fd642 100644 --- a/includes/locale.h +++ b/includes/locale.h @@ -4,8 +4,7 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// Provides information on locale specifics as well as a function to change the -// active locale to something else but the startup default "C". +// Localization // ---------------------------------------------------------------------------- #ifndef __LOCALE_H diff --git a/includes/math.h b/includes/math.h index f737c21..c03037e 100644 --- a/includes/math.h +++ b/includes/math.h @@ -4,7 +4,7 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// Provides floating point math functions. +// Mathematics // ---------------------------------------------------------------------------- #ifndef __MATH_H @@ -48,19 +48,19 @@ typedef float_t; // TODO #ifndef __cplusplus -#define signbit( x ) // TODO -#define fpclassify( x ) // TODO -#define isfinite( x ) // TODO -#define isinf( x ) // TODO -#define isnan( x ) // TODO -#define isnormal( x ) // TODO - #define isgreater( x, y ) // TODO #define isgreaterequal( x, y ) // TODO #define isless( x, y ) // TODO #define islessequal( x, y ) // TODO #define islessgreater( x, y ) // TODO #define isunordered( x, y ) // TODO +#define fpclassify( x ) // TODO +#define isfinite( x ) // TODO + +#define isinf( x ) // TODO +#define isnan( x ) // TODO +#define isnormal( x ) // TODO +#define signbit( x ) // TODO #else // __cplusplus @@ -128,7 +128,8 @@ long double sinh( long double x ); float asin( float x ); long double asin( long double x ); -// These functions return the hyperbolic arcsine of their parameter. +// These functions compute the arc hyperbolic sine of x. +// @returns arsinh x. float asinh( float x ); long double asinh( long double x ); @@ -140,7 +141,7 @@ long double cos( long double x ); float cosh( float x ); long double cosh( long double x ); -// These functions return the arccosine of their parameter. +// These functions return the arcsine of their parameter. float acos( float x ); long double acos( long double x ); @@ -165,8 +166,8 @@ float atanh( float x ); long double atanh( long double x ); // TODO -float atan2( float x, float y ); -long double atan2( long double x, long double y ); +float atan2( float y, float x ); +long double atan2( long double y, long double x ); // These functions return sqrt( x^2 + y^2 ). float hypot( float x, float y ); @@ -336,22 +337,23 @@ long double tgamma( long double x ); // ---------------------------------------------------------------------------- // FUNCTIONS - Standard C -// These functions return the magnitude of its parameter. +// These functions return the magnitude of their parameter. double fabs( double x ); float fabsf( float x ); long double fabsl( long double x ); -// These functions return the sine of its parameter. +// These functions compute the sine of x (measured in radians). +// @returns sin x. double sin( double x ); float sinf( float x ); long double sinl( long double x ); -// These functions return the hyperbolic cosine of its parameter. +// These functions return the hyperbolic cosine of their parameter. double sinh( double x ); float sinhf( float x ); long double sinhl( long double x ); -// These functions return the arcsine of its parameter. +// These functions return the arcsine of their parameter. double asin( double x ); float asinf( float x ); long double asinl( long double x ); @@ -361,17 +363,18 @@ double asinh( double x ); float asinhf( float x ); long double asinhl( long double x ); -// These functions return the cosine of its parameter. +// These functions compute the cosine of x (measured in radians). +// @returns cos x. double cos( double x ); float cosf( float x ); long double cosl( long double x ); -// These functions return the hyperbolic cosine of its parameter. +// These functions return the hyperbolic cosine of their parameter. double cosh( double x ); float coshf( float x ); long double coshl( long double x ); -// These functions return the arccosine of its parameter. +// These functions return the arccosine of their parameter. double acos( double x ); float acosf( float x ); long double acosl( long double x ); @@ -381,17 +384,19 @@ double acosh( double x ); float acoshf( float x ); long double acoshl( long double x ); -// These functions return the tangent of its parameter. +// These functions return the tangent of x (measured in radians). +// @returns tan x. double tan( double x ); float tanf( float x ); long double tanl( long double x ); -// These functions return the hyperbolic tangent of its parameter. +// These functions return the hyperbolic tangent of their parameter. double tanh( double x ); float tanhf( float x ); long double tanhl( long double x ); -// These functions return the arctangent of its parameter. +// These functions compute the principal value of the arc tangent of x. +// @returns arctan x in the interval [-p/2, +p/2] radians. double atan( double x ); float atanf( float x ); long double atanl( long double x ); @@ -411,12 +416,12 @@ double hypot( double x, double y ); float hypotf( float x, float y ); long double hypotl( long double x, long double y ); -// These functions return its parameter x, raised to the power y. +// These functions return their parameter x, raised to the power y. double pow( double x, double y ); float powf( float x, float y ); long double powl( long double x, long double y ); -// These functions return the square root of its parameter. +// These functions return the square root of their parameter. double sqrt( double x ); float sqrtf( float x ); long double sqrtl( long double x ); @@ -451,12 +456,12 @@ double ldexp( double x, int exp ); float ldexpf( float x, int exp ); long double ldexpl( long double x, int exp ); -// These functions return the natural logarithm of its parameter. +// These functions return the natural logarithm of their parameter. double log( double x ); float logf( float x ); long double logl( long double x ); -// These functions return the logarithm (base 10 ) of its parameter. +// These functions return the logarithm (base 10 ) of their parameter. double log10( double x ); float log10f( float x ); long double log10l( long double x ); @@ -486,7 +491,7 @@ double ceil( double x ); float ceilf( float x ); long double ceill( long double x ); -// These functions return the largest integer no larger than its parameter. +// These functions return the largest integer no larger than their parameter. double floor( double x ); float floorf( float x ); long double floorl( long double x ); diff --git a/includes/setjmp.h b/includes/setjmp.h index fe4fbb6..dda36ea 100644 --- a/includes/setjmp.h +++ b/includes/setjmp.h @@ -4,7 +4,7 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// TODO +// Nonlocal jumps // ---------------------------------------------------------------------------- #ifndef __SETJMP_H diff --git a/includes/signal.h b/includes/signal.h index 36b073e..bfc9888 100644 --- a/includes/signal.h +++ b/includes/signal.h @@ -4,7 +4,7 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// TODO +// Signal handling // ---------------------------------------------------------------------------- #ifndef __SIGNAL_H diff --git a/includes/stdarg.h b/includes/stdarg.h index 6afedec..e094332 100644 --- a/includes/stdarg.h +++ b/includes/stdarg.h @@ -4,7 +4,7 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// TODO +// Variable arguments // ---------------------------------------------------------------------------- #ifndef __STDARG_H @@ -23,4 +23,12 @@ typedef do-type va_list; #define va_end( va_list ap ) // TODO #define va_start( va_list ap, last-par ) // TODO +/* +From PDPClib: + +#define va_start(ap, parmN) ap = (char *)&parmN + 4 +#define va_arg(ap, type) *(type *)(ap += sizeof(type), ap - sizeof(type)) +#define va_end(ap) ap = 0 +*/ + #endif // __STDARG_H diff --git a/includes/stdbool.h b/includes/stdbool.h index 7f58ab7..0e1c2a5 100644 --- a/includes/stdbool.h +++ b/includes/stdbool.h @@ -4,7 +4,7 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// TODO +// Boolean type and values // ---------------------------------------------------------------------------- #ifndef __STDBOOL_H diff --git a/includes/stddef.h b/includes/stddef.h index d72ca71..32bfb32 100644 --- a/includes/stddef.h +++ b/includes/stddef.h @@ -4,7 +4,7 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// TODO +// Common definitions // ---------------------------------------------------------------------------- #ifndef __STDDEF_H diff --git a/includes/stdint.h b/includes/stdint.h index 66f31fd..ef21b9c 100644 --- a/includes/stdint.h +++ b/includes/stdint.h @@ -4,12 +4,132 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// TODO +// Integer types // ---------------------------------------------------------------------------- #ifndef __STDINT_H #define __STDINT_H __STDINT_H -// TODO +// ---------------------------------------------------------------------------- +// TYPEDEFS + +typedef int8_t; // TODO +typedef int16_t; // TODO +typedef int32_t; // TODO +typedef int64_t; // TODO + +typedef uint8_t; // TODO +typedef uint16_t; // TODO +typedef uint32_t; // TODO +typedef uint64_t; // TODO + +typedef int_least8_t; // TODO +typedef int_least16_t; // TODO +typedef int_least32_t; // TODO +typedef int_least64_t; // TODO + +typedef uint_least8_t; // TODO +typedef uint_least16_t; // TODO +typedef uint_least32_t; // TODO +typedef uint_least64_t; // TODO + +typedef int_fast8_t; // TODO +typedef int_fast16_t; // TODO +typedef int_fast32_t; // TODO +typedef int_fast64_t; // TODO + +typedef uint_fast8_t; // TODO +typedef uint_fast16_t; // TODO +typedef uint_fast32_t; // TODO +typedef uint_fast64_t; // TODO + +typedef intptr_t; // TODO +typedef uintptr_t; // TODO + +typedef intmax_t; // TODO +typedef uintmax_t; // TODO + +// ---------------------------------------------------------------------------- +// MACROS + +#define INT8_MIN // TODO +#define INT16_MIN // TODO +#define INT32_MIN // TODO +#define INT64_MIN // TODO + +#define INT8_MAX 0x7f +#define INT16_MAX 0x7fff +#define INT32_MAX 0x7fffffff +#define INT64_MAX 0x7fffffffffffffff + +#define UINT8_MAX 0xff +#define UINT16_MAX 0xffff +#define UINT32_MAX 0xffffffff +#define UINT64_MAX 0xffffffffffffffff + +#define INT_LEAST8_MIN // TODO +#define INT_LEAST16_MIN // TODO +#define INT_LEAST32_MIN // TODO +#define INT_LEAST64_MIN // TODO + +#define INT_LEAST8_MAX // TODO +#define INT_LEAST16_MAX // TODO +#define INT_LEAST32_MAX // TODO +#define INT_LEAST64_MAX // TODO + +#define UINT_LEAST8_MAX // TODO +#define UINT_LEAST16_MAX // TODO +#define UINT_LEAST32_MAX // TODO +#define UINT_LEAST64_MAX // TODO + +#define INT_FAST8_MIN // TODO +#define INT_FAST16_MIN // TODO +#define INT_FAST32_MIN // TODO +#define INT_FAST64_MIN // TODO + +#define INT_FAST8_MAX // TODO +#define INT_FAST16_MAX // TODO +#define INT_FAST32_MAX // TODO +#define INT_FAST64_MAX // TODO + +#define UINT_FAST8_MAX // TODO +#define UINT_FAST16_MAX // TODO +#define UINT_FAST32_MAX // TODO +#define UINT_FAST64_MAX // TODO + +#define INTPTR_MIN // TODO +#define INTPTR_MAX // TODO +#define UINTPTR_MAX // TODO + +#define INT8_C(x) // TODO +#define INT16_C(x) // TODO +#define INT32_C(x) // TODO +#define INT64_C(x) // TODO + +#define UINT8_C(x) // TODO +#define UINT16_C(x) // TODO +#define UINT32_C(x) // TODO +#define UINT64_C(x) // TODO + +#define INTMAX_C(x) // TODO +#define UINTMAX_C(x) // TODO + +#define PTRDIFF_MIN // TODO +#define PTRDIFF_MAX // TODO + +#define SIG_ATOMIC_MIN // TODO +#define SIG_ATOMIC_MAX // TODO + +#define SIZE_MAX // TODO + +#define WCHAR_MIN // TODO +#define WCHAR_MAX // TODO + +#define WINT_MIN // TODO +#define WINT_MAX // TODO + +#define INTMAX_MIN // TODO +#define INTMAX_MAX // TODO +#define UINTMAX_MAX // TODO #endif // __STDINT_H diff --git a/includes/stdio.h b/includes/stdio.h index 62b5af1..ee46af7 100644 --- a/includes/stdio.h +++ b/includes/stdio.h @@ -4,12 +4,95 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// TODO +// Input/output // ---------------------------------------------------------------------------- #ifndef __STDIO_H #define __STDIO_H __STDIO_H -// TODO +// ---------------------------------------------------------------------------- +// MACROS + +#define _IOFBF // TODO +#define _IOLBF // TODO +#define _IONBF // TODO +#define BUFSIZ // TODO +#define EOF // TODO +#define FILENAME_MAX // TODO +#define FOPEN_MAX // TODO +#define L_tmpnam // TODO +#define NULL 0 +#define SEEK_CUR // TODO +#define SEEK_END // TODO +#define SEEK_SET // TODO +#define TMP_MAX // TODO + +#define stderr // TODO +#define stdin // TODO +#define stdout // TODO + +// ---------------------------------------------------------------------------- +// TYPEDEFS + +typedef FILE; // TODO +typedef fpos_t; // TODO +typedef size_t; // TODO + +// ---------------------------------------------------------------------------- +// FUNCTIONS + +// TODO: Documentation. + +void clearerr( FILE * stream ); +int fclose( FILE * stream ); +int feof( FILE * stream ); +int ferror( FILE * stream ); +int fflush( FILE * stream ); +FILE * fopen( const char * restrict filename, const char * restrict mode ); +FILE * freopen( const char * restrict filename, const char * restrict mode, FILE * stream ); +int remove( const char * filename ); +int rename( const char * old, const char * new ); +void rewind( FILE * stream ); +void setbuf( FILE * restrict stream, char * restrict buf ); +int setvbuf( FILE * restrict stream, char * restrict buf, int mode, size_t size ); +FILE * tmpfile( void ) +char * tmpnam( char * s ); + +int fseek( FILE * stream, long offset, int mode ); +int fsetpos( FILE * stream, const fpos_t * pos ); +int fgetpos( FILE * restrict stream, fpos_t * restrict pos ); +long ftell( FILE * stream ); + +int fgetc( FILE * stream ); +char *fgets( char * restrict s, int n, FILE * restrict stream ); +size_t fread( void * restrict ptr, size_t size, size_t nelem, FILE * restrict stream ); +int getc( FILE * stream ); +int getchar( void ); +char * gets( char * s ); +int ungetc( int c, FILE * stream ); + +int fputc( int c, FILE * stream ); +int fputs( const char * restrict s, FILE * restrict stream ); +size_t fwrite( const void * restrict ptr, size_t size, size_t nelem, FILE * restrict stream ); +void perror( const char * s ); +int putc( int c, FILE * stream ); +int putchar( int c ); +int puts( const char * s ); + +int fscanf( FILE * restrict stream, const char * restrict format, ... ); +int scanf( const char * restrict format, ... ); +int sscanf( const char * restrict s, const char * restrict format, ... ); +int vfscanf( FILE * restrict stream, const char * restrict format, va_list ap ); +int vscanf( const char * restrict format, va_list ap ); +int vsscanf( const char * restrict s, const char * restrict format, va_list ap ); + +int fprintf( FILE * restrict stream, const char * restrict format, ... ); +int printf( const char * restrict format, ... ); +int snprintf( char * restrict s, size_t n, const char * restrict format, ... ); +int sprintf( char * restrict s, const char * restrict format, ... ); +int vfprintf( FILE * restrict stream, const char * restrict format, va_list ap ); +int vprintf( const char * restrict format, va_list ap ); +int vsnprintf( char * restrict s, size_t n, const char * restrict format, va_list ap ); +int vsprintf( char * restrict s, const char * restrict format, va_list ap); #endif // __STDIO_H diff --git a/includes/stdlib.h b/includes/stdlib.h index 1b9a905..4518f22 100644 --- a/includes/stdlib.h +++ b/includes/stdlib.h @@ -4,12 +4,129 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// TODO +// General utilities // ---------------------------------------------------------------------------- #ifndef __STDLIB_H #define __STDLIB_H __STDLIB_H -// TODO +// ---------------------------------------------------------------------------- +// MACROS + +#define EXIT_FAILURE // TODO +#define EXIT_SUCCESS // TODO +#define MB_CUR_MAX // TODO +#define NULL 0 +#define RAND_MAX // TODO + +// ---------------------------------------------------------------------------- +// TYPEDEFS + +typedef struct +{ + int quotient; + int remainder; +} div_t; + +typedef struct +{ + long quotient; + long remainder; +} ldiv_t; + +typedef struct +{ long long quotient; + long long remainder; +} lldiv_t; + +typedef size_t; // TODO + +#ifndef __cplusplus +typedef wchar_t; // TODO +#endif // __cplusplus + +// ---------------------------------------------------------------------------- +// FUNCTIONS - C++ + +#ifdef __cplusplus + +long abs( long i ); +long long abs( long long i ); + +ldiv_t div( long numer, long denom ); +lldiv_t div( long long numer, long long denom ); + +extern "C++" int atexit( void (*func) ( void ) ); +extern "C" int atexit( void (*func) ( void ) ); + +extern "C++" void * bsearch( const void * key, const void * base, + size_t nelem, size_t size, + int (*cmp) ( const void * ck, const void * ce ) ); +extern "C" void * bsearch( const void * key, const void * base, + size_t nelem, size_t size, + int (*cmp) ( const void * ck, const void * ce ) ); + +extern "C++" void qsort( void * base, size_t nelem, size_t size, + int (*cmp) ( const void * e1, const void * e2 ) ); +extern "C" void qsort( void * base, size_t nelem, size_t size, + int (*cmp) ( const void * e1, const void * e2 ) ); + +#endif // __cplusplus + +// ---------------------------------------------------------------------------- +// FUNCTIONS - Standard C + +int abs( int i ); +long long llabs( long long i ); +long labs( long i ); + +div_t div( int numer, int denom ); +lldiv_t lldiv( long long numer, long long denom ); +ldiv_t ldiv( long numer, long denom ); + +int rand( void ); +void srand( unsigned int seed ); + +double atof( const char * s ); +int atoi( const char * s ); +long atol( const char * s ); +long long atoll( const char * s); + +double strtod( const char * restrict s, char * * restrict endptr ); +float strtof( const char * restrict s, char * * restrict endptr ); +long double strtold( const char * restrict s, char * * restrict endptr ); + +long long strtoll( const char * restrict s, char * * restrict endptr, int base ); +unsigned long long strtoull( const char * restrict s, char * * restrict endptr, int base); + +long strtol( const char * restrict s, char * * restrict endptr, int base ); +unsigned long strtoul( const char * restrict s, char * * restrict endptr, int base); + +void * calloc( size_t nelem, size_t size ); +void free( void * ptr ); +void * malloc( size_t size ); +void * realloc( void * ptr, size_t size ); + +int mblen( const char * s, size_t n ); +size_t mbstowcs( wchar_t * restrict wcs, const char * restrict s, size_t n ); +int mbtowc( wchar_t * restrict pwc, const char * restrict s, size_t n ); +size_t wcstombs( char * restrict s, const wchar_t * restrict wcs, size_t n ); +int wctomb( char * s, wchar_t wchar ); + +void _Exit( int status ); +void exit( int status ); +void abort( void ); +char * getenv( const char * name ); +int system( const char * s ); + +#ifndef __cplusplus + +int atexit( void (*func) ( void ) ); +void * bsearch( const void * key, const void * base, size_t nelem, size_t size, + int (*cmp) ( const void * ck, const void * ce) ); +void qsort( void * base, size_t nelem, size_t size, + int (*cmp) ( const void * e1, const void * e2) ); + +#endif // __cplusplus #endif // __STDLIB_H diff --git a/includes/string.h b/includes/string.h index 9528577..2fa5284 100644 --- a/includes/string.h +++ b/includes/string.h @@ -4,12 +4,64 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// Provides functions for handling C strings ('\0' terminated char arrays). +// String handling // ---------------------------------------------------------------------------- #ifndef __STRING_H #define __STRING_H __STRING_H -// TODO +// ---------------------------------------------------------------------------- +// MACROS + +#define NULL 0 + +// ---------------------------------------------------------------------------- +// TYPEDEFS + +typedef size_t; + +// ---------------------------------------------------------------------------- +// FUNCTIONS + +int memcmp( const void * s1, const void * s2, size_t n ); +void * memcpy( void * restrict s1, const void * restrict s2, size_t n ); +void * memmove( void * s1, const void * s2, size_t n ); +void * memset( void * s, int c, size_t n ); +char * strcat( char * restrict s1, const char * restrict s2 ); +int strcmp( const char * s1, const char * s2 ); +int strcoll( const char * s1, const char * s2 ); +char * strcpy( char * restrict s1, const char * restrict s2 ); +size_t strcspn( const char * s1, const char * s2 ); +char * strerror( int errcode ); +size_t strlen( const char * s ); +char * strncat( char * restrict s1, const char * restrict s2, size_t n ); +int strncmp( const char * s1, const char * s2, size_t n ); +char * strncpy( char * restrict s1, const char * restrict s2, size_t n ); +size_t strspn( const char * s1, const char * s2 ); +char * strtok( char * restrict s1, const char * restrict s2 ); +size_t strxfrm( char * restrict s1, const char * restrict s2, size_t n ); + +#ifdef __cplusplus + +const void * memchr( const void * s, int c, size_t n ); +void * memchr( void * s, int c, size_t n ); +const char * strchr( const char * s, int c ); +char * strchr( char * s, int c ); +const char * strpbrk( const char * s1, const char * s2 ); +char * strpbrk( char * s1, const char * s2 ); +const char * strrchr( const char * s, int c ); +char * strrchr( char * s, int c ); +const char * strstr( const char * s1, const char * s2 ); +char * strstr( char * s1, const char * s2 ); + +#else + +void * memchr( const void * s, int c, size_t n ); +char * strchr( const char * s, int c ); +char * strpbrk( const char *s1, const char * s2 ); +char * strrchr( const char * s, int c ); +char * strstr( const char * s1, const char * s2 ); + +#endif // __cplusplus #endif // __STRING_H diff --git a/includes/tgmath.h b/includes/tgmath.h index 976715b..c356272 100644 --- a/includes/tgmath.h +++ b/includes/tgmath.h @@ -4,12 +4,374 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// TODO +// Type-generic math // ---------------------------------------------------------------------------- #ifndef __TGMATH_H #define __TGMATH_H __TGMATH_H +// These functions return the sine of their parameter. +double sin(double value); +float sin(float value); +long double sin(long double value); +double _Complex sin(double _Complex value); +float _Complex sin(float _Complex value); +long double _Complex sin(long double _Complex value); + +// These functions return the hyperbolic sine of their parameter. +double sinh(double value); +float sinh(float value); +long double sinh(long double value); +double _Complex sinh(double _Complex value); +float _Complex sinh(float _Complex value); +long double _Complex sinh(long double _Complex value); + +// These functions return the arcsine of their parameter. +double asin(double value); +float asin(float value); +long double asin(long double value); +double _Complex asin(double _Complex value); +float _Complex asin(float _Complex value); +long double _Complex asin(long double _Complex value); + +// These functions return the hyperbolic arcsine of their parameter. +double asinh(double value); +float asinh(float value); +long double asinh(long double value); +double _Complex asinh(double _Complex value); +float _Complex asinh(float _Complex value); +long double _Complex asinh(long double _Complex value); + +// These functions return the cosine of their parameter. +double cos(double value); +float cos(float value); +long double cos(long double value); +double _Complex cos(double _Complex value); +float _Complex cos(float _Complex value); +long double _Complex cos(long double _Complex value); + +// These functions return the hyperbolic cosine of their parameter. +double cosh(double value); +float cosh(float value); +long double cosh(long double value); +double _Complex cosh(double _Complex value); +float _Complex cosh(float _Complex value); +long double _Complex cosh(long double _Complex value); + +// These functions return the arccosine of their parameter. +double acos(double value); +float acos(float value); +long double acos(long double value); +double _Complex acos(double _Complex value); +float _Complex acos(float _Complex value); +long double _Complex acos(long double _Complex value); + +// These functions return the hyperbolic arccosine of their parameter. +double acosh(double value); +float acosh(float value); +long double acosh(long double value); +double _Complex acosh(double _Complex value); +float _Complex acosh(float _Complex value); +long double _Complex acosh(long double _Complex value); + +// These functions return the tangent of their parameter. +double tan(double value); +float tan(float value); +long double tan(long double value); +double _Complex tan(double _Complex value); +float _Complex tan(float _Complex value); +long double _Complex tan(long double _Complex value); + +// These functions return the hyperbolic tangent of their parameter. +double tanh(double value); +float tanh(float value); +long double tanh(long double value); +double _Complex tanh(double _Complex value); +float _Complex tanh(float _Complex value); +long double _Complex tanh(long double _Complex value); + +// These functions return the arctangent of their parameter. +double atan(double value); +float atan(float value); +long double atan(long double value); +double _Complex atan(double _Complex value); +float _Complex atan(float _Complex value); +long double _Complex atan(long double _Complex value); + +// These functions return the hyperbolic arctangent of their parameter. +double atanh(double value); +float atanh(float value); +long double atanh(long double value); +double _Complex atanh(double _Complex value); +float _Complex atanh(float _Complex value); +long double _Complex atanh(long double _Complex value); + +// These functions return the angle whose tangent is x / y. +double atan2(double x, double y); +float atan2(float x, float y); +long double atan2(long double x, long double y); + +// These functions return the phase angle of their parameter. +double carg(double _Complex value); +float carg(float _Complex value); +long double carg(long double _Complex value); + +// These functions return the largest integer no larger than their parameter. +double floor(double value); +float floor(float value); +long double floor(long double value); + +// These functions return the smallest integer not less than their parameter. +double ceil(double value); +float ceil(float value); +long double ceil(long double value); + +// These functions return the square root of their parameter. +double sqrt(double value); +float sqrt(float value); +long double sqrt(long double value); +double _Complex sqrt(double _Complex value); +float _Complex sqrt(float _Complex value); +long double _Complex sqrt(long double _Complex value); + +// These functions return the cube root of their parameter. +double cbrt(double value); +float cbrt(float value); +long double cbrt(long double value); + +// These functions return the imaginary part of their parameter. +double cimag(double _Complex value); +float cimag(float _Complex value); +long double cimag(long double _Complex value); + +// These functions return the real value of their parameter. +double creal(double _Complex value); +float creal(float _Complex value); +long double creal(long double _Complex value); + +// These functions return the conjugate of their parameter. +double _Complex conj(double _Complex value); +float _Complex conj(float _Complex value); +long double _Complex conj(long double _Complex value); + +// These functions return their parameter x with the sign of y. +double copysign(double x, double y); +float copysign(float x, float y); +long double copysign(long double x, long double y); + +// These functions return the projection of their parameter. +double _Complex cproj(double _Complex value); +float _Complex cproj(float _Complex value); +long double _Complex cproj(long double _Complex value); + +// These functions return the error function of their parameter. +double erf(double value); +float erf(float value); +long double erf(long double value); + +// These functions return the complementary error function of their parameter. +double erfc(double value); +float erfc(float value); +long double erfc(long double value); + +// These functions return the exponential of their parameter (e^x). +double exp(double value); +float exp(float value); +long double exp(long double value); +double _Complex exp(double _Complex value); +float _Complex exp(float _Complex value); +long double _Complex exp(long double _Complex value); + +// These functions return 2 raised to the power of their parameter (2^x). +double exp2(double value); +float exp2(float value); +long double exp2(long double value); + +// These functions return exp(value) - 1. +double expm1(double value); +float expm1(float value); +long double expm1(long double value); + +// These functions return the magnitude of their parameter. +double fabs(double value); +float fabs(float value); +long double fabs(long double value); +double fabs(double _Complex value); +float fabs(float _Complex value); +long double fabs(long double _Complex value); + +// These functions return the larger of (x-y) and zero. +double fdim(double x, double y); +float fdim(float x, float y); +long double fdim(long double x, long double y); + +// These functions return (x * y + z) to arbitrary intermediate precision. +double fma(double x, double y, double z); +float fma(float x, float y, float z); +long double fma(long double x, long double y, long double z); + +// These functions return the larger of their parameters. +double fmax(double x, double y); +float fmax(float x, float y); +long double fmax(long double x, long double y); + +// These functions return the smaller of their parameters. +double fmin(double x, double y); +float fmin(float x, float y); +long double fmin(long double x, long double y); + +// These functions return the remainder of (x/y). +double fmod(double x, double y); +float fmod(float x, float y); +long double fmod(long double x, long double y); + +// These functions return a fraction (as return value) and an integer +// exponent (in the parameter 'exponent') that represent value, with the +// fraction being in the interval [0.5, 1) or being zero. If value is zero, +// exponent will also be zero. +// (fraction * 2^exponent) == value) +double frexp(double value, int * exponent); +float frexp(float value, int * exponent); +long double frexp(long double value, int * exponent); + +// These functions return x raised to the power of y. +double pow(double x, double y); +float pow(float x, float y); +long double pow(long double x, long double y); +double _Complex pow(double _Complex x, double _Complex y); +float _Complex pow(float _Complex x, float _Complex y); +long double _Complex pow(long double _Complex x, long double _Complex y); + +// TODO: Check spelling of hypothenuse and cathedes. +// These functions determine the length of the hypothenuse for the cathedes +// x and y. (Square root of a^2 + b^2.) +double hypot(double a, double b); +float hypot(float a, float b); +long double hypot(long double a, long double b); + +// These functions return (int) logb(value). +int ilogb(double value); +int ilogb(float value); +int ilogb(long double value); + +// These functions return (value * 2^exponent). +double ldexp(double value, int exponent); +float ldexp(float value, int exponent); +long double ldexp(long double value, int exponent); + +// These functions return the natural logarithm of their parameter. +double log(double value); +float log(float value); +long double log(long double value); +double _Complex log(double _Complex value); +float _Complex log(float _Complex value); +long double _Complex log(long double _Complex value); + +// These functions return the logarithm (base 10) of their parameter. +double log10(double value); +float log10(float value); +long double log10(long double value); + +// These functions return the natural logarithm of (their parameter + 1). +double log1p(double value); +float log1p(float value); +long double log1p(long double value); + +// These functions return the logarithm (base 2) of their parameter. +double log2(double value); +float log2(float value); +long double log2(long double value); + +// TODO: What do these functions actually do? +double logb(double value); +float logb(float value); +long double logb(long double value); + +// These functions return their parameter rounded to the next integer, using +// the current rounding mode. +long long llrint(double value); +long long llrint(float value); +long long llrint(long double value); +long lrint(double value); +long lrint(float value); +long lrint(long double value); +double rint(double value); +float rint(float value); +long double rint(long double value); + +// These functions return their parameter rounded to the next integer, with +// halfway values rounded away from zero regardless of current rounding mode. +long long llround(double value); +long long llround(float value); +long long llround(long double value); +long lround(double value); +long lround(float value); +long lround(long double value); +// TODO: Do the round() functions really return FP values? +double round(double value); +float round(float value); +long double round(long double value); + +// These functions return their parameter, rounded toward zero. +// TODO: Do these functions really return FP values? +double trunc(double value); +float trunc(float value); +long double trunc(long double value); + +// These functions store the integer part of value in integer, and return the +// remaining part of value. +double modf(double value, double * integer); +float modf(float value, float * integer); +long double modf(long double value, long double * integer); + +// These functions return their parameter rounded to the next integer, using +// the current rounding mode but without raising an inexact FP exception. +double nearbyint(double value); +float nearbyint(float value); +long double nearbyint(long double value); + +// These functions return the next representable value after the smaller of +// their parameters. +// TODO: This might be a wrong description. +double nextafter(double x, double y); +float nextafter(float x, float y); +long double nextafter(long double x, long double y); + +// These functions return the next representable value after the smaller of +// their parameters. +// TODO: This might be a wrong description. +double nexttoward(double x, long double y); +float nexttoward(float x, long double y); +long double nexttoward(long double x, long double y); + // TODO +double remainder(double x, double y); +float remainder(float x, float y); +long double remainder(long double x, long double y); + +// TODO +double remquo(double x, double y, int * pquo); +float remquo(float x, float y, int * pquo); +long double remquo(long double x, long double y, int * pquo); + +// TODO +double scalbln(double x, long ex); +float scalbln(float x, long ex); +long double scalbln(long double x, long ex); + +// TODO +double scalbn(double x, int ex); +float scalbn(float x, int ex); +long double scalbn(long double x, int ex); + +// These functions return the gamma function of their parameter. +double tgamma(double value); +float tgamma(float value); +long double tgamma(long double value); + +// These functions return log( fabs( tgamma(value) ) ). +double lgamma(double value); +float lgamma(float value); +long double lgamma(long double value); #endif // __TGMATH_H diff --git a/includes/time.h b/includes/time.h index aeda70f..db2eb7c 100644 --- a/includes/time.h +++ b/includes/time.h @@ -4,12 +4,38 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// Provides a time datatype and time handling functions. +// Date and time // ---------------------------------------------------------------------------- #ifndef __TIME_H #define __TIME_H __TIME_H -// TODO +// ---------------------------------------------------------------------------- +// MACROS + +#define CLOCKS_PER_SEC // TODO +#define NULL 0 + +// ---------------------------------------------------------------------------- +// TYPES + +typedef clock_t; +typedef size_t; +typedef time_t; +struct tm; + +// ---------------------------------------------------------------------------- +// FUNCTIONS + +char * asctime( const struct tm * tptr ); +clock_t clock( void ); +char * ctime( const time_t * tod ); +double difftime( time_t t1, time_t t0 ); +struct tm * gmtime( const time_t * tod ); +struct tm * localtime( const time_t * tod ); +time_t mktime( struct tm * tptr ); +size_t strftime( char * restrict s, size_t n, const char * restrict format, + const struct tm * restrict tptr ); +time_t time( time_t * tod ); #endif // __TIME_H diff --git a/includes/wchar.h b/includes/wchar.h index 1b4142b..4ac64c5 100644 --- a/includes/wchar.h +++ b/includes/wchar.h @@ -4,12 +4,116 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// TODO +// Extended multibyte and wide character utilities // ---------------------------------------------------------------------------- #ifndef __WCHAR_H #define __WCHAR_H __WCHAR_H -// TODO +// ---------------------------------------------------------------------------- +// MACROS + +#define NULL 0 +#define WCHAR_MAX // TODO +#define WCHAR_MIN // TODO +#define WEOF // TODO + +// ---------------------------------------------------------------------------- +// TYPEDEFS + +typedef mbstate_t; +typedef size_t; +typedef wint_t; +struct tm; + +#ifndef __cplusplus +typedef wchar_t; +#endif // __cplusplus + +// ---------------------------------------------------------------------------- +// FUNCTIONS + +wint_t fgetwc( FILE * stream ); +wchar_t * fgetws( wchar_t * restrict s, int n, FILE * restrict stream ); +wint_t fputwc( wchar_t c, FILE * stream ); +int fputws( const wchar_t * restrict s, FILE * restrict stream ); +int fwide( FILE * stream, int mode ); +wint_t getwc( FILE * stream ); +wint_t getwchar( void ); +wint_t putwc( wchar_t c, FILE * stream ); +wint_t putwchar( wchar_t c ); +wint_t ungetwc( wint_t c, FILE * stream ); + +int fwscanf( FILE * restrict stream, const wchar_t * restrict format, ... ); +int swscanf( const wchar_t * restrict s, const wchar_t * restrict format, ... ); +int wscanf( const wchar_t * restrict format, ... ); +int fwprintf( FILE * restrict stream, const wchar_t * restrict format, ... ); +int swprintf( wchar_t * restrict s, size_t n, const wchar_t * restrict format, ... ); +int wprintf( const wchar_t * restrict format, ... ); +int vfwscanf( FILE * restrict stream, const wchar_t * restrict format, va_list arg ); +int vswscanf( const wchar_t * restrict s, size_t n, const wchar_t * restrict format, va_list arg ); +int vwscanf( const wchar_t * restrict format, va_list arg ); +int vfwprintf( FILE * restrict stream, const wchar_t * restrict format, va_list arg ); +int vswprintf( wchar_t * restrict s, size_t n, const wchar_t * restrict format, va_list arg ); +int vwprintf( const wchar_t * restrict format, va_list arg ); + +size_t wcsftime( wchar_t * restrict s, size_t maxsize, const wchar_t * restrict format, const struct tm * restrict timeptr ); + +wint_t btowc( int c ); +size_t mbrlen( const char * restrict s, size_t n, mbstate_t * restrict ps ); +size_t mbrtowc( wchar_t * restrict pwc, const char * restrict s, size_t n, mbstate_t * restrict ps ); +int mbsinit( const mbstate_t * ps ); +size_t mbsrtowcs( wchar_t * restrict dst, const char * * restrict src, size_t len, mbstate_t * restrict ps ); +size_t wcrtomb( char * restrict s, wchar_t wc, mbstate_t * restrict ps ); +size_t wcsrtombs(char * restrict dst, const wchar_t * * restrict src, size_t len, mbstate_t * restrict ps ); +double wcstod( const wchar_t * restrict nptr, wchar_t * * restrict endptr ); +float wcstof( const wchar_t * restrict nptr, wchar_t * * restrict endptr); +long double wcstold( const wchar_t * restrict nptr, wchar_t * * restrict endptr); +long long wcstoll( const wchar_t * restrict nptr, wchar_t * * restrict endptr, int base ); +unsigned long long wcstoull( const wchar_t * restrict nptr, wchar_t * * restrict endptr, int base ); +long wcstol( const wchar_t * restrict nptr, wchar_t * * restrict endptr, int base ); +unsigned long wcstoul( const wchar_t * restrict nptr, wchar_t * * restrict endptr, int base ); +int wctob( wint_t c ); + +wchar_t * wcscat( wchar_t * restrict s1, const wchar_t * restrict s2); +int wcscmp( const wchar_t * s1, const wchar_t * s2 ); +int wcscoll( const wchar_t * s1, const wchar_t * s2 ); +wchar_t * wcscpy( wchar_t * restrict s1, const wchar_t * restrict s2 ); +size_t wcscspn( const wchar_t * s1, const wchar_t * s2 ); +size_t wcslen( const wchar_t * s ); +wchar_t * wcsncat( wchar_t * restrict s1, const wchar_t * restrict s2, size_t n ); +int wcsncmp( const wchar_t * s1, const wchar_t * s2, size_t n ); +wchar_t * wcsncpy( wchar_t * restrict s1, const wchar_t * restrict s2, size_t n ); +size_t wcsspn( const wchar_t * s1, const wchar_t * s2 ); +wchar_t * wcsstr( const wchar_t * s1, const wchar_t * s2 ); +wchar_t * wcstok( wchar_t * restrict s1, const wchar_t * restrict s2, wchar_t * * restrict ptr ); +size_t wcsxfrm( wchar_t * restrict s1, const wchar_t * restrict s2, size_t n ); +int wmemcmp( const wchar_t * s1, const wchar_t * s2, size_t n ); +wchar_t * wmemcpy( wchar_t * restrict s1, const wchar_t * restrict s2, size_t n ); +wchar_t * wmemmove( wchar_t * s1, const wchar_t * s2, size_t n ); +wchar_t * wmemset( wchar_t * s, wchar_t c, size_t n ); + +#ifdef __cplusplus + +const wchar_t * wcschr( const wchar_t * s, wchar_t c ); +wchar_t * wcschr( wchar_t * s, wchar_t c ); +const wchar_t * wcspbrk( const wchar_t * s1, const wchar_t * s2 ); +wchar_t * wcspbrk( wchar_t * s1, const wchar_t * s2 ); +const wchar_t * wcsrchr( const wchar_t * s, wchar_t c ); +wchar_t * wcsrchr( wchar_t * s, wchar_t c ); +const wchar_t * wcsstr( const wchar_t * s1, const wchar_t * s2 ); +wchar_t * wcsstr( wchar_t * s1, const wchar_t * s2 ); +const wchar_t * wmemchr( const wchar_t * s, wchar_t c, size_t n ); +wchar_t * wmemchr( wchar_t * s, wchar_t c, size_t n ); + +#else + +wchar_t * wcschr( const wchar_t * s, wchar_t c ); +wchar_t * wcspbrk( const wchar_t * s1, const wchar_t * s2 ); +wchar_t * wcsrchr( const wchar_t * s, wchar_t c ); +wchar_t * wcsstr( const wchar_t * s1, const wchar_t * s2 ); +wchar_t * wmemchr( const wchar_t * s, wchar_t c, size_t n); + +#endif // __cplusplus #endif // __WCHAR_H diff --git a/includes/wctype.h b/includes/wctype.h index 9db5694..32485b9 100644 --- a/includes/wctype.h +++ b/includes/wctype.h @@ -4,12 +4,41 @@ // Public Domain C Library - http://pdclib.sourceforge.net // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// Provides a wchar_t equivalent to ctype.h. +// Wide character classification and mapping utilities // ---------------------------------------------------------------------------- #ifndef __WCTYPE_H #define __WCTYPE_H __WCTYPE_H -// TODO +// ---------------------------------------------------------------------------- +// TYPEDEFS + +typedef wctrans_t; +typedef wctype_t; +typedef wint_t; + +// ---------------------------------------------------------------------------- +// FUNCTIONS + +int iswalnum( wint_t c ); +int iswalpha( wint_t c ); +int iswblank( wint_t c ); +int iswcntrl( wint_t c ); +int iswctype( wint_t c, wctype_t category ); +int iswdigit( wint_t c ); +int iswgraph( wint_t c ); +int iswlower( wint_t c ); +int iswprint( wint_t c ); +int iswpunct( wint_t c ); +int iswspace( wint_t c ); +int iswupper( wint_t c ); +int iswxdigit( wint_t c ); + +wint_t towctrans( wint_t c, wctrans_t category ); +wint_t towlower( wint_t c ); +wint_t towupper( wint_t c ); + +wctrans_t wctrans( const char * property ); +wctype_t wctype( const char * property ); #endif // __WCTYPE_H -- 2.40.0