2000-04-09  Ulrich Drepper  <drepper@redhat.com>

	* localedata/Makefile: Add rules to clean up directories created by
	new strfmon tests.

2000-04-09  Geoff Clare  <gwc@unisoft.com>

	* localedata/tst-fmon.data: Added new tests for strfmon()
	using test locales with all combinations of cs_precedes,
	sign_posn and sep_by_space.
	* localedata/tst-fmon.sh: Updated to support the new tests.
	* localedata/tst-fmon-locales/tstfmon_n01y12: New file containing
	the localedef source for the new strfmon() test locale.
	* localedata/tst-fmon-locales/tstfmon_n02n40: Likewise.
	* localedata/tst-fmon-locales/tstfmon_n10y31: Likewise.
	* localedata/tst-fmon-locales/tstfmon_n11y41: Likewise.
	* localedata/tst-fmon-locales/tstfmon_n12y11: Likewise.
	* localedata/tst-fmon-locales/tstfmon_n20n32: Likewise.
	* localedata/tst-fmon-locales/tstfmon_n30y20: Likewise.
	* localedata/tst-fmon-locales/tstfmon_n41n00: Likewise.
	* localedata/tst-fmon-locales/tstfmon_y01y10: Likewise.
	* localedata/tst-fmon-locales/tstfmon_y02n22: Likewise.
	* localedata/tst-fmon-locales/tstfmon_y22n42: Likewise.
	* localedata/tst-fmon-locales/tstfmon_y30y21: Likewise.
	* localedata/tst-fmon-locales/tstfmon_y32n31: Likewise.
	* localedata/tst-fmon-locales/tstfmon_y40y00: Likewise.
	* localedata/tst-fmon-locales/tstfmon_y42n21: Likewise.

	* stdlib/strfmon.c: Correct problems with missing or extra
	spaces for unusual combinations of sign_posn and sep_by_space.
	Improved left-precision alignment code.
This commit is contained in:
Ulrich Drepper 2000-04-10 05:13:54 +00:00
parent fe9d16a544
commit 8956ac9e97
20 changed files with 646 additions and 50 deletions

View File

@ -1,3 +1,35 @@
2000-04-09 Ulrich Drepper <drepper@redhat.com>
* localedata/Makefile: Add rules to clean up directories created by
new strfmon tests.
2000-04-09 Geoff Clare <gwc@unisoft.com>
* localedata/tst-fmon.data: Added new tests for strfmon()
using test locales with all combinations of cs_precedes,
sign_posn and sep_by_space.
* localedata/tst-fmon.sh: Updated to support the new tests.
* localedata/tst-fmon-locales/tstfmon_n01y12: New file containing
the localedef source for the new strfmon() test locale.
* localedata/tst-fmon-locales/tstfmon_n02n40: Likewise.
* localedata/tst-fmon-locales/tstfmon_n10y31: Likewise.
* localedata/tst-fmon-locales/tstfmon_n11y41: Likewise.
* localedata/tst-fmon-locales/tstfmon_n12y11: Likewise.
* localedata/tst-fmon-locales/tstfmon_n20n32: Likewise.
* localedata/tst-fmon-locales/tstfmon_n30y20: Likewise.
* localedata/tst-fmon-locales/tstfmon_n41n00: Likewise.
* localedata/tst-fmon-locales/tstfmon_y01y10: Likewise.
* localedata/tst-fmon-locales/tstfmon_y02n22: Likewise.
* localedata/tst-fmon-locales/tstfmon_y22n42: Likewise.
* localedata/tst-fmon-locales/tstfmon_y30y21: Likewise.
* localedata/tst-fmon-locales/tstfmon_y32n31: Likewise.
* localedata/tst-fmon-locales/tstfmon_y40y00: Likewise.
* localedata/tst-fmon-locales/tstfmon_y42n21: Likewise.
* stdlib/strfmon.c: Correct problems with missing or extra
spaces for unusual combinations of sign_posn and sep_by_space.
Improved left-precision alignment code.
2000-04-07 Andreas Jaeger <aj@suse.de>
* posix/Makefile (CFLAGS-regex.c): Remove DEBUG.

View File

