diff options
author | oehhar <harald.oehlmann@elmicron.de> | 2020-10-25 20:03:10 (GMT) |
---|---|---|
committer | oehhar <harald.oehlmann@elmicron.de> | 2020-10-25 20:03:10 (GMT) |
commit | 861d8f512fd6d21d600999faa12dde6bd363bef0 (patch) | |
tree | 208136f99d7fbd4f5dce23083936e73c41f1584f /generic/tclBinary.c | |
parent | 48d0827130389368a247f26b480bd819a1c753e5 (diff) | |
download | tcl-861d8f512fd6d21d600999faa12dde6bd363bef0.zip tcl-861d8f512fd6d21d600999faa12dde6bd363bef0.tar.gz tcl-861d8f512fd6d21d600999faa12dde6bd363bef0.tar.bz2 |
TIP586: C String Parsing Support for binary scan
Diffstat (limited to 'generic/tclBinary.c')
-rw-r--r-- | generic/tclBinary.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c index f53c707..8a3541b 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -1518,7 +1518,8 @@ BinaryScanCmd( } switch (cmd) { case 'a': - case 'A': { + case 'A': + case 'C': { unsigned char *src; if (arg >= objc) { @@ -1540,10 +1541,18 @@ BinaryScanCmd( size = count; /* - * Trim trailing nulls and spaces, if necessary. + * Apply C string semantics or trim trailing + * nulls and spaces, if necessary. */ - if (cmd == 'A') { + if (cmd == 'C') { + for (i = 0; i < size; i++) { + if (src[i] == '\0') { + size = i; + break; + } + } + } else if (cmd == 'A') { while (size > 0) { if (src[size - 1] != '\0' && src[size - 1] != ' ') { break; |