summaryrefslogtreecommitdiffstats
path: root/mac/tclMacInit.c
diff options
context:
space:
mode:
authorjingham <jingham>1999-05-11 07:11:46 (GMT)
committerjingham <jingham>1999-05-11 07:11:46 (GMT)
commit7e5fa22b2798227ac6c6f48a3f0d6f767f658c14 (patch)
tree75a17d12246664b170ac64121f77deff56d7ef90 /mac/tclMacInit.c
parent7c4092a142f2c47e20b34c96adfb38b9a70083a6 (diff)
downloadtcl-7e5fa22b2798227ac6c6f48a3f0d6f767f658c14.zip
tcl-7e5fa22b2798227ac6c6f48a3f0d6f767f658c14.tar.gz
tcl-7e5fa22b2798227ac6c6f48a3f0d6f767f658c14.tar.bz2
Various small fixes that were required to get Tcl to build cleanly on the Mac.
Diffstat (limited to 'mac/tclMacInit.c')
-rw-r--r--mac/tclMacInit.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/mac/tclMacInit.c b/mac/tclMacInit.c
index 6bf6169..53ab851 100644
--- a/mac/tclMacInit.c
+++ b/mac/tclMacInit.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclMacInit.c,v 1.3 1999/04/16 00:47:20 stanton Exp $
+ * RCS: @(#) $Id: tclMacInit.c,v 1.4 1999/05/11 07:12:16 jingham Exp $
*/
#include <AppleEvents.h>
@@ -573,6 +573,64 @@ TclpCheckStackSpace()
/*
*----------------------------------------------------------------------
*
+ * TclpFindVariable --
+ *
+ * Locate the entry in environ for a given name. On Unix and Macthis
+ * routine is case sensitive, on Windows this matches mixed case.
+ *
+ * Results:
+ * The return value is the index in environ of an entry with the
+ * name "name", or -1 if there is no such entry. The integer at
+ * *lengthPtr is filled in with the length of name (if a matching
+ * entry is found) or the length of the environ array (if no matching
+ * entry is found).
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TclpFindVariable(name, lengthPtr)
+ CONST char *name; /* Name of desired environment variable
+ * (native). */
+ int *lengthPtr; /* Used to return length of name (for
+ * successful searches) or number of non-NULL
+ * entries in environ (for unsuccessful
+ * searches). */
+{
+ int i, result = -1;
+ register CONST char *env, *p1, *p2;
+ Tcl_DString envString;
+
+ Tcl_DStringInit(&envString);
+ for (i = 0, env = environ[i]; env != NULL; i++, env = environ[i]) {
+ p1 = Tcl_ExternalToUtfDString(NULL, env, -1, &envString);
+ p2 = name;
+
+ for (; *p2 == *p1; p1++, p2++) {
+ /* NULL loop body. */
+ }
+ if ((*p1 == '=') && (*p2 == '\0')) {
+ *lengthPtr = p2 - name;
+ result = i;
+ goto done;
+ }
+
+ Tcl_DStringFree(&envString);
+ }
+
+ *lengthPtr = i;
+
+ done:
+ Tcl_DStringFree(&envString);
+ return result;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* Tcl_Init --
*
* This procedure is typically invoked by Tcl_AppInit procedures