SOURCES: elinks-mailcap_DISPLAY.patch (NEW) - previously when the ...
witekfl
witekfl at pld-linux.org
Sun Mar 16 22:05:13 CET 2008
Author: witekfl Date: Sun Mar 16 21:05:13 2008 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- previously when the master session of ELinks was run on a console
and slave session on X11, the mailcap handler for console was choosen
on a X11 terminal. The patch fixes this bug.
---- Files affected:
SOURCES:
elinks-mailcap_DISPLAY.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/elinks-mailcap_DISPLAY.patch
diff -u /dev/null SOURCES/elinks-mailcap_DISPLAY.patch:1.1
--- /dev/null Sun Mar 16 22:05:13 2008
+++ SOURCES/elinks-mailcap_DISPLAY.patch Sun Mar 16 22:05:08 2008
@@ -0,0 +1,106 @@
+bug 638: Save, set and restore the DISPLAY environment variable.
+
+Thanks to this trick the appropriate handler is executed,
+even in a mixed (X11, framebuffer) environment.
+
+---
+commit 65a3518a912d6cc6aa38cee4a4142299d7a25cc7
+tree 47b6a1c4af22420fef498ac26dd0955e79428024
+parent 81f8ee1fa2b94ef40460eb4a42710e1ed9e22c98
+author Witold Filipczyk <witekfl at poczta.onet.pl> Sun, 16 Mar 2008 16:29:32 +0100
+committer Witold Filipczyk <nobody at nowhere> Sun, 16 Mar 2008 16:29:32 +0100
+
+ configure.in | 1 +
+ src/mime/backend/mailcap.c | 58 +++++++++++++++++++++++++++++++++++++++++++-
+ 2 files changed, 58 insertions(+), 1 deletions(-)
+
+diff --git a/configure.in b/configure.in
+index 0a867ae..5cfeaa9 100644
+--- a/configure.in
++++ b/configure.in
+@@ -307,6 +307,7 @@ AC_CHECK_FUNCS(gettimeofday clock_gettime)
+ AC_CHECK_FUNCS([cygwin_conv_to_full_win32_path])
+
+ AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
++AC_CHECK_FUNCS(unsetenv)
+ AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
+ AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
+
+diff --git a/src/mime/backend/mailcap.c b/src/mime/backend/mailcap.c
+index 76ea78b..70e270d 100644
+--- a/src/mime/backend/mailcap.c
++++ b/src/mime/backend/mailcap.c
+@@ -646,8 +646,57 @@ get_mailcap_entry(unsigned char *type)
+ return entry;
+ }
+
++#if defined(HAVE_SETENV) || defined(HAVE_PUTENV)
++/* restore == 0 set DISPLAY
++ * restore == 1 restore DISPLAY
++ */
++static void
++set_display(int xwin, int restore)
++{
++ static unsigned char *display = NULL;
++
++ if (!restore) {
++ display = getenv("DISPLAY");
++ if (display) display = stracpy(display);
++ if (xwin) {
++#ifdef HAVE_SETENV
++ setenv("DISPLAY", ":0", 1);
++#else
++ putenv("DISPLAY=:0");
++#endif
++ } else {
++#ifdef HAVE_UNSETENV
++ unsetenv("DISPLAY");
++#else
++ putenv("DISPLAY");
++#endif
++ }
++ } else { /* restore DISPLAY */
++ if (display) {
++#ifdef HAVE_SETENV
++ setenv("DISPLAY", display, 1);
++#else
++ {
++ static unsigned char DISPLAY[1024] = { 'D','I','S','P','L','A','Y','=' };
++
++ strncpy(DISPLAY + 8, display, 1023 - 8);
++ putenv(DISPLAY);
++ }
++#endif
++ mem_free(display);
++ } else {
++#ifdef HAVE_UNSETENV
++ unsetenv("DISPLAY");
++#else
++ putenv("DISPLAY");
++#endif
++ }
++ }
++}
++#endif
++
+ static struct mime_handler *
+-get_mime_handler_mailcap(unsigned char *type, int options)
++get_mime_handler_mailcap(unsigned char *type, int xwin)
+ {
+ struct mailcap_entry *entry;
+ struct mime_handler *handler;
+@@ -658,7 +707,14 @@ get_mime_handler_mailcap(unsigned char *type, int options)
+ || (!mailcap_map && !init_mailcap_map()))
+ return NULL;
+
++#if defined(HAVE_SETENV) || defined(HAVE_PUTENV)
++ set_display(xwin, 0);
++#endif
+ entry = get_mailcap_entry(type);
++
++#if defined(HAVE_SETENV) || defined(HAVE_PUTENV)
++ set_display(xwin, 1);
++#endif
+ if (!entry) return NULL;
+
+ program = format_command(entry->command, type, entry->copiousoutput);
================================================================
More information about the pld-cvs-commit
mailing list