Fri Feb 24 18:36:49 2012 UTC ()
PR/46089: David Shao: Don't use f{g,s}etpos because there is no portable
way of extracting the offset from them, which is all that is needed in
this case. Just use fseeko/ftello.


(christos)
diff -r0 -r1.1 pkgsrc/multimedia/libmp4v2/patches/patch-am
diff -r0 -r1.1 pkgsrc/multimedia/libmp4v2/patches/patch-ao
diff -r0 -r1.1 pkgsrc/multimedia/libmp4v2/patches/patch-ap
diff -r0 -r1.1 pkgsrc/multimedia/libmp4v2/patches/patch-aq
diff -r0 -r1.1 pkgsrc/multimedia/libmp4v2/patches/patch-ar
diff -r0 -r1.1 pkgsrc/multimedia/libmp4v2/patches/patch-as
diff -r0 -r1.1 pkgsrc/multimedia/libmp4v2/patches/patch-at
diff -r0 -r1.1 pkgsrc/multimedia/libmp4v2/patches/patch-au
diff -r0 -r1.1 pkgsrc/multimedia/libmp4v2/patches/patch-av

File Added: pkgsrc/multimedia/libmp4v2/patches/Attic/patch-am
$NetBSD: patch-am,v 1.1 2012/02/24 18:36:48 christos Exp $

