- Timestamp:
- Aug 5, 2023, 1:08:10 PM (17 months ago)
- Branches:
- master
- Children:
- 6d5790d
- Parents:
- 419985c
- Location:
- libcfa/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/common.hfa
r419985c r76acb60 10 10 // Created On : Wed Jul 11 17:54:36 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 5 1 1:52:08202313 // Update Count : 2612 // Last Modified On : Sat Aug 5 13:05:27 2023 13 // Update Count : 32 14 14 // 15 15 … … 17 17 18 18 // TEMPORARY 19 #define Exception( name ) exception name{}; staticvtable( name ) name ## _vt19 #define Exception( name ) exception name{}; vtable( name ) name ## _vt 20 20 #define Throw( name ) throw (name){ &name ## _vt } 21 21 -
libcfa/src/stdlib.cfa
r419985c r76acb60 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 16 16:31:34202313 // Update Count : 63 312 // Last Modified On : Sat Aug 5 11:53:43 2023 13 // Update Count : 637 14 14 // 15 15 … … 65 65 //--------------------------------------- 66 66 67 float _Complex strto( const char sptr[], char ** eptr ) { 67 static vtable(out_of_range) out_of_range_vt; 68 static vtable(invalid_argument) invalid_argument_vt; 69 70 forall( T | { T strto( const char sptr[], char * eptr[], int ); } ) 71 T convert( const char sptr[] ) { 72 char * eptr; 73 errno = 0; // reset 74 T val = strto( sptr, &eptr, 10 ); // attempt conversion 75 if ( errno == ERANGE ) Throw( out_of_range ); 76 if ( eptr == sptr || // conversion failed, no characters generated 77 *eptr != '\0' ) Throw( invalid_argument ); // not at end of str ? 78 return val; 79 } // convert 80 81 float _Complex strto( const char sptr[], char * eptr[] ) { 68 82 float re, im; 69 83 char * eeptr; … … 76 90 } // strto 77 91 78 double _Complex strto( const char sptr[], char * * eptr) {92 double _Complex strto( const char sptr[], char * eptr[] ) { 79 93 double re, im; 80 94 char * eeptr; … … 87 101 } // strto 88 102 89 long double _Complex strto( const char sptr[], char * * eptr) {103 long double _Complex strto( const char sptr[], char * eptr[] ) { 90 104 long double re, im; 91 105 char * eeptr; -
libcfa/src/stdlib.hfa
r419985c r76acb60 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 11:30:04202313 // Update Count : 7 6612 // Last Modified On : Sat Aug 5 11:53:42 2023 13 // Update Count : 774 14 14 // 15 15 … … 22 22 #include <stdlib.h> // *alloc, strto*, ato* 23 23 #include <heap.hfa> 24 24 #include <errno.h> 25 25 26 26 // Reduce includes by explicitly defining these routines. … … 294 294 295 295 static inline { 296 int strto( const char sptr[], char ** eptr, int base ) { return (int)strtol( sptr, eptr, base ); } 297 unsigned int strto( const char sptr[], char ** eptr, int base ) { return (unsigned int)strtoul( sptr, eptr, base ); } 298 long int strto( const char sptr[], char ** eptr, int base ) { return strtol( sptr, eptr, base ); } 299 unsigned long int strto( const char sptr[], char ** eptr, int base ) { return strtoul( sptr, eptr, base ); } 300 long long int strto( const char sptr[], char ** eptr, int base ) { return strtoll( sptr, eptr, base ); } 301 unsigned long long int strto( const char sptr[], char ** eptr, int base ) { return strtoull( sptr, eptr, base ); } 302 303 float strto( const char sptr[], char ** eptr ) { return strtof( sptr, eptr ); } 304 double strto( const char sptr[], char ** eptr ) { return strtod( sptr, eptr ); } 305 long double strto( const char sptr[], char ** eptr ) { return strtold( sptr, eptr ); } 306 } // distribution 307 308 float _Complex strto( const char sptr[], char ** eptr ); 309 double _Complex strto( const char sptr[], char ** eptr ); 310 long double _Complex strto( const char sptr[], char ** eptr ); 296 int strto( const char sptr[], char * eptr[], int base ) { return (int)strtol( sptr, eptr, base ); } 297 unsigned int strto( const char sptr[], char * eptr[], int base ) { return (unsigned int)strtoul( sptr, eptr, base ); } 298 long int strto( const char sptr[], char * eptr[], int base ) { return strtol( sptr, eptr, base ); } 299 unsigned long int strto( const char sptr[], char * eptr[], int base ) { return strtoul( sptr, eptr, base ); } 300 long long int strto( const char sptr[], char * eptr[], int base ) { return strtoll( sptr, eptr, base ); } 301 unsigned long long int strto( const char sptr[], char * eptr[], int base ) { return strtoull( sptr, eptr, base ); } 302 303 float strto( const char sptr[], char * eptr[] ) { return strtof( sptr, eptr ); } 304 double strto( const char sptr[], char * eptr[] ) { return strtod( sptr, eptr ); } 305 long double strto( const char sptr[], char * eptr[] ) { return strtold( sptr, eptr ); } 306 } // distribution 307 308 float _Complex strto( const char sptr[], char * eptr[] ); 309 double _Complex strto( const char sptr[], char * eptr[] ); 310 long double _Complex strto( const char sptr[], char * eptr[] ); 311 312 exception out_of_range {}; 313 exception invalid_argument {}; 314 315 forall( T | { T strto( const char sptr[], char * eptr[], int ); } ) 316 T convert( const char sptr[] ); 311 317 312 318 static inline {
Note: See TracChangeset
for help on using the changeset viewer.