@ -45,9 +45,12 @@ ld-test-names := test1 test2 test3 test4 test5
ld-test-srcs := $(addprefix tests/,$(addsuffix .cm,$(ld-test-names)) \
$(addsuffix .def,$(ld-test-names)))
fmon-tests = n01y12 n02n40 n10y31 n11y41 n12y11 n20n32 n30y20 n41n00 \
y01y10 y02n22 y22n42 y30y21 y32n31 y40y00 y42n21
generated := $(test-input) $(test-output)
generated-dirs := $(basename $(test-input)) en_US $(ld-test-names) tt_TT\
de_DE.437
de_DE.437 $(addprefix tstfmon_,$(fmon-tests))
distribute := CHECKSUMS README SUPPORTED ChangeLog \
$(charmaps) $(locales) $(repertoiremaps) \

View File

@ -0,0 +1,28 @@
repertoiremap mnemonic.ds
# One of a set of test locales for strfmon()
# The six characters after the "_" in the locale name indicate
# the last six LC_MONETARY values below.
LC_CTYPE
copy "POSIX"
END LC_CTYPE
LC_MONETARY
int_curr_symbol "<U><S><D><SP>"
currency_symbol "<DO>"
mon_decimal_point "<.>"
mon_thousands_sep "<,>"
mon_grouping 3;3
positive_sign "<+>"
negative_sign "<->"
int_frac_digits 2
frac_digits 2
p_cs_precedes 0
p_sign_posn 0
p_sep_by_space 1
n_cs_precedes 1
n_sign_posn 1
n_sep_by_space 2
END LC_MONETARY

View File

@ -0,0 +1,28 @@
repertoiremap mnemonic.ds
# One of a set of test locales for strfmon()
# The six characters after the "_" in the locale name indicate
# the last six LC_MONETARY values below.
LC_CTYPE
copy "POSIX"
END LC_CTYPE
LC_MONETARY
int_curr_symbol "<U><S><D><SP>"
currency_symbol "<DO>"
mon_decimal_point "<.>"
mon_thousands_sep "<,>"
mon_grouping 3;3
positive_sign "<+>"
negative_sign "<->"
int_frac_digits 2
frac_digits 2
p_cs_precedes 0
p_sign_posn 0
p_sep_by_space 2
n_cs_precedes 0
n_sign_posn 4
n_sep_by_space 0
END LC_MONETARY

View File

@ -0,0 +1,28 @@
repertoiremap mnemonic.ds
# One of a set of test locales for strfmon()
# The six characters after the "_" in the locale name indicate
# the last six LC_MONETARY values below.
LC_CTYPE
copy "POSIX"
END LC_CTYPE
LC_MONETARY
int_curr_symbol "<U><S><D><SP>"
currency_symbol "<DO>"
mon_decimal_point "<.>"
mon_thousands_sep "<,>"
mon_grouping 3;3
positive_sign "<+>"
negative_sign "<->"
int_frac_digits 2
frac_digits 2
p_cs_precedes 0
p_sign_posn 1
p_sep_by_space 0
n_cs_precedes 1
n_sign_posn 3
n_sep_by_space 1
END LC_MONETARY

View File

@ -0,0 +1,28 @@
repertoiremap mnemonic.ds
# One of a set of test locales for strfmon()
# The six characters after the "_" in the locale name indicate
# the last six LC_MONETARY values below.
LC_CTYPE
copy "POSIX"
END LC_CTYPE
LC_MONETARY
int_curr_symbol "<U><S><D><SP>"
currency_symbol "<DO>"
mon_decimal_point "<.>"
mon_thousands_sep "<,>"
mon_grouping 3;3
positive_sign "<+>"
negative_sign "<->"
int_frac_digits 2
frac_digits 2
p_cs_precedes 0
p_sign_posn 1
p_sep_by_space 1
n_cs_precedes 1
n_sign_posn 4
n_sep_by_space 1
END LC_MONETARY

View File

@ -0,0 +1,28 @@
repertoiremap mnemonic.ds
# One of a set of test locales for strfmon()
# The six characters after the "_" in the locale name indicate
# the last six LC_MONETARY values below.
LC_CTYPE
copy "POSIX"
END LC_CTYPE
LC_MONETARY
int_curr_symbol "<U><S><D><SP>"
currency_symbol "<DO>"
mon_decimal_point "<.>"
mon_thousands_sep "<,>"
mon_grouping 3;3
positive_sign "<+>"
negative_sign "<->"
int_frac_digits 2
frac_digits 2
p_cs_precedes 0
p_sign_posn 1
p_sep_by_space 2
n_cs_precedes 1
n_sign_posn 1
n_sep_by_space 1
END LC_MONETARY

