[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

RFC: Patch for kazehakase



My (recently adopted) package kazehakase fails to build on GNU/Hurd:

mozilla.cpp: In function 'gboolean xulrunner_init()':
mozilla.cpp:132: error: 'PATH_MAX' was not declared in this scope
mozilla.cpp:135: error: 'xpcomPath' was not declared in this scope
make[6]: *** [gecko_la-mozilla.lo] Error 1

I prepared a patch, and I kindly ask you to confirm if it is sane.
Thanks in advance!

One more thing...  While looking at the implementation of
GRE_GetGREPathWithProperties, I noticed that the Mozilla guys use
MAXPATHLEN unconditionally.  I looked at xulrunner's .diff.gz and
found this:

--- xulrunner-1.9.0.13.orig/config/rules.mk
+++ xulrunner-1.9.0.13/config/rules.mk
...
@@ -541,6 +544,14 @@
 endif 
 
 #
+# GNU doesn't have path length limitation
+#
+
+ifeq ($(OS_ARCH),GNU)
+OS_CPPFLAGS += -DPATH_MAX=1024 -DMAXPATHLEN=1024
+endif
+
+# 

Is this a proper way to solve the problem?  Maybe it was just a quick
temporary fix as porting xulrunner is probably not trivial?  Anyway,
should I apply my patch or resort to a similar hack given the fact
that xulrunner has hardcoded PATH_MAX?  The latter doesn't look right
to me.

2009-08-20  Yavor Doganov  <yavor@gnu.org>

	Avoid PATH_MAX, which is undefined on GNU/Hurd.
	* module/embed/gecko/mozilla.cpp (xulrunner_init): Use a
	geometrically growing loop to allocate memory dynamically.


* local directory is at yavor@gnu.org--debian/kazehakase--debian--1.0--patch-52
* comparing to yavor@gnu.org--debian/kazehakase--debian--1.0--patch-52
M  module/embed/gecko/mozilla.cpp

* modified files

--- orig/module/embed/gecko/mozilla.cpp
+++ mod/module/embed/gecko/mozilla.cpp
@@ -136,32 +136,53 @@
 		"1.9.1", PR_FALSE
 	};
 
-	char xpcomPath[PATH_MAX];
+	char *xpcomPath, *lastSlash;
+	gsize allocated = 128;
+	nsresult rv;
+
+	while (1)
+		{
+			xpcomPath = (char *) g_malloc0(allocated);
+
+			rv = GRE_GetGREPathWithProperties(&greVersion, 1,
+							  nsnull, 0,
+							  xpcomPath,
+							  allocated);
+
+			if (strlen(xpcomPath) < allocated - 1)
+				break;
+
+			g_free(xpcomPath);
+			allocated *= 2;
+		}
 
-	nsresult rv = GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0,
-						   xpcomPath, sizeof(xpcomPath));
 	if (NS_FAILED(rv))
-		return FALSE;
+		goto out;
 
 	rv = XPCOMGlueStartup(xpcomPath);
 	if (NS_FAILED(rv))
-		return FALSE;
+		goto out;
 
 	rv = GTKEmbedGlueStartup();
 	if (NS_FAILED(rv))
-		return FALSE;
+		goto out;
 
 	rv = GTKEmbedGlueStartupInternal();
 	if (NS_FAILED(rv))
-		return FALSE;
+		goto out;
 
-	char *lastSlash = strrchr(xpcomPath, '/');
+	lastSlash = strrchr(xpcomPath, '/');
 	if (lastSlash)
 		*lastSlash = '\0';
 
 	gtk_moz_embed_set_path(xpcomPath);
 
+	g_free(xpcomPath);
 	return TRUE;
+
+ out:
+	g_free(xpcomPath);
+	return FALSE;
 }
 
 static nsresult




Reply to: