diff options
author | Vadim Zborovskii <vadim_z@triniti.ru> | 2012-07-14 01:21:07 +0400 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2013-08-19 21:15:55 +1000 |
commit | 74b38b366e17e5075e3a44994c6b2fb95d2f2a03 (patch) | |
tree | 0e60ff74b8d77cd8e11d9b85390ae87bbaa976f9 | |
parent | 05f1c54f9c2aabf0621a9faba234cd4ea006c6e9 (diff) | |
download | jimtcl-74b38b366e17e5075e3a44994c6b2fb95d2f2a03.zip jimtcl-74b38b366e17e5075e3a44994c6b2fb95d2f2a03.tar.gz jimtcl-74b38b366e17e5075e3a44994c6b2fb95d2f2a03.tar.bz2 |
Fixes to make behaviour of Jim's 'binary' more compliant to Tcl.
-rw-r--r-- | binary.tcl | 6 | ||||
-rw-r--r-- | jim.c | 4 |
2 files changed, 7 insertions, 3 deletions
@@ -14,7 +14,8 @@ proc binary {cmd args} { proc "binary format" {formatString args} { set bitoffset 0 set result {} - foreach {conv t u n} [regexp -all -inline {([a-zA-Z@])(u)?([*0-9]*)} $formatString] { + # This RE is too unreliable... + foreach {conv t u n} [regexp -all -inline {([^[:space:]])(u)?([*0-9]*)} $formatString] { if {$t in {a A}} { set value [binary.nextarg args] set sn [string bytelength $value] @@ -116,7 +117,8 @@ proc "binary scan" {value formatString {args varName}} { # Throws an error if no more args set bitoffset 0 set count 0 - foreach {conv t u n} [regexp -all -inline {([a-zA-Z@])(u)?([*0-9]*)} $formatString] { + # This RE is too unreliable... + foreach {conv t u n} [regexp -all -inline {([^[:space:]])(u)?([*0-9]*)} $formatString] { set rembytes $([string bytelength $value] - $bitoffset / 8) if {$t in {a A}} { if {$n eq "*"} { @@ -605,9 +605,11 @@ int Jim_DoubleToString(char *buf, double doubleValue) #endif return len; } - /* inf or Infinity -> Inf, nan -> Nan */ + /* inf or Infinity -> Inf, nan -> NaN */ if (buf[i] == 'i' || buf[i] == 'I' || buf[i] == 'n' || buf[i] == 'N') { buf[i] = toupper(UCHAR(buf[i])); + if (buf[i] == 'n' || buf[i] == 'N') + buf[i+2] = toupper(UCHAR(buf[i+2])); buf[i + 3] = 0; return i + 3; } |