Changeset 860
- Timestamp:
- Nov 10, 2007, 11:58:43 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/commafmt.c
r859 r860 13 13 25 May 05 SHL Add CommaFmtULL, CommaFmtUL 14 14 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat 15 05 Nov 07 GKY Use commafmtULL to display file sizes for large file support 16 10 Nov 07 GKY Get thousands separator from country info for file sizes. 15 17 16 18 ***********************************************************************/ 17 19 18 20 /* 19 ** COMMAFMT.C 20 ** Public domain by Bob Stout 21 ** 22 ** Notes: 1. Use static buffer to eliminate error checks on buffer overflow 23 ** and reduce code size. 24 ** 2. By making the numeric argument a long and prototyping it before 25 ** use, passed numeric arguments will be implicitly cast to longs 26 ** thereby avoiding int overflow. 27 ** 3. Use the thousands grouping and thousands separator from the 28 ** ANSI locale to make this more robust. 21 * COMMAFMT.C 22 * Adapted from public domain code by Bob Stout 23 * 24 * 2. By making the numeric argument a long and prototyping it before 25 * use, passed numeric arguments will be implicitly cast to longs 26 * thereby avoiding int overflow. 27 * 3. Use the thousands grouping and thousands separator from the 28 * ANSI locale to make this more robust. 29 29 */ 30 30 31 #define INCL_WIN 31 32 #define INCL_LONGLONG 32 33 #include <os2.h> … … 35 36 #include <stdio.h> 36 37 #include <string.h> 38 #include "fm3dll.h" 37 39 38 40 size_t commafmt(char *pszBuf, // Output buffer … … 57 59 58 60 for (; cChars <= cBufSize; ++cChars, ++cDigits) { 59 *pch-- = (CHAR) 61 *pch-- = (CHAR)(lNumber % 10 + '0'); 60 62 lNumber /= 10; 61 63 if (!lNumber) 62 64 break; 63 65 if (cDigits % 3 == 0) { 64 *pch-- = ',';66 *pch-- = *ThousandsSeparator; 65 67 ++cChars; 66 68 } … … 85 87 } 86 88 87 //=== CommaFmtULL: format long long number with commas and SI unit suffix === 89 /** 90 * Format long long number with commas and SI unit suffix 91 * @param pszBuf Points to output buffer 92 * @param cBufSize Buffer size including space for terminating nul 93 * @param ullNumber Number to convert 94 * @param chPreferred Preferred suffix, blank, K, M 95 * @return size of formatting string excluding terminating nul 96 */ 88 97 89 98 size_t CommaFmtULL(char *pszBuf, // Output buffer … … 109 118 } 110 119 111 c = commafmt(pszBuf, cBufSize, (LONG) 120 c = commafmt(pszBuf, cBufSize, (LONG)ullNumber); 112 121 113 122 if (chSuffix != ' ') { -
trunk/dll/fm3dll.h
r856 r860 63 63 01 Sep 07 GKY Add xDosSetPathInfo to fix case where FS3 buffer crosses 64k boundary 64 64 04 Nov 07 GKY Add pszFmtFileSize to CNRITEM to display large file sizes 65 10 Nov 07 GKY Add ThousandSeparator variable for file sizes NLS tseparator. 65 66 66 67 ***********************************************************************/ … … 1372 1373 hwndLED, hwndLEDHdr, hwndAutoMLE, hwndCmdlist; 1373 1374 DATADEF HBITMAP hbmLEDon, hbmLEDoff; 1374 DATADEF CHAR ArcTempRoot[9] ;1375 DATADEF CHAR ArcTempRoot[9], ThousandsSeparator[2]; 1375 1376 DATADEF HPOINTER hptrArrow, hptrBusy, hptrLast, hptrDir, hptrFile, hptrRemote, 1376 1377 hptrFloppy, hptrDrive, hptrRemovable, hptrCDROM,hptrVirtual,hptrRamdisk, -
trunk/dll/init.c
r856 r860 36 36 25 Aug 07 SHL Work around DosSetPathInfo kernel defect 37 37 01 Sep 07 GKY Use xDosSetPathInfo to fix case where FS3 buffer crosses 64k boundry 38 10 Nov 07 GKY Get thousands separator from country info for file sizes. 38 39 39 40 ***********************************************************************/ … … 53 54 #define INCL_DOSERRORS 54 55 #define INCL_LONGLONG 56 #define INCL_DOSNLS 55 57 #include <os2.h> 56 58 #include <os2me.h> … … 941 943 CollectorsortFlags = sortFlags = SORT_DIRSFIRST; 942 944 945 //Get default Country info 946 { 947 COUNTRYCODE Country = {0}; 948 ULONG ulInfoLen = 0; 949 COUNTRYINFO CtryInfo = {0}; 950 951 DosQueryCtryInfo(sizeof(CtryInfo), &Country, 952 &CtryInfo, &ulInfoLen); 953 *ThousandsSeparator = CtryInfo.szThousandsSeparator[0]; 954 } 955 943 956 // load preferences from profile (INI) file 944 957 size = sizeof(BOOL); -
trunk/dll/misc.c
r859 r860 34 34 14 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat 35 35 01 Sep 07 GKY Use xDosSetPathInfo to fix case where FS3 buffer crosses 64k boundry 36 05 Nov 07 GKY Use commafmtULL to display file sizes for large file support 36 37 37 38 ***********************************************************************/
Note:
See TracChangeset
for help on using the changeset viewer.