diff options
Diffstat (limited to 'desktop')
-rwxr-xr-x | desktop/source/pagein/pagein.c | 15 | ||||
-rw-r--r-- | desktop/unx/source/args.c | 8 | ||||
-rwxr-xr-x | desktop/unx/source/start.c | 42 |
3 files changed, 44 insertions, 21 deletions
diff --git a/desktop/source/pagein/pagein.c b/desktop/source/pagein/pagein.c index 3ba12f9437a2..947b4b7375d5 100755 --- a/desktop/source/pagein/pagein.c +++ b/desktop/source/pagein/pagein.c @@ -107,16 +107,25 @@ int pagein_execute (int argc, char **argv) if ((argv[i][0] == '@') && ((fp = fopen (argv[i], "r")) == 0)) { - char path[1024]; + char fullpath[4096]; + char *path; + strncpy (fullpath, argv[i] + 1, 3000); + if (!(path = strrchr (fullpath, '/'))) + path = fullpath; + else + path++; + if ((fp = fopen (&(argv[i][1]), "r")) == 0) { fprintf (stderr, "fopen %s: %s\n", &(argv[i][1]), strerror(errno)); continue; } - while (fgets (path, sizeof(path), fp) != 0) + while (fgets (path, 1024, fp) != 0) { path[strlen(path) - 1] = '\0', k = 0; - if (do_pagein (path, &k) == 0) + + /* paths relative to the location of the pagein file */ + if (do_pagein (fullpath, &k) == 0) { /* accumulate total size */ nbytes += k; diff --git a/desktop/unx/source/args.c b/desktop/unx/source/args.c index 0f47f791d5eb..d69fe62e2466 100644 --- a/desktop/unx/source/args.c +++ b/desktop/unx/source/args.c @@ -61,10 +61,10 @@ static struct { { "minimized", 0, 1, 0, 0, NULL }, /* pagein bits */ - { "writer", 0, 0, 0, 0, "@pagein-writer" }, - { "calc", 0, 0, 0, 0, "@pagein-calc" }, - { "draw", 0, 0, 0, 0, "@pagein-draw" }, - { "impress", 0, 0, 0, 0, "@pagein-impress" }, + { "writer", 0, 0, 0, 0, "pagein-writer" }, + { "calc", 0, 0, 0, 0, "pagein-calc" }, + { "draw", 0, 0, 0, 0, "pagein-draw" }, + { "impress", 0, 0, 0, 0, "pagein-impress" }, /* nothing much */ { "version", 0, 1, 1, 1, NULL }, diff --git a/desktop/unx/source/start.c b/desktop/unx/source/start.c index e81cd6129d0a..b3042f75ea24 100755 --- a/desktop/unx/source/start.c +++ b/desktop/unx/source/start.c @@ -728,6 +728,24 @@ system_checks( void ) /* re-use the pagein code */ extern int pagein_execute (int argc, char **argv); +#define REL_PATH "/../basis-link/program" +static char *build_pagein_path (Args *args, const char *pagein_name) +{ + char *path; + rtl_String *app_path; + + app_path = ustr_to_str (args->pAppPath); + path = malloc (app_path->length + strlen (pagein_name) + sizeof (REL_PATH) + 8); + strcpy (path, "@"); + strcpy (path + 1, rtl_string_getStr (app_path)); + strcat (path, "/../basis-link/program/"); + strcat (path, pagein_name); + + rtl_string_release( app_path ); + + return path; +} + void exec_pagein (Args *args) { @@ -735,24 +753,20 @@ exec_pagein (Args *args) #ifdef MACOSX (void)args; #else - char *argv[5]; - rtl_String *app_path; - - app_path = ustr_to_str (args->pAppPath); + char *argv[3]; + /* don't use -L - since that does a chdir that breaks relative paths */ argv[0] = "dummy-pagein"; - argv[1] = malloc (app_path->length + sizeof ("-L/../basis-link/program") + 2); - strcpy (argv[1], "-L"); - strcat (argv[1], app_path->buffer); - strcat (argv[1], "/../basis-link/program"); - argv[2] = "@pagein-common"; - argv[3] = (char *)args->pPageinType; - argv[4] = NULL; - - rtl_string_release( app_path ); + argv[1] = build_pagein_path (args, "pagein-common"); + if (args->pPageinType) { + argv[2] = build_pagein_path (args, args->pPageinType); + } else + argv[2] = NULL; - pagein_execute (args->pPageinType ? 4 : 3, argv); + pagein_execute (args->pPageinType ? 3 : 2, argv); + if (argv[2]) + free (argv[2]); free (argv[1]); #endif } |