View File

@ -0,0 +1,28 @@
repertoiremap mnemonic.ds
# One of a set of test locales for strfmon()
# The six characters after the "_" in the locale name indicate
# the last six LC_MONETARY values below.
LC_CTYPE
copy "POSIX"
END LC_CTYPE
LC_MONETARY
int_curr_symbol "<U><S><D><SP>"
currency_symbol "<DO>"
mon_decimal_point "<.>"
mon_thousands_sep "<,>"
mon_grouping 3;3
positive_sign "<+>"
negative_sign "<->"
int_frac_digits 2
frac_digits 2
p_cs_precedes 0
p_sign_posn 2
p_sep_by_space 0
n_cs_precedes 0
n_sign_posn 3
n_sep_by_space 2
END LC_MONETARY

View File

@ -0,0 +1,28 @@
repertoiremap mnemonic.ds
# One of a set of test locales for strfmon()
# The six characters after the "_" in the locale name indicate
# the last six LC_MONETARY values below.
LC_CTYPE
copy "POSIX"
END LC_CTYPE
LC_MONETARY
int_curr_symbol "<U><S><D><SP>"
currency_symbol "<DO>"
mon_decimal_point "<.>"
mon_thousands_sep "<,>"
mon_grouping 3;3
positive_sign "<+>"
negative_sign "<->"
int_frac_digits 2
frac_digits 2
p_cs_precedes 0
p_sign_posn 3
p_sep_by_space 0
n_cs_precedes 1
n_sign_posn 2
n_sep_by_space 0
END LC_MONETARY

View File

@ -0,0 +1,28 @@
repertoiremap mnemonic.ds
# One of a set of test locales for strfmon()
# The six characters after the "_" in the locale name indicate
# the last six LC_MONETARY values below.
LC_CTYPE
copy "POSIX"
END LC_CTYPE
LC_MONETARY
int_curr_symbol "<U><S><D><SP>"
currency_symbol "<DO>"
mon_decimal_point "<.>"
mon_thousands_sep "<,>"
mon_grouping 3;3
positive_sign "<+>"
negative_sign "<->"
int_frac_digits 2
frac_digits 2
p_cs_precedes 0
p_sign_posn 4
p_sep_by_space 1
n_cs_precedes 0
n_sign_posn 0
n_sep_by_space 0
END LC_MONETARY

View File

@ -0,0 +1,28 @@
repertoiremap mnemonic.ds
# One of a set of test locales for strfmon()
# The six characters after the "_" in the locale name indicate
# the last six LC_MONETARY values below.
LC_CTYPE
copy "POSIX"
END LC_CTYPE
LC_MONETARY
int_curr_symbol "<U><S><D><SP>"
currency_symbol "<DO>"
mon_decimal_point "<.>"
mon_thousands_sep "<,>"
mon_grouping 3;3
positive_sign "<+>"
negative_sign "<->"
int_frac_digits 2
frac_digits 2
p_cs_precedes 1
p_sign_posn 0
p_sep_by_space 1
n_cs_precedes 1
n_sign_posn 1
n_sep_by_space 0
END LC_MONETARY

View File

@ -0,0 +1,28 @@
repertoiremap mnemonic.ds
# One of a set of test locales for strfmon()
# The six characters after the "_" in the locale name indicate
# the last six LC_MONETARY values below.
LC_CTYPE
copy "POSIX"
END LC_CTYPE
LC_MONETARY
int_curr_symbol "<U><S><D><SP>"
currency_symbol "<DO>"
mon_decimal_point "<.>"
mon_thousands_sep "<,>"
mon_grouping 3;3
positive_sign ""
negative_sign "<O></><D>"
int_frac_digits 2
frac_digits 2
p_cs_precedes 1
p_sign_posn 0
p_sep_by_space 2
n_cs_precedes 0
n_sign_posn 2
n_sep_by_space 2
END LC_MONETARY

