diff --git a/pd/src/pd.tk b/pd/src/pd.tk index a71b5b16fd3f2beeb6cd4a96c3462255aee19333..4a81db78f2b9baf16d0ec7780a377bd757e57592 100644 --- a/pd/src/pd.tk +++ b/pd/src/pd.tk @@ -8461,14 +8461,16 @@ proc pdtk_open_files_via_unique {filenames} { proc pdtk_check_unique {unique filenames} { #puts stderr "pdtk_check_unique $unique $filenames" global appname + set startup_dir [pwd] if { $unique == 0 } { foreach file $filenames { - #puts stderr $file - cd [file dirname $file] + #puts stderr "$file [file dirname $file] $startup_dir" + catch {cd [file dirname $file]} set dir [pwd] set name [file tail $file] #puts stderr "********DIR:$dir FILE:$name COMBINED:[file join $dir $name]" lappend final_filenames [file join $dir $name] + cd $startup_dir } #puts stderr "send pd-l2ork pdtk_open_files_via_unique $final_filenames" set outcome [catch {send pd-l2ork pdtk_open_files_via_unique \{$final_filenames\}}] diff --git a/pd/src/s_main.c b/pd/src/s_main.c index 6ef5121d65d3e522edbcf00d37b464a6f82aeac2..85eaf34a72284997f03bd47e93d55c6a29ceb7a9 100644 --- a/pd/src/s_main.c +++ b/pd/src/s_main.c @@ -309,7 +309,11 @@ int sys_main(int argc, char **argv) int length = 0; t_namelist *nl; for (nl = sys_openlist; nl; nl = nl->nl_next) - length = length + strlen(nl->nl_string) + 1; + { + // for starting and ending quotes plus a space or null terminating + // character, we add 3 additional characters per entry + length = length + strlen(nl->nl_string) + 3; + } if((filenames = malloc(length)) != NULL) { filenames[0] = '\0'; // ensures the memory is an empty string @@ -321,7 +325,7 @@ int sys_main(int argc, char **argv) strcat(filenames,nl->nl_string); if (nl->nl_next) strcat(filenames,"\" \""); - else strcat(filenames,"\""); + else strcat(filenames,"\"\0"); // ensures proper termination } } //fprintf(stderr,"final list: <%s>\n", filenames);