diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2007-04-10 14:47:06 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2007-04-10 14:47:06 (GMT) |
commit | 0379fe02395721d2ea1419c61ca69ec818561082 (patch) | |
tree | e12acd4bb445070087067812722f564f29218f8d /generic/tclFileName.c | |
parent | f7f181d5456b19b4726f71223362bf82d761d8ff (diff) | |
download | tcl-0379fe02395721d2ea1419c61ca69ec818561082.zip tcl-0379fe02395721d2ea1419c61ca69ec818561082.tar.gz tcl-0379fe02395721d2ea1419c61ca69ec818561082.tar.bz2 |
Handle creation of Tcl_Objs from constant strings better (easier to use, more
efficient). After [Patch 1529526] (afredd)
Diffstat (limited to 'generic/tclFileName.c')
-rw-r--r-- | generic/tclFileName.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/generic/tclFileName.c b/generic/tclFileName.c index 131a8d5..b9417d6 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclFileName.c,v 1.79 2007/04/02 18:48:03 dgp Exp $ + * RCS: @(#) $Id: tclFileName.c,v 1.80 2007/04/10 14:47:15 dkf Exp $ */ #include "tclInt.h" @@ -663,7 +663,7 @@ SplitUnixPath( if (length > 0) { Tcl_Obj *nextElt; if ((elementStart[0] == '~') && (elementStart != path)) { - nextElt = Tcl_NewStringObj("./",2); + TclNewLiteralStringObj(nextElt, "./"); Tcl_AppendToObj(nextElt, elementStart, length); } else { nextElt = Tcl_NewStringObj(elementStart, length); @@ -731,11 +731,10 @@ SplitWinPath( length = p - elementStart; if (length > 0) { Tcl_Obj *nextElt; - if ((elementStart != path) - && ((elementStart[0] == '~') + if ((elementStart != path) && ((elementStart[0] == '~') || (isalpha(UCHAR(elementStart[0])) && elementStart[1] == ':'))) { - nextElt = Tcl_NewStringObj("./",2); + TclNewLiteralStringObj(nextElt, "./"); Tcl_AppendToObj(nextElt, elementStart, length); } else { nextElt = Tcl_NewStringObj(elementStart, length); @@ -1972,9 +1971,9 @@ TclGlob( if (len == prefixLen) { if ((pattern[0] == '\0') || (strchr(separators, pattern[0]) == NULL)) { - elems[0] = Tcl_NewStringObj(".", 1); + TclNewLiteralStringObj(elems[0], "."); } else { - elems[0] = Tcl_NewStringObj("/", 1); + TclNewLiteralStringObj(elems[0], "/"); } } else { elems[0] = Tcl_NewStringObj(oldStr+prefixLen, len-prefixLen); |