git: 77ed2a8a5a09 - main - games/{gtk,net}radiant: fix getting file length on Unix-like systems

From: Alexey Dokuchaev <danfe_at_FreeBSD.org>
Date: Tue, 14 Feb 2023 06:04:25 UTC
The branch main has been updated by danfe:

URL: https://cgit.FreeBSD.org/ports/commit/?id=77ed2a8a5a0908bc06e9258dda820bf656eb27a0

commit 77ed2a8a5a0908bc06e9258dda820bf656eb27a0
Author:     Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2023-02-14 05:59:28 +0000
Commit:     Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2023-02-14 05:59:28 +0000

    games/{gtk,net}radiant: fix getting file length on Unix-like systems
    
    Decloak Q_filelength() which takes a pointer to FILE, not an integer
    file descriptor, and optimize away superfluous call thereof.
    
    Reported by:    pkg-fallout (clang 15)
---
 .../files/patch-tools_quake3_q3data_md3lib.c       | 24 ++++++++++++++++++++++
 .../files/patch-tools_quake3_q3data_md3lib.c       | 24 ++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/games/gtkradiant/files/patch-tools_quake3_q3data_md3lib.c b/games/gtkradiant/files/patch-tools_quake3_q3data_md3lib.c
new file mode 100644
index 000000000000..bc91176a3ebe
--- /dev/null
+++ b/games/gtkradiant/files/patch-tools_quake3_q3data_md3lib.c
@@ -0,0 +1,24 @@
+--- tools/quake3/q3data/md3lib.c.orig	2006-02-10 22:01:20 UTC
++++ tools/quake3/q3data/md3lib.c
+@@ -25,10 +25,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ #endif
+ #include "md3lib.h"
+ 
+-#if defined (__linux__) || defined (__APPLE__)
+-#define filelength Q_filelength
+-#endif
+-
+ /*
+ ** MD3_ComputeTagFromTri
+ */
+@@ -149,8 +145,8 @@ void MD3_Dump( const char *filename )
+ 		Error( "Unable to open '%s'\n", filename );
+ 	}
+ 
+-	fileSize = filelength( fileno( fp ) );
+-	_buffer = malloc( filelength( fileno( fp ) ) );
++	fileSize = Q_filelength( fp );
++	_buffer = malloc( fileSize );
+ 	fread( _buffer, fileSize, 1, fp );
+ 	fclose( fp );
+ 
diff --git a/games/netradiant/files/patch-tools_quake3_q3data_md3lib.c b/games/netradiant/files/patch-tools_quake3_q3data_md3lib.c
new file mode 100644
index 000000000000..78fead3efc19
--- /dev/null
+++ b/games/netradiant/files/patch-tools_quake3_q3data_md3lib.c
@@ -0,0 +1,24 @@
+--- tools/quake3/q3data/md3lib.c.orig	2015-06-21 12:05:40 UTC
++++ tools/quake3/q3data/md3lib.c
+@@ -25,10 +25,6 @@
+ #endif
+ #include "md3lib.h"
+ 
+-#if defined ( __linux__ ) || defined ( __APPLE__ )
+-#define filelength Q_filelength
+-#endif
+-
+ /*
+ ** MD3_ComputeTagFromTri
+ */
+@@ -149,8 +145,8 @@ void MD3_Dump( const char *filename ){
+ 		Error( "Unable to open '%s'\n", filename );
+ 	}
+ 
+-	fileSize = filelength( fileno( fp ) );
+-	_buffer = malloc( filelength( fileno( fp ) ) );
++	fileSize = Q_filelength( fp );
++	_buffer = malloc( fileSize );
+ 	fread( _buffer, fileSize, 1, fp );
+ 	fclose( fp );
+