On Darwin, basename returns a pointer to internal static storage space ...

Is'nt that vicious. This would cause two successive basename to
point on the same zone, which gave strange effects on command
line reading (ex:BOOM) ...
This commit is contained in:
Christophe Alexandre 2002-10-07 12:10:47 +00:00
parent d2fe4abb6a
commit 03d3e70eb8
1 changed files with 10 additions and 1 deletions

View File

@ -45,6 +45,7 @@
# include <signal.h>
# include <stdlib.h>
# include <unistd.h>
# include <libgen.h>
# include <mut.h>
# include "aut.h"
@ -118,8 +119,16 @@ char *autbasename( Name, Extension )
{
int Index;
char *NewName;
char *NewNameTmp;
NewName = basename( mbkstrdup( Name ) );
NewNameTmp = mbkstrdup( Name );
NewName = mbkstrdup (basename( NewNameTmp ) );
/* We copy the result of basename because basename */
/* can return a pointer to internal static storage */
/* space on systems like Darwin */
mbkfree(NewNameTmp);
if ( Extension != (char *)0 )
{