diff --git a/libs/generic/vector.h b/libs/generic/vector.h index 5592fbbb..9818587a 100644 --- a/libs/generic/vector.h +++ b/libs/generic/vector.h @@ -256,7 +256,7 @@ inline TextOutputStreamType& ostream_write( TextOutputStreamType& outputStream, template TextOutputStreamType& ostream_write( TextOutputStreamType& t, const Vector4& v ){ - return t << "[ " << v.x() << " " << v.y() << " " << v.z() << " " << v.w() << " ]"; + return t << "[ " << v.x() << ' ' << v.y() << ' ' << v.z() << ' ' << v.w() << " ]"; } diff --git a/libs/math/matrix.h b/libs/math/matrix.h index 0b95800f..b9e098ed 100644 --- a/libs/math/matrix.h +++ b/libs/math/matrix.h @@ -1167,7 +1167,7 @@ inline void matrix4_pivoted_transform_by_euler_xyz_degrees( Matrix4& self, const template inline TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const Matrix4& m ){ - return ostream << m.x() << " " << m.y() << " " << m.z() << " " << m.t(); + return ostream << m.x() << ' ' << m.y() << ' ' << m.z() << ' ' << m.t(); } #endif diff --git a/tools/quake3/common/cmdlib.cpp b/tools/quake3/common/cmdlib.cpp index 4d2f7e51..d5aa910c 100644 --- a/tools/quake3/common/cmdlib.cpp +++ b/tools/quake3/common/cmdlib.cpp @@ -32,6 +32,8 @@ #include "inout.h" #include "qstringops.h" #include "qpathops.h" +#include "stream/stringstream.h" +#include "stream/textstream.h" #include #include #include @@ -78,33 +80,25 @@ char *ex_argv[MAX_EX_ARGC]; #include "io.h" void ExpandWildcards( int *argc, char ***argv ){ struct _finddata_t fileinfo; - int handle; - int i; - char filename[1024]; - char filepath[1024]; - char *path; ex_argc = 0; - for ( i = 0 ; i < *argc ; i++ ) + for ( int i = 0 ; i < *argc ; i++ ) { - path = ( *argv )[i]; + char *path = ( *argv )[i]; if ( path[0] == '-' || ( !strchr( path, '*' ) && !strchr( path, '?' ) ) ) { ex_argv[ex_argc++] = path; continue; } - handle = _findfirst( path, &fileinfo ); + const int handle = _findfirst( path, &fileinfo ); if ( handle == -1 ) { return; } - ExtractFilePath( path, filepath ); - do { - sprintf( filename, "%s%s", filepath, fileinfo.name ); - ex_argv[ex_argc++] = copystring( filename ); + ex_argv[ex_argc++] = copystring( StringOutputStream( 256 )( PathFilenameless( path ), fileinfo.name ) ); } while ( _findnext( handle, &fileinfo ) != -1 ); _findclose( handle ); diff --git a/tools/quake3/common/qpathops.h b/tools/quake3/common/qpathops.h index ae0dfd9c..735f6226 100644 --- a/tools/quake3/common/qpathops.h +++ b/tools/quake3/common/qpathops.h @@ -85,21 +85,3 @@ inline void FixDOSName( char *src ){ if ( *src == '\\' ) *src = '/'; } - -// file directory with trailing slash -// NOTE: includes the slash, otherwise -// backing to an empty path will be wrong when appending a slash -inline void ExtractFilePath( const char *path, char *dest ){ - strcpyQ( dest, path, path_get_filename_start( path ) - path + 1 ); // +1 for '\0' -} - -// file name w/o extension -inline void ExtractFileBase( const char *path, char *dest ){ - const char* start = path_get_filename_start( path ); - const char* end = path_get_filename_base_end( start ); - strcpyQ( dest, start, end - start + 1 ); // +1 for '\0' -} - -inline void ExtractFileExtension( const char *path, char *dest ){ - strcpy( dest, path_get_extension( path ) ); -} diff --git a/tools/quake3/q3map2/minimap.cpp b/tools/quake3/q3map2/minimap.cpp index c86affb1..9b3cc312 100644 --- a/tools/quake3/q3map2/minimap.cpp +++ b/tools/quake3/q3map2/minimap.cpp @@ -448,9 +448,6 @@ void MergeRelativePath( char *out, const char *absolute, const char *relative ){ int MiniMapBSPMain( Args& args ){ char minimapFilename[1024]; - char basename[1024]; - char path[1024]; - char relativeMinimapFilename[1024]; bool autolevel; float minimapSharpen; float border; @@ -578,14 +575,14 @@ int MiniMapBSPMain( Args& args ){ MiniMapMakeMinsMaxs( mins, maxs, border, keepaspect ); if ( strEmpty( minimapFilename ) ) { - ExtractFileBase( source, basename ); - ExtractFilePath( source, path ); - sprintf( relativeMinimapFilename, g_game->miniMapNameFormat, basename ); - MergeRelativePath( minimapFilename, path, relativeMinimapFilename ); + const CopiedString basename( PathFilename( source ) ); + const CopiedString path( PathFilenameless( source ) ); + char relativeMinimapFilename[1024]; + sprintf( relativeMinimapFilename, g_game->miniMapNameFormat, basename.c_str() ); + MergeRelativePath( minimapFilename, path.c_str(), relativeMinimapFilename ); Sys_Printf( "Output file name automatically set to %s\n", minimapFilename ); } - ExtractFilePath( minimapFilename, path ); - Q_mkdir( path ); + Q_mkdir( CopiedString( PathFilenameless( minimapFilename ) ).c_str() ); if ( minimapSharpen >= 0 ) { minimap.sharpen_centermult = 8 * minimapSharpen + 1;