strfmon: Fix an edge case when sep_by_space is 2
Fix an edge case by printing the required space when, the currency symbol succeeds the value, a space separates the sign from the value and the sign position precedes the quantity and the currency symbol. In other words: n_cs_precedes = 0 n_sep_by_space = 2 n_sign_posn = 1 From The Open Group's localeconv[1]: > When {p,n,int_p,int_n}_sep_by_space is 2: > If the currency symbol and sign string are adjacent, a space separates > them; otherwise, a space separates the sign string from the value. Format Before After [%n] [-123.45¤] [- 123.45¤] [1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/localeconv.html Obtained from: Darwin Reviewed by: kib PR: 267282 Github PR: #619 MFC after: 1 week
This commit is contained in:
parent
947efadc3d
commit
750fe3e6a4
@ -296,7 +296,8 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
|
||||
* non-negative value
|
||||
* = 1 - space separates the symbol from the value
|
||||
* = 2 - space separates the symbol and the sign string,
|
||||
* if adjacent.
|
||||
* if adjacent; otherwise, a space separates
|
||||
* the sign string from the value
|
||||
*
|
||||
* p_sign_posn & n_sign_posn
|
||||
*
|
||||
@ -338,8 +339,11 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
|
||||
} else if (sep_by_space == 1)
|
||||
PRINT(space_char);
|
||||
}
|
||||
} else if (sign_posn == 1)
|
||||
} else if (sign_posn == 1) {
|
||||
PRINTS(signstr);
|
||||
if (sep_by_space == 2)
|
||||
PRINT(' ');
|
||||
}
|
||||
|
||||
PRINTS(asciivalue);
|
||||
|
||||
|
@ -116,7 +116,7 @@ ATF_TC_BODY(strfmon_cs_precedes_0, tc)
|
||||
/* sep_by_space x sign_posn */
|
||||
{ "[(123.00$)] [-123.00$] [123.00$-] [123.00-$] [123.00$-]" },
|
||||
{ "[(123.00 $)] [-123.00 $] [123.00 $-] [123.00 -$] [123.00 $-]" },
|
||||
{ "[(123.00$)] [-123.00$] [123.00$ -] [123.00- $] [123.00$ -]" }, /* XXX */
|
||||
{ "[(123.00$)] [- 123.00$] [123.00$ -] [123.00- $] [123.00$ -]" },
|
||||
};
|
||||
size_t i, j;
|
||||
struct lconv *lc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user