On 01/12/2016 11:56 PM, IOhannes m zmölnig wrote: > On 01/12/2016 11:34 PM, IOhannes m zmölnig wrote: >> i will check this immediately. > > actually it turns out that loading anything via it's absolute path is > broken (and [declare -stdlib] uses this): > > e.g. [/usr/lib/pd/extra/zexy/zexy] fails now.
which means that the culprit is really in the new loader code (unrelated to [declare]). anyhow, attached you find two patches that supposedly fix this problem. 0001: does special handling for absolute paths (which was stripped out in my loader rewrite - on purpose, but accidentally no replacement was provided), by trying to load them first (if applicable). 0002: fixes the extra/ stripping/appending when generating the absolute pathnames for stdlib/stdpath. gfrdsa IOhannes
From 2fbad149cee66c1f672886a0d4ce855f57e8b278 Mon Sep 17 00:00:00 2001 From: IOhannes m zmoelnig <[email protected]> Date: Wed, 13 Jan 2016 00:38:47 +0100 Subject: [PATCH 1/2] try to load absolute paths first --- src/s_loader.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/s_loader.c b/src/s_loader.c index f52bd10..0be940e 100644 --- a/src/s_loader.c +++ b/src/s_loader.c @@ -312,13 +312,30 @@ int sys_load_lib(t_canvas *canvas, const char *classname) int dspstate = canvas_suspend_dsp(); struct _loadlib_data data; data.canvas = canvas; - data.classname = classname; data.ok = 0; + /* if classname is absolute, try this first */ + if (sys_isabsolutepath(classname)) + { + /* this is just copied from sys_open_absolute() + LATER avoid code duplication */ + char dirbuf[MAXPDSTRING], *z = strrchr(classname, '/'); + int dirlen; + if (!z) + return (0); + dirlen = z - classname; + if (dirlen > MAXPDSTRING-1) + dirlen = MAXPDSTRING-1; + strncpy(dirbuf, classname, dirlen); + dirbuf[dirlen] = 0; + data.classname=classname+(dirlen+1); + sys_loadlib_iter(dirbuf, &data); + } + data.classname = classname; + if(!data.ok) + canvas_path_iterate(canvas, (t_canvas_path_iterator)sys_loadlib_iter, + &data); - canvas_path_iterate(canvas, (t_canvas_path_iterator)sys_loadlib_iter, - &data); - - /* if loaders failed to far, we try a last time without a PATH + /* if loaders failed so far, we try a last time without a PATH * let the loaders search wherever they want */ if (!data.ok) sys_loadlib_iter(0, &data); -- 2.7.0.rc3
From ddd392a67bbf71a00c9b362a9668d6630d6ba149 Mon Sep 17 00:00:00 2001 From: IOhannes m zmoelnig <[email protected]> Date: Wed, 13 Jan 2016 00:51:54 +0100 Subject: [PATCH 2/2] append 'extra' to canvas_completepath() this function is only used in '-stdlib' and '-stdpath' handling, where we always want the '/extra/' component. also, the extra-normalisation (stripping any trailing "extra/" from the stdlib/stdpath) is now done before calling canvas_completepath(). this way, both [declare -stdpath foo] and [declare -stdpath extra/foo] will evaluate to /usr/lib/pd/extra/foo --- src/g_canvas.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/g_canvas.c b/src/g_canvas.c index dc2a53e..21ca4e3 100644 --- a/src/g_canvas.c +++ b/src/g_canvas.c @@ -1299,9 +1299,9 @@ static void canvas_completepath(char *from, char *to, int bufsize) } else { // if not absolute path, append Pd lib dir - strncpy(to, sys_libdir->s_name, bufsize-4); - to[bufsize-3] = '\0'; - strcat(to, "/"); + strncpy(to, sys_libdir->s_name, bufsize-10); + to[bufsize-9] = '\0'; + strcat(to, "/extra/"); } strncat(to, from, bufsize-strlen(to)); to[bufsize-1] = '\0'; @@ -1339,15 +1339,17 @@ static void canvas_stdpath(t_canvasenvironment *e, char *stdpath) return; } + /* strip "extra/"-prefix */ + if (!strncmp("extra/", stdpath, 6)) + stdpath+=6; + + /* prefix full pd-path (including extra) */ canvas_completepath(stdpath, strbuf, MAXPDSTRING); if (check_exists(strbuf)) { e->ce_path = namelist_append(e->ce_path, strbuf, 0); return; } - /* strip "extra/"-prefix */ - if (!strncmp("extra/", stdpath, 6)) - stdpath+=6; /* check whether the given subdir is in one of the standard-paths */ for (nl=sys_staticpath; nl; nl=nl->nl_next) { @@ -1370,14 +1372,15 @@ static void canvas_stdlib(t_canvasenvironment *e, char *stdlib) return; } + /* strip "extra/"-prefix */ + if (!strncmp("extra/", stdlib, 6)) + stdlib+=6; + + /* prefix full pd-path (including extra) */ canvas_completepath(stdlib, strbuf, MAXPDSTRING); if (sys_load_lib(0, strbuf)) return; - // strip "extra/"-prefix - if (!strncmp("extra/", stdlib, 6)) - stdlib+=6; - /* check whether the given library is located in one of the standard-paths */ for (nl=sys_staticpath; nl; nl=nl->nl_next) { @@ -1495,6 +1498,7 @@ int canvas_path_iterate(t_canvas*x, t_canvas_path_iterator fun, void *user_data) int count = 0; if (!fun) return 0; + /* iterate through canvas-local paths */ for (y = x; y; y = y->gl_owner) if (y->gl_env) { -- 2.7.0.rc3
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Pd-dev mailing list [email protected] http://lists.puredata.info/listinfo/pd-dev
