* source.c (openp): Expand tilde in path entries.
authorThiago Jung Bauermann <bauerman@br.ibm.com>
Wed, 30 May 2012 03:42:21 +0000 (03:42 +0000)
committerThiago Jung Bauermann <bauerman@br.ibm.com>
Wed, 30 May 2012 03:42:21 +0000 (03:42 +0000)
gdb/ChangeLog
gdb/source.c

index b199f875cbc4af83d884f2abc9f87f9b8dd3a38f..c2f01b9462e00950c98203736d0766e1bd6ef552 100644 (file)
@@ -1,3 +1,7 @@
+2012-05-30  Thiago Jung Bauermann  <thiago.bauermann@linaro.org>
+
+       * source.c (openp): Expand tilde in path entries.
+
 2012-05-29  Doug Evans  <dje@google.com>
 
        * buildsym.c (block_compar): Fix comment.
index 27c5b0e00b52d780f4c5106b6beb75d03292d6d6..7de86b4925161652aac2dd708dfc925cc14917d6 100644 (file)
@@ -769,6 +769,25 @@ openp (const char *path, int opts, const char *string,
            }
          strcpy (filename, current_directory);
        }
+      else if (strchr(dir, '~'))
+       {
+        /* See whether we need to expand the tilde.  */
+         int newlen;
+         char *tilde_expanded;
+
+         tilde_expanded  = tilde_expand (dir);
+
+         /* First, realloc the filename buffer if too short.  */
+         len = strlen (tilde_expanded);
+         newlen = len + strlen (string) + 2;
+         if (newlen > alloclen)
+           {
+             alloclen = newlen;
+             filename = alloca (alloclen);
+           }
+         strcpy (filename, tilde_expanded);
+         xfree (tilde_expanded);
+       }
       else
        {
          /* Normal file name in path -- just use it.  */