On Fri, Mar 9, 2012 at 8:40 PM, asmwarrior<asmwarrior@gmail.com> wrote:
On 2012-3-9 6:39, Doug Evans wrote:
No such quick check is available, but I think we can ignore the cost
of the xmalloc/xfree for this particular case until the data shows
it's a problem.
Ok, this is the modified patch.(simply replace gdb_fullpath with xfullpath)
It works Ok under mingw+windowsXP.
Thanks.
This needs a ChangeLog entry of course.
Something like
2012-03-14 Zhang Yuanhui<asmwarrior@gmail.com>
* source.c (find_and_open_source): Consistently pass resulting
full path through xfullpath.
Further comments inline with the patch.
diff --git a/gdb/source.c b/gdb/source.c
index cfdf81b..cd87e34 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -979,6 +979,7 @@ find_and_open_source (const char *filename,
char *path = source_path;
const char *p;
int result;
+ char *lpath;
Move this declaration into the block where it is used.
/* Quick way out if we already know its full name. */
@@ -997,7 +998,12 @@ find_and_open_source (const char *filename,
result = open (*fullname, OPEN_MODE);
if (result>= 0)
- return result;
+ {
Add a comment here explaining why we're calling xfullpath.
E.g.,
/* Call xfullpath here to be consistent with openp
which we use below. */
+ lpath = xfullpath(*fullname);
+ xfree(*fullname);
Space before '('.
Plus, for consistency, I think the indentation here should use tabs.
+ *fullname = lpath;
+ return result;
+ }
/* Didn't work -- free old one, try again. */
xfree (*fullname);
*fullname = NULL;
Ok with those changes.
Thanks!