Changeset 390 for trunk/src


Ignore:
Timestamp:
May 30, 2011, 5:44:18 PM (14 years ago)
Author:
pr
Message:

Add nlsThousandsLong to fix signed/unsigned display error.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cppbase/bs_string_base.cpp

    r254 r390  
    88
    99/*
    10  *      This file Copyright (C) 1999-2001 Ulrich M”ller.
     10 *      This file Copyright (C) 1999-2011 Ulrich M”ller.
    1111 *      This program is free software; you can redistribute it and/or modify
    1212 *      it under the terms of the GNU General Public License as published by
     
    374374 *
    375375 *@@added V0.9.18 (2002-03-08) [umoeller]
     376 *@@changed WarpIN V1.0.20 (2011-05-30) [pr]: fix signed/unsigned error
    376377 */
    377378
     
    383384    CHAR sz[100];
    384385    if (cThousands)
    385         nlsThousandsULong(sz, value, cThousands);
     386        nlsThousandsLong(sz, value, cThousands);
    386387    else
    387388        _itoa(value, sz, 10);
  • trunk/src/helpers/nls.c

    r386 r390  
    2222
    2323/*
    24  *      Copyright (C) 1997-2010 Ulrich M”ller.
     24 *      Copyright (C) 1997-2011 Ulrich M”ller.
    2525 *      This file is part of the "XWorkplace helpers" source package.
    2626 *      This is free software; you can redistribute it and/or modify
     
    762762
    763763/*
     764 *@@ nlsThousandsLong:
     765 *      signed version of above.
     766 *
     767 *@@added WarpIn V1.0.20 (2011-05-30) [pr]
     768 */
     769
     770PSZ nlsThousandsLong(PSZ pszTarget,       // out: decimal as string
     771                     LONG l,              // in: decimal to convert
     772                     CHAR cThousands)     // in: separator char (e.g. '.')
     773{
     774    CHAR    szTemp[30];
     775    USHORT  ust = 0,
     776            uss,
     777            usLen = sprintf(szTemp, "%ld", l);
     778
     779    for (uss = 0;
     780         uss < usLen;
     781         uss++)
     782    {
     783        if (uss)
     784            if (((usLen - uss) % 3) == 0)
     785            {
     786                pszTarget[ust] = cThousands;
     787                ust++;
     788            }
     789
     790        pszTarget[ust++] = szTemp[uss];
     791    }
     792
     793    pszTarget[ust] = '\0';
     794
     795    return pszTarget;
     796}
     797
     798/*
    764799 *@@ nlsThousandsDouble:
    765800 *      like nlsThousandsULong, but for a "double"
Note: See TracChangeset for help on using the changeset viewer.