[INTERPRETER]
* NEW: Format() now pad numbers with spaces according to the number of '#' characters before the decimal point. git-svn-id: svn://localhost/gambas/trunk@1696 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
727229118c
commit
03800cc050
1 changed files with 14 additions and 9 deletions
|
@ -203,17 +203,22 @@ static void add_currency(const char *sym)
|
|||
}
|
||||
|
||||
|
||||
static void add_zero(int zero, int *before)
|
||||
static void add_char(char c, int count, int *before)
|
||||
{
|
||||
while (zero > 0)
|
||||
while (count > 0)
|
||||
{
|
||||
put_char('0');
|
||||
zero--;
|
||||
put_char(c);
|
||||
count--;
|
||||
|
||||
add_thousand_sep(before);
|
||||
}
|
||||
}
|
||||
|
||||
static void add_zero(int count, int *before)
|
||||
{
|
||||
add_char('0', count, before);
|
||||
}
|
||||
|
||||
|
||||
static int search(const char *src, int len, const char *list, int start, boolean not)
|
||||
{
|
||||
|
@ -936,12 +941,12 @@ _FORMAT:
|
|||
|
||||
/* les chiffres avant la virgule */
|
||||
|
||||
thousand = Max(before_zero, number_exp);
|
||||
thousand = Max(before, Max(before_zero, number_exp));
|
||||
thousand_ptr = comma ? &thousand : NULL;
|
||||
|
||||
if (number_exp > 0)
|
||||
{
|
||||
if (before_zero > number_exp)
|
||||
add_char(' ', before - Max(before_zero, number_exp), thousand_ptr);
|
||||
add_zero(before_zero - number_exp, thousand_ptr);
|
||||
|
||||
add_string(buf_start, Min(number_exp, ndigit), thousand_ptr);
|
||||
|
@ -951,7 +956,7 @@ _FORMAT:
|
|||
}
|
||||
else
|
||||
{
|
||||
if (before_zero > 0)
|
||||
add_char(' ', before - before_zero, thousand_ptr);
|
||||
add_zero(before_zero, thousand_ptr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue