[Libreoffice-commits] .: Branch 'libreoffice-3-4' - desktop/source desktop/unx

Michael Meeks michael at kemper.freedesktop.org
Wed May 4 12:31:34 PDT 2011


 desktop/source/pagein/pagein.c |   15 +++++++++++---
 desktop/unx/source/args.c      |    8 +++----
 desktop/unx/source/start.c     |   42 +++++++++++++++++++++++++++--------------
 3 files changed, 44 insertions(+), 21 deletions(-)

New commits:
commit 226362003a4705edd15764e0b022d6a3b351fb82
Author: Michael Meeks <michael.meeks at novell.com>
Date:   Wed May 4 20:27:43 2011 +0100

    fix fdo#36838 by avoiding -L argument to pagein

diff --git a/desktop/source/pagein/pagein.c b/desktop/source/pagein/pagein.c
index 097b093..b625c57 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 0f47f79..d69fe62 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 b0f5ab3..b6ae8aa 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
 }


More information about the Libreoffice-commits mailing list