[quake3-commits] r2098 - trunk/code/qcommon

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Jul 24 18:12:21 EDT 2011


Author: thilo
Date: 2011-07-24 18:12:21 -0400 (Sun, 24 Jul 2011)
New Revision: 2098

Modified:
   trunk/code/qcommon/files.c
   trunk/code/qcommon/q_shared.c
   trunk/code/qcommon/q_shared.h
Log:
Fix extension name comparison for DLL files


Modified: trunk/code/qcommon/files.c
===================================================================
--- trunk/code/qcommon/files.c	2011-07-24 22:01:50 UTC (rev 2097)
+++ trunk/code/qcommon/files.c	2011-07-24 22:12:21 UTC (rev 2098)
@@ -557,7 +557,7 @@
 		const char *function )
 {
 	// Check if the filename ends with the library extension
-	if( !Q_stricmp( COM_GetExtension( filename ), DLL_EXT ) )
+	if(COM_CompareExtension(filename, DLL_EXT))
 	{
 		Com_Error( ERR_FATAL, "%s: Not allowed to manipulate '%s' due "
 			"to %s extension", function, filename, DLL_EXT );

Modified: trunk/code/qcommon/q_shared.c
===================================================================
--- trunk/code/qcommon/q_shared.c	2011-07-24 22:01:50 UTC (rev 2097)
+++ trunk/code/qcommon/q_shared.c	2011-07-24 22:12:21 UTC (rev 2098)
@@ -82,7 +82,31 @@
 		Q_strncpyz(out, in, destsize);
 }
 
+/*
+============
+COM_CompareExtension
 
+string compare the end of the strings and return qtrue if strings match
+============
+*/
+qboolean COM_CompareExtension(const char *in, const char *ext)
+{
+	int inlen, extlen;
+	
+	inlen = strlen(in);
+	extlen = strlen(ext);
+	
+	if(extlen <= inlen)
+	{
+		in += inlen - extlen;
+		
+		if(!Q_stricmp(in, ext))
+			return qtrue;
+	}
+	
+	return qfalse;
+}
+
 /*
 ==================
 COM_DefaultExtension

Modified: trunk/code/qcommon/q_shared.h
===================================================================
--- trunk/code/qcommon/q_shared.h	2011-07-24 22:01:50 UTC (rev 2097)
+++ trunk/code/qcommon/q_shared.h	2011-07-24 22:12:21 UTC (rev 2098)
@@ -709,6 +709,7 @@
 char	*COM_SkipPath( char *pathname );
 const char	*COM_GetExtension( const char *name );
 void	COM_StripExtension(const char *in, char *out, int destsize);
+qboolean COM_CompareExtension(const char *in, const char *ext);
 void	COM_DefaultExtension( char *path, int maxSize, const char *extension );
 
 void	COM_BeginParseSession( const char *name );



More information about the quake3-commits mailing list