mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Fix up osdfunc_exec()
git-svn-id: https://svn.eduke32.com/eduke32@7152 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
60e9bca926
commit
eb81507565
1 changed files with 13 additions and 16 deletions
|
@ -164,41 +164,42 @@ int OSD_Exec(const char *szScript)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
int32_t handle, len = 0;
|
int32_t handle, len = 0;
|
||||||
char *buf = NULL;
|
|
||||||
|
|
||||||
if ((handle = kopen4load(szScript, 0)) == -1)
|
if ((handle = kopen4load(szScript, 0)) == -1)
|
||||||
err = 1;
|
err = 1;
|
||||||
else if ((len = kfilelength(handle)) <= 0)
|
else if ((len = kfilelength(handle)) <= 0)
|
||||||
err = 2; // blank file
|
err = 2; // blank file
|
||||||
else if ((buf = (char *) Xmalloc(len + 1)) == NULL)
|
|
||||||
err = 3;
|
|
||||||
|
|
||||||
if (!err || err == 3)
|
if (!err)
|
||||||
OSD_Printf("Executing \"%s\"\n", szScript);
|
OSD_Printf("Executing \"%s\"\n", szScript);
|
||||||
|
|
||||||
|
auto buf = (char *) Xmalloc(len + 1);
|
||||||
|
|
||||||
if (err || kread(handle, buf, len) != len)
|
if (err || kread(handle, buf, len) != len)
|
||||||
{
|
{
|
||||||
if (!err || err == 3) // no error message for blank file
|
if (err != 2) // no error message for blank file
|
||||||
OSD_Printf("Error executing \"%s\"!\n", szScript);
|
OSD_Printf("Error executing \"%s\"!\n", szScript);
|
||||||
if (handle != -1) kclose(handle);
|
|
||||||
|
if (handle != -1)
|
||||||
|
kclose(handle);
|
||||||
|
|
||||||
Bfree(buf);
|
Bfree(buf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
kclose(handle);
|
kclose(handle);
|
||||||
|
buf[len] = '\0';
|
||||||
buf[len] = 0;
|
|
||||||
osd->execdepth++;
|
|
||||||
|
|
||||||
char const *cp = strtok(buf, "\r\n");
|
char const *cp = strtok(buf, "\r\n");
|
||||||
|
|
||||||
|
++osd->execdepth;
|
||||||
while (cp != NULL)
|
while (cp != NULL)
|
||||||
{
|
{
|
||||||
OSD_Dispatch(cp);
|
OSD_Dispatch(cp);
|
||||||
cp = strtok(NULL, "\r\n");
|
cp = strtok(NULL, "\r\n");
|
||||||
}
|
}
|
||||||
|
--osd->execdepth;
|
||||||
|
|
||||||
osd->execdepth--;
|
|
||||||
Bfree(buf);
|
Bfree(buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -251,12 +252,8 @@ static int osdfunc_exec(osdfuncparm_t const * const parm)
|
||||||
if (parm->numparms != 1)
|
if (parm->numparms != 1)
|
||||||
return OSDCMD_SHOWHELP;
|
return OSDCMD_SHOWHELP;
|
||||||
|
|
||||||
char fn[BMAX_PATH];
|
if (OSD_Exec(parm->parms[0]))
|
||||||
|
OSD_Printf("%sexec: file \"%s\" not found.\n", osd->draw.errorfmt, parm->parms[0]);
|
||||||
Bstrcpy(fn,parm->parms[0]);
|
|
||||||
|
|
||||||
if (OSD_Exec(fn))
|
|
||||||
OSD_Printf("%sexec: file \"%s\" not found.\n", osd->draw.errorfmt, fn);
|
|
||||||
|
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue