r44908 - /desktop/unstable/gnome-terminal/debian/patches/Provide-fallback-for-reading-current-directory-if-OS.patch

biebl at users.alioth.debian.org biebl at users.alioth.debian.org
Sun May 31 17:09:29 UTC 2015


Author: biebl
Date: Sun May 31 17:09:28 2015
New Revision: 44908

URL: http://svn.debian.org/wsvn/pkg-gnome/?sc=1&rev=44908
Log:
This time add the patch for real...

Added:
    desktop/unstable/gnome-terminal/debian/patches/Provide-fallback-for-reading-current-directory-if-OS.patch

Added: desktop/unstable/gnome-terminal/debian/patches/Provide-fallback-for-reading-current-directory-if-OS.patch
URL: http://svn.debian.org/wsvn/pkg-gnome/desktop/unstable/gnome-terminal/debian/patches/Provide-fallback-for-reading-current-directory-if-OS.patch?rev=44908&op=file
==============================================================================
--- desktop/unstable/gnome-terminal/debian/patches/Provide-fallback-for-reading-current-directory-if-OS.patch	(added)
+++ desktop/unstable/gnome-terminal/debian/patches/Provide-fallback-for-reading-current-directory-if-OS.patch	[utf-8] Sun May 31 17:09:28 2015
@@ -0,0 +1,101 @@
+From c9003e9c6efa23505c7998697804725c070ef5ac Mon Sep 17 00:00:00 2001
+From: Martin Pitt <martinpitt at gnome.org>
+Date: Sun, 31 May 2015 19:00:36 +0200
+Subject: [PATCH] Provide fallback for reading current directory if OSC 7 fails
+
+Bug: https://bugzilla.gnome.org/show_bug.cgi?id=697475
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=712628
+---
+ src/terminal-screen.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 66 insertions(+)
+
+Index: gnome-terminal-3.16.2/src/terminal-screen.c
+===================================================================
+--- gnome-terminal-3.16.2.orig/src/terminal-screen.c	2015-05-31 19:02:09.509732458 +0200
++++ gnome-terminal-3.16.2/src/terminal-screen.c	2015-05-31 19:02:09.509732458 +0200
+@@ -216,6 +216,63 @@
+ 
+ G_DEFINE_TYPE (TerminalScreen, terminal_screen, VTE_TYPE_TERMINAL)
+ 
++static char *
++cwd_of_pid (int pid)
++{
++  static const char patterns[][18] = {
++    "/proc/%d/cwd",         /* Linux */
++    "/proc/%d/path/cwd",    /* Solaris >= 10 */
++  };
++  guint i;
++
++  if (pid == -1)
++    return NULL;
++
++  /* Try to get the working directory using various OS-specific mechanisms */
++  for (i = 0; i < G_N_ELEMENTS (patterns); ++i)
++    {
++      char cwd_file[64];
++      char buf[PATH_MAX + 1];
++      int len;
++
++      /* disable "format not a string literal" error, we know what we are doing */
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wformat-nonliteral"
++      g_snprintf (cwd_file, sizeof (cwd_file), patterns[i], pid);
++#pragma GCC diagnostic pop
++      len = readlink (cwd_file, buf, sizeof (buf) - 1);
++
++      if (len > 0 && buf[0] == '/')
++        return g_strndup (buf, len);
++
++      /* If that didn't do it, try this hack */
++      if (len <= 0)
++        {
++          char *cwd, *working_dir = NULL;
++
++          cwd = g_get_current_dir ();
++          if (cwd != NULL)
++            {
++              /* On Solaris, readlink returns an empty string, but the
++               * link can be used as a directory, including as a target
++               * of chdir().
++               */
++              if (chdir (cwd_file) == 0)
++                {
++                  working_dir = g_get_current_dir ();
++                  (void) chdir (cwd);
++                }
++              g_free (cwd);
++            }
++
++          if (working_dir)
++            return working_dir;
++        }
++    }
++
++  return NULL;
++}
++
+ static void
+ free_tag_data (TagData *tagdata)
+ {
+@@ -1541,12 +1598,21 @@
+ char *
+ terminal_screen_get_current_dir (TerminalScreen *screen)
+ {
++  TerminalScreenPrivate *priv = screen->priv;
+   const char *uri;
+ 
+   uri = vte_terminal_get_current_directory_uri (VTE_TERMINAL (screen));
+   if (uri != NULL)
+     return g_filename_from_uri (uri, NULL, NULL);
+ 
++  if (priv->child_pid > 0) {
++    char *cwd = cwd_of_pid (priv->child_pid);
++    if (cwd != NULL) {
++      g_debug ("terminal_screen_get_current_dir: VTE current dir n/a, reading from /proc: %s", cwd);
++      return cwd;
++    }
++  }
++
+   if (screen->priv->initial_working_directory)
+     return g_strdup (screen->priv->initial_working_directory);
+ 




More information about the pkg-gnome-commits mailing list