2022-06-17  Juan Manuel Guerrero <juan.guerrero@gmx.de>


	* lib/vorbisfile.c [DJGPP]: Include required DJGPP specific
	headers.
	(ov_open) [__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 libvorbis-1.3.7.orig/lib/vorbisfile.c libvorbis-1.3.7/lib/vorbisfile.c
--- libvorbis-1.3.7.orig/lib/vorbisfile.c	2020-07-03 16:22:20 +0000
+++ libvorbis-1.3.7/lib/vorbisfile.c	2022-07-16 19:07:22 +0000
@@ -999,6 +999,12 @@ int ov_open_callbacks(void *f,OggVorbis_
   return _ov_open2(vf);
 }
 
+#if 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() */
+#endif
 int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes){
   ov_callbacks callbacks = {
     (size_t (*)(void *, size_t, size_t, void *))  fread,
@@ -1007,6 +1013,27 @@ int ov_open(FILE *f,OggVorbis_File *vf,c
     (long (*)(void *))                            ftell
   };
 
+#if 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(f);
+    if (isatty(fd))
+    {
+      if (O_BINARY == setmode(fd, O_BINARY))
+        __djgpp_set_ctrl_c(1);
+      else
+        setmode(fd, O_TEXT);
+    }
+  }
+#endif
+
   return ov_open_callbacks((void *)f, vf, initial, ibytes, callbacks);
 }
 
