Changeset 23
- Timestamp:
- May 3, 2015, 3:37:31 PM (10 years ago)
- Location:
- rxutilex/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
rxutilex/trunk/rxutilex.c
r22 r23 39 39 // #define USE_DQPS 40 40 41 // Uncomment to use legacy C style locale data instead of the OS/2 ULS library 42 #define LEGACY_C_LOCALE 41 43 42 44 #define INCL_WINATOM … … 52 54 #include <os2.h> 53 55 #endif 54 #include <locale.h> 56 55 57 #include <stdio.h> 56 58 #include <stdlib.h> 57 59 #include <string.h> 58 60 #include <time.h> 61 62 #ifdef LEGACY_C_LOCALE 63 #include <locale.h> 64 #include <nl_types.h> 65 #include <langinfo.h> 66 #else 67 #include <unidef.h> 68 #endif 69 59 70 #define INCL_RXSHV 60 71 #define INCL_RXFUNC 61 72 #include <rexxsaa.h> 62 #include <nl_types.h>63 #include <langinfo.h>64 73 65 74 #pragma import( DosGetPrty, "DosGetPrty", "DOSCALL1", 9 ) … … 85 94 #define US_PIDSTR_MAXZ ( CCHMAXPATH + 100 ) // ...of a process information string 86 95 #define US_TIMESTR_MAXZ 256 // ...of a formatted time string 87 #define US_NUMSTR_MAXZ 256// ...of a formatted number string96 #define US_NUMSTR_MAXZ 64 // ...of a formatted number string 88 97 #define US_PIPESTATUS_MAXZ 128 // ...of a pipe status string 89 98 … … 641 650 QSPTRREC *pBuf; // Data returned by DosQProcStatus() 642 651 #else 643 QS GREC **pBuf; // Data returned by DosQuerySysState()652 QSPTRREC *pBuf; // Data returned by DosQuerySysState() // 2015-04-23 SHL 644 653 #endif 645 654 QSPREC *pPrec; // Pointer to process information block … … 673 682 pBuf = (QSPTRREC *) malloc( UL_SSBUFSIZE ); 674 683 #else 675 pBuf = (QS GREC **) malloc( UL_SSBUFSIZE );684 pBuf = (QSPTRREC *) malloc( UL_SSBUFSIZE ); // 2015-04-23 SHL 676 685 #endif 677 686 … … 690 699 return ( 0 ); 691 700 } 692 pPrec = pBuf->pProcRec; 701 pPrec = pBuf->pProcRec; // 2015-04-23 SHL 693 702 #else 694 703 // Get running process information using DosQuerySysState() … … 699 708 return ( 0 ); 700 709 } 701 pPrec = (QSPREC *) ( (PBYTE) (*pBuf) + sizeof(QSGREC) );710 pPrec = pBuf->pProcRec; 702 711 #endif 703 712 … … 916 925 * * 917 926 * REXX ARGUMENTS: * 918 * 1. Number to be formatted. (REQUIRED)*919 * 2. Number of decimal places to use for floating point values. Ignored*920 * for integer values. Defaults to 2 if not specified.*927 * 1. Number to be formatted. (REQUIRED) * 928 * 2. Number of decimal places to use for floating point * 929 * values. Ignored for integer values. (DEFAULT: 2) * 921 930 * * 922 931 * REXX RETURN VALUE: The formatted number, or '' on error. * … … 925 934 { 926 935 CHAR achNumber[ US_NUMSTR_MAXZ ]; // Formatted output string 927 PSZ pszSep = NULL; 928 float fVal; 929 int iVal; 930 int iPrec; 936 float fVal; // Input value as floating point 937 int iVal; // Input value as integer 938 int iPrec; // Requested decimal precision 939 PSZ pszSep = NULL; // Separator string 940 #ifndef LEGACY_C_LOCALE 941 CHAR achTemp[ US_NUMSTR_MAXZ ]; // Temporary buffer 942 LocaleObject locale = NULL; // ULS locale object 943 struct UniLconv *punilc = NULL; // ULS locale conventions structure 944 CHAR *p = NULL; // Moving pointers within buffers 945 CHAR *q = NULL; // ... 946 int rc = 0; 947 #endif 931 948 932 949 // Make sure we have at least one valid argument (the input number) 933 950 if ( argc < 1 || ( !RXVALIDSTRING(argv[0]) )) return ( 40 ); 951 952 #ifdef LEGACY_C_LOCALE 934 953 935 954 // Use the locale settings from the environment … … 1012 1031 } 1013 1032 1033 #else 1034 rc = UniCreateLocaleObject( UNI_MBS_STRING_POINTER, "", &locale ); 1035 if ( rc != ULS_SUCCESS ) { 1036 WriteErrorCode( rc, "UniCreateLocaleObject"); 1037 MAKERXSTRING( *prsResult, "", 0 ); 1038 return ( 0 ); 1039 } 1040 rc = UniQueryLocaleInfo(locale_object, &puni_lconv); 1041 if ( rc != ULS_SUCCESS ) { 1042 WriteErrorCode( rc, "UniQueryLocaleInfo"); 1043 MAKERXSTRING( *prsResult, "", 0 ); 1044 return ( 0 ); 1045 } 1046 1047 // Check for a decimal place and treat as float or integer accordingly 1048 if ( strchr( argv[0].strptr, '.') != NULL ) { 1049 if (( sscanf( argv[0].strptr, "%f", &fVal )) != 1 ) return ( 40 ); 1050 if ( argc >= 2 && ( RXVALIDSTRING(argv[1]) ) && 1051 (( sscanf( argv[1].strptr, "%d", &iPrec )) == 1 )) 1052 { 1053 // Use user-specified precision 1054 sprintf( achNumber, "%.*f", iPrec, fVal ); 1055 } 1056 else 1057 sprintf( achNumber, "%.2f", fVal ); 1058 } 1059 else { 1060 if (( sscanf( argv[0].strptr, "%d", &iVal )) != 1 ) return ( 40 ); 1061 sprintf( achNumber, "%d", iVal ); 1062 } 1063 1064 #endif 1065 1014 1066 // Return the formatted number 1015 1067 MAKERXSTRING( *prsResult, achNumber, strlen( achNumber )); … … 1340 1392 WriteErrorCode( 0, NULL ); 1341 1393 1342 // Parse the various time items1343 1394 if ( !(argc == 1 && RXVALIDSTRING(argv[0])) ) return ( 40 ); 1344 1395 … … 2073 2124 QSPTRREC *pBuf; // Data returned by DosQProcStatus() 2074 2125 #else 2075 QS GREC **pBuf; // Data returned by DosQuerySysState()2126 QSPTRREC *pBuf; // Data returned by DosQuerySysState() // 2015-04-23 SHL 2076 2127 #endif 2077 2128 QSPREC *pPrec; // Pointer to process information block … … 2102 2153 pBuf = (QSPTRREC *) malloc( UL_SSBUFSIZE ); 2103 2154 #else 2104 pBuf = (QS GREC **) malloc( UL_SSBUFSIZE );2155 pBuf = (QSPTRREC *) malloc( UL_SSBUFSIZE ); // 2015-04-23 SHL 2105 2156 #endif 2106 2157 … … 2125 2176 return ( rc ); 2126 2177 } 2127 pPrec = (QSPREC *) ( (PBYTE) (*pBuf) + sizeof(QSGREC) );2178 pPrec = (QSPREC *)(((QSPTRREC*)pBuf) -> pProcRec); // 2015-04-23 SHL 2128 2179 #endif 2129 2180 … … 2334 2385 ulRc = RexxVariablePool( &shvVar ); 2335 2386 if ( ulRc > 1 ) 2336 printf("Unable to set %s: rc = %d \n", shvVar.shvname.strptr, shvVar.shvret );2337 } 2338 2339 2387 printf("Unable to set %s: rc = %d, ulRc = %x\n", shvVar.shvname.strptr, shvVar.shvret, ulRc ); /* 2015-04-23 SHL */ 2388 } 2389 2390 -
rxutilex/trunk/rxutilex.def
r22 r23 1 1 LIBRARY RXUTILEX INITINSTANCE TERMINSTANCE 2 2 DATA MULTIPLE NONSHARED 3 DESCRIPTION '@#Alex Taylor:0.1. 0#@##1## 31 Oct 2014 20:32:56REINFORCE::::::@@Extended REXX Utility Functions'3 DESCRIPTION '@#Alex Taylor:0.1.1#@##1## 3 May 2015 22:36:07 REINFORCE::::::@@Extended REXX Utility Functions' 4 4 5 5 EXPORTS Sys2LoadFuncs
Note:
See TracChangeset
for help on using the changeset viewer.