Revision: 77544
http://sourceforge.net/p/brlcad/code/77544
Author: starseeker
Date: 2020-10-22 15:44:24 +0000 (Thu, 22 Oct 2020)
Log Message:
-----------
Adapt libtclcad auto_path setup changes from thirdparty rework branch. Uses
bu_dir to do path lookups.
Modified Paths:
--------------
brlcad/trunk/src/libtclcad/auto_path.c
Modified: brlcad/trunk/src/libtclcad/auto_path.c
===================================================================
--- brlcad/trunk/src/libtclcad/auto_path.c 2020-10-22 15:24:43 UTC (rev
77543)
+++ brlcad/trunk/src/libtclcad/auto_path.c 2020-10-22 15:44:24 UTC (rev
77544)
@@ -37,250 +37,270 @@
#endif
#include "bu/app.h"
+#include "bu/path.h"
+#include "bu/ptbl.h"
#include "tclcad.h"
#define MAX_BUF 2048
-/* Appends a new path to the path list, preceded by BU_PATH_SEPARATOR.
- *
- * The path is specified as a sequence of string arguments, one per
- * directory, terminated by a (const char *)NULL argument.
- *
- * BU_DIR_SEPARATOR is inserted between the string arguments (but not
- * before or after the path).
- */
-static void
-join_path(struct bu_vls *path_list, ...)
-{
- va_list ap;
- const char *dir;
-
- bu_vls_putc(path_list, BU_PATH_SEPARATOR);
-
- va_start(ap, path_list);
-
- dir = va_arg(ap, const char *);
- while (dir != NULL) {
- bu_vls_printf(path_list, "%s", dir);
-
- dir = va_arg(ap, const char *);
- if (dir != NULL) {
- bu_vls_putc(path_list, BU_DIR_SEPARATOR);
- }
- }
- va_end(ap);
-}
-
/**
* Set up the Tcl auto_path for locating various necessary BRL-CAD
* scripting resources. Detect whether the current invocation is from
* an installed binary or not and append to the auto_path accordingly
* for where the needed tclscript resources should be found.
- *
- ** installed invocation paths
- * BRLCAD_ROOT/lib/tclTCL_VERSION/init.tcl
- * BRLCAD_ROOT/lib/tclTK_VERSION/tk.tcl
- * BRLCAD_ROOT/lib/itclITCL_VERSION/itcl.tcl
- * BRLCAD_ROOT/lib/itkITCL_VERSION/itk.tcl
- * BRLCAD_ROOT/lib/iwidgetsIWIDGETS_VERSION/iwidgets.tcl
- * BRLCAD_ROOT/share/tclscripts/pkgIndex.tcl and subdirs
- *
- * if TCLCAD_LIBRARY_PATH is set
- * append to search path
- * get installation directory and invocation path
- * if being run from installation directory
- * add installation paths to search path
- * if being run from source directory
- * add source paths to search path
- * add installation paths to search path
*/
void
tclcad_auto_path(Tcl_Interp *interp)
{
- struct bu_vls auto_path = BU_VLS_INIT_ZERO;
- struct bu_vls lappend = BU_VLS_INIT_ZERO;
- const char *library_path = NULL;
- struct bu_vls root_buf = BU_VLS_INIT_ZERO;
- const char *root = NULL;
- const char *data = NULL;
- char buffer[MAX_BUF] = {0};
-
- const char *which_argv = NULL;
- const char *srcpath = NULL;
- int from_installed = 0;
-
- int found_init_tcl = 0;
- int found_tk_tcl = 0;
- int found_itcl_tcl = 0;
- int found_itk_tcl = 0;
-
- char pathsep[2] = { BU_PATH_SEPARATOR, '\0' };
-
- struct bu_vls initpath = BU_VLS_INIT_ZERO;
- struct bu_vls tcl = BU_VLS_INIT_ZERO;
- struct bu_vls itcl = BU_VLS_INIT_ZERO;
-#ifdef HAVE_TK
- struct bu_vls tk = BU_VLS_INIT_ZERO;
- struct bu_vls itk = BU_VLS_INIT_ZERO;
- struct bu_vls iwidgets = BU_VLS_INIT_ZERO;
-#endif
-
if (!interp) {
/* nothing to do */
return;
}
+ /* Used for getenv calls */
+ const char *env = NULL;
+
+
/* If we are using an external Tcl, we need the
* location of its init file */
- bu_vls_trunc(&initpath, 0);
+ int tcl_set = 0;
#ifdef TCL_SYSTEM_INITTCL_PATH
+ struct bu_vls initpath = BU_VLS_INIT_ZERO;
bu_vls_printf(&initpath, "set tcl_library {%s}", TCL_SYSTEM_INITTCL_PATH);
if (Tcl_Eval(interp, bu_vls_addr(&initpath))) {
- bu_log("Problem initializaing tcl_library to system init.tcl path:
Tcl_Eval ERROR:\n%s\n", Tcl_GetStringResult(interp));
+ bu_log("Problem initializing tcl_library to system init.tcl path:
Tcl_Eval ERROR:\n%s\n", Tcl_GetStringResult(interp));
+ } else {
+ tcl_set = 1;
}
+ bu_vls_free(&initpath);
#endif
- bu_vls_printf(&tcl, "tcl%s", TCL_VERSION);
- bu_vls_printf(&itcl, "itcl%s", ITCL_VERSION);
-#ifdef HAVE_TK
- bu_vls_printf(&tk, "tk%s", TK_VERSION);
- bu_vls_printf(&itk, "itk%s", ITCL_VERSION);
- bu_vls_printf(&iwidgets, "iwidgets%s", IWIDGETS_VERSION);
-#endif
+ struct bu_ptbl paths = BU_PTBL_INIT_ZERO;
- root = bu_brlcad_root("", 1);
- bu_vls_printf(&root_buf, "%s", root);
- root = bu_vls_addr(&root_buf);
- data = bu_brlcad_root("share", 1);
+ /* If TCLCAD_LIBRARY_PATH is set, add to active paths. */
+ env = getenv("TCLCAD_LIBRARY_PATH");
+ if (env) {
+ struct bu_vls buffer = BU_VLS_INIT_ZERO;
+ /* limit path length from env var for sanity */
+ bu_vls_strncat(&buffer, env, MAX_BUF);
+ const char *p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&paths, (long *)p);
+ bu_vls_free(&buffer);
+ }
- /* determine if TCLCAD_LIBRARY_PATH is set */
- library_path = getenv("TCLCAD_LIBRARY_PATH");
- if (library_path) {
- /* it is set, set auto_path. limit buf just because. */
- bu_vls_strncat(&auto_path, library_path, MAX_BUF);
+ /* See if user set ITCL_LIBRARY override */
+ int itcl_set = 0;
+ env = getenv("ITCL_LIBRARY");
+ if (env) {
+ struct bu_vls buffer = BU_VLS_INIT_ZERO;
+ bu_vls_strncat(&buffer, env, MAX_BUF);
+ bu_vls_printf(&buffer, "%citcl.tcl", BU_DIR_SEPARATOR);
+ if (bu_file_exists(bu_vls_cstr(&buffer), NULL)) {
+ const char *p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&paths, (long *)p);
+ itcl_set = 1;
+ } else {
+ bu_log("Warning: ITCL_LIBRARY environment variable is set to %s,
but file itcl.tcl is not found in that directory, skipping.\n", env);
+ }
+ bu_vls_free(&buffer);
}
- /* make sure tcl_library path is in the auto_path */
- snprintf(buffer, MAX_BUF, "set tcl_library");
- Tcl_Eval(interp, buffer);
- bu_vls_strncat(&auto_path, Tcl_GetStringResult(interp), MAX_BUF);
+ /* See if user set ITK_LIBRARY override */
+ int itk_set = 0;
+ env = getenv("ITK_LIBRARY");
+ if (env) {
+ struct bu_vls buffer = BU_VLS_INIT_ZERO;
+ bu_vls_strncat(&buffer, env, MAX_BUF);
+ bu_vls_printf(&buffer, "%citk.tcl", BU_DIR_SEPARATOR);
+ if (bu_file_exists(bu_vls_cstr(&buffer), NULL)) {
+ const char *p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&paths, (long *)p);
+ } else {
+ bu_log("Warning: ITK_LIBRARY environment variable is set to %s, but
file itk.tcl is not found in that directory, skipping.\n", env);
+ }
+ bu_vls_free(&buffer);
+ }
- /* get string of invocation binary */
- which_argv = bu_which(bu_argv0_full_path());
- if (!which_argv) {
- which_argv = bu_argv0_full_path();
+ /* If tcl_library is defined in the interp, capture it for addition */
+ {
+ struct bu_vls buffer = BU_VLS_INIT_ZERO;
+ /* limit path length from env var for sanity */
+ bu_vls_sprintf(&buffer, "set tcl_library");
+ Tcl_Eval(interp, bu_vls_cstr(&buffer));
+ bu_vls_sprintf(&buffer, "%s", Tcl_GetStringResult(interp));
+ if (bu_vls_strlen(&buffer)) {
+ const char *p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&paths, (long *)p);
+ }
+ bu_vls_free(&buffer);
}
- /* get name of installation binary */
- snprintf(buffer, MAX_BUF, "%s%cbin%c%s", root, BU_DIR_SEPARATOR,
BU_DIR_SEPARATOR, bu_getprogname());
+ /* Set up the subdirectories of interest. Some are static, but some are
+ * version specific - we construct a table of all of them for easier
+ * use in subsequent testing. */
+ struct bu_ptbl lib_subpaths = BU_PTBL_INIT_ZERO;
+ struct bu_ptbl data_subpaths = BU_PTBL_INIT_ZERO;
+ {
+ const char *p = NULL;
+ struct bu_vls buffer = BU_VLS_INIT_ZERO;
- /* are we running from an installed binary? if so add to path */
- if (bu_file_exists(buffer, NULL) && bu_file_same(buffer, which_argv)) {
- from_installed = 1;
- join_path(&auto_path, root, "lib", NULL);
- join_path(&auto_path, root, "lib", bu_vls_addr(&tcl), NULL);
+ bu_vls_sprintf(&buffer, "tcl%s", TCL_VERSION);
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&lib_subpaths, (long *)p);
+
+ bu_vls_sprintf(&buffer, "itcl%s", ITCL_VERSION);
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&lib_subpaths, (long *)p);
+
#ifdef HAVE_TK
- join_path(&auto_path, root, "lib", bu_vls_addr(&tk), NULL);
+ bu_vls_sprintf(&buffer, "tk%s", TK_VERSION);
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&lib_subpaths, (long *)p);
+
+ bu_vls_sprintf(&buffer, "itk%s", ITCL_VERSION);
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&lib_subpaths, (long *)p);
+
+ bu_vls_sprintf(&buffer, "Iwidgets%s", IWIDGETS_VERSION);
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&lib_subpaths, (long *)p);
+
+ bu_vls_sprintf(&buffer, "Tkhtml3.0");
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&lib_subpaths, (long *)p);
+
+ bu_vls_sprintf(&buffer, "Tktable2.10");
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&lib_subpaths, (long *)p);
#endif
- join_path(&auto_path, root, "lib", bu_vls_addr(&itcl), NULL);
-#ifdef HAVE_TK
- join_path(&auto_path, root, "lib", bu_vls_addr(&itk), NULL);
- join_path(&auto_path, root, "lib", bu_vls_addr(&iwidgets), NULL);
-#endif
- join_path(&auto_path, data, "tclscripts", NULL);
- join_path(&auto_path, data, "tclscripts", "lib", NULL);
- join_path(&auto_path, data, "tclscripts", "util", NULL);
- join_path(&auto_path, data, "tclscripts", "mged", NULL);
- join_path(&auto_path, data, "tclscripts", "geometree", NULL);
- join_path(&auto_path, data, "tclscripts", "graph", NULL);
- join_path(&auto_path, data, "tclscripts", "rtwizard", NULL);
- join_path(&auto_path, data, "tclscripts", "archer", NULL);
- join_path(&auto_path, data, "tclscripts", "boteditor", NULL);
- join_path(&auto_path, data, "tclscripts", "checker", NULL);
- join_path(&auto_path, data, "tclscripts", "lod", NULL);
- }
- /* be sure to check installation paths even if we aren't running from
there */
- if (!from_installed) {
- join_path(&auto_path, root, "lib", NULL);
- join_path(&auto_path, root, "lib", bu_vls_addr(&tcl), NULL);
-#ifdef HAVE_TK
- join_path(&auto_path, root, "lib", bu_vls_addr(&tk), NULL);
-#endif
- join_path(&auto_path, root, "lib", bu_vls_addr(&itcl), NULL);
-#ifdef HAVE_TK
- join_path(&auto_path, root, "lib", bu_vls_addr(&itk), NULL);
- join_path(&auto_path, root, "lib", bu_vls_addr(&iwidgets), NULL);
-#endif
- join_path(&auto_path, data, "tclscripts", NULL);
- join_path(&auto_path, data, "tclscripts", "lib", NULL);
- join_path(&auto_path, data, "tclscripts", "util", NULL);
- join_path(&auto_path, data, "tclscripts", "mged", NULL);
- join_path(&auto_path, data, "tclscripts", "geometree", NULL);
- join_path(&auto_path, data, "tclscripts", "graph", NULL);
- join_path(&auto_path, data, "tclscripts", "rtwizard", NULL);
- join_path(&auto_path, data, "tclscripts", "archer", NULL);
- join_path(&auto_path, data, "tclscripts", "boteditor", NULL);
- join_path(&auto_path, data, "tclscripts", "checker", NULL);
- join_path(&auto_path, data, "tclscripts", "lod", NULL);
+ bu_vls_sprintf(&buffer, "tclscripts");
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&data_subpaths, (long *)p);
+
+ bu_vls_sprintf(&buffer, "tclscripts%clib", BU_DIR_SEPARATOR);
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&data_subpaths, (long *)p);
+
+ bu_vls_sprintf(&buffer, "tclscripts%cutil", BU_DIR_SEPARATOR);
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&data_subpaths, (long *)p);
+
+ bu_vls_sprintf(&buffer, "tclscripts%cmged", BU_DIR_SEPARATOR);
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&data_subpaths, (long *)p);
+
+ bu_vls_sprintf(&buffer, "tclscripts%cgeometree", BU_DIR_SEPARATOR);
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&data_subpaths, (long *)p);
+
+ bu_vls_sprintf(&buffer, "tclscripts%crtwizard", BU_DIR_SEPARATOR);
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&data_subpaths, (long *)p);
+
+ bu_vls_sprintf(&buffer, "tclscripts%carcher", BU_DIR_SEPARATOR);
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&data_subpaths, (long *)p);
+
+ bu_vls_sprintf(&buffer, "tclscripts%cboteditor", BU_DIR_SEPARATOR);
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&data_subpaths, (long *)p);
+
+ bu_vls_sprintf(&buffer, "tclscripts%cchecker", BU_DIR_SEPARATOR);
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&data_subpaths, (long *)p);
+
+ bu_vls_sprintf(&buffer, "tclscripts%clod", BU_DIR_SEPARATOR);
+ p = bu_strdup(bu_vls_cstr(&buffer));
+ bu_ptbl_ins(&data_subpaths, (long *)p);
}
- /* printf("AUTO_PATH IS %s\n", bu_vls_addr(&auto_path)); */
-
- /* see if user already set ITCL_LIBRARY override */
- library_path = getenv("ITCL_LIBRARY");
- if (!found_itcl_tcl && library_path) {
- snprintf(buffer, MAX_BUF, "%s%citcl.tcl", library_path,
BU_DIR_SEPARATOR);
- if (bu_file_exists(buffer, NULL)) {
- found_itcl_tcl=1;
+ // First off, see what's in BU_DIR_LIB.
+ char libdir[MAXPATHLEN] = {0};
+ struct bu_vls lib_path = BU_VLS_INIT_ZERO;
+ bu_dir(libdir, MAXPATHLEN, BU_DIR_LIB, NULL);
+ {
+ struct bu_ptbl found_subpaths = BU_PTBL_INIT_ZERO;
+ if (strlen(libdir)) {
+ // Have a library directory, see what's in it
+ for (size_t i = 0; i < BU_PTBL_LEN(&lib_subpaths); i++) {
+ const char *fname = (const char *)BU_PTBL_GET(&lib_subpaths, i);
+ bu_vls_sprintf(&lib_path, "%s%c%s", libdir, BU_DIR_SEPARATOR,
fname);
+ if (bu_file_exists(bu_vls_cstr(&lib_path), NULL)) {
+ // Have a path
+ const char *p = bu_strdup(bu_vls_cstr(&lib_path));
+ bu_ptbl_ins(&paths, (long *)p);
+ bu_ptbl_ins(&found_subpaths, (long *)fname);
+ }
+ }
+ // Clear anything we found out of lib_subpaths - we don't need or
+ // want to find it again. The more local to the install, the
+ // better...
+ for (size_t i = 0; i < BU_PTBL_LEN(&found_subpaths); i++) {
+ bu_ptbl_rm(&lib_subpaths, BU_PTBL_GET(&found_subpaths, i));
+ }
}
+ bu_ptbl_free(&found_subpaths);
}
- /* see if user already set ITK_LIBRARY override */
- library_path = getenv("ITK_LIBRARY");
- if (!found_itk_tcl && library_path) {
- snprintf(buffer, MAX_BUF, "%s%citk.tcl", library_path,
BU_DIR_SEPARATOR);
- if (bu_file_exists(buffer, NULL)) {
- found_itk_tcl=1;
+ // Now that we've looked for the libs, handle the data dirs.
+ struct bu_vls data_path = BU_VLS_INIT_ZERO;
+ char datadir[MAXPATHLEN] = {0};
+ bu_dir(datadir, MAXPATHLEN, BU_DIR_DATA, NULL);
+ if (strlen(datadir)) {
+ // Have a directory, see what's in it
+ for (size_t i = 0; i < BU_PTBL_LEN(&data_subpaths); i++) {
+ const char *fname = (const char *)BU_PTBL_GET(&data_subpaths, i);
+ bu_vls_sprintf(&data_path, "%s%c%s", datadir, BU_DIR_SEPARATOR,
fname);
+ if (bu_file_exists(bu_vls_cstr(&data_path), NULL)) {
+ // Have a path
+ const char *p = bu_strdup(bu_vls_cstr(&data_path));
+ bu_ptbl_ins(&paths, (long *)p);
+ } else {
+ bu_log("Warning: data path %s is not present in directory
%s\n", fname, datadir);
+ }
}
}
- /* iterate over the auto_path list and modify the real Tcl auto_path */
- for (srcpath = strtok(bu_vls_addr(&auto_path), pathsep);
- srcpath;
- srcpath = strtok(NULL, pathsep)) {
-
+ /* Iterate over the paths set and modify the real Tcl auto_path */
+ int tk_set = 0;
+ for (size_t i = 0; i < BU_PTBL_LEN(&paths); i++) {
+ const char *path = (const char *)BU_PTBL_GET(&paths, i);
/* make sure it exists before appending */
- if (bu_file_exists(srcpath, NULL)) {
- /* printf("APPENDING: %s\n", srcpath); */
- bu_vls_sprintf(&lappend, "lappend auto_path {%s}", srcpath);
+ if (bu_file_exists(path, NULL)) {
+ //printf("APPENDING: %s\n", path);
+ struct bu_vls lappend = BU_VLS_INIT_ZERO;
+ bu_vls_sprintf(&lappend, "lappend auto_path {%s}", path);
(void)Tcl_Eval(interp, bu_vls_addr(&lappend));
+ bu_vls_free(&lappend);
} else {
- /* printf("NOT APPENDING: %s\n", srcpath); */
+ //printf("NOT APPENDING: %s\n", path);
continue;
}
+ /* Look for a number of special case initializations */
+
+ struct bu_vls buffer = BU_VLS_INIT_ZERO;
/* specifically look for init.tcl so we can set tcl_library */
- if (!found_init_tcl) {
- snprintf(buffer, MAX_BUF, "%s%cinit.tcl", srcpath,
BU_DIR_SEPARATOR);
- if (bu_file_exists(buffer, NULL)) {
+ if (!tcl_set) {
+ bu_vls_sprintf(&buffer, "%s%cinit.tcl", path, BU_DIR_SEPARATOR);
+ if (bu_file_exists(bu_vls_cstr(&buffer), NULL)) {
/* this really sets it */
- snprintf(buffer, MAX_BUF, "set tcl_library {%s}", srcpath);
- if (Tcl_Eval(interp, buffer)) {
+ bu_vls_sprintf(&buffer, "set tcl_library {%s}", path);
+ if (Tcl_Eval(interp, bu_vls_cstr(&buffer))) {
bu_log("Tcl_Eval ERROR:\n%s\n",
Tcl_GetStringResult(interp));
} else {
- found_init_tcl=1;
+ tcl_set=1;
}
- /* extra measures necessary for "create interp":
- * determine if TCL_LIBRARY is set, and set it if not.
- */
- library_path = getenv("TCL_LIBRARY");
- if (!library_path) {
+ /* extra measures necessary for "create interp": determine if
+ * TCL_LIBRARY is set, and set it if not. */
+ env = getenv("TCL_LIBRARY");
+ if (!env) {
/* this REALLY sets it */
- snprintf(buffer, MAX_BUF, "set env(TCL_LIBRARY) {%s}",
srcpath);
- if (Tcl_Eval(interp, buffer)) {
+ bu_vls_sprintf(&buffer, "set env(TCL_LIBRARY) {%s}", path);
+ if (Tcl_Eval(interp, bu_vls_cstr(&buffer))) {
bu_log("Tcl_Eval ERROR:\n%s\n",
Tcl_GetStringResult(interp));
}
}
@@ -288,59 +308,65 @@
}
/* specifically look for tk.tcl so we can set tk_library */
- if (!found_tk_tcl) {
- snprintf(buffer, MAX_BUF, "%s%ctk.tcl", srcpath, BU_DIR_SEPARATOR);
- if (bu_file_exists(buffer, NULL)) {
+ if (!tk_set) {
+ bu_vls_sprintf(&buffer, "%s%ctk.tcl", path, BU_DIR_SEPARATOR);
+ if (bu_file_exists(bu_vls_cstr(&buffer), NULL)) {
/* this really sets it */
- snprintf(buffer, MAX_BUF, "set tk_library {%s}", srcpath);
- if (Tcl_Eval(interp, buffer)) {
+ bu_vls_sprintf(&buffer, "set tk_library {%s}", path);
+ if (Tcl_Eval(interp, bu_vls_cstr(&buffer))) {
bu_log("Tcl_Eval ERROR:\n%s\n",
Tcl_GetStringResult(interp));
} else {
- found_tk_tcl=1;
+ tk_set=1;
}
}
}
/* specifically look for itcl.tcl so we can set ITCL_LIBRARY */
- if (!found_itcl_tcl) {
- snprintf(buffer, MAX_BUF, "%s%citcl.tcl", srcpath,
BU_DIR_SEPARATOR);
- if (bu_file_exists(buffer, NULL)) {
+ if (!itcl_set) {
+ bu_vls_sprintf(&buffer, "%s%citcl.tcl", path, BU_DIR_SEPARATOR);
+ if (bu_file_exists(bu_vls_cstr(&buffer), NULL)) {
/* this really sets it */
- snprintf(buffer, MAX_BUF, "set env(ITCL_LIBRARY) {%s}",
srcpath);
- if (Tcl_Eval(interp, buffer)) {
+ bu_vls_sprintf(&buffer, "set env(ITCL_LIBRARY) {%s}", path);
+ if (Tcl_Eval(interp, bu_vls_cstr(&buffer))) {
bu_log("Tcl_Eval ERROR:\n%s\n",
Tcl_GetStringResult(interp));
} else {
- found_itcl_tcl=1;
+ itcl_set=1;
}
}
}
/* specifically look for itk.tcl so we can set ITK_LIBRARY */
- if (!found_itk_tcl) {
- snprintf(buffer, MAX_BUF, "%s%citk.tcl", srcpath, BU_DIR_SEPARATOR);
- if (bu_file_exists(buffer, NULL)) {
+ if (!itk_set) {
+ bu_vls_sprintf(&buffer, "%s%citk.tcl", path, BU_DIR_SEPARATOR);
+ if (bu_file_exists(bu_vls_cstr(&buffer), NULL)) {
/* this really sets it */
- snprintf(buffer, MAX_BUF, "set env(ITK_LIBRARY) {%s}", srcpath);
- if (Tcl_Eval(interp, buffer)) {
+ bu_vls_sprintf(&buffer, "set env(ITK_LIBRARY) {%s}", path);
+ if (Tcl_Eval(interp, bu_vls_cstr(&buffer))) {
bu_log("Tcl_Eval ERROR:\n%s\n",
Tcl_GetStringResult(interp));
} else {
- found_itk_tcl=1;
+ itk_set=1;
}
}
}
+
+ bu_vls_free(&buffer);
}
- which_argv = NULL;
- bu_vls_free(&tcl);
- bu_vls_free(&itcl);
-#ifdef HAVE_TK
- bu_vls_free(&tk);
- bu_vls_free(&itk);
- bu_vls_free(&iwidgets);
-#endif
- bu_vls_free(&auto_path);
- bu_vls_free(&lappend);
- bu_vls_free(&root_buf);
+ for (size_t i = 0; i < BU_PTBL_LEN(&lib_subpaths); i++) {
+ char *str = (char *)BU_PTBL_GET(&lib_subpaths, i);
+ bu_free(str, "subpath string");
+ }
+ bu_ptbl_free(&lib_subpaths);
+ for (size_t i = 0; i < BU_PTBL_LEN(&data_subpaths); i++) {
+ char *str = (char *)BU_PTBL_GET(&data_subpaths, i);
+ bu_free(str, "subpath string");
+ }
+ bu_ptbl_free(&data_subpaths);
+ for (size_t i = 0; i < BU_PTBL_LEN(&paths); i++) {
+ char *str = (char *)BU_PTBL_GET(&paths, i);
+ bu_free(str, "subpath string");
+ }
+ bu_ptbl_free(&paths);
return;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits