summaryrefslogtreecommitdiffstats
path: root/generic/tclParse.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2011-08-09 05:57:48 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2011-08-09 05:57:48 (GMT)
commitbc61e591021b6e5b5e4a49fe1f0111b4a475cc27 (patch)
tree2277837e46f9b03157ad83e443ce3b6c2bd8175e /generic/tclParse.c
parent9d1a20b757fd40ae5b636621c9c7ce303c15043a (diff)
downloadtcl-bc61e591021b6e5b5e4a49fe1f0111b4a475cc27.zip
tcl-bc61e591021b6e5b5e4a49fe1f0111b4a475cc27.tar.gz
tcl-bc61e591021b6e5b5e4a49fe1f0111b4a475cc27.tar.bz2
Change the signature of TclParseHex(), such that it can now parse up to 8 hex characters
Diffstat (limited to 'generic/tclParse.c')
-rw-r--r--generic/tclParse.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/generic/tclParse.c b/generic/tclParse.c
index c33ef5b..2b0dab4 100644
--- a/generic/tclParse.c
+++ b/generic/tclParse.c
@@ -744,11 +744,11 @@ int
TclParseHex(
const char *src, /* First character to parse. */
int numBytes, /* Max number of byes to scan */
- Tcl_UniChar *resultPtr) /* Points to storage provided by caller where
- * the Tcl_UniChar resulting from the
+ int *resultPtr) /* Points to storage provided by caller where
+ * the character resulting from the
* conversion is to be written. */
{
- Tcl_UniChar result = 0;
+ int result = 0;
register const char *p = src;
while (numBytes--) {
@@ -808,7 +808,8 @@ TclParseBackslash(
* written there. */
{
register const char *p = src+1;
- Tcl_UniChar result;
+ Tcl_UniChar unichar;
+ int result;
int count;
char buf[TCL_UTF_MAX];
@@ -906,14 +907,14 @@ TclParseBackslash(
*/
if (isdigit(UCHAR(*p)) && (UCHAR(*p) < '8')) { /* INTL: digit */
- result = UCHAR(*p - '0');
+ result = *p - '0';
p++;
if ((numBytes == 2) || !isdigit(UCHAR(*p)) /* INTL: digit */
|| (UCHAR(*p) >= '8')) {
break;
}
count = 3;
- result = UCHAR((result << 3) + (*p - '0'));
+ result = (result << 3) + (*p - '0');
p++;
if ((numBytes == 3) || !isdigit(UCHAR(*p)) /* INTL: digit */
|| (UCHAR(*p) >= '8')) {
@@ -932,14 +933,15 @@ TclParseBackslash(
*/
if (Tcl_UtfCharComplete(p, numBytes - 1)) {
- count = Tcl_UtfToUniChar(p, &result) + 1; /* +1 for '\' */
+ count = Tcl_UtfToUniChar(p, &unichar) + 1; /* +1 for '\' */
} else {
char utfBytes[TCL_UTF_MAX];
memcpy(utfBytes, p, (size_t) (numBytes - 1));
utfBytes[numBytes - 1] = '\0';
- count = Tcl_UtfToUniChar(utfBytes, &result) + 1;
+ count = Tcl_UtfToUniChar(utfBytes, &unichar) + 1;
}
+ result = unichar;
break;
}
@@ -947,7 +949,7 @@ TclParseBackslash(
if (readPtr != NULL) {
*readPtr = count;
}
- return Tcl_UniCharToUtf((int) result, dst);
+ return Tcl_UniCharToUtf(result, dst);
}
/*