Skip to content

Commit

Permalink
utils: don't tell me to use non-standard functions, use POSIX compati…
Browse files Browse the repository at this point in the history
…ble lseek everywhere
  • Loading branch information
a1batross authored and SNMetamorph committed Sep 14, 2023
1 parent 120c904 commit 7e60804
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion common/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ GNU General Public License for more details.
#define O_BINARY 0
#define O_TEXT 0
#define _mkdir( x ) mkdir( x, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH )
#define tell( a ) lseek(a, 0, SEEK_CUR)
#define LoadLibrary( x ) dlopen( x, RTLD_NOW )
#define GetProcAddress( x, y ) dlsym( x, y )
#define FreeLibrary( x ) dlclose( x )
Expand Down
6 changes: 3 additions & 3 deletions utils/common/bspfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,23 +414,23 @@ void LoadBSPFile( const char *filename )
void AddLump( int lumpnum, void *data, int len )
{
dlump_t *lump = &header->lumps[lumpnum];
lump->fileofs = tell( wadfile );
lump->fileofs = lseek( wadfile, 0, SEEK_CUR );
lump->filelen = len;
SafeWrite( wadfile, data, (len + 3) & ~3 );
}

static void AddExtraLump( int lumpnum, void *data, int len, dextrahdr_t *header )
{
dlump_t* lump = &header->lumps[lumpnum];
lump->fileofs = tell( wadfile );
lump->fileofs = lseek( wadfile, 0, SEEK_CUR );
lump->filelen = len;
SafeWrite( wadfile, data, (len + 3) & ~3 );
}

void AddLumpClipnodes( int lumpnum )
{
dlump_t *lump = &header->lumps[lumpnum];
lump->fileofs = tell( wadfile );
lump->fileofs = lseek( wadfile, 0, SEEK_CUR );

if( g_numclipnodes < MAX_MAP_CLIPNODES )
{
Expand Down
2 changes: 1 addition & 1 deletion utils/common/wadfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ GNU General Public License for more details.
#include "port.h"

#ifndef ALLOW_WADS_IN_PACKS
#define FS_Tell( x ) tell( x )
#define FS_Tell( x ) lseek( x, 0, SEEK_CUR )
#define FS_Seek( x, y, z ) lseek( x, y, z )
#define FS_Read( x, y, z ) read( x, y, z )
#define FS_Write( x, y, z ) write( x, y, z )
Expand Down
2 changes: 1 addition & 1 deletion utils/pxmakewad/lmptex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ bool LMP_CheckForReplace( dlumpinfo_t *find, rgbdata_t *image, int &width, int &
size_t oldpos;
lmp_t test;

oldpos = tell( W_GetHandle( output_wad ) ); // don't forget restore original position
oldpos = lseek( W_GetHandle( output_wad ), 0, SEEK_CUR ); // don't forget restore original position

if( lseek( W_GetHandle( output_wad ), find->filepos, SEEK_SET ) == -1 )
{
Expand Down
2 changes: 1 addition & 1 deletion utils/pxmakewad/miptex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ bool MIP_CheckForReplace( dlumpinfo_t *find, rgbdata_t *image, int &width, int &
size_t oldpos;
mip_t test;

oldpos = tell( W_GetHandle( output_wad ) ); // don't forget restore original position
oldpos = lseek( W_GetHandle( output_wad ), 0, SEEK_CUR ); // don't forget restore original position

if( lseek( W_GetHandle( output_wad ), find->filepos, SEEK_SET ) == -1 )
{
Expand Down

0 comments on commit 7e60804

Please sign in to comment.