--- lib/mp4v2/mp4file_io.cpp.orig	2007-04-30 16:29:28.000000000 -0400
+++ lib/mp4v2/mp4file_io.cpp	2012-02-24 13:04:54.000000000 -0500
@@ -34,13 +34,11 @@
 			}
 			return fpos;
 		} else {
-			fpos_t fpos;
-			if (fgetpos(pFile, &fpos) < 0) { 
+			u_int64_t fpos = ftello(pFile);
+			if (fpos == (u_int64_t)-1) {
 				throw new MP4Error(errno, "MP4GetPosition");
 			}
-			uint64_t ret;
-			FPOS_TO_VAR(fpos, uint64_t, ret);
-			return ret;
+			return fpos;
 		}
 	} else {
 		return m_memoryBufferPosition;
@@ -56,9 +54,7 @@
 				throw new MP4Error("setting position via Virtual I/O", "MP4SetPosition");
 			}
 		}	else {
-			fpos_t fpos;
-			VAR_TO_FPOS(fpos, pos);
-			if (fsetpos(pFile, &fpos) < 0) { 
+			if (fseeko(pFile, pos, SEEK_SET) < 0) { 
 				throw new MP4Error(errno, "MP4SetPosition");
 			}
 		}

File Added: pkgsrc/multimedia/libmp4v2/patches/Attic/patch-ao
$NetBSD: patch-ao,v 1.1 2012/02/24 18:36:48 christos Exp $

--- lib/mp4v2/virtual_io.cpp.orig	2006-10-23 18:26:38.000000000 -0400
+++ lib/mp4v2/virtual_io.cpp	2012-02-24 13:04:41.000000000 -0500
@@ -39,20 +39,16 @@
 int FILE_SetPosition(void *user, u_int64_t position)
 {
 	FILE *fp = (FILE *)user;
-	fpos_t fpos;
-	VAR_TO_FPOS(fpos, position);
-	return fsetpos(fp, &fpos);
+	return fseeko(fp, position, SEEK_SET) == -1 ? -1 : 0;
 }
 
 int FILE_GetPosition(void *user, u_int64_t *position)
 {
 	FILE *fp = (FILE *)user;
-	fpos_t fpos;
-	if (fgetpos(fp, &fpos) < 0) { 
+	*position = ftello(fp);
+	if (*position == (u_int64_t)-1) { 
 		throw new MP4Error(errno, "MP4GetPosition");
 	}
-	
-	FPOS_TO_VAR(fpos, u_int64_t, *position);
 	return 0;
 }
 

File Added: pkgsrc/multimedia/libmp4v2/patches/Attic/patch-ap
$NetBSD: patch-ap,v 1.1 2012/02/24 18:36:48 christos Exp $

--- lib/mpeg2t/mpeg2t_dump.cpp.orig	2007-02-07 12:34:16.000000000 -0500
+++ lib/mpeg2t/mpeg2t_dump.cpp	2012-02-24 13:05:14.000000000 -0500
@@ -18,7 +18,7 @@
   mpeg2t_es_t *es_pid;
   mpeg2t_pid_t *pidptr;
   bool verbose = false;
-  fpos_t pos;
+  u_int64_t pos;
   const char *ProgName = argv[0];
   const char *usage = "";
   uint16_t pid = 0;
@@ -97,11 +97,9 @@
     if (buflen > 0) {
       memmove(buffer, buffer + readfromfile - buflen, buflen);
     }
-    fgetpos(ifile, &pos);
+    pos = ftello(ifile);
     if (verbose) {
-      uint64_t position;
-      FPOS_TO_VAR(pos, uint64_t, position);
-      fprintf(stdout, "file pos %llu\n", position);
+      fprintf(stdout, "file pos %llu\n", pos);
     }
     readfromfile = buflen + fread(buffer + buflen, 1, BUFFER_SIZE - buflen, ifile);
     buflen = readfromfile;

File Added: pkgsrc/multimedia/libmp4v2/patches/Attic/patch-aq
$NetBSD: patch-aq,v 1.1 2012/02/24 18:36:48 christos Exp $

--- lib/mpeg2t/mpeg2t_extract.cpp.orig	2007-03-29 14:52:16.000000000 -0400
+++ lib/mpeg2t/mpeg2t_extract.cpp	2012-02-24 13:05:47.000000000 -0500
@@ -34,7 +34,7 @@
   mpeg2t_es_t *es_pid;
   mpeg2t_pid_t *pidptr;
   bool verbose = false;
-  fpos_t pos;
+  u_int64_t pos;
   const char *ProgName = argv[0];
   const char *usage = "";
   uint16_t pid = 0;
@@ -119,10 +119,8 @@
     if (buflen > 0) {
       memmove(buffer, buffer + readfromfile - buflen, buflen);
     }
-    fgetpos(ifile, &pos);
-    uint64_t position;
-    FPOS_TO_VAR(pos, uint64_t, position);
-    fprintf(stdout, "file pos %llu\n", position);
+    pos = ftello(ifile);
+    fprintf(stdout, "file pos %llu\n", pos);
     readfromfile = buflen + fread(buffer + buflen, 1, BUFFER_SIZE - buflen, ifile);
     buflen = readfromfile;
     ptr = buffer;

File Added: pkgsrc/multimedia/libmp4v2/patches/Attic/patch-ar
$NetBSD: patch-ar,v 1.1 2012/02/24 18:36:48 christos Exp $

--- lib/mpeg2t/test.cpp.orig	2005-04-19 17:50:48.000000000 -0400
+++ lib/mpeg2t/test.cpp	2012-02-24 13:06:28.000000000 -0500
@@ -100,7 +100,7 @@
   mpeg2t_pid_t *pidptr;
   int64_t start_offset = 0;
   bool verbose = false;
-  fpos_t pos;
+  u_int64_t pos;
   const char *ProgName = argv[0];
   const char *usage = "";
   //  int lastcc, ccset;
@@ -184,13 +184,11 @@
       printf("buflen is %d\n", buflen);
       memmove(buffer, buffer + readfromfile - buflen, buflen);
     }
-    fgetpos(ifile, &pos);
-    uint64_t position;
-    FPOS_TO_VAR(pos, uint64_t, position);
-    fprintf(stdout, "file pos 0x%llx %s\n", position - buflen,
-	(position - buflen) % 188 == 0 ? "" : "no mult");
+    pos = ftello(ifile);
+    fprintf(stdout, "file pos 0x%llx %s\n", pos - buflen,
+	(pos - buflen) % 188 == 0 ? "" : "no mult");
 
-    if (position - buflen == 0x11a0) {
+    if (pos - buflen == 0x11a0) {
       printf("here\n");
     }
     readfromfile = buflen + fread(buffer + buflen, 1, BUFFER_SIZE - buflen, ifile);

File Added: pkgsrc/multimedia/libmp4v2/patches/Attic/patch-as
$NetBSD: patch-as,v 1.1 2012/02/24 18:36:48 christos Exp $

--- player/plugin/audio/mad/mp3_file.cpp.orig	2004-12-22 14:47:50.000000000 -0500
+++ player/plugin/audio/mad/mp3_file.cpp	2012-02-24 13:07:19.000000000 -0500
@@ -384,9 +384,7 @@
   mp3->m_framecount = fpos->frames;
   mp3->m_buffer_on = 0;
   mp3->m_buffer_size = 0;
-  fpos_t pos;
-  VAR_TO_FPOS(pos, fpos->file_position);
-  fsetpos(mp3->m_ifile, &pos);
+  fseeko(mp3->m_ifile, &fpos->file_position, SEEK_SET);
   return 0;
 }
   

File Added: pkgsrc/multimedia/libmp4v2/patches/Attic/patch-at
$NetBSD: patch-at,v 1.1 2012/02/24 18:36:49 christos Exp $

--- player/plugin/video/xvid/xvid_file.cpp.orig	2005-02-25 19:10:54.000000000 -0500
+++ player/plugin/video/xvid/xvid_file.cpp	2012-02-24 13:07:41.000000000 -0500
@@ -395,9 +395,7 @@
   xvid->m_buffer_on = 0;
   xvid->m_buffer_size = 0;
 
-  fpos_t pos;
-  VAR_TO_FPOS(pos, fpos->file_position);
-  fsetpos(xvid->m_ifile, &pos);
+  fseeko(xvid->m_ifile, fpos->file_position, SEEK_SET);
 
   xvid_reset_buffer(xvid);
   return 0;

File Added: pkgsrc/multimedia/libmp4v2/patches/Attic/patch-au
$NetBSD: patch-au,v 1.1 2012/02/24 18:36:49 christos Exp $

--- player/src/codec/mp3/mp3_file.cpp.orig	2006-04-17 15:03:50.000000000 -0400
+++ player/src/codec/mp3/mp3_file.cpp	2012-02-24 13:07:57.000000000 -0500
@@ -424,9 +424,7 @@
   mp3->m_framecount = fpos->frames;
   mp3->m_buffer_on = 0;
   mp3->m_buffer_size = 0;
-  fpos_t pos;
-  VAR_TO_FPOS(pos, fpos->file_position);
-  fsetpos(mp3->m_ifile, &pos);
+  fseeko(mp3->m_ifile, fpos->file_position, SEEK_SET);
   return 0;
 }
   

File Added: pkgsrc/multimedia/libmp4v2/patches/Attic/patch-av
$NetBSD: patch-av,v 1.1 2012/02/24 18:36:49 christos Exp $

--- player/src/codec/mpeg4/mpeg4_file.cpp.orig	2005-05-09 17:30:19.000000000 -0400
+++ player/src/codec/mpeg4/mpeg4_file.cpp	2012-02-24 13:08:16.000000000 -0500
@@ -362,9 +362,7 @@
   divx->m_buffer_on = 0;
   divx->m_buffer_size = 0;
 
-  fpos_t pos;
-  VAR_TO_FPOS(pos, fpos->file_position);
-  fsetpos(divx->m_ifile, &pos);
+  fseeko(divx->m_ifile, fpos->file_position, SEEK_SET);
   divx_reset_buffer(divx);
   return 0;
 }