void AddLibraryName( char *name, char priority ) /**********************************************/ { library_list **new_owner; library_list **owner; library_list *lib; int len; for( owner = &HeadLibs; (lib = *owner) != NULL; owner = &lib->next ) { if( lib->libname[0] < priority ) { break; } if( FNAMECMPSTR( lib->libname + 1, name ) == 0 ) { return; } } new_owner = owner; for( ; (lib = *owner) != NULL; owner = &lib->next ) { if( FNAMECMPSTR( lib->libname + 1, name ) == 0 ) { *owner = lib->next; break; } } if( lib == NULL ) { len = strlen( name ); lib = CMemAlloc( offsetof( library_list, libname ) + len + 2 ); memcpy( lib->libname + 1, name, len + 1 ); } lib->libname[0] = priority; lib->next = *new_owner; *new_owner = lib; }
static bool stringIsDifferent( const char *from_pch, const char *curr, unsigned msg ) { if( ! CompFlags.pch_min_check ) { if( FNAMECMPSTR( from_pch, curr ) != 0 ) { pchWarn( msg ); return( true ); } } return( false ); }
static void PrepareModList( void ) /********************************/ { file_list *list; mod_entry *mod; mod_entry *curr; libnamelist *blacklist; mod = Root->mods; for( list = Root->files; list != NULL; list = list->next_file ) { if( strcmp( list->file->name, mod->f.fname ) == 0 ) { SetupModule( &mod, list ); } else if( mod->n.next_mod != NULL ) { if( FNAMECMPSTR( list->file->name, mod->n.next_mod->f.fname ) == 0 ) { mod->modinfo |= MOD_KILL; mod = mod->n.next_mod; SetupModule( &mod, list ); } } if( mod == NULL ) { break; } } while( mod != NULL ) { mod->modinfo |= MOD_KILL; // no match found mod = mod->n.next_mod; } blacklist = CalcLibBlacklist(); mod = LibModules; while( mod != NULL ) { if( mod->f.fname == NULL ) { mod->modinfo |= MOD_KILL; } else if( !(mod->modinfo & MOD_VISITED) ) { list = AddObjLib( mod->f.fname, LIB_PRIORITY_MID ); CheckNewFile( mod, list, 1); CheckBlacklist( list, blacklist ); for( curr = mod->n.next_mod; curr != NULL; curr = curr->n.next_mod){ if( curr->f.fname == mod->f.fname ) { curr->f.source = list; curr->modinfo |= MOD_VISITED; } } mod->f.source = list; } mod->modinfo &= ~MOD_VISITED; mod = mod->n.next_mod; } FreeList( SavedUserLibs ); SavedUserLibs = NULL; }
static libnamelist *CalcLibBlacklist( void ) /*******************************************/ /* figure out if the user has changed any of the specified libraries, and * torch anything after a changed library */ { infilelist *userlibs; libnamelist *oldlibs; userlibs = CachedLibFiles; for( oldlibs = SavedUserLibs; oldlibs != NULL; oldlibs = oldlibs->next ) { if( userlibs == NULL ) return( oldlibs ); if( FNAMECMPSTR( userlibs->name, oldlibs->name ) != 0 ) return( oldlibs ); userlibs = userlibs->next; } return( NULL ); }
infilelist * AllocUniqueFileEntry( char *name, path_entry *path ) /**********************************************************************/ { infilelist * entry; for( entry = CachedLibFiles; entry != NULL; entry = entry->next ) { if( FNAMECMPSTR( entry->name, name ) == 0 ) { return entry; // we found 1 with the same name. } } entry = AllocEntry( name, path ); // didn't find one, so allocate a new 1 if( CachedLibFiles == NULL ) { // add libraries to the end of the CachedLibFiles = entry; // regular cached files list. LinkList( &CachedFiles, entry ); } else { LinkList( &CachedLibFiles, entry ); } return entry; }
static void CheckBlacklist( file_list *list, libnamelist *blacklist ) /*******************************************************************/ { unsigned length; unsigned length_b; unsigned delta; if( list->status & STAT_HAS_CHANGED ) return; length = strlen( list->file->name ); for( ; blacklist != NULL; blacklist = blacklist->next ) { length_b = strlen( blacklist->name ); if( length >= length_b ) { delta = length - length_b; if( FNAMECMPSTR( blacklist->name,list->file->name + delta ) == 0 ) { list->status |= STAT_HAS_CHANGED; return; } } } }
static bool stalePCH( char *include_file ) { time_t stamp; cg_switches test_gen; cg_target_switches test_target; auto char buff1[_MAX_PATH]; auto char buff2[_MAX_PATH]; auto COMP_FLAGS testflags; PCHReadVar( test_gen ); PCHReadVar( test_target ); if( test_gen != GenSwitches || test_target != TargetSwitches ) { pchWarn( WARN_PCH_CONTENTS_OPTIONS ); return( true ); } if( PCHReadUInt() != ErrPCHVersion() ) { pchWarn( WARN_PCH_CONTENTS_HEADER_ERROR ); return( true ); } if( PCHReadUInt() != TYPC_LAST ) { pchWarn( WARN_PCH_CONTENTS_HEADER_ERROR ); return( true ); } if( PCHReadUInt() != sizeof( COMP_FLAGS ) ) { pchWarn( WARN_PCH_CONTENTS_HEADER_ERROR ); return( true ); } PCHReadVar( testflags ); if( checkCompFlags( &testflags ) ) { pchWarn( WARN_PCH_CONTENTS_OPTIONS ); return( true ); } readFileString( buff1 ); if( FNAMECMPSTR( buff1, WholeFName ) == 0 ) { if( CompFlags.pch_debug_info_opt ) { // this source file created the PCH but it is being recompiled // so we have to recreate the PCH along with the debug info pchWarn( WARN_PCH_DEBUG_OPTIMIZE ); return( true ); } } readFileString( buff1 ); include_file = IoSuppFullPath( include_file, buff2, sizeof( buff2 ) ); if( FNAMECMPSTR( buff1, include_file ) != 0 ) { pchWarn( WARN_PCH_CONTENTS_INCFILE ); return( true ); } readFileString( buff1 ); getcwd( buff2, sizeof( buff2 ) ); if( stringIsDifferent( buff1, buff2, WARN_PCH_CONTENTS_CWD ) ) { return( true ); } if( CompFlags.pch_min_check ) { flushUntilNullString( buff2 ); } else { HFileListStart(); for(;;) { HFileListNext( buff1 ); readFileString( buff2 ); if( stringIsDifferent( buff1, buff2, WARN_PCH_CONTENTS_INCLUDE ) ) { return( true ); } if( buff1[0] == '\0' ) break; } } for( ; *readFileString( buff1 ) != '\0'; ) { PCHReadVar( stamp ); if( ! sameStamp( buff1, stamp ) ) { PCHWarn2p( WARN_PCH_CONTENTS_HFILE, buff1 ); return( true ); } } if( ! PCHVerifyMacroCheck() ) { return( true ); } transferCompFlags( &testflags ); return( false ); }