]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Merge remote-tracking branch 'github/master'
authorRudolf Polzer <divverent@alientrap.org>
Tue, 27 Mar 2012 10:11:37 +0000 (12:11 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Tue, 27 Mar 2012 10:11:37 +0000 (12:11 +0200)
Conflicts:
.gitignore
config.py
libs/synapse/synapse.cpp
plugins/imagehl/lbmlib.cpp
plugins/surface_heretic2/surfacedialog.cpp
plugins/surface_ufoai/surfacedialog.cpp
radiant/brushscript.cpp
radiant/main.cpp
radiant/preferences.cpp
tools/quake3/common/cmdlib.c
tools/quake3/common/cmdlib.h
tools/quake3/q3map2/path_init.c
windows_compile_guide/index.html

contrib/bobtoolz/DBrush.cpp
libs/splines/splines.cpp
libs/splines/util_str.cpp
tools/quake3/common/cmdlib.c
tools/quake3/common/cmdlib.h
tools/quake3/common/inout.c
tools/quake3/q3map2/main.c
tools/quake3/q3map2/path_init.c
tools/quake3/q3map2/q3map2.h

index 7c24cd0fa4ff3f25be30322c26f2257612ba3468..4a2b9c097969c4fa9766ab0ffd3cda41d5b211b5 100644 (file)
@@ -708,7 +708,7 @@ void DBrush::SaveToFile( FILE *pFile ){
                                 ( *pp )->texInfo.m_texdef.scale[0], ( *pp )->texInfo.m_texdef.scale[0],
                                 ( *pp )->texInfo.m_texdef.rotate );
 
-               fprintf( pFile, buffer );
+               fprintf( pFile, "%s", buffer );
        }
 
        fprintf( pFile, "}\n" );
