Changeset 860 for trunk/dll/commafmt.c


Ignore:
Timestamp:
Nov 10, 2007, 11:58:43 PM (18 years ago)
Author:
Gregg Young
Message:

Use the thousand separator from NLS Country info for file sizes. Repalce dir.ico & pmap.bmp with new versions from David

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/commafmt.c

    r859 r860  
    1313  25 May 05 SHL Add CommaFmtULL, CommaFmtUL
    1414  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.
    1517
    1618***********************************************************************/
    1719
    1820/*
    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.
    2929 */
    3030
     31#define INCL_WIN
    3132#define INCL_LONGLONG
    3233#include <os2.h>
     
    3536#include <stdio.h>
    3637#include <string.h>
     38#include "fm3dll.h"
    3739
    3840size_t commafmt(char *pszBuf,   // Output buffer
     
    5759
    5860  for (; cChars <= cBufSize; ++cChars, ++cDigits) {
    59     *pch-- = (CHAR) (lNumber % 10 + '0');
     61    *pch-- = (CHAR)(lNumber % 10 + '0');
    6062    lNumber /= 10;
    6163    if (!lNumber)
    6264      break;
    6365    if (cDigits % 3 == 0) {
    64       *pch-- = ',';
     66      *pch-- = *ThousandsSeparator;
    6567      ++cChars;
    6668    }
     
    8587}
    8688
    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 */
    8897
    8998size_t CommaFmtULL(char *pszBuf,        // Output buffer
     
    109118  }
    110119
    111   c = commafmt(pszBuf, cBufSize, (LONG) ullNumber);
     120  c = commafmt(pszBuf, cBufSize, (LONG)ullNumber);
    112121
    113122  if (chSuffix != ' ') {
Note: See TracChangeset for help on using the changeset viewer.