mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
dtcreate: Replace broken GetBaseName with basename
GetBaseName causes segfaults, because when the pathname ends in a "/" it returns NULL. This happens when trying to give a valid filename to dtcreate for an icon.
This commit is contained in:
parent
7d2fee2769
commit
f5ac4cf8f9
1 changed files with 2 additions and 19 deletions
|
@ -33,30 +33,13 @@
|
|||
#include <Dt/Icon.h>
|
||||
#include <X11/cursorfont.h>
|
||||
#include "UxXt.h"
|
||||
#include <libgen.h>
|
||||
|
||||
#include "dtcreate.h"
|
||||
#include "CreateActionAppShell.h"
|
||||
#include "fileio.h"
|
||||
#include "cmnrtns.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* GetBaseName */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
char * GetBaseName(char *pszFileName)
|
||||
{
|
||||
char *name;
|
||||
|
||||
name = strrchr(pszFileName, '/');
|
||||
if (name) {
|
||||
name = strtok(name, "/");
|
||||
return(name);
|
||||
} else {
|
||||
return(pszFileName);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* ReplaceSpaces */
|
||||
|
@ -273,7 +256,7 @@ void load_icons (Widget wid, XtPointer client_data,
|
|||
*/
|
||||
{
|
||||
XtVaGetValues(IconSelector, XmNuserData, &iSource, NULL);
|
||||
base_name = GetBaseName(path_and_base_name);
|
||||
base_name = basename(path_and_base_name);
|
||||
ptr = XtMalloc(strlen(base_name) + 1);
|
||||
strcpy(ptr, base_name);
|
||||
switch (iSource) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue