Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2008-12-12
06:36 • Closed ticket [2368084fff]: #343: Add %b (binary) specifier to format/scan... artifact: efffc38d07 user: ferrieux
2008-12-09
04:21 • Ticket [2368084fff]: 4 changes artifact: be9b3e3fe4 user: ferrieux
04:19 • Ticket [2368084fff]: 4 changes artifact: 1c778f3e35 user: ferrieux
04:19 • Add attachment bin2.patch to ticket [2368084fff] artifact: 80ccbff32c user: ferrieux
04:19 • Ticket [2368084fff] #343: Add %b (binary) specifier to format/scan status ... artifact: 922c112e68 user: ferrieux
2008-12-08
18:03 • Ticket [2368084fff]: 2 changes artifact: 0651811640 user: dkf
2008-12-01
07:54 • Add attachment bin.patch to ticket [2368084fff] artifact: c68b119b3a user: ferrieux
07:54 • Ticket [2368084fff] Add %b (binary) specifier to format/scan status still ... artifact: 235ecdf662 user: ferrieux
00:54 • New ticket [2368084fff]. artifact: 367aed09ca user: ferrieux

#343: Add %b (binary) specifier to [format/scan]

Closed / Accepted2368084fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2008-12-01 00:54:21
The attached patch adds a %b specifier meaning 'binary' to the [format] and [scan] commands. It is thus continuing in the direction pioneered by the recent addition of "0b" in [expr]'s number parsing.

The specifier of course also works with "#" (adding "0b" if nonzero) and wide- and bignum modifiers (%lb, %llb).

In addition, the patch fixes the following bug in [scan]:

    % scan 0b101 %i x
    1
    % puts $x
    0

The patch includes proper tests and documentation update. Does it really need a TIP ?
ferrieuxplain2008-12-01 07:54:21
File Added - 303554: bin.patch
dkf Ticket [2368084fff]: 2 changes [History diff]2008-12-08 18:03:52
ferrieuxplain2008-12-09 04:19:35
File Added - 304588: bin2.patch
ferrieuxplain2008-12-09 04:19:36
After discussion with Don, it appears that the [scan %i] "fix", which is orthogonal to the TIP, is a dangerous breach of compatibility. So let's leave octal in its pond for now. Patch updated to restore the aforementioned bug. Now this patch is 100% faithful to the TIP's text.
File Added: bin2.patch
ferrieuxplain2008-12-09 04:21:45
The mention of "octal" in the previous comment is confusing. I meant, let's just leave %i in all its historical ugliness (which includes things related to octal). Anyway.
ferrieuxplain2008-12-12 06:36:38
TIP accepted, patch committed.
Log in (anonymous is fine) to add a comment.

Attachments: