aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-10-03 02:20:24 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-10-03 02:20:24 +0000
commit0dc933020bbd37805495b84ba208ade6254a84fb (patch)
tree0b0968c33c3047a75d253d031d6b1f8d6e2faee7
parentedcbcf6ae5371cd5e382ec2ec018f0c0caf38dca (diff)
simplified pdlib.tcl loading to just use c_externdir straight for loading, no hunting in the path
svn path=/trunk/externals/loaders/tclpd/; revision=15465
-rw-r--r--Makefile4
-rw-r--r--pkgIndex.tcl1
-rw-r--r--tclpd.c48
3 files changed, 13 insertions, 40 deletions
diff --git a/Makefile b/Makefile
index df7a5b9..7d86660 100644
--- a/Makefile
+++ b/Makefile
@@ -37,7 +37,7 @@ EXTRA_DIST = tcl.i tcl_extras.h pdlib.tcl pkgIndex.tcl $(TCLPD_SOURCES) ChangeLo
# -I"$(PD_INCLUDE)/pd" supports the header location for 0.43
INCLUDES = -I"$(PD_INCLUDE)/pd"
-CFLAGS = $(INCLUDES) -Wall -W -g -DPDSUF=\".$(EXTENSION)\" -std=c99
+CFLAGS = $(INCLUDES) -Wall -W -g
LDFLAGS =
LIBS =
LIBS_linux = -ltcl8.5
@@ -53,7 +53,7 @@ LIBS_windows = -ltcl85
# get library version from meta file
LIBRARY_VERSION = $(shell sed -n 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' $(LIBRARY_NAME)-meta.pd)
-CFLAGS += -DPD -DVERSION='"$(LIBRARY_VERSION)"'
+CFLAGS += -DPD -DVERSION='"$(LIBRARY_VERSION)"' -std=c99
PD_INCLUDE = $(PD_PATH)/include
# where to install the library, overridden below depending on platform
diff --git a/pkgIndex.tcl b/pkgIndex.tcl
deleted file mode 100644
index f460393..0000000
--- a/pkgIndex.tcl
+++ /dev/null
@@ -1 +0,0 @@
-package ifneeded TclpdLib 0.17 [list source [file join $TCLPD_DIR pdlib.tcl]]
diff --git a/tclpd.c b/tclpd.c
index e5db1e6..66e7d2d 100644
--- a/tclpd.c
+++ b/tclpd.c
@@ -11,7 +11,11 @@ void tclpd_setup(void) {
return;
}
+#if PD_MAJOR_VERSION==0 && PD_MINOR_VERSION<43
post("tclpd loader v" TCLPD_VERSION);
+#else
+ logpost(NULL, 3, "tclpd loader v" TCLPD_VERSION);
+#endif
proxyinlet_setup();
@@ -19,51 +23,21 @@ void tclpd_setup(void) {
Tcl_Init(tcl_for_pd);
Tclpd_SafeInit(tcl_for_pd);
- char *dirname = (char*)malloc(PATH_MAX);
- char *dirresult = (char*)malloc(PATH_MAX);
- /* nameresult is only a pointer in dirresult space so don't delete[] it. */
- char *nameresult;
- if(getcwd(dirname, PATH_MAX) < 0) {
- post("tclpd loader: FATAL: cannot get current dir");
- /* exit(69); */ return;
- }
-
- int fd;
- t_class* foo_class = class_new(gensym("tclpd_init"), 0, 0, 0, 0, 0);
-
- if((fd = open_via_path(dirname, "tclpd", PDSUF, dirresult, &nameresult, PATH_MAX, 1)) >= 0) {
- post("tclpd loader found at %s", dirname);
- close(fd);
- } else if((fd = open_via_path(foo_class->c_externdir->s_name, "tclpd", PDSUF, dirresult, &nameresult, PATH_MAX, 1)) >= 0) {
- post("tclpd loader found at %s", foo_class->c_externdir->s_name);
- close(fd);
- } else {
- post("tclpd loader: %s was not found via the -path!", "tclpd" PDSUF);
- }
-
- Tcl_SetVar(tcl_for_pd, "TCLPD_DIR", dirresult, 0);
Tcl_Eval(tcl_for_pd, "package provide Tclpd " TCLPD_VERSION);
- if(Tcl_Eval(tcl_for_pd, "source $TCLPD_DIR/pkgIndex.tcl") != TCL_OK) {
- post("tclpd loader: error loading %s/pkgIndex.tcl", dirresult);
- }
-
- if(Tcl_Eval(tcl_for_pd, "source $TCLPD_DIR/tcl.tcl") == TCL_OK) {
- post("tclpd loader: loaded %s/tcl.tcl", dirresult);
- }
-
- if(Tcl_Eval(tcl_for_pd,"source $env(HOME)/.pd.tcl") == TCL_OK) {
- post("tclpd loader: loaded ~/.pd.tcl");
+ t_class* foo_class = class_new(gensym("tclpd_init"), 0, 0, 0, 0, 0);
+ char buf[PATH_MAX];
+
+ snprintf(buf, PATH_MAX, "%s/pdlib.tcl", foo_class->c_externdir->s_name);
+ if(Tcl_EvalFile(tcl_for_pd, buf) != TCL_OK) {
+ error("tclpd loader: error loading %s", buf);
}
- free(dirresult);
- free(dirname);
-
sys_register_loader(tclpd_do_load_lib);
}
void tclpd_interp_error(int result) {
- post("tclpd error: %s", Tcl_GetStringResult(tcl_for_pd));
+ error("tclpd error: %s", Tcl_GetStringResult(tcl_for_pd));
post(" (see stderr for details)");
fprintf(stderr, "------------------- Tcl error: -------------------\n");