diff options
author | dgp <dgp@noemail.net> | 2011-03-06 22:33:01 (GMT) |
---|---|---|
committer | dgp <dgp@noemail.net> | 2011-03-06 22:33:01 (GMT) |
commit | 5aa2c4d7fc432398b662519f080b8f7c918c5581 (patch) | |
tree | dba041e4a0b7494a00e6c28357073b27feb6d9c9 /generic/tclUtil.c | |
parent | b08aed08dd92dfd47b5e6cd1fdd0e1825a8a1388 (diff) | |
parent | 839ddd5a0e82b93e05a9fdcf7068ef7769540df9 (diff) | |
download | tcl-5aa2c4d7fc432398b662519f080b8f7c918c5581.zip tcl-5aa2c4d7fc432398b662519f080b8f7c918c5581.tar.gz tcl-5aa2c4d7fc432398b662519f080b8f7c918c5581.tar.bz2 |
* generic/tclBasic.c: More replacements of Tcl_UtfBackslash() calls
* generic/tclCompile.c: with TclParseBackslash() where possible.
* generic/tclCompCmdsSZ.c:
* generic/tclParse.c:
* generic/tclUtil.c:
FossilOrigin-Name: 6b0527ff33cf34229d6dddc3d6b8998897633da3
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r-- | generic/tclUtil.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 3fd6271..7161fdd 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -326,14 +326,13 @@ TclFindElement( * * TclCopyAndCollapse -- * - * Copy a string and eliminate any backslashes that aren't in braces. + * Copy a string and substitute all backslash escape sequences * * Results: - * Count characters get copied from src to dst. Along the way, if - * backslash sequences are found outside braces, the backslashes are - * eliminated in the copy. After scanning count chars from source, a null - * character is placed at the end of dst. Returns the number of - * characters that got copied. + * Count bytes get copied from src to dst. Along the way, backslash + * sequences are substituted in the copy. After scanning count bytes + * from src, a null character is placed at the end of dst. Returns + * the number of bytes that got written to dst. * * Side effects: * None. @@ -343,26 +342,28 @@ TclFindElement( int TclCopyAndCollapse( - int count, /* Number of characters to copy from src. */ + int count, /* Number of byte to copy from src. */ const char *src, /* Copy from here... */ char *dst) /* ... to here. */ { - register char c; - int numRead; int newCount = 0; - int backslashCount; - for (c = *src; count > 0; src++, c = *src, count--) { + while (count > 0) { + char c = *src; if (c == '\\') { - backslashCount = Tcl_UtfBackslash(src, &numRead, dst); + int numRead; + int backslashCount = TclParseBackslash(src, count, &numRead, dst); + dst += backslashCount; newCount += backslashCount; - src += numRead-1; - count -= numRead-1; + src += numRead; + count -= numRead; } else { *dst = c; dst++; newCount++; + src++; + count--; } } *dst = 0; @@ -742,7 +743,7 @@ Tcl_ScanCountedElement( } else { int size; - Tcl_UtfBackslash(p, &size, NULL); + TclParseBackslash(p, lastChar - p, &size, NULL); p += size-1; flags |= USE_BRACES; } |