Revision: 9856 http://pure-data.svn.sourceforge.net/pure-data/?rev=9856&view=rev Author: eighthave Date: 2008-05-19 12:25:03 -0700 (Mon, 19 May 2008)
Log Message: ----------- made full paths work for declare -stdlib and -stdpath, fixing bug #1828573
Modified Paths: -------------- branches/pd-extended/v0-40/pd/src/g_canvas.c
Modified: branches/pd-extended/v0-40/pd/src/g_canvas.c =================================================================== --- branches/pd-extended/v0-40/pd/src/g_canvas.c 2008-05-19 09:13:17 UTC (rev 9855) +++ branches/pd-extended/v0-40/pd/src/g_canvas.c 2008-05-19 19:25:03 UTC (rev 9856) @@ -1513,6 +1513,26 @@ } }
+static void canvas_completepath(char *from, char *to) +{ + if(! (from[0] == '/' || from[0] == '~' +#ifdef MSW + || from[0] == '%' || (from[1] == ':' && from[2] == '/') +#endif + )) + { + strncpy(to, sys_libdir->s_name, FILENAME_MAX-4); + to[FILENAME_MAX-3] = '\0'; + strcat(to, "/"); + } + else + { + to[0] = '\0'; + } + strncat(to, from, FILENAME_MAX-strlen(to)); + to[FILENAME_MAX-1] = '\0'; +} + static void canvas_declare(t_canvas *x, t_symbol *s, int argc, t_atom *argv) { int i; @@ -1524,7 +1544,7 @@ #endif for (i = 0; i < argc; i++) { - char strbuf[MAXPDSTRING]; + char strbuf[FILENAME_MAX]; char *flag = atom_getsymbolarg(i, argc, argv)->s_name; if ((argc > i+1) && !strcmp(flag, "-path")) { @@ -1534,12 +1554,7 @@ } else if ((argc > i+1) && !strcmp(flag, "-stdpath")) { - strncpy(strbuf, sys_libdir->s_name, MAXPDSTRING-3); - strbuf[MAXPDSTRING-4] = 0; - strcat(strbuf, "/"); - strncpy(strbuf, atom_getsymbolarg(i+1, argc, argv)->s_name, - MAXPDSTRING-strlen(strbuf)); - strbuf[MAXPDSTRING-1] = 0; + canvas_completepath(atom_getsymbolarg(i+1, argc, argv)->s_name, strbuf); e->ce_path = namelist_append(e->ce_path, strbuf, 0); i++; } @@ -1550,12 +1565,7 @@ } else if ((argc > i+1) && !strcmp(flag, "-stdlib")) { - strncpy(strbuf, sys_libdir->s_name, MAXPDSTRING-3); - strbuf[MAXPDSTRING-4] = 0; - strcat(strbuf, "/"); - strncpy(strbuf, atom_getsymbolarg(i+1, argc, argv)->s_name, - MAXPDSTRING-strlen(strbuf)); - strbuf[MAXPDSTRING-1] = 0; + canvas_completepath(atom_getsymbolarg(i+1, argc, argv)->s_name, strbuf); sys_load_lib(0, strbuf); i++; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.