View File

@ -0,0 +1,28 @@
repertoiremap mnemonic.ds
# One of a set of test locales for strfmon()
# The six characters after the "_" in the locale name indicate
# the last six LC_MONETARY values below.
LC_CTYPE
copy "POSIX"
END LC_CTYPE
LC_MONETARY
int_curr_symbol "<U><S><D><SP>"
currency_symbol "<DO>"
mon_decimal_point "<.>"
mon_thousands_sep "<,>"
mon_grouping 3;3
positive_sign "<+>"
negative_sign "<->"
int_frac_digits 2
frac_digits 2
p_cs_precedes 1
p_sign_posn 2
p_sep_by_space 2
n_cs_precedes 0
n_sign_posn 4
n_sep_by_space 2
END LC_MONETARY

View File

@ -0,0 +1,28 @@
repertoiremap mnemonic.ds
# One of a set of test locales for strfmon()
# The six characters after the "_" in the locale name indicate
# the last six LC_MONETARY values below.
LC_CTYPE
copy "POSIX"
END LC_CTYPE
LC_MONETARY
int_curr_symbol "<U><S><D><SP>"
currency_symbol "<DO>"
mon_decimal_point "<.>"
mon_thousands_sep "<,>"
mon_grouping 3;3
positive_sign "<+>"
negative_sign "<->"
int_frac_digits 2
frac_digits 2
p_cs_precedes 1
p_sign_posn 3
p_sep_by_space 0
n_cs_precedes 1
n_sign_posn 2
n_sep_by_space 1
END LC_MONETARY

View File

@ -0,0 +1,28 @@
repertoiremap mnemonic.ds
# One of a set of test locales for strfmon()
# The six characters after the "_" in the locale name indicate
# the last six LC_MONETARY values below.
LC_CTYPE
copy "POSIX"
END LC_CTYPE
LC_MONETARY
int_curr_symbol "<U><S><D><SP>"
currency_symbol "<DO>"
mon_decimal_point "<.>"
mon_thousands_sep "<,>"
mon_grouping 3;3
positive_sign "<+>"
negative_sign "<->"
int_frac_digits 2
frac_digits 2
p_cs_precedes 1
p_sign_posn 3
p_sep_by_space 2
n_cs_precedes 0
n_sign_posn 3
n_sep_by_space 1
END LC_MONETARY

View File

@ -0,0 +1,28 @@
repertoiremap mnemonic.ds
# One of a set of test locales for strfmon()
# The six characters after the "_" in the locale name indicate
# the last six LC_MONETARY values below.
LC_CTYPE
copy "POSIX"
END LC_CTYPE
LC_MONETARY
int_curr_symbol "<U><S><D><SP>"
currency_symbol "<DO>"
mon_decimal_point "<.>"
mon_thousands_sep "<,>"
mon_grouping 3;3
positive_sign "<+>"
negative_sign "<->"
int_frac_digits 2
frac_digits 2
p_cs_precedes 1
p_sign_posn 4
p_sep_by_space 0
n_cs_precedes 1
n_sign_posn 0
n_sep_by_space 0
END LC_MONETARY

View File

@ -0,0 +1,28 @@
repertoiremap mnemonic.ds
# One of a set of test locales for strfmon()
# The six characters after the "_" in the locale name indicate
# the last six LC_MONETARY values below.
LC_CTYPE
copy "POSIX"
END LC_CTYPE
LC_MONETARY
int_curr_symbol "<U><S><D><SP>"
currency_symbol "<DO>"
mon_decimal_point "<.>"
mon_thousands_sep "<,>"
mon_grouping 3;3
positive_sign "<+>"
negative_sign "<->"
int_frac_digits 2
frac_digits 2
p_cs_precedes 1
p_sign_posn 4
p_sep_by_space 2
n_cs_precedes 0
n_sign_posn 2
n_sep_by_space 1
END LC_MONETARY

View File

