mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
Fix code style, and make some minor changes
Assume timidity is in the user's PATH if not the specified location Also, get the error message for the execvp failure if it does fail
This commit is contained in:
parent
233fce7ef6
commit
18e76c978c
1 changed files with 21 additions and 10 deletions
|
@ -529,20 +529,27 @@ bool TimidityPPMIDIDevice::LaunchTimidity ()
|
|||
int spaceIdx = 0;
|
||||
int spaceInExePathCount = -1;
|
||||
FString TimidityExe;
|
||||
do {
|
||||
do
|
||||
{
|
||||
spaceIdx = CommandLine.IndexOf(' ', spaceIdx);
|
||||
spaceInExePathCount += 1;
|
||||
TimidityExe = CommandLine.Left(spaceIdx);
|
||||
glob(TimidityExe.GetChars(), 0, NULL, &glb);
|
||||
} while (spaceIdx != -1 && glb.gl_pathc == 0);
|
||||
if (spaceIdx == -1) return false;
|
||||
if (spaceIdx == -1)
|
||||
{
|
||||
TimidityExe = FString("timidity"); // Maybe it's in your PATH?
|
||||
}
|
||||
globfree(&glb);
|
||||
|
||||
int strCount = 1;
|
||||
for (spaceIdx = 0; spaceIdx < CommandLine.Len(); spaceIdx++) {
|
||||
if (CommandLine[spaceIdx] == ' ') {
|
||||
for (spaceIdx = 0; spaceIdx < CommandLine.Len(); spaceIdx++)
|
||||
{
|
||||
if (CommandLine[spaceIdx] == ' ')
|
||||
{
|
||||
++strCount;
|
||||
if (CommandLine[spaceIdx+1] == ' ') {
|
||||
if (CommandLine[spaceIdx+1] == ' ')
|
||||
{
|
||||
--strCount;
|
||||
}
|
||||
}
|
||||
|
@ -558,11 +565,14 @@ bool TimidityPPMIDIDevice::LaunchTimidity ()
|
|||
strcpy(TimidityArgs[0], TimidityExe.GetChars());
|
||||
|
||||
int argLen;
|
||||
while (curSpace != -1) {
|
||||
while (curSpace != -1)
|
||||
{
|
||||
curSpace = CommandLine.IndexOf(' ', spaceIdx);
|
||||
if (curSpace != spaceIdx) {
|
||||
if (curSpace != spaceIdx)
|
||||
{
|
||||
argLen = curSpace - spaceIdx + 1;
|
||||
if (argLen < 0) {
|
||||
if (argLen < 0)
|
||||
{
|
||||
argLen = CommandLine.Len() - curSpace;
|
||||
}
|
||||
TimidityArgs[i] = new char[argLen];
|
||||
|
@ -573,7 +583,8 @@ bool TimidityPPMIDIDevice::LaunchTimidity ()
|
|||
}
|
||||
|
||||
DPrintf(DMSG_NOTIFY, "Timidity EXE: \x1cG%s\n", TimidityExe.GetChars());
|
||||
for (i = 0; i < strCount; i++) {
|
||||
for (i = 0; i < strCount; i++)
|
||||
{
|
||||
DPrintf(DMSG_NOTIFY, "arg %d: \x1cG%s\n", i, TimidityArgs[i]);
|
||||
}
|
||||
|
||||
|
@ -588,7 +599,7 @@ bool TimidityPPMIDIDevice::LaunchTimidity ()
|
|||
close (WavePipe[1]);
|
||||
|
||||
execvp (TimidityExe.GetChars(), TimidityArgs);
|
||||
fprintf(stderr,"execvp failed\n");
|
||||
fprintf(stderr,"execvp failed: %s\n", strerror(errno));
|
||||
_exit (0); // if execvp succeeds, we never get here
|
||||
}
|
||||
else if (forkres < 0)
|
||||
|
|
Loading…
Reference in a new issue