mc and embedded lib.



Hello guys,

    As we discussed on the mc-devel channel today, here is a patch that
allows Midnight Commander to be built with the lightweight Embedded glib
implementation, the patch is against the mc-4.6.2-pre1 release.

    It is a proof of concept, as I hardcoded the location in my disk
where I have installed eglib, but the result is a fully functional mc:

mono$ ldd /tmp/eglib/bin/mc
	linux-gate.so.1 =>  (0xffffe000)
	libSM.so.6 => /usr/lib/libSM.so.6 (0xb7fd4000)
	libICE.so.6 => /usr/lib/libICE.so.6 (0xb7fba000)
	libX11.so.6 => /usr/lib/libX11.so.6 (0xb7e99000)
	libext2fs.so.2 => /lib/libext2fs.so.2 (0xb7e74000)
	libcom_err.so.2 => /lib/libcom_err.so.2 (0xb7e70000)
	libgpm.so.1 => /usr/lib/libgpm.so.1 (0xb7e68000)
	libc.so.6 => /lib/libc.so.6 (0xb7d25000)
	libm.so.6 => /lib/libm.so.6 (0xb7cff000)
	libxcb-xlib.so.0 => /usr/lib/libxcb-xlib.so.0 (0xb7cfc000)
	libxcb.so.1 => /usr/lib/libxcb.so.1 (0xb7ce3000)
	libdl.so.2 => /lib/libdl.so.2 (0xb7cdf000)
	/lib/ld-linux.so.2 (0xb7fff000)
	libncurses.so.5 => /lib/libncurses.so.5 (0xb7ca7000)
	libXau.so.6 => /usr/lib/libXau.so.6 (0xb7ca3000)
mono$ ls -l /tmp/eglib/bin/mc
-rwxr-xr-x 1 miguel users 2203175 2009-02-05 17:45 /tmp/eglib/bin/mc*

It is also necessary to bundle gtree.c and gnode.c for the mc/editor in
that case. 

Miguel.
diff -ru mc-4.6.2-pre1/configure.ac eglib-mc-4.6.2//configure.ac
--- mc-4.6.2-pre1/configure.ac	2007-09-10 10:25:30.000000000 -0400
+++ eglib-mc-4.6.2//configure.ac	2009-02-05 15:54:51.000000000 -0500
@@ -33,9 +33,18 @@
 AC_ARG_WITH([glib_static],
 	    [  --with-glib-static       Link glib statically [[no]]])
 
-glib_found=no
-if test "x$with_glib12" != "xyes"; then
-	PKG_CHECK_MODULES(GLIB, [glib-2.0], [glib_found=yes], [:])
+AC_ARG_WITH([eglib],
+	    [  --with-eglib             Uses embedded glib (eglib) [[no]]])
+
+if test x$with_eglib = xyes; then
+	glib_found=yes
+	GLIB_CFLAGS="-I/cvs/mono/eglib/src"
+	GLIB_LIBS="-L/cvs/mono/eglib/src -leglib"
+else
+	glib_found=no
+	if test "x$with_glib12" != "xyes"; then
+		PKG_CHECK_MODULES(GLIB, [glib-2.0], [glib_found=yes], [:])
+		fi
 fi
 
 dnl Fall back to glib-1.2, don't use pkgconfig to find it.
@@ -65,14 +74,6 @@
 
 	dnl Used in src/glibcompat.c
 	AC_CHECK_FUNCS([strlcpy])
-else
-	PKG_CHECK_MODULES(GMODULE, [gmodule-2.0], [gmodule_found=yes])
-	GLIB_LIBDIR="`$PKG_CONFIG --variable=libdir glib-2.0`"
-fi
-
-if test "x$gmodule_found" = "xyes" ; then
-	dnl Check if the gmodule functionality supported on this system.
-	AC_G_MODULE_SUPPORTED
 fi
 
 AC_HEADER_MAJOR
