[MPlayer-dev-eng] Export mp_basename in a function
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Thu Nov 11 21:01:40 CET 2010
On Thu, Nov 11, 2010 at 12:53:25PM -0700, Kevin DeKorte wrote:
> On 11/11/2010 12:44 PM, Reimar Döffinger wrote:
> > On Thu, Nov 11, 2010 at 05:32:14PM +0100, Clément Bœsch wrote:
> >> @@ -193,3 +193,16 @@ void set_codec_path(const char *path)
> >> strcpy(codec_path, path);
> >> needs_free = 1;
> >> }
> >> +
> >> +char *mp_basename(char *path)
> >> +{
> >> + char *s;
> >> +
> >> +#if HAS_DOS_PATHS
> >> + s = strrchr(path, '\\');
> >> + if (s)
> >> + return s + 1;
> >> +#endif
> >> + s = strrchr(path, '/');
> >> + return s ? s + 1 : s;
> >> +}
> >
> > Please use 4 spaces for indentation if you add a completely new
> > function and the surrounding code does not consistently use
> > something else.
> > Also please use "const char" instead of "char" (I think
> > you might have to change some more code to avoid new warnings,
> > but I think it should be possible without real issues).
>
> Any particular reason you are not using the GNU version of basename at
> least for the non-windows code path? (man 3 basename)
What's the point if we need the code anyway for Windows?
Most importantly though: because we can't. Those functions
are an idiocy and cannot be used on strings you don't want
to modify.
More information about the MPlayer-dev-eng
mailing list