Changeset 22
- Timestamp:
- Nov 1, 2014, 3:02:00 AM (11 years ago)
- Location:
- rxutilex/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
rxutilex/trunk/FUNCTIONS
r21 r22 154 154 Formats a number to use thousands-grouping characters. The system values 155 155 for the current locale are used for the thousands-grouping character and 156 the decimal place, if any. Note that the IBM C runtime's built-in locale156 the decimal place, if any. Note that the IBM C runtime's locale 157 157 definitions are used; these may not correspond precisely to the system 158 158 locales as defined in the OS/2 Locale object. … … 176 176 177 177 Converts a number of seconds from the epoch (1970-01-01 0:00:00 UTC) into 178 a formatted date and time string. 178 a formatted date and time string. 179 179 180 180 REXX ARGUMENTS: -
rxutilex/trunk/rxutilex.c
r21 r22 60 60 #define INCL_RXFUNC 61 61 #include <rexxsaa.h> 62 #include <nl_types.h> 63 #include <langinfo.h> 62 64 63 65 #pragma import( DosGetPrty, "DosGetPrty", "DOSCALL1", 9 ) … … 73 75 #define SZ_LIBRARY_NAME "RXUTILEX" // Name of this library 74 76 #define SZ_ERROR_NAME "SYS2ERR" // REXX variable used to store error codes 75 #define SZ_VERSION "0.1. 0" // Current version of this library77 #define SZ_VERSION "0.1.1" // Current version of this library 76 78 77 79 // Maximum string lengths... … … 923 925 { 924 926 CHAR achNumber[ US_NUMSTR_MAXZ ]; // Formatted output string 925 PSZ pszTZ, // Pointer to TZ environment var 926 pszSetTZ; 927 PSZ pszSep = NULL; 927 928 float fVal; 928 929 int iVal; … … 932 933 if ( argc < 1 || ( !RXVALIDSTRING(argv[0]) )) return ( 40 ); 933 934 934 935 /* These next 4 lines really shouldn't be necessary, but without them 936 * getenv() and (apparently) tzset() may see the value of TZ as NULL 937 * if the environment variable was changed in the REXX script. 938 */ 939 DosScanEnv("TZ", &pszTZ ); 940 pszSetTZ = (PSZ) malloc( strlen( pszTZ ) + 5 ); 941 if ( pszSetTZ ) { 942 sprintf( pszSetTZ, "TZ=%s", pszTZ ); 943 putenv( pszSetTZ ); 944 } 945 946 // Use the locale and timezone settings from the environment 947 tzset(); 948 setlocale( LC_ALL, ""); 935 // Use the locale settings from the environment 936 pszSep = nl_langinfo( THOUSEP ); 937 if ( !pszSep || !strlen(pszSep) ) { 938 /* If the current locale isn't known to the C runtime, use a common 939 * known locale for the same language, if possible. 940 */ 941 PSZ pszLang, p; 942 if (( DosScanEnv("LANG", &pszLang ) == NO_ERROR ) && 943 pszLang && ( strlen( pszLang ) >= 2 )) 944 { 945 p = strdup( pszLang ); 946 if ( !strnicmp( p, "en_us", 2 )) setlocale( LC_NUMERIC, "EN_US"); 947 else if ( !strnicmp( p, "en_uk", 2 )) setlocale( LC_NUMERIC, "EN_GB"); 948 else if ( !strnicmp( p, "de", 2 )) setlocale( LC_NUMERIC, "DE_DE"); 949 else if ( !strnicmp( p, "es", 2 )) setlocale( LC_NUMERIC, "ES_ES"); 950 else if ( !strnicmp( p, "fr", 2 )) setlocale( LC_NUMERIC, "FR_FR"); 951 else if ( !strnicmp( p, "it", 2 )) setlocale( LC_NUMERIC, "IT_IT"); 952 else if ( !strnicmp( p, "ja", 2 )) setlocale( LC_NUMERIC, "JA_JP"); 953 /* 954 else if ( !strnicmp( p, "ar", 2 )) setlocale( LC_NUMERIC, "ar_AA"); 955 else if ( !strnicmp( p, "be", 2 )) setlocale( LC_NUMERIC, "be_BY"); 956 else if ( !strnicmp( p, "bg", 2 )) setlocale( LC_NUMERIC, "bg_BG"); 957 else if ( !strnicmp( p, "be", 2 )) setlocale( LC_NUMERIC, "be_BY"); 958 else if ( !strnicmp( p, "ca", 2 )) setlocale( LC_NUMERIC, "ca_ES"); 959 else if ( !strnicmp( p, "cs", 2 )) setlocale( LC_NUMERIC, "cs_CZ"); 960 else if ( !strnicmp( p, "da", 2 )) setlocale( LC_NUMERIC, "da_DK"); 961 else if ( !strnicmp( p, "de", 2 )) setlocale( LC_NUMERIC, "de_DE"); 962 else if ( !strnicmp( p, "el", 2 )) setlocale( LC_NUMERIC, "el_GR"); 963 else if ( !strnicmp( p, "es", 2 )) setlocale( LC_NUMERIC, "es_ES"); 964 else if ( !strnicmp( p, "fi", 2 )) setlocale( LC_NUMERIC, "fi_FI"); 965 else if ( !strnicmp( p, "fr", 2 )) setlocale( LC_NUMERIC, "fr_FR"); 966 else if ( !strnicmp( p, "hr", 2 )) setlocale( LC_NUMERIC, "hr_HR"); 967 else if ( !strnicmp( p, "hu", 2 )) setlocale( LC_NUMERIC, "hu_HU"); 968 else if ( !strnicmp( p, "is", 2 )) setlocale( LC_NUMERIC, "is_IS"); 969 else if ( !strnicmp( p, "it", 2 )) setlocale( LC_NUMERIC, "it_IT"); 970 else if ( !strnicmp( p, "iw", 2 )) setlocale( LC_NUMERIC, "iw_IL"); 971 else if ( !strnicmp( p, "ja", 2 )) setlocale( LC_NUMERIC, "ja_JP"); 972 else if ( !strnicmp( p, "ko", 2 )) setlocale( LC_NUMERIC, "ko_KR"); 973 else if ( !strnicmp( p, "mk", 2 )) setlocale( LC_NUMERIC, "mk_MK"); 974 else if ( !strnicmp( p, "nl", 2 )) setlocale( LC_NUMERIC, "nl_NL"); 975 else if ( !strnicmp( p, "no", 2 )) setlocale( LC_NUMERIC, "no_NO"); 976 else if ( !strnicmp( p, "pl", 2 )) setlocale( LC_NUMERIC, "pl_PL"); 977 else if ( !strnicmp( p, "pt", 2 )) setlocale( LC_NUMERIC, "pt_PT"); 978 else if ( !strnicmp( p, "ro", 2 )) setlocale( LC_NUMERIC, "ro_RO"); 979 else if ( !strnicmp( p, "ru", 2 )) setlocale( LC_NUMERIC, "ru_RU"); 980 else if ( !strnicmp( p, "sh", 2 )) setlocale( LC_NUMERIC, "sh_SP"); 981 else if ( !strnicmp( p, "sk", 2 )) setlocale( LC_NUMERIC, "sk_SK"); 982 else if ( !strnicmp( p, "sl", 2 )) setlocale( LC_NUMERIC, "sl_SI"); 983 else if ( !strnicmp( p, "sq", 2 )) setlocale( LC_NUMERIC, "sq_AL"); 984 else if ( !strnicmp( p, "sv", 2 )) setlocale( LC_NUMERIC, "sv_SE"); 985 else if ( !strnicmp( p, "th", 2 )) setlocale( LC_NUMERIC, "th_TH"); 986 else if ( !strnicmp( p, "tr", 2 )) setlocale( LC_NUMERIC, "tr_TR"); 987 else if ( !strnicmp( p, "uk", 2 )) setlocale( LC_NUMERIC, "uk_UA"); 988 else if ( !strnicmp( p, "zh", 2 )) setlocale( LC_NUMERIC, "zh_TW"); 989 */ 990 else setlocale( LC_NUMERIC, "EN_US"); 991 free(p); 992 } 993 else setlocale( LC_NUMERIC, "en_us"); 994 } 995 else setlocale( LC_NUMERIC, ""); 949 996 950 997 // Check for a decimal place and treat as float or integer accordingly … … 968 1015 MAKERXSTRING( *prsResult, achNumber, strlen( achNumber )); 969 1016 970 if ( pszSetTZ ) free( pszSetTZ );971 1017 return ( 0 ); 972 1018 } -
rxutilex/trunk/rxutilex.def
r21 r22 1 1 LIBRARY RXUTILEX INITINSTANCE TERMINSTANCE 2 2 DATA MULTIPLE NONSHARED 3 DESCRIPTION '@#Alex Taylor:0.1.0#@##1## 28 Oct 2014 20:00:26 REINFORCE::::::@@Extended REXX Utility Functions'3 DESCRIPTION '@#Alex Taylor:0.1.0#@##1## 31 Oct 2014 20:32:56 REINFORCE::::::@@Extended REXX Utility Functions' 4 4 5 5 EXPORTS Sys2LoadFuncs -
rxutilex/trunk/testlib.cmd
r21 r22 26 26 say 27 27 28 say 'Physical Memory:' Sys2 QueryPhysicalMemory() 'kB'28 say 'Physical Memory:' Sys2FormatNumber( Sys2QueryPhysicalMemory() ) 'kB' 29 29 say 30 30 31 31 et = Sys2GetEpochTime() 32 say 'Current calendar time is' et'seconds after the epoch.'32 say 'Current calendar time is' Sys2FormatNumber( et ) 'seconds after the epoch.' 33 33 say 'Current local time is "'Sys2FormatTime(et, 'l')'"' 34 34 say 'Current UTC time is "'Sys2FormatTime(et, 'l', 'u')'"' … … 37 37 say Sys2LocateDLL('ehxdlmri') 38 38 39 say Sys2FormatNumber('100')40 say Sys2FormatNumber('10000')41 say Sys2FormatNumber('5003.543', 1)42 43 39 call Sys2DropFuncs 44 40 return 0
Note:
See TracChangeset
for help on using the changeset viewer.