summaryrefslogtreecommitdiffstats
path: root/generic/tclCompExpr.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-12-04 18:26:31 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-12-04 18:26:31 (GMT)
commitf9fb8c8daf918e57d3a50a0428623a5e5c260e70 (patch)
tree04aa3988f0683b5fd4ff884d7665cdef01b73fd3 /generic/tclCompExpr.c
parent0a2ac311c1e846784b98690d22c678d68ec117ec (diff)
downloadtcl-f9fb8c8daf918e57d3a50a0428623a5e5c260e70.zip
tcl-f9fb8c8daf918e57d3a50a0428623a5e5c260e70.tar.gz
tcl-f9fb8c8daf918e57d3a50a0428623a5e5c260e70.tar.bz2
Stop using isalnum(.). Its results are not portable. Replace with our
own private routine TclIsBareword() that does exactly what we want.
Diffstat (limited to 'generic/tclCompExpr.c')
-rw-r--r--generic/tclCompExpr.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c
index dde4e56..2470931 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.c
@@ -1920,8 +1920,7 @@ ParseLexeme(
literal = Tcl_NewObj();
if (TclParseNumber(NULL, literal, NULL, start, numBytes, &end,
TCL_PARSE_NO_WHITESPACE) == TCL_OK) {
- if (end < start + numBytes && !isalnum(UCHAR(*end))
- && UCHAR(*end) != '_') {
+ if (end < start + numBytes && !TclIsBareword(*end)) {
number:
TclInitStringRep(literal, start, end-start);
@@ -1945,7 +1944,7 @@ ParseLexeme(
if (literal->typePtr == &tclDoubleType) {
const char *p = start;
while (p < end) {
- if (!isalnum(UCHAR(*p++))) {
+ if (!TclIsBareword(*p++)) {
/*
* The number has non-bareword characters, so we
* must treat it as a number.
@@ -1969,7 +1968,13 @@ ParseLexeme(
}
}
- if (!isalnum(UCHAR(*start))) {
+ /*
+ * We reject leading underscores in bareword. No sensible reason why.
+ * Might be inspired by reserved identifier rules in C, which of course
+ * have no direct relevance here.
+ */
+
+ if (!TclIsBareword(*start) || *start == '_') {
if (Tcl_UtfCharComplete(start, numBytes)) {
scanned = Tcl_UtfToUniChar(start, &ch);
} else {
@@ -1983,7 +1988,7 @@ ParseLexeme(
return scanned;
}
end = start;
- while (numBytes && (isalnum(UCHAR(*end)) || (UCHAR(*end) == '_'))) {
+ while (numBytes && TclIsBareword(*end)) {
end += 1;
numBytes -= 1;
}