Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* basename() troubles
@ 2001-05-13  6:59 Mark Kettenis
  2001-05-13  8:41 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Kettenis @ 2001-05-13  6:59 UTC (permalink / raw)
  To: gdb

Eli's latest patch to symtab.c:

2001-05-06  Eli Zaretskii  <eliz@is.elta.co.il>

	* symtab.c (lookup_symtab_1, lookup_partial_symtab): Use basename
	instead of non-portable search for `/'.  Use FILENAME_CMP instead
	of STREQ, to account for case-insensitive filesystems.
	(top-level): #include "filenames.h".

uses the following bit of code:

  if (basename (name) == name)
    ...

in a couple of places.  Unfortunately the FreeBSD basename() always
returns a pointer to internal static storage space.  Therefore the
check will always fail.  There are basically two ways to solve this
problem:

 * Use strcmp() to compare the strings.

 * Use lbasename() from libiberty which has well defined semantics.

The latter is probably a bit more efficient, and has the additional
advantage of removing our dependence on whatever broken basename()
implementation the host supplies.  Do people agree?

Another question is, wheter we should replace the other basename() calls with
lbasename() as well.

Mark


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: basename() troubles
  2001-05-13  6:59 basename() troubles Mark Kettenis
@ 2001-05-13  8:41 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2001-05-13  8:41 UTC (permalink / raw)
  To: kettenis; +Cc: gdb

> Date: Sun, 13 May 2001 15:59:43 +0200
> From: Mark Kettenis <kettenis@wins.uva.nl>
> 
> Eli's latest patch to symtab.c:
> 
> 2001-05-06  Eli Zaretskii  <eliz@is.elta.co.il>
> 
> 	* symtab.c (lookup_symtab_1, lookup_partial_symtab): Use basename
> 	instead of non-portable search for `/'.  Use FILENAME_CMP instead
> 	of STREQ, to account for case-insensitive filesystems.
> 	(top-level): #include "filenames.h".
> 
> uses the following bit of code:
> 
>   if (basename (name) == name)
>     ...
> 
> in a couple of places.  Unfortunately the FreeBSD basename() always
> returns a pointer to internal static storage space.  Therefore the
> check will always fail.

Sorry, I failed to consider this possibility.

> There are basically two ways to solve this
> problem:
> 
>  * Use strcmp() to compare the strings.

You mean FILENAME_CMP ;-)

>  * Use lbasename() from libiberty which has well defined semantics.
> 
> The latter is probably a bit more efficient, and has the additional
> advantage of removing our dependence on whatever broken basename()
> implementation the host supplies.  Do people agree?

I do agree that using libiberty's version is a better solution.

> Another question is, wheter we should replace the other basename() calls with
> lbasename() as well.

I think this is only justified if basename's return value is used as
in symtab.c; I think such cases are rare.  I have a slightly outdated
source tree, and I can only see one other case like that:
source.c:open_source_file (does this mean it didn't work on FreeBSD as
well? that code is quite old, I think).


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-05-13  8:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-13  6:59 basename() troubles Mark Kettenis
2001-05-13  8:41 ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox