Changeset 42 for rxutilex/trunk/rxutilex.c
- Timestamp:
- Mar 30, 2018, 8:38:35 PM (8 years ago)
- File:
-
- 1 edited
-
rxutilex/trunk/rxutilex.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
rxutilex/trunk/rxutilex.c
r41 r42 1067 1067 * must not contain any separators already, and any decimal point which it * 1068 1068 * contains must be a period (rather than any localized decimal symbol). * 1069 * The maximum value is that of a signed 64-bit integer, or a long double. * 1069 1070 * * 1070 1071 * REXX ARGUMENTS: * … … 1081 1082 PSZ pszSep = NULL; // Thousands separator string 1082 1083 PSZ pszDec = NULL; // Decimal point string 1084 PSZ pszNeg = NULL; // Negative sign string 1083 1085 #ifdef LEGACY_C_LOCALE 1084 1086 float fVal = 0; // Input value as floating point 1085 1087 int iVal; // Input value as integer 1086 1088 #else 1087 ULONGLONGllVal = 0;1089 LONGLONG llVal = 0; 1088 1090 long double ldVal = 0, 1089 1091 ldFrac = 0; 1090 PSZ p; 1091 CHAR achFrac[ 16 ]; 1092 int rc = 0; 1092 PSZ p, 1093 a; 1094 BOOL bNeg = FALSE; 1095 CHAR achFrac[ 16 ]; 1096 int rc = 0; 1093 1097 #endif 1094 1098 … … 1178 1182 } 1179 1183 1184 // Return the formatted number 1185 SaveResultString( prsResult, achNumber, strlen(achNumber) ); 1186 1180 1187 #else 1181 1188 … … 1184 1191 // GetLocaleString has already set the error indicator 1185 1192 SaveResultString( prsResult, NULL, 0 ); 1186 return ( 0 );1193 goto finish; 1187 1194 } 1188 1195 rc = GetLocaleString( &pszDec, LOCI_sDecimal ); … … 1190 1197 // GetLocaleString has already set the error indicator 1191 1198 SaveResultString( prsResult, NULL, 0 ); 1192 return ( 0 ); 1193 } 1199 goto finish; 1200 } 1201 rc = GetLocaleString( &pszNeg, LOCI_sNegativeSign ); 1202 if ( rc ) { 1203 // GetLocaleString has already set the error indicator 1204 SaveResultString( prsResult, NULL, 0 ); 1205 goto finish; 1206 } 1207 1208 // Check for negative value 1209 //if ( argv[0].strptr == '-') bNeg = TRUE; 1194 1210 1195 1211 // Check for a decimal place and treat as float or integer accordingly … … 1207 1223 else 1208 1224 sprintf( achFrac, "%.2Lf", ldFrac ); 1225 1209 1226 // Format the integer part 1210 GroupNumber( achNumber, llVal, pszSep ); 1227 a = achNumber; 1228 if ( llVal < 0 ) { 1229 sprintf( a, pszNeg ); 1230 a += strlen( pszNeg ); 1231 } 1232 GroupNumber( a, llabs( llVal ), pszSep ); 1211 1233 // Append the fractional part 1212 1234 if (( p = strchr( achFrac, '.')) != NULL ) { … … 1217 1239 else { 1218 1240 if (( sscanf( argv[0].strptr, "%lld", &llVal )) != 1 ) return ( 40 ); 1219 GroupNumber( achNumber, llVal, pszSep ); 1220 } 1221 1222 free( pszSep ); 1241 a = achNumber; 1242 if ( llVal < 0 ) { 1243 sprintf( a, pszNeg ); 1244 a += strlen( pszNeg ); 1245 } 1246 GroupNumber( a, llabs( llVal ), pszSep ); 1247 } 1248 1249 // Return the formatted number 1250 SaveResultString( prsResult, achNumber, strlen(achNumber) ); 1251 1252 finish: 1253 if ( pszSep ) free( pszSep ); 1254 if ( pszDec ) free( pszDec ); 1255 if ( pszNeg ) free( pszNeg ); 1256 1223 1257 #endif 1224 1225 // Return the formatted number1226 SaveResultString( prsResult, achNumber, strlen(achNumber) ); // 2016-02-20 SHL1227 1258 1228 1259 return ( 0 );
Note:
See TracChangeset
for help on using the changeset viewer.
