2009-02-11 Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* libvo/ideo_out_pgm.c (md5_draw_frame): Use the correct conversion
	specifier qualifier.

	* src/mpeg2dec.c (print_fps): Use the correct conversion specifier
	qualifier.

	* src/extract_mpeg2.c (handle_args): Include local getopt.h.

	* src/dump_state.c (dump_state): Use the correct conversion specifier
	qualifier.

	* src/getopt.h [__GNU_LIBRARY__, __DJGPP__]: For DJGPP do not declare
	getopt() as extern and include unistd.h for getopt() prototype.

	* src/getopt.c [__GNU_LIBRARY__, __DJGPP__]: Also for DJGPP include
	stdlib.h to provide the getenv() prototype.
	[getenv]: For DJGPP do not declare getenv() as extern.

	* src/corrupt_mpeg2.c (handle_args): Use the correct conversion
	specifier qualifier.
	(main): Use the correct conversion specifier qualifier.






diff -aprNU5 libmpeg2-0.5.1.orig/libvo/video_out_pgm.c libmpeg2-0.5.1/libvo/video_out_pgm.c
--- libmpeg2-0.5.1.orig/libvo/video_out_pgm.c	2008-07-09 22:00:08 +0000
+++ libmpeg2-0.5.1/libvo/video_out_pgm.c	2009-02-11 19:52:04 +0000
@@ -332,13 +332,13 @@ static void md5_draw_frame (vo_instance_
     instance->md5_block[14] = instance->md5_bytes << 3;
     instance->md5_block[15] = instance->md5_bytes >> 29;
     little_endian (instance->md5_block, 14);
     md5_transform (instance->md5_hash, instance->md5_block);
 
-    printf ("%08x%08x%08x%08x *%d.pgm\n", swap (instance->md5_hash[0]),
-	    swap (instance->md5_hash[1]) , swap (instance->md5_hash[2]),
-	    swap (instance->md5_hash[3]), instance->framenum++);
+    printf ("%08jx%08jx%08jx%08jx *%d.pgm\n", (uintmax_t)swap (instance->md5_hash[0]),
+	    (uintmax_t)swap (instance->md5_hash[1]) , (uintmax_t)swap (instance->md5_hash[2]),
+	    (uintmax_t)swap (instance->md5_hash[3]), instance->framenum++);
 }
 
 vo_instance_t * vo_md5_open (void)
 {
     return internal_open (md5_draw_frame, md5_writer);
diff -aprNU5 libmpeg2-0.5.1.orig/src/corrupt_mpeg2.c libmpeg2-0.5.1/src/corrupt_mpeg2.c
--- libmpeg2-0.5.1.orig/src/corrupt_mpeg2.c	2008-07-11 19:48:04 +0000
+++ libmpeg2-0.5.1/src/corrupt_mpeg2.c	2009-02-12 21:40:56 +0000
@@ -167,12 +167,12 @@ static void handle_args (int argc, char 
     while ((c = getopt (argc, argv, "hl:s:r:v:")) != -1)
 	switch (c) {
 	case 'l':
 	    if (seed_file || seed_loaded)
 		print_usage (argv);
-	    if (sscanf (optarg, "%08x%08x%08x%08x",
-			rsl, rsl+1, rsl+2, rsl+3) != 4)
+	    if (sscanf (optarg, "%08jx%08jx%08jx%08jx",
+			(uintmax_t *)rsl, (uintmax_t *)(rsl+1), (uintmax_t *)(rsl+2), (uintmax_t *)(rsl+3)) != 4)
 		print_usage (argv);
 	    seed_loaded = 1;
 	    break;
 
 	case 's':
@@ -328,12 +328,12 @@ int main (int argc, char ** argv)
 
     if (!seed_loaded) {
 	srand (time (NULL));
 	for (i = 0; i < 4; i++)
 	    rsl[i] = rand ();
-	fprintf (seed_file, "%08x%08x%08x%08x\n",
-		 rsl[0], rsl[1], rsl[2], rsl[3]);
+	fprintf (seed_file, "%08jx%08jx%08jx%08jx\n",
+		 (uintmax_t)rsl[0], (uintmax_t)rsl[1], (uintmax_t)rsl[2], (uintmax_t)rsl[3]);
 	fclose (seed_file);
     }
 
     for (i = 4; i < 55; i++)
 	rsl[i] = 0;
diff -aprNU5 libmpeg2-0.5.1.orig/src/dump_state.c libmpeg2-0.5.1/src/dump_state.c
--- libmpeg2-0.5.1.orig/src/dump_state.c	2008-07-11 17:27:00 +0000
+++ libmpeg2-0.5.1/src/dump_state.c	2009-02-11 19:52:06 +0000
@@ -381,14 +381,14 @@ void dump_state (FILE * f, mpeg2_state_t
 	    fprintf (f, " SKIP");
 	fprintf (f, " fields %d", pic->nb_fields);
 	if (pic->flags & PIC_FLAG_TOP_FIELD_FIRST)
 	    fprintf (f, " TFF");
 	if (pic->flags & PIC_FLAG_TAGS)
-	    fprintf (f, " pts %08x dts %08x", pic->tag, pic->tag2);
+	    fprintf (f, " pts %08jx dts %08jx", (uintmax_t)(pic->tag), (uintmax_t)(pic->tag2));
 	fprintf (f, " time_ref %d", pic->temporal_reference);
 	if (pic->flags & PIC_FLAG_COMPOSITE_DISPLAY)
-	    fprintf (f, " composite %05x", pic->flags >> 12);
+	    fprintf (f, " composite %05jx", (uintmax_t)(pic->flags >> 12));
 	fprintf (f, " offset");
 	nb_pos = pic->nb_fields;
 	if (seq->flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)
 	    nb_pos >>= 1;
 	for (i = 0; i < nb_pos; i++)
diff -aprNU5 libmpeg2-0.5.1.orig/src/extract_mpeg2.c libmpeg2-0.5.1/src/extract_mpeg2.c
--- libmpeg2-0.5.1.orig/src/extract_mpeg2.c	2008-07-09 18:28:24 +0000
+++ libmpeg2-0.5.1/src/extract_mpeg2.c	2009-02-11 23:18:54 +0000
@@ -25,11 +25,11 @@
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
-#include <getopt.h>
+#include "getopt.h"
 #ifdef HAVE_IO_H
 #include <fcntl.h>
 #include <io.h>
 #endif
 #include <inttypes.h>
diff -aprNU5 libmpeg2-0.5.1.orig/src/getopt.c libmpeg2-0.5.1/src/getopt.c
--- libmpeg2-0.5.1.orig/src/getopt.c	2008-07-09 18:28:24 +0000
+++ libmpeg2-0.5.1/src/getopt.c	2009-02-11 23:18:56 +0000
@@ -60,11 +60,11 @@
 #ifndef ELIDE_CODE
 
 
 /* This needs to come after some library #include
    to get __GNU_LIBRARY__ defined.  */
-#ifdef	__GNU_LIBRARY__
+#if defined (__GNU_LIBRARY__) || defined (__DJGPP__)
 /* Don't include stdlib.h for non-GNU C libraries because some of them
    contain conflicting prototypes for getopt.  */
 # include <stdlib.h>
 # include <unistd.h>
 #endif	/* GNU C library.  */
@@ -205,18 +205,16 @@ static char *posixly_correct;
 # endif
 
 /* Avoid depending on library functions or files
    whose names are inconsistent.  */
 
-#ifndef getenv
+#if !defined (getenv) && !defined (__DJGPP__)
 extern char *getenv ();
 #endif
 
 static char *
-my_index (str, chr)
-     const char *str;
-     int chr;
+my_index (const char *str, int chr)
 {
   while (*str)
     {
       if (*str == chr)
 	return (char *) str;
diff -aprNU5 libmpeg2-0.5.1.orig/src/getopt.h libmpeg2-0.5.1/src/getopt.h
--- libmpeg2-0.5.1.orig/src/getopt.h	2008-07-09 18:28:24 +0000
+++ libmpeg2-0.5.1/src/getopt.h	2009-02-12 21:00:50 +0000
@@ -131,11 +131,16 @@ struct option
 /* Many other libraries have conflicting prototypes for getopt, with
    differences in the consts, in stdlib.h.  To avoid compilation
    errors, only prototype getopt for the GNU C library.  */
 extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
 # else /* not __GNU_LIBRARY__ */
+#  ifdef __DJGPP__
+/*  For getopt() declaration.  */
+#   include <unistd.h>
+#  else
 extern int getopt ();
+#  endif
 # endif /* __GNU_LIBRARY__ */
 
 # ifndef __need_getopt
 extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
 		        const struct option *__longopts, int *__longind);
diff -aprNU5 libmpeg2-0.5.1.orig/src/mpeg2dec.c libmpeg2-0.5.1/src/mpeg2dec.c
--- libmpeg2-0.5.1.orig/src/mpeg2dec.c	2008-07-09 19:16:04 +0000
+++ libmpeg2-0.5.1/src/mpeg2dec.c	2009-02-12 21:53:22 +0000
@@ -95,12 +95,12 @@ static void print_fps (int final)
 	if (total_elapsed)
 	    tfps = frame_counter * 100.0 / total_elapsed;
 	else
 	    tfps = 0;
 
-	fprintf (stderr,"\n%d frames decoded in %.2f seconds (%.2f fps)\n",
-		 frame_counter, total_elapsed / 100.0, tfps);
+	fprintf (stderr,"\n%ju frames decoded in %.2f seconds (%.2f fps)\n",
+		 (uintmax_t)frame_counter, total_elapsed / 100.0, tfps);
 
 	return;
     }
 
     frame_counter++;
@@ -112,12 +112,12 @@ static void print_fps (int final)
     frames = frame_counter - last_count;
 
     fps = frames * 100.0 / elapsed;
     tfps = frame_counter * 100.0 / total_elapsed;
 
-    fprintf (stderr, "%d frames in %.2f sec (%.2f fps), "
-	     "%d last %.2f sec (%.2f fps)\033[K\r", frame_counter,
+    fprintf (stderr, "%ju frames in %.2f sec (%.2f fps), "
+	     "%d last %.2f sec (%.2f fps)\033[K\r", (uintmax_t)frame_counter,
 	     total_elapsed / 100.0, tfps, frames, elapsed / 100.0, fps);
 
     last_count = frame_counter;
 }
 






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

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

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

	* src/mpeg2dec.c [__DJGPP__]: Include required DJGPP specific headers.
	(main) [__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 -aprNU5 libmpeg2-0.5.1.orig/src/corrupt_mpeg2.c libmpeg2-0.5.1/src/corrupt_mpeg2.c
--- libmpeg2-0.5.1.orig/src/corrupt_mpeg2.c	2022-12-29 18:44:22 +0000
+++ libmpeg2-0.5.1/src/corrupt_mpeg2.c	2022-12-29 18:51:56 +0000
@@ -31,10 +31,14 @@
 #include <getopt.h>
 #include <ctype.h>
 #ifdef HAVE_IO_H
 #include <fcntl.h>
 #include <io.h>
+#if defined(__DJGPP__)
+#include <unistd.h>       /* declares isatty() */
+#include <sys/exceptn.h>  /* declares __djgpp_set_ctrl_c() */
+#endif
 #endif
 #include <inttypes.h>
 
 static FILE * in_file;
 static FILE * seed_file;
@@ -320,10 +324,21 @@ int main (int argc, char ** argv)
     int i;
 
 #ifdef HAVE_IO_H
     setmode (fileno (stdin), O_BINARY);
     setmode (fileno (stdout), O_BINARY);
+#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.  */
+
+    if (isatty(fileno(stdout)))
+    {
+      setmode (fileno (stdin), O_TEXT);
+      setmode (fileno (stdout), O_TEXT);
+    }
+#endif
 #endif
 
     handle_args (argc, argv);
 
     if (!seed_loaded) {
diff -aprNU5 libmpeg2-0.5.1.orig/src/extract_mpeg2.c libmpeg2-0.5.1/src/extract_mpeg2.c
--- libmpeg2-0.5.1.orig/src/extract_mpeg2.c	2022-12-29 18:44:22 +0000
+++ libmpeg2-0.5.1/src/extract_mpeg2.c	2022-12-29 18:51:54 +0000
@@ -29,10 +29,14 @@
 #include <errno.h>
 #include "getopt.h"
 #ifdef HAVE_IO_H
 #include <fcntl.h>
 #include <io.h>
+#if defined(__DJGPP__)
+#include <unistd.h>       /* declares isatty() */
+#include <sys/exceptn.h>  /* declares __djgpp_set_ctrl_c() */
+#endif
 #endif
 #include <inttypes.h>
 
 #define BUFFER_SIZE 4096
 static uint8_t buffer[BUFFER_SIZE];
@@ -445,10 +449,21 @@ static void ts_loop (void)
 int main (int argc, char ** argv)
 {
 #ifdef HAVE_IO_H
     setmode (fileno (stdin), O_BINARY);
     setmode (fileno (stdout), O_BINARY);
+#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.  */
+
+    if (isatty(fileno(stdout)))
+    {
+      setmode (fileno (stdin), O_TEXT);
+      setmode (fileno (stdout), O_TEXT);
+    }
+#endif
 #endif
 
     handle_args (argc, argv);
 
     if (demux_pva)
diff -aprNU5 libmpeg2-0.5.1.orig/src/mpeg2dec.c libmpeg2-0.5.1/src/mpeg2dec.c
--- libmpeg2-0.5.1.orig/src/mpeg2dec.c	2022-12-29 18:44:22 +0000
+++ libmpeg2-0.5.1/src/mpeg2dec.c	2022-12-29 18:51:56 +0000
@@ -30,10 +30,14 @@
 #include <signal.h>
 #include <getopt.h>
 #ifdef HAVE_IO_H
 #include <fcntl.h>
 #include <io.h>
+#if defined(__DJGPP__)
+#include <unistd.h>       /* declares isatty() */
+#include <sys/exceptn.h>  /* declares __djgpp_set_ctrl_c() */
+#endif
 #endif
 #ifdef LIBVO_SDL
 #include <SDL/SDL.h>
 #endif
 #include <inttypes.h>
@@ -763,10 +767,21 @@ static void es_loop (void)
 int main (int argc, char ** argv)
 {
 #ifdef HAVE_IO_H
     setmode (fileno (stdin), O_BINARY);
     setmode (fileno (stdout), O_BINARY);
+#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.  */
+
+    if (isatty(fileno(stdout)))
+    {
+      setmode (fileno (stdin), O_TEXT);
+      setmode (fileno (stdout), O_TEXT);
+    }
+#endif
 #endif
 
     fprintf (stderr, PACKAGE"-"VERSION
 	     " - by Michel Lespinasse <walken@zoy.org> and Aaron Holtzman\n");
 