@ -19,7 +19,7 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# The format of this file is pretty simple: Each line contains a test
# for strfmon. Fields are seperated by TABs. Lines that start with a
# for strfmon. Fields are separated by TABs. Lines that start with a
# '#' are comments and are ignored.
#
# Field Description
@ -126,3 +126,112 @@ en_US.ISO-8859-1 %!(#5n 3456.781 3,456.78
en_US.ISO-8859-1 %#5n 123.45 $ 123.45
en_US.ISO-8859-1 %#5n -123.45 -$ 123.45
en_US.ISO-8859-1 %#5n 3456.781 $ 3,456.78
#
# check all cs_precedes/sign_posn/sep_by_space combinations using
# special test locales. The six characters after the "_" indicate
# these three values for positive and then negative quantities.
#
tstfmon_n01y12 %n 123.45 123.45 $
tstfmon_n01y12 %n -123.45 - $123.45
tstfmon_n01y12 %11n 123.45 123.45 $
tstfmon_n01y12 %11n -123.45 - $123.45
tstfmon_n01y12 %^=*#5n 123.45 **123.45 $
tstfmon_n01y12 %^=*#5n -123.45 - $**123.45
#
tstfmon_n02n40 %n 123.45 123.45$
tstfmon_n02n40 %n -123.45 123.45$-
tstfmon_n02n40 %11n 123.45 123.45$
tstfmon_n02n40 %11n -123.45 123.45$-
tstfmon_n02n40 %^=*#5n 123.45 **123.45$
tstfmon_n02n40 %^=*#5n -123.45 **123.45$-
#
tstfmon_n10y31 %n 123.45 +123.45$
tstfmon_n10y31 %n -123.45 -$ 123.45
tstfmon_n10y31 %11n 123.45 +123.45$
tstfmon_n10y31 %11n -123.45 -$ 123.45
tstfmon_n10y31 %^=*#5n 123.45 +**123.45$
tstfmon_n10y31 %^=*#5n -123.45 -$ **123.45
#
tstfmon_n11y41 %n 123.45 +123.45 $
tstfmon_n11y41 %n -123.45 $- 123.45
tstfmon_n11y41 %11n 123.45 +123.45 $
tstfmon_n11y41 %11n -123.45 $- 123.45
tstfmon_n11y41 %^=*#5n 123.45 +**123.45 $
tstfmon_n11y41 %^=*#5n -123.45 $- **123.45
#
tstfmon_n12y11 %n 123.45 +123.45$
tstfmon_n12y11 %n -123.45 -$ 123.45
tstfmon_n12y11 %11n 123.45 +123.45$
tstfmon_n12y11 %11n -123.45 -$ 123.45
tstfmon_n12y11 %^=*#5n 123.45 +**123.45$
tstfmon_n12y11 %^=*#5n -123.45 -$ **123.45
#
tstfmon_n20n32 %n 123.45 123.45$+
tstfmon_n20n32 %n -123.45 123.45- $
tstfmon_n20n32 %11n 123.45 123.45$+
tstfmon_n20n32 %11n -123.45 123.45- $
tstfmon_n20n32 %^=*#5n 123.45 **123.45$+
tstfmon_n20n32 %^=*#5n -123.45 **123.45- $
#
tstfmon_n30y20 %n 123.45 123.45+$
tstfmon_n30y20 %n -123.45 $123.45-
tstfmon_n30y20 %11n 123.45 123.45+$
tstfmon_n30y20 %11n -123.45 $123.45-
tstfmon_n30y20 %^=*#5n 123.45 **123.45+$
tstfmon_n30y20 %^=*#5n -123.45 $**123.45-
#
tstfmon_n41n00 %n 123.45 123.45 $+
tstfmon_n41n00 %n -123.45 (123.45$)
tstfmon_n41n00 %11n 123.45 123.45 $+
tstfmon_n41n00 %11n -123.45 (123.45$)
tstfmon_n41n00 %^=*#5n 123.45 **123.45 $+
tstfmon_n41n00 %^=*#5n -123.45 (**123.45$)
#
tstfmon_y01y10 %n 123.45 $ 123.45
tstfmon_y01y10 %n -123.45 -$123.45
tstfmon_y01y10 %11n 123.45 $ 123.45
tstfmon_y01y10 %11n -123.45 -$123.45
tstfmon_y01y10 %^=*#5n 123.45 $ **123.45
tstfmon_y01y10 %^=*#5n -123.45 -$**123.45
#
tstfmon_y02n22 %n 123.45 $123.45
tstfmon_y02n22 %n -123.45 123.45$ O/D
tstfmon_y02n22 %12n 123.45 $123.45
tstfmon_y02n22 %12n -123.45 123.45$ O/D
tstfmon_y02n22 %^=*#5n 123.45 $**123.45
tstfmon_y02n22 %^=*#5n -123.45 **123.45$ O/D
#
tstfmon_y22n42 %n 123.45 $123.45+
tstfmon_y22n42 %n -123.45 123.45$ -
tstfmon_y22n42 %11n 123.45 $123.45+
tstfmon_y22n42 %11n -123.45 123.45$ -
tstfmon_y22n42 %^=*#5n 123.45 $**123.45+
tstfmon_y22n42 %^=*#5n -123.45 **123.45$ -
#
tstfmon_y30y21 %n 123.45 +$123.45
tstfmon_y30y21 %n -123.45 $ 123.45-
tstfmon_y30y21 %11n 123.45 +$123.45
tstfmon_y30y21 %11n -123.45 $ 123.45-
tstfmon_y30y21 %^=*#5n 123.45 +$**123.45
tstfmon_y30y21 %^=*#5n -123.45 $ **123.45-
#
tstfmon_y32n31 %n 123.45 + $123.45
tstfmon_y32n31 %n -123.45 123.45 -$
tstfmon_y32n31 %11n 123.45 + $123.45
tstfmon_y32n31 %11n -123.45 123.45 -$
tstfmon_y32n31 %^=*#5n 123.45 + $**123.45
tstfmon_y32n31 %^=*#5n -123.45 **123.45 -$
#
tstfmon_y40y00 %n 123.45 $+123.45
tstfmon_y40y00 %n -123.45 ($123.45)
tstfmon_y40y00 %11n 123.45 $+123.45
tstfmon_y40y00 %11n -123.45 ($123.45)
tstfmon_y40y00 %^=*#5n 123.45 $+**123.45
tstfmon_y40y00 %^=*#5n -123.45 ($**123.45)
#
tstfmon_y42n21 %n 123.45 $ +123.45
tstfmon_y42n21 %n -123.45 123.45 $-
tstfmon_y42n21 %11n 123.45 $ +123.45
tstfmon_y42n21 %11n -123.45 123.45 $-
tstfmon_y42n21 %^=*#5n 123.45 $ +**123.45
tstfmon_y42n21 %^=*#5n -123.45 **123.45 $-

View File

@ -19,13 +19,17 @@
# not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
DEBUG=0
case $1 in
-d) DEBUG=1; shift ;;
esac
common_objpfx=$1
datafile=$2
DEBUG=0
here=`pwd`
lang=`sed -e '/^#/d' -e '/^$/d' -e '/^C /d' -e 's/^\([^ ]*\).*/\1/' $datafile | sort | uniq`
lang=`sed -e '/^#/d' -e '/^$/d' -e '/^C /d' -e '/^tstfmon/d' -e 's/^\([^ ]*\).*/\1/' $datafile | sort | uniq`
# Generate data files.
for l in $lang; do
@ -37,6 +41,14 @@ for l in $lang; do
${common_objpfx}locale/localedef \
--quiet -i $cn -f $fn ${common_objpfx}localedata/$cns
done
for cns in `cd ./tst-fmon-locales && ls tstfmon_*`; do
cn=tst-fmon-locales/$cns
fn=charmaps/ISO-8859-1
I18NPATH=. \
${common_objpfx}elf/ld.so --library-path $common_objpfx \
${common_objpfx}locale/localedef \
--quiet -i $cn -f $fn ${common_objpfx}localedata/$cns
done
# Run the tests.
IFS=" " # This is a TAB
@ -54,7 +66,9 @@ while read locale format value expect; do
else
echo "Locale: \"${locale}\" Format: \"${format}\"" \
"Value: \"${value}\" Expect: \"${expect}\" failed"
exit 1
if [ $DEBUG -eq 0 ]; then
exit 1
fi
fi
fi
done < $datafile

