Update of /cvsroot/pure-data/externals/loaders
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4532
Modified Files:
libdir.c
Log Message:
added the doc/5.reference/classname path to the global helppath if loaded library into global namespace; fixed compiler warning about unsigned int comparison
Index: libdir.c
===================================================================
RCS file: /cvsroot/pure-data/externals/loaders/libdir.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** libdir.c 13 Oct 2007 03:26:22 -0000 1.7
--- libdir.c 26 Nov 2007 06:24:22 -0000 1.8
***************
*** 39,43 ****
static int libdir_loader(t_canvas *canvas, char *classname)
{
! int fd = -1, i;
char fullclassname[MAXPDSTRING], dirbuf[MAXPDSTRING];
char reldirbuf[MAXPDSTRING], curdir[MAXPDSTRING], *nameptr;
--- 39,45 ----
static int libdir_loader(t_canvas *canvas, char *classname)
{
! int fd = -1;
! unsigned int i;
! char helppathname[MAXPDSTRING];
char fullclassname[MAXPDSTRING], dirbuf[MAXPDSTRING];
char reldirbuf[MAXPDSTRING], curdir[MAXPDSTRING], *nameptr;
***************
*** 45,101 ****
/* look for meta file (classname)/(classname)-meta.pd */
! strncpy(fullclassname, classname, MAXPDSTRING - 6);
! strcat(fullclassname, "/");
! strncat(fullclassname, classname, MAXPDSTRING - strlen(fullclassname) - 6);
! strcat(fullclassname, "-meta");
!
! /* if this is being called from a canvas, then add the library path to the
! * canvas-local path */
#if (PD_MINOR_VERSION >= 40)
! if(canvas)
! {
! canvasenvironment = canvas_getenv(canvas);
! if ((fd = canvas_open(0, fullclassname, ".pd",
! dirbuf, &nameptr, MAXPDSTRING, 0)) < 0)
! {
! return (0);
! }
! close(fd);
! // G.Holzmann: canvas will look to a relative path to it, so we cannot add
// the absulote dirbuf path, we have to make it relative to the current canvas
! // (see from line 1561 in g_canvas.c)
! sys_unbashfilename(canvas_getdir(canvas)->s_name, curdir);
!
! // count depth of the current dir
! for(i=0; i<strlen(curdir); i++)
! {
! if(curdir[i] == 47) // 47 is "/" in ascii
strncat(reldirbuf, "../", MAXPDSTRING);
! }
! strncat(reldirbuf, dirbuf, MAXPDSTRING);
! // TODO: have this add to the canvas-local path only
! canvasenvironment->ce_path = namelist_append(canvasenvironment->ce_path,
! reldirbuf, 0);
! post("libdir_loader: added %s to the canvas-local path", classname);
! }
! else
#endif
! {
! if ((fd = open_via_path(".", fullclassname, ".pd",
! dirbuf, &nameptr, MAXPDSTRING, 0)) < 0)
! {
! return (0);
! }
! close(fd);
! sys_searchpath = namelist_append(sys_searchpath, dirbuf, 0);
! post("libdir_loader: added %s to the global classpath", classname);
! // post("\tThis is deprecated behavior.");
! }
! /* post("libdir_loader loaded fullclassname: '%s'\n", fullclassname); */
if (sys_verbose)
post("Loaded libdir %s from %s", classname, dirbuf);
--- 47,108 ----
/* look for meta file (classname)/(classname)-meta.pd */
! strncpy(fullclassname, classname, MAXPDSTRING - 6);
! strcat(fullclassname, "/");
! strncat(fullclassname, classname, MAXPDSTRING - strlen(fullclassname) - 6);
! strcat(fullclassname, "-meta");
!
! /* if this is being called from a canvas, then add the library path to the
! * canvas-local path */
#if (PD_MINOR_VERSION >= 40)
! if(canvas)
! {
! canvasenvironment = canvas_getenv(canvas);
! if ((fd = canvas_open(0, fullclassname, ".pd",
! dirbuf, &nameptr, MAXPDSTRING, 0)) < 0)
! {
! return (0);
! }
! close(fd);
! // G.Holzmann: canvas will look to a relative path to it, so we cannot add
// the absulote dirbuf path, we have to make it relative to the current canvas
! // (see from line 1561 in g_canvas.c)
! sys_unbashfilename(canvas_getdir(canvas)->s_name, curdir);
!
! // count depth of the current dir
! for(i=0; i<strlen(curdir); i++)
! {
! if(curdir[i] == 47) // 47 is "/" in ascii
strncat(reldirbuf, "../", MAXPDSTRING);
! }
! strncat(reldirbuf, dirbuf, MAXPDSTRING);
! // TODO: have this add to the canvas-local path only
! canvasenvironment->ce_path = namelist_append(canvasenvironment->ce_path,
! reldirbuf, 0);
! post("libdir_loader: added %s to the canvas-local path", classname);
! }
! else
#endif
! {
! if ((fd = open_via_path(".", fullclassname, ".pd",
! dirbuf, &nameptr, MAXPDSTRING, 0)) < 0)
! {
! return (0);
! }
! close(fd);
! sys_searchpath = namelist_append(sys_searchpath, dirbuf, 0);
! strncpy(helppathname, sys_libdir->s_name, MAXPDSTRING-30);
! helppathname[MAXPDSTRING-30] = 0;
! strcat(helppathname, "/doc/5.reference/");
! strcat(helppathname, classname);
! sys_helppath = namelist_append(sys_helppath, helppathname, 0);
! post("libdir_loader: added %s to the global classpath", classname);
! // post("\tThis is deprecated behavior.");
! }
! /* post("libdir_loader loaded fullclassname: '%s'\n", fullclassname); */
if (sys_verbose)
post("Loaded libdir %s from %s", classname, dirbuf);
***************
*** 110,120 ****
sys_register_loader(libdir_loader);
#else
! error("to function, this needs to be compiled against Pd 0.40 or higher,\n");
! post("\tor a version that has sys_register_loader()");
#endif
post("libdir loader %s",version);
post("\twritten by Hans-Christoph Steiner <hans(a)at.or.at>");
post("\tcompiled on "__DATE__" at "__TIME__ " ");
! post("\tcompiled against Pd version %d.%d.%d.%s", PD_MAJOR_VERSION,
! PD_MINOR_VERSION, PD_BUGFIX_VERSION, PD_TEST_VERSION);
}
--- 117,127 ----
sys_register_loader(libdir_loader);
#else
! error("to function, this needs to be compiled against Pd 0.40 or higher,\n");
! post("\tor a version that has sys_register_loader()");
#endif
post("libdir loader %s",version);
post("\twritten by Hans-Christoph Steiner <hans(a)at.or.at>");
post("\tcompiled on "__DATE__" at "__TIME__ " ");
! post("\tcompiled against Pd version %d.%d.%d.%s", PD_MAJOR_VERSION,
! PD_MINOR_VERSION, PD_BUGFIX_VERSION, PD_TEST_VERSION);
}