index 42c3493958744bf3ab89b578e4be6dbcdfcf786a..05cb3bf972c09d5b6723be51710b0c088f9fac5a 100644 (file)
@@ -393,7 +393,6 @@ void idSplineList::setSelectedPoint( idVec3 *p ) {
 
 const idVec3 *idSplineList::getPosition( long t ) {
        static idVec3 interpolatedPos;
-       static long lastTime = -1;
 
        int count = splineTime.Num();
        if ( count == 0 ) {
@@ -644,7 +643,6 @@ bool idCameraDef::waitEvent( int index ) {
 
 void idCameraDef::buildCamera() {
        int i;
-       int lastSwitch = 0;
        idList<float> waits;
        idList<int> targets;
 
@@ -653,7 +651,6 @@ void idCameraDef::buildCamera() {
        // we have a base time layout for the path and the target path
        // now we need to layer on any wait or speed changes
        for ( i = 0; i < events.Num(); i++ ) {
-               idCameraEvent *ev = events[i];
                events[i]->setTriggered( false );
                switch ( events[i]->getType() ) {
                case idCameraEvent::EVENT_TARGET: {
@@ -864,7 +861,8 @@ void idCameraDef::parse( const char *( *text )  ) {
 bool idCameraDef::load( const char *filename ) {
        char *buf;
        const char *buf_p;
-       int length = FS_ReadFile( filename, (void **)&buf );
+
+       FS_ReadFile( filename, (void **)&buf );
        if ( !buf ) {
                return false;
        }
@@ -1363,7 +1361,6 @@ void idSplinePosition::write( fileHandle_t file, const char *p ) {
 }
 
 void idCameraDef::addTarget( const char *name, idCameraPosition::positionType type ) {
-       const char *text = ( name == NULL ) ? va( "target0%d", numTargets() + 1 ) : name;
        idCameraPosition *pos = newFromType( type );
        if ( pos ) {
                pos->setName( name );
index 8ac9dea3a8f5a80781f18ff1013898304dcbbe73..62fdaedc50f6f5905beb1b22977841568ab7d0bb 100644 (file)
@@ -487,9 +487,6 @@ void TestStringClass
        i = a.length();                 // i == 0
        i = c.length();                 // i == 4
 
-       const char *s1 = a.c_str(); // s1 == "\0"
-       const char *s2 = c.c_str(); // s2 == "test\0"
-
        t = new idStr();                        // t->len == 0, t->data == "\0"
        delete t;                           // t == ?
 
index 5164001c04fae612b26de2758328c07e01fbfb03..41fd1ca140c7b15389c706e447d76e200379b14c 100644 (file)
@@ -244,7 +244,10 @@ char *ExpandArg( const char *path ){
 
 char *ExpandPath( const char *path ){
        static char full[1024];
-       if ( !*qdir || path[0] == '/' || path[0] == '\\' || path[1] == ':' ) {
+       if ( !qdir ) {
+               Error( "ExpandPath called without qdir set" );
+       }
+       if ( path[0] == '/' || path[0] == '\\' || path[1] == ':' ) {
                strcpy( full, path );
                return full;
        }
@@ -254,7 +257,7 @@ char *ExpandPath( const char *path ){
 
 char *ExpandGamePath( const char *path ){
        static char full[1024];
-       if ( !*gamedir ) {
+       if ( !gamedir[0] ) {
                Error( "ExpandGamePath called without gamedir set" );
        }
        if ( path[0] == '/' || path[0] == '\\' || path[1] == ':' ) {
index 3c9b5a543d07c72373103f50d076855fb61b19d6..f6f5e4d17106108c173a13e8e15cd53e32fb3e9d 100644 (file)
@@ -56,7 +56,7 @@
 #ifdef PATH_MAX
 #define MAX_OS_PATH     PATH_MAX
 #else
-#define MAX_OS_PATH     1024
+#define MAX_OS_PATH     4096
 #endif
 #define MEM_BLOCKSIZE 4096
 
index 6920995fcb8d8838bcfecd6272d60a861155ed70..2c1758a76b08f35a9f96675eb20fdc320fe28e45 100644 (file)
@@ -43,6 +43,7 @@
 #include "libxml/tree.h"
 
 // utf8 conversion
+#include <glib.h>
 #include <glib/gconvert.h>
 #include <glib/gmem.h>
 
index b53a6973c56c9afcf87f7fac53fa90cc386765be..76591a2ad29391bfd6b54cf43b17b912ace87f9a 100644 (file)
@@ -48,6 +48,38 @@ vec_t Random( void ){
 }
 
 
+char *Q_strncpyz( char *dst, const char *src, size_t len ) {
+       if ( len == 0 ) {
+               abort();
+       }
+
+       strncpy( dst, src, len );
+       dst[ len - 1 ] = '\0';
+       return dst;
+}
+
+
+char *Q_strcat( char *dst, size_t dlen, const char *src ) {
+       size_t n = strlen( dst  );
+
+       if ( n > dlen ) {
+               abort(); /* buffer overflow */
+       }
+
+       return Q_strncpyz( dst + n, src, dlen - n );
+}
+
+
+char *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen ) {
+       size_t n = strlen( dst );
+
+       if ( n > dlen ) {
+               abort(); /* buffer overflow */
+       }
+
+       return Q_strncpyz( dst + n, src, MIN( slen, dlen - n ) );
+}
+
 
 /*
    ExitQ3Map()
index 2591c5bf45b54ba9e7467bd43a42e9f9f139ae28..07ebc31b1e154dc2ade01a871560ad49a3b1635a 100644 (file)
@@ -66,26 +66,21 @@ char *LokiGetHomeDir( void ){
        #ifndef Q_UNIX
        return NULL;
        #else
+       static char     buf[ 4096 ];
+       struct passwd   pw, *pwp;
        char            *home;
-       uid_t id;
-       struct passwd   *pwd;
        static char homeBuf[MAX_OS_PATH];
 
 
        /* get the home environment variable */
        home = getenv( "HOME" );
-       if ( home == NULL ) {
-               /* do some more digging */
-               id = getuid();
-               setpwent();
-               while ( ( pwd = getpwent() ) != NULL )
-               {
-                       if ( pwd->pw_uid == id ) {
-                               home = pwd->pw_dir;
-                               break;
-                       }
+
+       /* look up home dir in password database */
+       if(!home)
+       {
+               if ( getpwuid_r( getuid(), &pw, buf, sizeof( buf ), &pwp ) == 0 ) {
+                       return pw.pw_dir;
                }
-               endpwent();
        }
 
        snprintf( homeBuf, sizeof( homeBuf ), "%s/.", home );
@@ -130,21 +125,16 @@ void LokiInitPaths( char *argv0 ){
        qboolean found;
 
 
+       path = getenv( "PATH" );
+
        /* do some path divining */
-       strcpy( temp, argv0 );
-       if ( strrchr( argv0, '/' ) ) {
+       Q_strncpyz( temp, argv0, sizeof( temp ) );
+       if ( strrchr( temp, '/' ) ) {
                argv0 = strrchr( argv0, '/' ) + 1;
        }
-       else
-       {
-               /* get path environment variable */
-               path = getenv( "PATH" );
-
-               /* minor setup */
-               last = last0;
-               last[ 0 ] = path[ 0 ];
-               last[ 1 ] = '\0';
+       else if ( path ) {
                found = qfalse;
+               last = path;
 
                /* go through each : segment of path */
                while ( last[ 0 ] != '\0' && found == qfalse )
@@ -160,17 +150,17 @@ void LokiInitPaths( char *argv0 ){
 
                        /* found home dir candidate */
                        if ( *path == '~' ) {
-                               strcpy( temp, home );
+                               Q_strncpyz( temp, home, sizeof( temp ) );
                                path++;
                        }
 
                        /* concatenate */
                        if ( last > ( path + 1 ) ) {
-                               strncat( temp, path, ( last - path ) );
-                               strcat( temp, "/" );
+                               Q_strncat( temp, sizeof( temp ), path, ( last - path ) );
+                               Q_strcat( temp, sizeof( temp ), "/" );
                        }
-                       strcat( temp, "./" );
-                       strcat( temp, argv0 );
+                       Q_strcat( temp, sizeof( temp ), "./" );
+                       Q_strcat( temp, sizeof( temp ), argv0 );
 
                        /* verify the path */
                        if ( access( temp, X_OK ) == 0 ) {
index 935d1c7f078baa9ff936670d85510cea5fe584b2..bbb3e76e73518d27b8bc12ef7a42ca46f51b2188 100644 (file)
@@ -85,6 +85,8 @@
 #include "md4.h"
 #include <stdlib.h>
 
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
 
 
 /* -------------------------------------------------------------------------------
@@ -1512,6 +1514,9 @@ surfaceInfo_t;
 
 /* main.c */
 vec_t                       Random( void );
+char                        *Q_strncpyz( char *dst, const char *src, size_t len );
+char                        *Q_strcat( char *dst, size_t dlen, const char *src );
+char                        *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen );
 int                         BSPInfo( int count, char **fileNames );
 int                         ScaleBSPMain( int argc, char **argv );
 int                         ConvertMain( int argc, char **argv );