2022-07-15  Juan Manuel Guerrero <juan.guerrero@gmx.de>


	* frontend/lametime.c [__DJGPP__]: Include required DJGPP specific
	headers.
	(lame_set_stream_binary_mode) [__DJGPP__]: For DJGPP, reenable SIGINT
	and SIGQUIT signals if stdin and/or stdout is connected to console and
	has been switched into binary mode.






diff -aprNU3 lame-3.100.orig/frontend/lametime.c lame-3.100/frontend/lametime.c
--- lame-3.100.orig/frontend/lametime.c	2011-04-25 05:58:00 +0000
+++ lame-3.100/frontend/lametime.c	2022-07-15 19:20:18 +0000
@@ -124,6 +124,11 @@ GetRealTime(void)
 #if defined(_WIN32) || defined(__CYGWIN__)
 # include <io.h>
 # include <fcntl.h>
+#elif defined(__DJGPP__)
+# include <io.h>           /* declares setmode() */
+# include <fcntl.h>        /* defines O_BINARY */
+# include <unistd.h>       /* declares isatty() */
+# include <sys/exceptn.h>  /* declares __djgpp_set_ctrl_c() */
 #else
 # include <unistd.h>
 #endif
@@ -137,6 +142,21 @@ lame_set_stream_binary_mode(FILE * const
     setmode(_fileno(fp), O_BINARY);
 #elif defined __CYGWIN__
     setmode(fileno(fp), _O_BINARY);
+#elif defined __DJGPP__
+    /* Putting stdin/stdout in binary mode if it is connected to
+       the console, would make it impossible for the user to
+       interrupt the program through Ctrl-C or Ctrl-Break.  */
+
+    /* This is DJGPP-specific.  By default, switching console
+       to binary mode disables SIGINT and SIGQUIT.  But we want
+       terminal reads to be interruptible.  */
+
+    {
+        int fd = fileno(fp);
+        setmode(fd, O_BINARY);
+        if (isatty(fd))
+            __djgpp_set_ctrl_c(1);
+    }
 #elif defined _WIN32
     _setmode(_fileno(fp), _O_BINARY);
 #else
