|
From: Alan W. I. <ir...@be...> - 2002-07-02 18:58:58
|
On Tue, 2 Jul 2002, Vince Darley wrote:
> On Tue, 2 Jul 2002, Alan W. Irwin wrote:
>
> > application-specific initialization failed: Can't find a usable
> > tcl/plplot.tcl in the following directories:
> > /usr/plplot5.1/library
> >
> > I have looked at your changes to tclAPI.h, and I believe they should be very
> > close to working for the installed version (in fact I got something similar
> > to this to work on install simply by modifying initScript, but you beat me
> > to check-in, and your solution is more sophisticated in that it is meant to
> > work both on windows and linux).
> >
> > The only question I have is your change to the treatment of libDir. Is that
> > new treatment somehow limiting the search to just the one directory above
> > for the installed version? If you go back to the old treatment, I think
> > that the installed version will work on Linux (but of course that might
> > blast the success you now have with plplot/tmp so I leave it to you to
> > figure this out in a general way).
>
> I don't think it should restrict the search to one directory, but it seems
> to be doing just that. Perhaps your solution is better. What were you
> going to change 'initScript' to?
I didn't do anything particularly sophisticated. 3 versions ago (i.e., for
version 1.32), this worked
fine for install (but not for built version in plplot/tmp).
static char initScript[] =
"tcl_findLibrary plplot 5.1.0/tcl \"\" plplot.tcl PL_LIBRARY pllibrary";
i.e., I just replaced 5.1 by 5.1.0/tcl for just this line in 1.32. So I was
essentially just doing what you are now doing with initScriptExtended, and I
therefore think your current approach should work fine except for some
additional changes you made to libDir. Here is the diff I am talking about
between version 1.32 and version 1.35. I may have it wrong, but I think I
understand the initScriptExtended stuff so by elimination I think it is the
changed libDir stuff that is causing the trouble.
Alan
*******************
Index: tclAPI.c
===================================================================
RCS file: /cvsroot/plplot/plplot/bindings/tcl/tclAPI.c,v
retrieving revision 1.32
retrieving revision 1.35
diff -u -3 -p -r1.32 -r1.35
--- tclAPI.c 2 Jul 2002 11:30:36 -0000 1.32
+++ tclAPI.c 2 Jul 2002 16:44:25 -0000 1.35
@@ -1,4 +1,4 @@
-/* $Id: tclAPI.c,v 1.32 2002/07/02 11:30:36 vincentdarley Exp $
+/* $Id: tclAPI.c,v 1.35 2002/07/02 16:44:25 vincentdarley Exp $
Copyright 1994, 1995
Maurice LeBrun mj...@di...
@@ -313,6 +313,15 @@ loopbackCmd(ClientData clientData, Tcl_I
static char defaultLibraryDir[200] = PL_LIBRARY;
extern char* plplotLibDir;
+#if (!defined(MAC_TCL) && !defined(__WIN32__))
+/*
+ * Use an extended search for installations on Unix where we
+ * have very likely installed plplot so that plplot.tcl is
+ * in /usr/local/plplot/lib/plplot5.1.0/tcl
+ */
+#define PLPLOT_EXTENDED_SEARCH
+#endif
+
/*
* PlbasicInit
*
@@ -326,7 +335,11 @@ PlbasicInit( Tcl_Interp *interp )
{
static char initScript[] =
"tcl_findLibrary plplot 5.1 \"\" plplot.tcl PL_LIBRARY pllibrary";
- char *libDir;
+#ifdef PLPLOT_EXTENDED_SEARCH
+ static char initScriptExtended[] =
+ "tcl_findLibrary plplot 5.1.0 \"\" tcl/plplot.tcl PL_LIBRARY pllibrary";
+#endif
+ char *libDir = NULL;
#ifdef USE_TCL_STUBS
/*
* We hard-wire 8.1 here, rather than TCL_VERSION, TK_VERSION because
@@ -359,16 +372,48 @@ PlbasicInit( Tcl_Interp *interp )
#endif
Tcl_SetVar(interp, "plversion", "5.1", TCL_GLOBAL_ONLY);
- if(Tcl_Eval(interp, initScript))
+ if (Tcl_Eval(interp, initScript) != TCL_OK) {
+#ifdef PLPLOT_EXTENDED_SEARCH
+ if (Tcl_Eval(interp, initScriptExtended) != TCL_OK) {
+ /* Last chance, look in '.' */
+ Tcl_DString ds;
+ if (Tcl_Access("plplot.tcl", 0) != 0) {
+ return TCL_ERROR;
+ }
+ if (Tcl_EvalFile(interp, "plplot.tcl") != TCL_OK) {
+ return TCL_ERROR;
+ }
+ /* It is in the current directory */
+ libDir = Tcl_GetCwd(interp, &ds);
+ if (libDir == NULL) {
+ return TCL_ERROR;
+ }
+ libDir = strdup(libDir);
+ Tcl_DStringFree(&ds);
+ }
+ /*
+ * Clear the result so the user isn't confused by an error
+ * message from the previous failed search
+ */
+ Tcl_ResetResult(interp);
+#else
return TCL_ERROR;
+#endif
+ }
- libDir = Tcl_GetVar(interp, "pllibrary", TCL_GLOBAL_ONLY);
if (libDir == NULL) {
- Tcl_SetVar(interp, "pllibrary", defaultLibraryDir, TCL_GLOBAL_ONLY);
+ libDir = Tcl_GetVar(interp, "pllibrary", TCL_GLOBAL_ONLY);
+ if (libDir == NULL) {
+ /* I don't believe this path can ever be reached now */
+ Tcl_SetVar(interp, "pllibrary", defaultLibraryDir, TCL_GLOBAL_ONLY);
+ libDir = defaultLibraryDir;
+ }
} else {
- /* Used by init code in plctrl.c */
- plplotLibDir = strdup(libDir);
+ Tcl_SetVar(interp, "pllibrary", libDir, TCL_GLOBAL_ONLY);
}
+
+ /* Used by init code in plctrl.c */
+ plplotLibDir = strdup(libDir);
#ifdef TCL_DIR
if (libDir == NULL) {
*******************
|