summaryrefslogtreecommitdiffstats
path: root/contrib/tcl/generic/tclEnv.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1996-09-18 14:12:34 +0000
committerphk <phk@FreeBSD.org>1996-09-18 14:12:34 +0000
commiteddad0f34b706e81103cb2e2b1fab377342f70a5 (patch)
treea65b0638d4c228ef402ccd1817c7173fd553c4db /contrib/tcl/generic/tclEnv.c
parent94e258bfb263226fd5924a6e9e26b3ab82fe6202 (diff)
parent4170733a21f58ada18a6760af477926f494b5b67 (diff)
downloadFreeBSD-src-eddad0f34b706e81103cb2e2b1fab377342f70a5.zip
FreeBSD-src-eddad0f34b706e81103cb2e2b1fab377342f70a5.tar.gz
This commit was generated by cvs2svn to compensate for changes in r18351,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/tcl/generic/tclEnv.c')
-rw-r--r--contrib/tcl/generic/tclEnv.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/contrib/tcl/generic/tclEnv.c b/contrib/tcl/generic/tclEnv.c
index 4b92cc2..cfffefe 100644
--- a/contrib/tcl/generic/tclEnv.c
+++ b/contrib/tcl/generic/tclEnv.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.
*
- * SCCS: @(#) tclEnv.c 1.34 96/04/15 18:18:36
+ * SCCS: @(#) tclEnv.c 1.37 96/07/23 16:28:26
*/
/*
@@ -211,12 +211,17 @@ TclGetEnv(name)
char *name; /* Name of desired environment variable. */
{
int i;
- size_t len;
+ size_t len, nameLen;
+ char *equal;
+ nameLen = strlen(name);
for (i = 0; environ[i] != NULL; i++) {
- len = (size_t) ((char *) strchr(environ[i], '=') - environ[i]);
- if ((len > 0 && !strncmp(name, environ[i], len))
- || (*name == '\0')) {
+ equal = strchr(environ[i], '=');
+ if (equal == NULL) {
+ continue;
+ }
+ len = (size_t) (equal - environ[i]);
+ if ((len == nameLen) && (strncmp(name, environ[i], len) == 0)) {
/*
* The caller of this function should regard this
* as static memory.
@@ -601,4 +606,11 @@ EnvExitProc(clientData)
ckfree(*p);
}
ckfree((char *) environ);
+
+ /*
+ * Note that we need to reset the environ global so the Borland C run-time
+ * doesn't choke on exit.
+ */
+
+ environ = NULL;
}
OpenPOWER on IntegriCloud