From ebd86fb5688dac848266e6a902ea192fe9aa1576 Mon Sep 17 00:00:00 2001 From: Thiago Jung Bauermann Date: Wed, 30 May 2012 03:42:21 +0000 Subject: [PATCH] * source.c (openp): Expand tilde in path entries. --- gdb/ChangeLog | 4 ++++ gdb/source.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b199f875cbc..c2f01b9462e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2012-05-30 Thiago Jung Bauermann + + * source.c (openp): Expand tilde in path entries. + 2012-05-29 Doug Evans * buildsym.c (block_compar): Fix comment. diff --git a/gdb/source.c b/gdb/source.c index 27c5b0e00b5..7de86b49251 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -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. */ -- 2.30.2