summaryrefslogtreecommitdiffstats
path: root/generic/tclStrToD.c
diff options
context:
space:
mode:
authorferrieux <ferrieux@users.sourceforge.net>2008-12-10 18:21:46 (GMT)
committerferrieux <ferrieux@users.sourceforge.net>2008-12-10 18:21:46 (GMT)
commit598d01fe5e0f51d30e934c1aba180b32b7733ebc (patch)
tree1a21e3ccc33a5243f3f2d9bf30b44617c5ff70e3 /generic/tclStrToD.c
parent418c8071f2eaf8ed93cf80189e6b775369dba84b (diff)
downloadtcl-598d01fe5e0f51d30e934c1aba180b32b7733ebc.zip
tcl-598d01fe5e0f51d30e934c1aba180b32b7733ebc.tar.gz
tcl-598d01fe5e0f51d30e934c1aba180b32b7733ebc.tar.bz2
TIP #343 IMPLEMENTATION - A Binary Specifier for [format/scan]
Diffstat (limited to 'generic/tclStrToD.c')
-rwxr-xr-xgeneric/tclStrToD.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c
index 2b4cde7..8eec7b4 100755
--- a/generic/tclStrToD.c
+++ b/generic/tclStrToD.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclStrToD.c,v 1.34 2008/04/01 20:08:22 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclStrToD.c,v 1.35 2008/12/10 18:21:47 ferrieux Exp $
*
*----------------------------------------------------------------------
*/
@@ -369,6 +369,8 @@ TclParseNumber(
break;
} else if (flags & TCL_PARSE_HEXADECIMAL_ONLY) {
goto zerox;
+ } else if (flags & TCL_PARSE_BINARY_ONLY) {
+ goto zerob;
} else if (flags & TCL_PARSE_OCTAL_ONLY) {
goto zeroo;
} else if (isdigit(UCHAR(c))) {
@@ -395,9 +397,9 @@ TclParseNumber(
case ZERO:
/*
* Scanned a leading zero (perhaps with a + or -). Acceptable
- * inputs are digits, period, X, and E. If 8 or 9 is encountered,
+ * inputs are digits, period, X, b, and E. If 8 or 9 is encountered,
* the number can't be octal. This state and the OCTAL state
- * differ only in whether they recognize 'X'.
+ * differ only in whether they recognize 'X' and 'b'.
*/
acceptState = state;
@@ -417,6 +419,9 @@ TclParseNumber(
state = ZERO_B;
break;
}
+ if (flags & TCL_PARSE_BINARY_ONLY) {
+ goto zerob;
+ }
if (c == 'o' || c == 'O') {
explicitOctal = 1;
state = ZERO_O;
@@ -602,6 +607,7 @@ TclParseNumber(
acceptPoint = p;
acceptLen = len;
case ZERO_B:
+ zerob:
if (c == '0') {
++numTrailZeros;
state = BINARY;