mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-27 06:22:06 +00:00
Fix premature exit of the fluid_shell on WinXP
When compiled with compatibility for WinXP (toolset v141_xp), read() may return 0 (EOF) rather than '\n' which led to an early exit of the shell after a single user input.
This commit is contained in:
parent
b6df34cc27
commit
c093b20c31
2 changed files with 8 additions and 5 deletions
|
@ -512,6 +512,7 @@ fluid_shell_run(void *data)
|
|||
|
||||
if(n < 0)
|
||||
{
|
||||
FLUID_LOG(FLUID_PANIC, "An error occurred while reading from stdin.");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -535,14 +536,12 @@ fluid_shell_run(void *data)
|
|||
|
||||
if(n == 0)
|
||||
{
|
||||
FLUID_LOG(FLUID_INFO, "Received EOF while reading commands, exiting the shell.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(prompt)
|
||||
{
|
||||
FLUID_FREE(prompt); /* -- free prompt */
|
||||
}
|
||||
FLUID_FREE(prompt); /* -- free prompt */
|
||||
|
||||
/* return FLUID_THREAD_RETURN_VALUE on success, something else on failure */
|
||||
return errors ? (fluid_thread_return_t)(-1) : FLUID_THREAD_RETURN_VALUE;
|
||||
|
|
|
@ -1251,6 +1251,9 @@ fluid_istream_gets(fluid_istream_t in, char *buf, int len)
|
|||
/* Handle read differently depending on if its a socket or file descriptor */
|
||||
if(!(in & FLUID_SOCKET_FLAG))
|
||||
{
|
||||
// usually read() is supposed to return '\n' as last valid character of the user input
|
||||
// when compiled with compatibility for WinXP however, read() may return 0 (EOF) rather than '\n'
|
||||
// this would cause the shell to exit early
|
||||
n = read(in, &c, 1);
|
||||
|
||||
if(n == -1)
|
||||
|
@ -1274,7 +1277,8 @@ fluid_istream_gets(fluid_istream_t in, char *buf, int len)
|
|||
if(n == 0)
|
||||
{
|
||||
*buf = 0;
|
||||
return 0;
|
||||
// return 1 if read from stdin, else 0, to fix early exit of shell
|
||||
return (in == STDIN_FILENO);
|
||||
}
|
||||
|
||||
if(c == '\n')
|
||||
|
|
Loading…
Reference in a new issue