View File

@ -388,6 +388,24 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...)
if (other_sign_posn == CHAR_MAX)
other_sign_posn = 1;
/* Check for degenerate cases */
if (sep_by_space == 2)
{
if (sign_posn == 0 ||
(sign_posn == 1 && !cs_precedes) ||
(sign_posn == 2 && cs_precedes))
/* sign and symbol are not adjacent, so no separator */
sep_by_space = 0;
}
if (other_sep_by_space == 2)
{
if (other_sign_posn == 0 ||
(other_sign_posn == 1 && !other_cs_precedes) ||
(other_sign_posn == 2 && other_cs_precedes))
/* sign and symbol are not adjacent, so no separator */
other_sep_by_space = 0;
}
/* Set the left precision and padding needed for alignment */
if (left_prec == -1)
{
@ -399,54 +417,48 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...)
/* Set left_pad to number of spaces needed to align positive
and negative formats */
int sign_precedes = 0;
int other_sign_precedes = 0;
int left_bytes = 0;
int other_left_bytes = 0;
if (sign_posn == 0 && !is_negative)
left_pad = 1;
/* Work out number of bytes for currency string and separator
preceding the value */
if (cs_precedes)
{
left_bytes += strlen (currency_symbol);
if (sep_by_space != 0)
++left_bytes;
}
if (other_cs_precedes)
{
other_left_bytes += strlen (currency_symbol);
if (other_sep_by_space != 0)
++other_left_bytes;
}
/* Work out number of bytes for the sign (or left parenthesis)
preceding the value */
if (sign_posn == 0 && is_negative)
++left_bytes;
else if (sign_posn == 1)
left_bytes += strlen (sign_string);
else if (cs_precedes && (sign_posn == 3 || sign_posn == 4))
left_bytes += strlen (sign_string);
if (other_sign_posn == 0 && !is_negative)
++other_left_bytes;
else if (other_sign_posn == 1)
other_left_bytes += strlen (other_sign_string);
else if (other_cs_precedes &&
(other_sign_posn == 3 || other_sign_posn == 4))
other_left_bytes += strlen (other_sign_string);
/* Compare the number of bytes preceding the value for
each format, and set the padding accordingly */
if (other_left_bytes > left_bytes)
left_pad = other_left_bytes - left_bytes;
else
left_pad = 0;
if (!cs_precedes && other_cs_precedes)
{
/* The other format has currency symbol preceding value,
but this format doesn't, so pad by the relevant amount */
left_pad += strlen (currency_symbol);
if (other_sep_by_space != 0)
++left_pad;
}
/* Work out for each format whether a sign (or left parenthesis)
precedes the value */
if (sign_posn == 0 || sign_posn == 1)
sign_precedes = 1;
if (other_sign_posn == 0 || other_sign_posn == 1)
other_sign_precedes = 1;
if (cs_precedes && (sign_posn == 3 || sign_posn == 4))
sign_precedes = 1;
if (other_cs_precedes
&& (other_sign_posn == 3 || other_sign_posn == 4))
other_sign_precedes = 1;
if (!sign_precedes && other_sign_precedes)
{
/* The other format has a sign (or left parenthesis) preceding
the value, but this format doesn't */
if (other_sign_posn == 0)
++left_pad;
else
left_pad += strlen (other_sign_string);
}
else if (sign_precedes && other_sign_precedes)
{
/* Both formats have a sign (or left parenthesis) preceding
the value, so compare their lengths */
int len_diff =
((other_sign_posn == 0 ? 1 : (int) strlen (other_sign_string))
- (sign_posn == 0 ? 1 : (int) strlen (sign_string)));
if (len_diff > 0)
left_pad += len_diff;
}
}
/* Perhaps we'll someday make these things configurable so
@ -481,6 +493,10 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...)
if (sep_by_space == 2)
out_char (' ');
out_string (sign_string);
if (sep_by_space == 1)
/* POSIX.2 and SUS are not clear on this case, but C99
says a space follows the adjacent-symbol-and-sign */
out_char (' ');
}
else
if (sep_by_space == 1)
@ -560,7 +576,9 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...)
if (print_curr_symbol)
{
if ((sign_posn == 3 && sep_by_space == 2)
|| (sign_posn == 4 && sep_by_space == 1)
|| (sign_posn == 2 && sep_by_space == 1)
|| (sign_posn == 1 && sep_by_space == 1)
|| (sign_posn == 0 && sep_by_space == 1))
out_char (' ');
out_string (currency_symbol);