diff -ru mc-4.6.2-pre1/edit/edit.c eglib-mc-4.6.2//edit/edit.c
--- mc-4.6.2-pre1/edit/edit.c	2007-01-04 10:37:23.000000000 -0500
+++ eglib-mc-4.6.2//edit/edit.c	2009-02-05 17:44:02.000000000 -0500
@@ -149,7 +149,7 @@
 
     if ((file = mc_open (filename, O_RDONLY | O_BINARY)) == -1) {
 	GString *errmsg = g_string_new(NULL);
-	g_string_sprintf(errmsg, _(" Cannot open %s for reading "), filename);
+	g_string_printf(errmsg, _(" Cannot open %s for reading "), filename);
 	edit_error_dialog (_("Error"), get_sys_error (errmsg->str));
 	g_string_free (errmsg, TRUE);
 	return 1;
@@ -271,7 +271,7 @@
 	    edit_cursor_move (edit, current - edit->curs1);
 	    if (pclose (f) > 0) {
 	        GString *errmsg = g_string_new (NULL);
-		g_string_sprintf (errmsg, _(" Error reading from pipe: %s "), p);
+		g_string_printf (errmsg, _(" Error reading from pipe: %s "), p);
 		edit_error_dialog (_("Error"), errmsg->str);
 		g_string_free (errmsg, TRUE);
 		g_free (p);
@@ -279,7 +279,7 @@
 	    }
 	} else {
 	    GString *errmsg = g_string_new (NULL);
-	    g_string_sprintf (errmsg, _(" Cannot open pipe for reading: %s "), p);
+	    g_string_printf (errmsg, _(" Cannot open pipe for reading: %s "), p);
 	    edit_error_dialog (_("Error"), errmsg->str);
 	    g_string_free (errmsg, TRUE);
 	    g_free (p);
@@ -326,7 +326,7 @@
 		     O_NONBLOCK | O_RDONLY | O_BINARY | O_CREAT | O_EXCL,
 		     0666);
 	if (file < 0) {
-	    g_string_sprintf (errmsg = g_string_new (NULL),
+	    g_string_printf (errmsg = g_string_new (NULL),
 		_(" Cannot open %s for reading "), filename);
 	    goto cleanup;
 	} else {
@@ -337,14 +337,14 @@
 
     /* Check what we have opened */
     if (mc_fstat (file, st) < 0) {
-	g_string_sprintf (errmsg = g_string_new (NULL),
+	g_string_printf (errmsg = g_string_new (NULL),
 	    _(" Cannot get size/permissions for %s "), filename);
 	goto cleanup;
     }
 
     /* We want to open regular files only */
     if (!S_ISREG (st->st_mode)) {
-	g_string_sprintf (errmsg = g_string_new (NULL),
+	g_string_printf (errmsg = g_string_new (NULL),
 	    _(" %s is not a regular file "), filename);
 	goto cleanup;
     }
@@ -358,7 +358,7 @@
     }
 
     if (st->st_size >= SIZE_LIMIT) {
-        g_string_sprintf (errmsg = g_string_new (NULL),
+        g_string_printf (errmsg = g_string_new (NULL),
 	    _(" File %s is too large "), filename);
 	goto cleanup;
     }
diff -ru mc-4.6.2-pre1/edit/edit-widget.h eglib-mc-4.6.2//edit/edit-widget.h
--- mc-4.6.2-pre1/edit/edit-widget.h	2007-02-02 20:03:53.000000000 -0500
+++ eglib-mc-4.6.2//edit/edit-widget.h	2009-02-05 16:05:01.000000000 -0500
@@ -2,6 +2,7 @@
 #define MC_EDIT_WIDGET_H
 
 #include "../src/dialog.h"		/* Widget */
+#include "gtree.h"
 #include "edit.h"
 
 #define MAX_MACRO_LENGTH 1024
diff -ru mc-4.6.2-pre1/edit/Makefile.am eglib-mc-4.6.2//edit/Makefile.am
--- mc-4.6.2-pre1/edit/Makefile.am	2005-07-24 09:37:58.000000000 -0400
+++ eglib-mc-4.6.2//edit/Makefile.am	2009-02-05 16:04:47.000000000 -0500
@@ -10,6 +10,6 @@
 	bookmark.c edit.c editcmd.c editwidget.c editdraw.c editkeys.c \
 	editmenu.c editoptions.c editcmddef.h edit.h edit-widget.h \
 	editlock.c editlock.h syntax.c usermap.h usermap.c wordproc.c \
-	choosesyntax.c
+	choosesyntax.c gtree.c gnode.c
 
 EXTRA_DIST = ChangeLog
diff -ru mc-4.6.2-pre1/edit/syntax.c eglib-mc-4.6.2//edit/syntax.c
--- mc-4.6.2-pre1/edit/syntax.c	2006-08-02 11:18:22.000000000 -0400
+++ eglib-mc-4.6.2//edit/syntax.c	2009-02-05 16:04:09.000000000 -0500
@@ -31,6 +31,7 @@
 #include <sys/stat.h>
 
 #include <stdlib.h>
+#include "gtree.h"
 
 #include "../src/global.h"
 
@@ -118,6 +119,7 @@
     return FALSE;
 }
 
+
 /* Completely destroys the defines tree */
 static inline void
 destroy_defines (GTree **defines)
diff -ru mc-4.6.2-pre1/src/glibcompat.c eglib-mc-4.6.2//src/glibcompat.c
--- mc-4.6.2-pre1/src/glibcompat.c	2005-11-02 21:18:38.000000000 -0500
+++ eglib-mc-4.6.2//src/glibcompat.c	2009-02-05 17:41:49.000000000 -0500
@@ -31,7 +31,7 @@
 #include "global.h"
 #include "glibcompat.h"
 
-#if GLIB_MAJOR_VERSION < 2
+#if GLIB_MAJOR_VERSION < 2 && !defined(_EGLIB_MAJOR)
 
 /* Functions g_strlcpy and g_strlcat were originally developed by
  * Todd C. Miller <Todd Miller courtesan com> to simplify writing secure code.
diff -ru mc-4.6.2-pre1/vfs/ftpfs.c eglib-mc-4.6.2//vfs/ftpfs.c
--- mc-4.6.2-pre1/vfs/ftpfs.c	2006-03-08 09:54:11.000000000 -0500
+++ eglib-mc-4.6.2//vfs/ftpfs.c	2009-02-05 17:45:46.000000000 -0500
@@ -478,8 +478,8 @@
     if (ftpfs_get_reply
 	(me, SUP.sock, reply_string,
 	 sizeof (reply_string) - 1) == COMPLETE) {
-	g_strup (reply_string);
-	SUP.remote_is_amiga = strstr (reply_string, "AMIGA") != 0;
+	g_strdown (reply_string);
+	SUP.remote_is_amiga = strstr (reply_string, "amiga") != 0;
 	if (MEDATA->logfile) {
 	    fprintf (MEDATA->logfile, "MC -- remote_is_amiga =  %d\n",
 		     SUP.remote_is_amiga);
--- mc-4.6.2-pre1/src/glibcompat.h	2005-11-02 21:18:38.000000000 -0500
+++ eglib-mc-4.6.2/src/glibcompat.h	2009-02-05 17:55:44.000000000 -0500
@@ -18,7 +18,7 @@
 #ifndef MC_GLIBCOMPAT_H
 #define MC_GLIBCOMPAT_H
 
-#if GLIB_MAJOR_VERSION < 2
+#if GLIB_MAJOR_VERSION < 2 && !defined(_EGLIB_MAJOR)
 
 gsize g_strlcat (gchar *dest, const gchar *src, gsize dest_size);
 gsize g_strlcpy (gchar *dest, const gchar *src, gsize dest_size);


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