Re: basename and dirname (was Re: CVS mess)

> Mark Galassi <> writes:
> On the whole, `dirname' and `basename' seem to a big mess -- with
> different usages all over the place.  `glibc' itself provides two
> behaviours for `basename' depending on whether you include <libgen.h> or
> not, yuck.

Hear hear! Yes it appears to be a huge mess.

> It appears that we would be much better off defining our own `g_dirname'
> and `g_basename' and use those exclusively.  In fact, GNU fileutils takes
> this route in `basename.c' (the function is called `base_name'):

Sounds like a hell of a plan.

>   /* In general, we can't use the builtin `basename' function if available,
>      since it has different meanings in different environments.
>      In some environments the builtin `basename' modifies its argument.  */
> My take on this whole deal:
> * Put g_dirname and g_basename into `glib' or somewhere nice.  If
>   nothing else, we could put `g_dirname' into gnome-utils/gdiskfree/df.c
>   and `g_basename' somewhere in ORBit.
> * Anyway, `g_basename' would be non-destructive.  `g_dirname' would use
>   `g_malloc' to allocate its return value.
> * Modify ORBit and gnome-utils/gdiskfree to use the g_* versions.
>   (Yay, no libiberty ;-)  We would then know what exactly we are getting
>   with these functions.


> - Hari
> -- 
> Raja R Harinath ------------------------------
> "When all else fails, read the instructions."      -- Cahn's Axiom
> "Our policy is, when in doubt, do the right thing."   -- Roy L Ash
> -- 
>          To unsubscribe: mail with 
>                        "unsubscribe" as the Subject.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]