Skip to content
Tcl Source Code History Of Ticket cd29ba23cc373c08
Login

History Of Ticket cd29ba23cc373c08

Artifacts Associated With Ticket cd29ba23cc373c08

  1. Ticket change [6ba3476db8] (rid 149060) by beric on 2016-10-05 07:32:18:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      According to the documentation, <i>%i scans an integer with the base (i.e. decimal, binary, octal, or hexadecimal) determined in the same fashion as described in expr.</i>
      
      So one can expect:
      
      <pre>
        scan 0b10 %i v ;# v = 2 expected, but is 0
        scan 0o77 %i v ;# v = 63 expected, but is 0
      </pre>
      
      Also note that:
      
      <pre>
        scan 0xf %i v ;# v = 15
        scan 077 %i v ;# v = 63
      </pre>
      
      The test scan-4.41 in scan.test, line 337 is also buggy:
      
      <pre>
      test scan-4.41 {Tcl_ScanObjCmd, base-unknown integer scanning} -setup {
          set x {}
      } -body {
          list [scan {10 010 0x10 0b10} {%i%i%i%i} x y z t] $x $y $z $t
      } -result {4 10 8 16 0}
      </pre>
      
      The flag TCL_PARSE_SCAN_PREFIXES set in tclScan.c for %i is documented as <i>ignore prefixes</i> in tclStrToD.c.
      
    5. foundin initialized to: "8.6.6"
    6. is_private initialized to: "0"
    7. login: "beric"
    8. priority initialized to: "5 Medium"
    9. resolution initialized to: "None"
    10. severity initialized to: "Critical"
    11. status initialized to: "Open"
    12. submitter initialized to: "beric"
    13. subsystem initialized to: "23. [scan]"
    14. title initialized to: "scan %i"
    15. type initialized to: "Bug"
  2. Ticket change [b29549d940] (rid 149104) by dkf on 2016-10-08 16:54:03:

    1. assignee changed to: "dgp"
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. priority changed to: "6"
  3. Ticket change [b2813638d9] (rid 149117) by ferrieux on 2016-10-09 08:41:36:

    1. icomment:
      Base-two is a rather late addition on Tcl (TIP 343, 2008).
      As such, extreme care is due wrt backward compatibility.
      In the course of the discussion around TIP 343, the risk was deemed too high of breaking scripts expecting "b" to be seen as an integer-breaker (as it had been for over 15 years before the TIP). Add to this the extreme rarity of base-two as a natural choice for input when %i is used (when it is the most natural choice, the code may be expected to explicitly [scan "0b%b"]).
      
      Now if you're proposing this for Tcl9, where incompatibility is expected, please say so.
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. resolution changed to: "Rejected"
    5. severity changed to: "Cosmetic"
    6. status changed to: "Pending"
  4. Ticket change [ba167c2e35] (rid 149118) by beric on 2016-10-09 09:24:54:

    1. icomment:
      So we have to live with this. Sad.
      Then I think the documentation should be changed to say the truth: %i only scans decimal, octal with "0" prefix, and hexadecimal ("0x" prefix) but not octal with "0o" nor binary with "0b" prefix.
      Could we add another % scan char?
      
    2. login: "beric"
    3. mimetype: "text/plain"
  5. Ticket change [8fb540b219] (rid 149122) by ferrieux on 2016-10-09 10:37:36:

    1. icomment:
      You're right about the documentation; fixed in commit b6c6a73a68dc1526.
      
      As for the scan chars, there's already %b; what do you have in mind ?
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
  6. Ticket change [d148c87226] (rid 149123) by beric on 2016-10-09 11:27:37:

    1. icomment:
      I mean, a new char, say %I, which does what was documented, scanning any integer format, including 0o and 0b.
      What I do instead of scan now is:
      
      if {[string is integer -strict $v]} {
          set v [expr {$v}]
      } else {  ...
      
    2. login: "beric"
    3. mimetype: "text/plain"
  7. Ticket change [a1afb77f02] (rid 149126) by ferrieux on 2016-10-09 14:49:09:

    1. icomment:
      If you feel your need is so ubiquitous it deserves the code bloat, submit a TIP.
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
  8. Ticket change [285b37248c] (rid 258125) by serhiy.storchaka on 2026-10-15 11:29:05:

    1. icomment: "Closing: decided above."
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
    4. status changed to: "Closed"
  9. Ticket change [87dde86d5e] (rid 259928) by serhiy.storchaka on 2026-10-22 17:19:26:

    1. closedate changed to: "2461328.978537581"
    2. closer changed to: "serhiy.storchaka"
    3. login: "serhiy.storchaka"