Tk Source Code

View Ticket
Login
2026-09-25
06:29 • Closed ticket [9e89324a]: spinbox parses its value with sscanf("%lf"), which depends on the LC_NUMERIC locale plus 6 other changes artifact: 5901f6dc user: oehhar
2026-09-24
08:22 • Pending ticket [2358545f]: spinbox formatting has side effect plus 4 other changes artifact: cd928ff7 user: serhiy.storchaka
08:19 • Ticket [9e89324a] spinbox parses its value with sscanf("%lf"), which depends on the LC_NUMERIC locale status still Open with 3 other changes artifact: 1926ae19 user: serhiy.storchaka
08:16 • Open ticket [9e89324a]. artifact: 92a0e2af user: serhiy.storchaka
08:13
Do not parse spinbox values with leading zeros as octal. The fix for [9e89324a0a] replaced sscanf() with Tcl_GetDouble(), which in Tcl 8.6 treats "08" as invalid octal and "010" as 8, so a spinbox with -format %02.0f went from 07 to 08 to 00. Strip leading zeros before Tcl_GetDouble(). [Bug 9e89324a0a] check-in: 833ef12b user: serhiy.storchaka tags: spinbox-octal-86
2026-09-22
15:11 • Closed ticket [9e89324a]: spinbox parses its value with sscanf("%lf"), which depends on the LC_NUMERIC locale plus 9 other changes artifact: 1c31feb1 user: jan.nijtmans
14:11
Fix [9e89324a0a]: spinbox parsing depends on the LC_NUMERIC locale check-in: e0dd3fdb user: jan.nijtmans tags: core-8-6-branch
12:50
Fix [9e89324a0a]: spinbox parsing depends on the LC_NUMERIC locale check-in: 0fd8698e user: jan.nijtmans tags: core-9-0-branch
12:23
Fix [9e89324a0a]: spinbox parsing depends on the LC_NUMERIC locale check-in: 009719f2 user: jan.nijtmans tags: trunk, main
2026-09-21
11:29
Add a test for [9e89324a0a], with a testsetlocale command to set the LC_NUMERIC locale closed check-in: 3766d40d user: serhiy.storchaka tags: spinbox-locale-parse
2026-09-20
17:53 • Ticket [2112563f] Tk is not safe against extensions that call setlocale(). status still Open with 3 other changes artifact: 844a6611 user: serhiy.storchaka
17:53 • Ticket [9e89324a] spinbox parses its value with sscanf("%lf"), which depends on the LC_NUMERIC locale status still Open with 3 other changes artifact: fcc00b73 user: serhiy.storchaka
17:52
Fix [9e89324a0a]: spinbox parses its value with sscanf("%lf"), which depends on the LC_NUMERIC locale

With a decimal comma "0.5" was read as 0, so the up button gave 0.1 instead of 0.6 and -from/-to clamped valid values. Use Tcl_GetDouble() instead, as for the -from, -to and -increment options. Same for the value reported to AT-SPI. check-in: a13d8dba user: serhiy.storchaka tags: spinbox-locale-parse

17:52 • New ticket [9e89324a] spinbox parses its value with sscanf("%lf"), which depends on the LC_NUMERIC locale. artifact: 62337674 user: serhiy.storchaka

Ticket UUID: 9e89324a0a79321a32dc48dd914821a2da31c05
Title: spinbox parses its value with sscanf("%lf"), which depends on the LC_NUMERIC locale
Type: Bug Version: 8.6, 9.0, 9.1b1
Submitter: serhiy.storchaka Created on: 2026-09-20 17:52:13
Subsystem: 17. [spinbox] Assigned To: jan.nijtmans
Priority: 1 Zero Severity: Important
Status: Closed Last Modified: 2026-09-25 06:29:48
Resolution: Fixed Closed By: oehhar
    Closed on: 2026-09-25 06:29:48
Description:

The spinbox parses the current value with sscanf("%lf") when the up/down button is invoked and when -from/-to are configured. sscanf() honours LC_NUMERIC, so after an extension or the embedding application has called setlocale(LC_NUMERIC, "") on a system with a decimal comma (de_DE, fr_FR, uk_UA, ...), "0.5" is read as 0:

spinbox .sb -from 0 -to 1 -increment 0.1 -format %.1f
.sb insert 0 0.5
.sb invoke buttonup   ;# 0.1 instead of 0.6
set v 0.7
spinbox .sb2 -from 0 -to 1 -increment 0.1 -format %.1f -textvariable v
.sb2 configure -from 0.2   ;# v becomes 0.2 instead of staying 0.7

Tested on main (9.1b1) and 8.6.17 with setlocale(LC_NUMERIC, "de_DE.utf8") called after Tk_Init. This is the parsing counterpart of [348b482ff7]; the general ticket is [2112563]. The value reported to AT-SPI by tkUnixAccessibility.c is parsed with atof() and has the same problem.

User Comments: oehhar added on 2026-09-25 06:29:48:

Jan has merged the fix by [8ebff84d]. I suppose, we can close this one.

Thanks, Harald


serhiy.storchaka added on 2026-09-24 08:19:32:

Reopened: on core-8-6-branch [e0dd3fdb59] brings back the octal problem of [2358545fff], which 8.5.10 fixed by using sscanf(). In Tcl 8.6, Tcl_GetDouble() treats "08" as invalid octal and "010" as 8, so a spinbox with -format %02.0f goes 07 → 08 → 00. Fix for 8.6 on spinbox-octal-86: strip leading zeros before Tcl_GetDouble(), test spinbox-26.2. 9.0 and trunk are not affected, since Tcl 9 does not parse leading zeros as octal; spinbox-octal-test adds the same test for trunk.


jan.nijtmans added on 2026-09-22 15:11:34:

Fixed on [009719f2f9e1422e|trunk], and also in core-9-0-branch and core-8-6-branch.

Many thanks, @serhiy.storchaka


serhiy.storchaka added on 2026-09-20 17:53:42:

Fixed on branch spinbox-locale-parse in [a13d8dbafb]: the value is parsed with Tcl_GetDouble(), like the -from, -to and -increment options.