Introduce path_canexec0() for convenience

This commit is contained in:
Kim Woelders 2020-05-02 07:59:58 +02:00
parent 1ea08c2075
commit 9a6825fadf
4 changed files with 15 additions and 8 deletions

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2007-2015 Kim Woelders
* Copyright (C) 2007-2020 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -321,3 +321,13 @@ path_canexec(const char *file)
Efree(s);
return 1;
}
int
path_canexec0(const char *cmd)
{
char exe[4096];
sscanf(cmd, "%4000s", exe);
return path_canexec(exe);
}

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2007 Kim Woelders
* Copyright (C) 2007-2020 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -60,5 +60,6 @@ const char *fullfileof(const char *s);
char *path_test(const char *file, unsigned int test);
int path_canexec(const char *file);
int path_canexec0(const char *cmd);
#endif /* _FILE_H_ */

View File

@ -316,8 +316,7 @@ FillFlatFileMenu(Menu * m, const char *file)
if ((act) && (!strcmp(act, "exec")) && (params))
{
sscanf(params, "%4000s", wd);
if (path_canexec(wd))
if (path_canexec0(params))
{
Esnprintf(wd, sizeof(wd), "exec %s", params);
mi = MenuItemCreate(txt, icon, wd, NULL);

View File

@ -1846,10 +1846,7 @@ MenuConfigLoad(FILE * fs)
/* if its an execute line then check to see if the exec is
* on your system before adding the menu entry */
if (!strcmp(s2, "exec"))
{
sscanf(p3, "%1000s", s3);
ok = path_canexec(s3);
}
ok = path_canexec0(p3);
if (ok)
{
mi = MenuItemCreate(txt, icon, p2, NULL);