]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
xz: Never use thousand separators in DJGPP builds.
authorLasse Collin <lasse.collin@tukaani.org>
Wed, 11 Mar 2020 19:15:35 +0000 (21:15 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Wed, 11 Mar 2020 19:15:35 +0000 (21:15 +0200)
DJGPP 2.05 added support for thousands separators but it's
broken at least under WinXP with Finnish locale that uses
a non-breaking space as the thousands separator. Workaround
by disabling thousands separators for DJGPP builds.

src/xz/util.c

index 39e8ec8b145ea572ddf80ec466e0bd42125cc91b..a1339f4fdf3cf09f558a6af0b533db4fd3b65355 100644 (file)
@@ -142,14 +142,24 @@ round_up_to_mib(uint64_t n)
 }
 
 
-/// Check if thousand separator is supported. Run-time checking is easiest,
-/// because it seems to be sometimes lacking even on POSIXish system.
+/// Check if thousands separator is supported. Run-time checking is easiest
+/// because it seems to be sometimes lacking even on a POSIXish system.
+/// Note that trying to use thousands separators when snprintf() doesn't
+/// support them results in undefined behavior. This just has happened to
+/// work well enough in practice.
+///
+/// DJGPP 2.05 added support for thousands separators but it's broken
+/// at least under WinXP with Finnish locale that uses a non-breaking space
+/// as the thousands separator. Workaround by disabling thousands separators
+/// for DJGPP builds.
 static void
 check_thousand_sep(uint32_t slot)
 {
        if (thousand == UNKNOWN) {
                bufs[slot][0] = '\0';
+#ifndef __DJGPP__
                snprintf(bufs[slot], sizeof(bufs[slot]), "%'u", 1U);
+#endif
                thousand = bufs[slot][0] == '1' ? WORKS : BROKEN;
        }