diff --git a/bld/rc/rc/c/exeobj.c b/bld/rc/rc/c/exeobj.c index 4014a6542e..9c1785ae89 100644 --- a/bld/rc/rc/c/exeobj.c +++ b/bld/rc/rc/c/exeobj.c @@ -69,8 +69,9 @@ static RcStatus readObjectTable( ExeFileInfo *src ) } static int copyObjectTable( ExeFileInfo *src, ExeFileInfo *dst ) -/***************************************************************/ -/* Copies the object table from src to dst adding one more entry to dst */ +/*************************************************************** + * Copies the object table from src to dst adding one more entry to dst + */ { uint_32 src_offset; /* start of the image pages */ uint_32 dst_offset; @@ -87,15 +88,21 @@ static int copyObjectTable( ExeFileInfo *src, ExeFileInfo *dst ) pe_exe_header *src_pehdr; pe_exe_header *dst_pehdr; - /* check for a resource object in the src exe */ + /* + * check for a resource object in the src exe + */ src_pehdr = src->u.PEInfo.WinHead; src_resource_rva = PE_DIRECTORY( *src_pehdr, PE_TBL_RESOURCE ).rva; dst_num_objects = src_num_objects = src_pehdr->fheader.num_objects; for( obj_num = 0; obj_num < src_num_objects; obj_num++ ) { if( src_resource_rva != 0 && src->u.PEInfo.Objects[obj_num].rva == src_resource_rva ) { - /* there already was a resource object */ + /* + * there already was a resource object + */ if( obj_num + 1 == src_num_objects ) { - /* it is the last object so just ignore it */ + /* + * it is the last object so just ignore it + */ dst_num_objects--; res_offset = src->u.PEInfo.Objects[obj_num].physical_offset + src->u.PEInfo.Objects[obj_num].physical_size; if( res_offset > src->DebugOffset ) { @@ -103,8 +110,9 @@ static int copyObjectTable( ExeFileInfo *src, ExeFileInfo *dst ) } continue; } else { - /* can't ignore it otherwise the rva's in the file will - be off*/ + /* + * can't ignore it otherwise the rva's in the file will be off + */ RcWarning( ERR_OLD_RESOURCE_OBJECT ); } } @@ -129,9 +137,11 @@ static int copyObjectTable( ExeFileInfo *src, ExeFileInfo *dst ) delta_offset = dst_offset - src_offset; if( dst_rva != src_rva ) { - /* This means that all the rva's in all image pages are now wrong. */ - /* Since this case is rare and the user can relink with a higher */ - /* object_align we just print an error messages and quit */ + /* + * This means that all the rva's in all image pages are now wrong. + * Since this case is rare and the user can relink with a higher + * object_align we just print an error messages and quit + */ RcError( ERR_PE_HEADER_SIZE_CHANGE ); return( -1 ); } @@ -149,18 +159,17 @@ static int copyObjectTable( ExeFileInfo *src, ExeFileInfo *dst ) return( dst_num_objects ); } -/* +static RcStatus copyOneObject( FILE *src_fp, pe_object *src_obj, + FILE *dst_fp, pe_object *dst_obj ) +/*************************************************************** + * * copyOneObject * if an error occurs this function MUST return without altering errno + * + * if this an uninitialized object (one for which there is not data in the file) + * then don't copy it */ -static RcStatus copyOneObject( FILE *src_fp, pe_object *src_obj, - FILE *dst_fp, pe_object *dst_obj ) -/***************************************************************/ { - /* - * if this an uninitialized object (one for which there is not - * data in the file) then don't copy it - */ if( (src_obj->flags & PE_OBJ_UNINIT_DATA) && ( src_obj->physical_offset == 0 ) ) { return( RS_OK ); } @@ -213,9 +222,10 @@ bool CopyExeObjects( ExeFileInfo *src, ExeFileInfo *dst ) } /* CopyExeObjects */ uint_32 GetNextObjPhysOffset( PEExeInfo *peinfo ) -/***********************************************/ -/* This routine assumes the num_objects in the header include one for the */ -/* resource object */ +/************************************************ + * This routine assumes the num_objects in the header include one for the + * resource object + */ { uint_32 next_off; pe_object *last_obj; @@ -228,9 +238,10 @@ uint_32 GetNextObjPhysOffset( PEExeInfo *peinfo ) } /* GetNextObjPhysOffset */ pe_va GetNextObjRVA( PEExeInfo *peinfo ) -/**************************************/ -/* This routine assumes the num_objects in the header include one for the */ -/* resource object */ +/*************************************** + * This routine assumes the num_objects in the header include one for the + * resource object + */ { uint_32 next_rva; pe_object *last_obj; @@ -238,8 +249,10 @@ pe_va GetNextObjRVA( PEExeInfo *peinfo ) pehdr = peinfo->WinHead; last_obj = peinfo->Objects + pehdr->fheader.num_objects - 2; -/* This next line should work if the nt loader followed the PE spec but it */ -/* doesn't so we can't use it */ +/* + * This next line should work if the nt loader followed the PE spec but it + * doesn't so we can't use it + */ // next_rva = last_obj->rva + last_obj->virtual_size; next_rva = last_obj->rva + last_obj->physical_size; return( ALIGN_VALUE( next_rva, PE( *pehdr, object_align ) ) ); diff --git a/bld/rc/rc/c/sharedio.c b/bld/rc/rc/c/sharedio.c index 77b3e86693..83f0849daf 100644 --- a/bld/rc/rc/c/sharedio.c +++ b/bld/rc/rc/c/sharedio.c @@ -44,6 +44,7 @@ #if !defined( INSIDE_WLINK ) || defined( _OS2 ) + #define MAX_OPEN_RESFILES 6 typedef struct { @@ -67,7 +68,7 @@ int RCCloseFile( FILE **fp ) return( rc ); } -bool OpenResFiles( ExtraRes *resnames, ResFileInfo **resinfo, bool *allopen, +bool OpenResFiles( ExtraRes *resnames, ResFileInfo **presfiles, bool *allopen, ExeType type, const char *exename ) /**************************************************************************/ { @@ -80,12 +81,12 @@ bool OpenResFiles( ExtraRes *resnames, ResFileInfo **resinfo, bool *allopen, WResTargetOS res_os; *allopen = true; - *resinfo = NULL; + *presfiles = NULL; rescnt = 0; for( ; resnames != NULL; resnames = resnames->next ) { resfile = RESALLOC( sizeof( ResFileInfo ) ); - resfile->next = *resinfo; - *resinfo = resfile; + resfile->next = *presfiles; + *presfiles = resfile; resfile->Dir = WResInitDir(); resfile->name = resnames->name; resfile->fp = ResOpenFileRO( resfile->name ); @@ -112,8 +113,9 @@ bool OpenResFiles( ExtraRes *resnames, ResFileInfo **resinfo, bool *allopen, RCCloseFile( &(resfile->fp) ); *allopen = false; } - - // remove the autodepend resource + /* + * remove the autodepend resource + */ res_name = WResIDFromStr( DEP_LIST_NAME ); res_type = WResIDFromNum( DEP_LIST_TYPE ); WResDelResource( resfile->Dir, res_type, res_name ); @@ -129,8 +131,10 @@ bool OpenResFiles( ExtraRes *resnames, ResFileInfo **resinfo, bool *allopen, } break; case EXE_TYPE_NE_OS2: - // No way to tell MS and IBM resource files apart, and I can't find - // a good way to figure out if this is a Watcom .res file + /* + * No way to tell MS and IBM resource files apart, and I can't find + * a good way to figure out if this is a Watcom .res file + */ if( res_os != WRES_OS_WIN16 && res_os != WRES_OS_OS2 ) { RcError( ERR_NONWIN_RES_TO_WIN_EXE, resfile->name, exename ); goto HANDLE_ERROR; @@ -143,13 +147,15 @@ bool OpenResFiles( ExtraRes *resnames, ResFileInfo **resinfo, bool *allopen, } break; case EXE_TYPE_LX: - // Same problem as with EXE_TYPE_NE_OS2 + /* + * Same problem as with EXE_TYPE_NE_OS2 + */ if( res_os != WRES_OS_OS2 && res_os != WRES_OS_WIN16 ) { RcError( ERR_NONOS2_RES_TO_OS2_EXE, resfile->name, exename ); goto HANDLE_ERROR; } break; - default: // EXE_TYPE_UNKNOWN + default: /* EXE_TYPE_UNKNOWN */ break; } rescnt++; @@ -157,8 +163,8 @@ bool OpenResFiles( ExtraRes *resnames, ResFileInfo **resinfo, bool *allopen, return( true ); HANDLE_ERROR: - CloseResFiles( *resinfo ); - *resinfo = NULL; + CloseResFiles( *presfiles ); + *presfiles = NULL; return( false ); } @@ -325,4 +331,5 @@ void ReportDupResource( WResID *nameid, WResID *typeid, const char *file1, RESFREE( type ); } } + #endif diff --git a/bld/rc/rc/h/sharedio.h b/bld/rc/rc/h/sharedio.h index 218e1ca8f6..d658622a56 100644 --- a/bld/rc/rc/h/sharedio.h +++ b/bld/rc/rc/h/sharedio.h @@ -38,7 +38,7 @@ typedef struct ExtraRes { extern int RCCloseFile( FILE **fp ); extern void ReportDupResource( WResID *nameid, WResID *typeid, const char *file1, const char *file2, bool warn ); -extern bool OpenResFiles( ExtraRes *resnames, ResFileInfo **resinfo, bool *allopen, ExeType type, const char *exename ); +extern bool OpenResFiles( ExtraRes *resnames, ResFileInfo **presfiles, bool *allopen, ExeType type, const char *exename ); extern void CloseResFiles( ResFileInfo *resfiles ); extern void SharedIOInitStatics( void ); extern char *LastWresErrStr( void );