summaryrefslogtreecommitdiffstats
path: root/generic/tclParse.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)
commitdd4c175c818027548fd867fe331db5239880b1fd (patch)
tree04aa3988f0683b5fd4ff884d7665cdef01b73fd3 /generic/tclParse.c
parent29b10229deb6b1489a5cf433a83bd0796feef568 (diff)
downloadtcl-dd4c175c818027548fd867fe331db5239880b1fd.zip
tcl-dd4c175c818027548fd867fe331db5239880b1fd.tar.gz
tcl-dd4c175c818027548fd867fe331db5239880b1fd.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/tclParse.c')
-rw-r--r--generic/tclParse.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/generic/tclParse.c b/generic/tclParse.c
index 90ec43d..025304c 100644
--- a/generic/tclParse.c
+++ b/generic/tclParse.c
@@ -628,6 +628,47 @@ TclIsSpaceProc(
/*
*----------------------------------------------------------------------
*
+ * TclIsBareword--
+ *
+ * Report whether byte is one that can be part of a "bareword".
+ * This concept is named in expression parsing, where it determines
+ * what can be a legal function name, but is the same definition used
+ * in determining what variable names can be parsed as variable
+ * substitutions without the benefit of enclosing braces. The set of
+ * ASCII chars that are accepted are the numeric chars ('0'-'9'),
+ * the alphabetic chars ('a'-'z', 'A'-'Z') and underscore ('_').
+ *
+ * Results:
+ * Returns 1, if byte is in the accepted set of chars, 0 otherwise.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TclIsBareword(
+ char byte)
+{
+ if (byte < '0' || byte > 'z') {
+ return 0;
+ }
+ if (byte <= '9' || byte >= 'a') {
+ return 1;
+ }
+ if (byte == '_') {
+ return 1;
+ }
+ if (byte < 'A' || byte > 'Z') {
+ return 0;
+ }
+ return 1;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* ParseWhiteSpace --
*
* Scans up to numBytes bytes starting at src, consuming white space
@@ -1343,7 +1384,6 @@ Tcl_ParseVarName(
{
Tcl_Token *tokenPtr;
register const char *src;
- unsigned char c;
int varIndex;
unsigned array;
@@ -1427,13 +1467,12 @@ Tcl_ParseVarName(
tokenPtr->numComponents = 0;
while (numBytes) {
- c = UCHAR(*src);
- if (isalnum(c) || (c == '_')) { /* INTL: ISO only, UCHAR. */
+ if (TclIsBareword(*src)) {
src += 1;
numBytes -= 1;
continue;
}
- if ((c == ':') && (numBytes != 1) && (src[1] == ':')) {
+ if ((src[0] == ':') && (numBytes != 1) && (src[1] == ':')) {
src += 2;
numBytes -= 2;
while (numBytes && (*src == ':')) {