OpenTTD: src/depend/depend.cpp File Reference

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
depend.cpp File Reference

Custom implementation of Makedepend. More...

`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <ctype.h>`
`#include <limits.h>`
`#include <unistd.h>`
`#include <map>`
`#include <set>`
`#include <stack>`
`#include <cassert>`

Go to the source code of this file.

## Data Structures
struct | StringCompare
| Comparator for strings. More...
class | File
| Helper class to read a file. More...
class | Lexer
| Lexer of a file. More...

## Macros
#define | lengthof(x) (sizeof(x) / sizeof(x[0]))
| Return the length of an fixed size array.
#define | lastof(x) (&x[lengthof(x) - 1])
| Get the last element of an fixed size array.
#define | PATH_MAX 260
| The maximum length of paths, if we don't know it.

## Typedefs
typedef std::set< const char *, StringCompare > | StringSet
| Set of C-style strings.
typedef std::map< const char *, StringSet *, StringCompare > | StringMap
| Mapping of C-style string to a set of C-style strings.
typedef std::pair< const char *, StringSet * > | StringMapItem
| Pair of C-style string and a set of C-style strings.
typedef std::map< const char *, Token, StringCompare > | KeywordList
| Mapping from a C-style keyword representation to a Token.

## Enumerations
enum | Token { TOKEN_UNKNOWN, TOKEN_END, TOKEN_EOL, TOKEN_SHARP, TOKEN_LOCAL, TOKEN_GLOBAL, TOKEN_IDENTIFIER, TOKEN_DEFINE, TOKEN_IF, TOKEN_IFDEF, TOKEN_IFNDEF, TOKEN_ELIF, TOKEN_ELSE, TOKEN_ENDIF, TOKEN_UNDEF, TOKEN_OR, TOKEN_AND, TOKEN_DEFINED, TOKEN_OPEN, TOKEN_CLOSE, TOKEN_NOT, TOKEN_ZERO, TOKEN_INCLUDE }
| A token returned by the tokenizer. More...
enum | Ignore { NOT_IGNORE, IGNORE_UNTIL_ELSE, IGNORE_UNTIL_ENDIF }
| Enumerator to tell how long to ignore 'stuff'. More...

## Functions
char * | strecpy (char *dst, const char *src, const char *last)
| Copies characters from one buffer to another.
static char * | strecat (char *dst, const char *src, const char *last)
| Appends characters from one string to another.
static void | free (const void *ptr)
| Version of the standard free that accepts const pointers.
const char * | GeneratePath (const char *dirname, const char *filename, bool local)
| Generate a path from a directory name and a relative filename.
bool | ExpressionDefined (Lexer *lexer, StringSet *defines, bool verbose)
| Try to parse a 'defined(expr)' expression.
bool | ExpressionOr (Lexer *lexer, StringSet *defines, bool verbose)
| Try to parse a 'expr || expr' expression.
bool | ExpressionNot (Lexer *lexer, StringSet *defines, bool verbose)
| Try to parse a '!expr' expression.
bool | ExpressionAnd (Lexer *lexer, StringSet *defines, bool verbose)
| Try to parse a 'expr && expr' expression.
void | ScanFile (const char *filename, const char *ext, bool header, bool verbose)
| Scan a file for includes, defines and the lot.
int | main (int argc, char *argv[])
| Entry point.

## Variables
static StringSet | _include_dirs
| Include directory to search in.
static StringMap | _files
| Files that have been parsed/handled with their dependencies.
static StringMap | _headers
| Dependencies of headers.
static StringSet | _defines
| The current 'active' defines.

## Detailed Description

Custom implementation of Makedepend.

We previously used makedepend, but that could not handle the amount of files we have and does not handle conditional includes in a sane manner. This caused many link problems because not enough files were recompiled. This has lead to the development of our own dependency generator. It is meant to be a substitute to the (relatively slow) dependency generation via gcc. It thus helps speeding up compilation. It will also ignore system headers making it less error prone when system headers are moved or renamed.

Definition in file depend.cpp.

## Macro Definition Documentation

#define lastof | ( |  | x | ) | (&x[lengthof(x) - 1])

Get the last element of an fixed size array.

Parameters

  x | The pointer to the first element of the array

Returns
  The pointer to the last element of the array

Definition at line 50 of file depend.cpp.

Referenced by _GenerateWorld(), TarScanner::AddFile(), FiosFileScanner::AddFile(), ScenarioScanner::AddFile(), ScriptInfo::AddLabels(), StringFilter::AddLine(), ScriptInfo::AddSetting(), Subsidy::AwardTo(), BuildContentTypeStringList(), CargoSpecNameSorter(), ChangeWorkingDirectoryToExecutable(), NetworkChatWindow::ChatTabCompletion(), NetworkChatWindow::ChatTabCompletionNextItem(), CheckExternalFiles(), ScriptInfo::CheckMethod(), CloneVehicleName(), ServerNetworkGameSocketHandler::CloseConnection(), CmdFoundTown(), CmdRenamePresident(), Squirrel::CompileError(), CopyFromOldName(), CopyOutDParam(), debug(), debug_print(), DetermineBasePaths(), DeterminePaths(), CrashLogOSX::DisplayCrashDialog(), DoAutosave(), DoLoad(), DoScanWorkingDirectory(), ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(), NetworkContentListWindow::DrawDetails(), DrawNewsString(), DrawRoadVehDetails(), DrawString(), DrawStringMultiLine(), CheatWindow::DrawWidget(), DriverFactoryBase::DriverFactoryBase(), AIInfo::DummyConstructor(), EngineNameSorter(), error(), Squirrel::ErrorPrintFunc(), ErrorUnknownCallbackResult(), ExtractTar(), CompanyNewsInformation::FillData(), GameScannerInfo::FindInfo(), AIScannerInfo::FindInfo(), FileList::FindItem(), GameScannerLibrary::FindLibrary(), AIScannerLibrary::FindLibrary(), FioCreateDirectory(), FioFOpenFile(), FiosDelete(), FiosGetFileList(), FiosGetHeightmapList(), FiosGetScenarioList(), FiosMakeHeightmapName(), FormatString(), GamelogPrint(), GamelogRevision(), GenerateCompanyName(), GenerateCompanyPasswordHash(), GeneratePath(), GeneratePresidentName(), NetworkAddress::GetAddressAsString(), GetCargoSuffix(), GetDebugString(), GetFileTitle(), GetFullFilename(), GetKeyboardLayout(), GetLanguageList(), GetSavegameFormat(), GetSaveLoadErrorString(), GetStringBoundingBox(), GetStringHeight(), GetStringLineCount(), GetTextfile(), grfmsg(), VehicleGroupWindow::GroupNameSorter(), FileStringReader::HandlePragma(), HandleSavegameLoadCrash(), HelpDialogFunc(), IConsoleAliasExec(), IConsoleGetSetting(), IConsoleListSettings(), IConsolePrintF(), IndustryDirectoryWindow::IndustryNameSorter(), IndustryTypeNameSorter(), IniSaveSettings(), InitializeLanguagePacks(), InitializeMusic(), Textbuf::InsertClipboard(), IsGoodGRFConfigList(), IsSameScript(), LanguagePackHeader::IsValid(), KeycodeToString(), ScriptInstance::LoadCompatibilityScripts(), LoadFromHighScore(), LoadTranslations(), main(), CrashLog::MakeCrashLog(), CrashLogOSX::MakeCrashLog(), MakePNGImage(), MakeScreenshot(), MakeScreenshotName(), MidiSendCommand(), DropDownListStringItem::NatSortFunc(), NetworkAddChatMessage(), NetworkAddress::NetworkAddress(), NetworkFindBroadcastIPsInternal(), NetworkFindName(), NetworkGameListHandleDelayedInsert(), NetworkHandlePauseChange(), NetworkSendCommand(), NetworkServerChangeClientName(), NetworkServerSendChat(), NetworkServerSetCompanyPassword(), NetworkUDPQueryServer(), NetworkUpdateClientName(), NetworkGameWindow::OnClick(), NetworkGameWindow::OnEditboxChanged(), NetworkStartServerWindow::OnEditboxChanged(), AIDebugWindow::OnEditboxChanged(), LandInfoWindow::OnInit(), NetworkStartServerWindow::OnQueryTextFinished(), CustomCurrencyWindow::OnQueryTextFinished(), ClientNetworkContentSocketHandler::OnReceiveData(), DepotWindow::OnRightClick(), SaveLoadWindow::OnTimeout(), NetworkContentListWindow::OpenExternalSearch(), openttd_main(), OutputContentState(), StringReader::ParseFile(), MusicDriver_Win32::PlaySong(), MusicDriver_ExtMidi::PlaySong(), Squirrel::PrintFunc(), PrintGrfInfo(), ReadLanguagePack(), ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(), ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(), ServerNetworkUDPSocketHandler::Receive_CLIENT_GET_NEWGRFS(), ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(), ServerNetworkGameSocketHandler::Receive_CLIENT_MAP_OK(), ServerNetworkGameSocketHandler::Receive_CLIENT_QUIT(), ServerNetworkGameSocketHandler::Receive_CLIENT_SET_NAME(), ClientNetworkGameSocketHandler::Receive_SERVER_CHAT(), ClientNetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS(), ClientNetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO(), ClientNetworkUDPSocketHandler::Receive_SERVER_RESPONSE(), ReconsiderGameScriptLanguage(), StoryBookWindow::RefreshSelectedPage(), ScriptScanner::RegisterScript(), SquirrelStd::require(), NetworkAddress::Resolve(), Squirrel::RunError(), SaveHighScoreValue(), SaveHighScoreValueNetwork(), SaveKeycodes(), IniFile::SaveToDisk(), SaveVersionInConfig(), FileScanner::Scan(), ScanFile(), ScanPath(), Script_CreateDummy(), Script_CreateDummyInfo(), DriverFactoryBase::SelectDriverImpl(), ServerNetworkGameSocketHandler::SendCompanyInfo(), ServerNetworkAdminSocketHandler::SendCompanyInfo(), ServerNetworkAdminSocketHandler::SendCompanyUpdate(), ServerNetworkAdminSocketHandler::SendError(), ServerNetworkGameSocketHandler::SendError(), SetFallbackFont(), TextfileWindow::SetFontNames(), FileToSaveLoad::SetName(), ScriptConfig::SettingsToString(), FileToSaveLoad::SetTitle(), ShowErrorMessage(), ShowHelp(), ShowInfoF(), ShowMissingContentWindow(), ShowNewGrfVehicleError(), SignList::SignNameFilter(), SignList::SignNameSorter(), StateGameLoop(), CompanyStationsWindow::StationNameSorter(), str_fmt(), TownDirectoryWindow::TownNameSorter(), TranslateGRFStrings(), ScanProgressWindow::UpdateNewGRFScanStatus(), ViewportSign::UpdatePosition(), usererror(), VehicleNameSorter(), VerifyTownName(), and DriverFactoryBase::~DriverFactoryBase().

#define lengthof | ( |  | x | ) | (sizeof(x) / sizeof(x[0]))

Return the length of an fixed size array.

Unlike sizeof this function returns the number of elements of the given type.

Parameters

  x | The pointer to the first element of the array

Returns
  The number of elements

Definition at line 42 of file depend.cpp.

Referenced by AddGenericCallback(), AddGRFString(), AddNewsItem(), AfterLoadGame(), NWidgetServerListHeader::AssignSizePosition(), BuildLandLegend(), BuildLinkStatsLegend(), CalcHeightdiff(), CanCargoServiceIndustry(), ChangeGRFNumUsedParams(), ChangeGRFParamMask(), ChangeIndustryProduction(), NetworkChatWindow::ChatTabCompletion(), AyStar::CheckTile(), CmdChangeCompanySetting(), CmdDoTownAction(), CmdFoundTown(), CmdRemoveRoadStop(), CMSAMine(), IndustryCargoesWindow::ComputeCargoDisplay(), VehicleGroupWindow::ComputeGroupInfoSize(), IndustryCargoesWindow::ComputeIndustryDisplay(), CargoesRow::ConnectIndustryAccepted(), CargoesRow::ConnectIndustryProduced(), ScriptInfo::Constructor(), CopyFile(), ErrorMessageData::CopyOutDParams(), GRFConfig::CopyParams(), IndustryCargoesWindow::CountMatchingAcceptingIndustries(), IndustryCargoesWindow::CountMatchingProducingIndustries(), DeliverGoodsToIndustry(), DeterminePaths(), DoCommandPInternal(), DoCreateNewIndustry(), LinkGraphOverlay::DrawContent(), IndustryViewWindow::DrawInfo(), DrawNewsString(), CheatWindow::DrawWidget(), ErrmsgWindow::DrawWidget(), NewsWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), AboutWindow::DrawWidget(), CompanyWindow::DrawWidget(), ErrorMessageData::ErrorMessageData(), ExtractTar(), FillNewGRFVehicleCache(), HeaderFileWriter::Finalise(), FindIndustryToDeliver(), FioCloseAll(), FixTTOEngines(), FormatBytes(), FormatString(), FreeTerminal(), FS2OTTD(), GenerateTownNameString(), AirportTileSpec::Get(), CargoSpec::Get(), AirportSpec::Get(), GetAllCargoSuffixes(), GetAmplitude(), CargoSpec::GetArraySize(), GetBridgeSpec(), IndustryDirectoryWindow::GetCargoTransportedPercentsIfValid(), CargoArray::GetCount(), GetCurrentLocale(), GetDistanceFromNearbyHouse(), GetGenericCallbackResult(), GetGRFContainerVersion(), IndustryDirectoryWindow::GetIndustryString(), GetMaskOfTownActions(), BuildTreesWindow::GetMaxTreeSpriteSize(), GetNetworkErrorMsg(), GetNewgrfCurrencyIdConverted(), GetNumberOfIndustries(), GRFFile::GetParam(), GetProductionAroundTiles(), CargoArray::GetSum(), GetTextfile(), AirportSpec::GetWithoutOverride(), GRFConfig::GRFConfig(), GRFFile::GRFFile(), GRFLoadConfig(), HandleIMEComposition(), StringReader::HandlePragma(), HeightMapCurves(), HelpDialogFunc(), IndustryCargoesWindow::HousesCanAccept(), IConsoleCmdExec(), IndustryDirectoryWindow::IndustryProductionSorter(), InitializeScreenshotFormats(), InitializeSpriteSorter(), SpriteFontCache::InitializeUnicodeGlyphMap(), IsCommandAllowedWhilePaused(), SmallSet< Tdir, items >::IsFull(), IsTileForestIndustry(), IsValidCommand(), NWidgetServerListHeader::IsWidgetVisible(), KeycodeToString(), LoadFromHighScore(), LoadIntList(), LoadNewGRF(), LoadOldVehicle(), MakeAustrianTownName(), CargoesRow::MakeCargoLabel(), MakeCatalanTownName(), MakeCzechTownName(), MakeDanishTownName(), MakeDutchTownName(), MakeEnglishAdditionalTownName(), MakeEnglishOriginalTownName(), MakeFinnishTownName(), MakeFrenchTownName(), MakeGermanTownName(), MakeHeightmapScreenshot(), MakeHungarianTownName(), MakeItalianTownName(), MakeNorwegianTownName(), MakePerformanceDetailPanels(), MakePolishTownName(), MakeRomanianTownName(), MakeScreenshotName(), MakeSillyTownName(), MakeSlovakTownName(), MakeSpanishTownName(), MakeSwedishTownName(), MakeSwissTownName(), MakeTurkishTownName(), VideoDriver_Win32::MakeWindow(), NewGRFWindow::NameSorter(), NetworkChatWindow::NetworkChatWindow(), NetworkServerShowStatusToConsole(), NewGRFDisplay(), CheatWindow::OnClick(), IndustryViewWindow::OnClick(), NetworkStartServerWindow::OnClick(), OrdersWindow::OnClick(), SmallMapWindow::OnInit(), HighScoreWindow::OnPaint(), MainWindow::OnPaint(), CompanyWindow::OnPaint(), AboutWindow::OnTick(), OTTD2FS(), OutputContentState(), ParseCode(), SmallMapWindow::RebuildColourIndexIfNecessary(), NetworkHTTPSocketHandler::Receive(), ClientNetworkGameSocketHandler::Receive_SERVER_ERROR(), NetworkGameSocketHandler::ReceiveCommand(), RemapTTOColour(), ResetGenericCallbacks(), ResetObjects(), ResetRailTypes(), LinkGraphSchedule::Run(), RunTileLoop(), SaveHighScoreValue(), SaveHighScoreValueNetwork(), SaveVersionInConfig(), DriverFactoryBase::SelectDriverImpl(), NetworkGameSocketHandler::SendCommand(), ServerNetworkAdminSocketHandler::SendCompanyEconomy(), ServerNetworkAdminSocketHandler::SendCompanyInfo(), NetworkSocketHandler::SendCompanyInformation(), ServerNetworkAdminSocketHandler::SendCompanyUpdate(), SetMouseCursorVehicle(), GRFConfig::SetParameterDefaults(), ErrmsgWindow::SetStringParameters(), QueryWindow::SetStringParameters(), SetupCargoForClimate(), SmallMapWindow::SetZoomLevel(), ShowNewGRFError(), SlCalcConvFileLen(), SlCalcConvMemLen(), MusicDriver_Win32::Start(), StringToContentType(), SwitchNewGRFBlitter(), TriggerIndustryProduction(), UpdateCursorSize(), UpdateIndustryStatistics(), UpdateStationAcceptance(), BuildObjectWindow::UpdateWidgetSize(), ErrmsgWindow::UpdateWidgetSize(), NewGRFParametersWindow::UpdateWidgetSize(), CheatWindow::UpdateWidgetSize(), NewsWindow::UpdateWidgetSize(), BuildIndustryWindow::UpdateWidgetSize(), AboutWindow::UpdateWidgetSize(), OrdersWindow::UpdateWidgetSize(), CompanyLeagueWindow::UpdateWidgetSize(), GameSettingsWindow::UpdateWidgetSize(), VehicleDetailsWindow::UpdateWidgetSize(), CompanyWindow::UpdateWidgetSize(), CommandCost::UseTextRefStack(), VehicleResolverObject::VehicleResolverObject(), ErrorMessageData::~ErrorMessageData(), and LinkGraphSchedule::~LinkGraphSchedule().

#define PATH_MAX 260

The maximum length of paths, if we don't know it.

Definition at line 121 of file depend.cpp.

Referenced by GeneratePath(), main(), and ScanFile().

## Typedef Documentation

typedef std::map<const char*, Token, StringCompare> KeywordList

Mapping from a C-style keyword representation to a Token.

Definition at line 239 of file depend.cpp.

typedef std::map<const char*, StringSet*, StringCompare> StringMap

Mapping of C-style string to a set of C-style strings.

Definition at line 140 of file depend.cpp.

typedef std::pair<const char*, StringSet*> StringMapItem

Pair of C-style string and a set of C-style strings.

Definition at line 142 of file depend.cpp.

typedef std::set<const char*, StringCompare> StringSet

Set of C-style strings.

Definition at line 138 of file depend.cpp.

## Enumeration Type Documentation

enum Ignore

Enumerator to tell how long to ignore 'stuff'.

Enumerator:

  NOT_IGNORE | No ignoring.
  IGNORE_UNTIL_ELSE | Ignore till a #else is reached.
  IGNORE_UNTIL_ENDIF | Ignore till a #endif is reached.

Definition at line 682 of file depend.cpp.

enum Token

A token returned by the tokenizer.

Enumerator:

  TOKEN_UNKNOWN | Unknown token.
  TOKEN_END | End of document.
  TOKEN_EOL | End of line.
  TOKEN_SHARP | # character, usually telling something important comes.
  TOKEN_LOCAL | Read a local include.
  TOKEN_GLOBAL | Read a global include.
  TOKEN_IDENTIFIER | Identifier within the data.
  TOKEN_DEFINE | (#)define in code
  TOKEN_IF | (#)if in code
  TOKEN_IFDEF | (#)ifdef in code
  TOKEN_IFNDEF | (#)ifndef in code
  TOKEN_ELIF | (#)elif in code
  TOKEN_ELSE | (#)else in code
  TOKEN_ENDIF | (#)endif in code
  TOKEN_UNDEF | (#)undef in code
  TOKEN_OR | '||' within `#if` expression
  TOKEN_AND | '&&' within `#if` expression
  TOKEN_DEFINED | 'defined' within `#if` expression
  TOKEN_OPEN | '(' within `#if` expression
  TOKEN_CLOSE | ')' within `#if` expression
  TOKEN_NOT | '!' within `#if` expression
  TOKEN_ZERO | '0' within `#if` expression
  TOKEN_INCLUDE | (#)include in code

Definition at line 212 of file depend.cpp.

## Function Documentation

bool ExpressionAnd | ( | Lexer * | lexer,
|  | StringSet * | defines,
|  | bool | verbose
| ) |  |

Try to parse a 'expr && expr' expression.

Parameters

  lexer | the lexer to get tokens from.
  defines | the set of known defines.
  verbose | whether to give verbose debugging information.

Returns
  the value of the expression.

Definition at line 650 of file depend.cpp.

References ExpressionDefined(), Lexer::GetToken(), Lexer::Lex(), and TOKEN_AND.

Referenced by ExpressionOr().

bool ExpressionDefined | ( | Lexer * | lexer,
|  | StringSet * | defines,
|  | bool | verbose
| ) |  |

Try to parse a 'defined(expr)' expression.

Parameters

  lexer | the lexer to get tokens from.
  defines | the set of known defines.
  verbose | whether to give verbose debugging information.

Returns
  the value of the expression.

Definition at line 620 of file depend.cpp.

References ExpressionNot(), Lexer::GetString(), Lexer::GetToken(), Lexer::Lex(), TOKEN_DEFINED, TOKEN_IDENTIFIER, and TOKEN_OPEN.

Referenced by ExpressionAnd(), and ExpressionNot().

bool ExpressionNot | ( | Lexer * | lexer,
|  | StringSet * | defines,
|  | bool | verbose
| ) |  |

Try to parse a '!expr' expression.

Also parses the '(expr)', '0' and identifiers. Finally it also consumes any unknown tokens.

Parameters

  lexer | the lexer to get tokens from.
  defines | the set of known defines.
  verbose | whether to give verbose debugging information.

Returns
  the value of the expression.

Definition at line 577 of file depend.cpp.

References ExpressionDefined(), ExpressionOr(), Lexer::GetToken(), Lexer::Lex(), TOKEN_IDENTIFIER, TOKEN_NOT, TOKEN_OPEN, TOKEN_UNKNOWN, and TOKEN_ZERO.

Referenced by ExpressionDefined().

bool ExpressionOr | ( | Lexer * | lexer,
|  | StringSet * | defines,
|  | bool | verbose
| ) |  |

Try to parse a 'expr || expr' expression.

Parameters

  lexer | the lexer to get tokens from.
  defines | the set of known defines.
  verbose | whether to give verbose debugging information.

Returns
  the value of the expression.

Definition at line 669 of file depend.cpp.

References ExpressionAnd(), Lexer::GetToken(), Lexer::Lex(), and TOKEN_OR.

Referenced by ExpressionNot(), and ScanFile().

static void free | ( | const void * | ptr | ) |
| inlinestatic

Version of the standard free that accepts const pointers.

Parameters

  ptr | The data to free.

Definition at line 114 of file depend.cpp.

Referenced by ScriptScanner::AddFile(), AddGRFString(), AddGRFTextToList(), AfterLoadGRFs(), AirportChangeInfo(), ReusableBuffer< SpriteLoader::CommonPixel >::Allocate(), AllocateMap(), TileMatrix< uint32, 4 >::AllocateStorage(), SmallMatrix< BaseEdge >::Assign(), AutoFreePtr< T >::Assign(), ScriptConfig::Change(), NetworkChatWindow::ChatTabCompletion(), CheckCaches(), CleanIndustryTileTable(), GroupStatistics::Clear(), BinaryHeap::Clear(), LoadCheckData::Clear(), Hash::Clear(), AutoFreeSmallVector< byte *, 16 >::Clear(), PersistentStorageArray< int32, 16 >::ClearChanges(), ScriptConfig::ClearConfigList(), FreeTypeFontCache::ClearFontCache(), SpriteFontCache::ClearGlyphToSpriteMap(), ClearSnowLine(), ClearTemporaryNewGRFData(), CmdAlterGroup(), CmdRenameCompany(), CmdRenameDepot(), CmdRenameEngine(), CmdRenamePresident(), CmdRenameSign(), CmdRenameStation(), CmdRenameTown(), CmdRenameVehicle(), CmdRenameWaypoint(), CmdSetGoalProgress(), CmdSetGoalText(), CmdSetStoryPageTitle(), CmdTownSetText(), BaseConsist::CopyConsistPropertiesFrom(), ErrorMessageData::CopyOutDParams(), DeallocateSpecFromStation(), DEF_CONSOLE_CMD(), DEFINE_NEWGRF_CLASS_METHOD(), DEFINE_POOL_METHOD(), Hash::Delete(), Hash::DeleteValue(), DetermineBasePaths(), DeterminePaths(), DistributeQueue(), DoScanNewGRFFiles(), Blitter_32bppOptimized::Encode(), FeatureTownName(), FioCloseFile(), FormatString(), BinaryHeap::Free(), CommandQueue::Free(), FreeEngine(), FreeHeightMap(), LangString::FreeTranslation(), GamelogFree(), GamelogGRFUpdate(), GetFontByFaceName(), GetLayouter(), Gunzip(), HeightMapAdjustWaterLevel(), IConsoleHistoryAdd(), IConsolePrint(), IndustriesChangeInfo(), IniLoadSettings(), IniSaveSettings(), InitGRFTownGeneratorNames(), InitializeOldNames(), InputLoop(), IsGoodGRFConfigList(), Lexer::Lex(), IniLoadFile::LoadFromDisk(), LoadHeightmap(), AyStar::Loop(), main(), MakeBMPImage(), MakePCXImage(), MakePNGImage(), NetworkClose(), NetworkExecuteLocalCommandQueue(), NetworkGameListHandleDelayedInsert(), NetworkGameListRemoveItem(), NetworkHandleCommandQueue(), openttd_main(), GRFText::operator delete(), ZeroedMemoryAllocator::operator delete(), ZeroedMemoryAllocator::operator delete[](), Blitter_32bppAnim::PostResize(), ByteBlob::RawFree(), ReadFileToMem(), Lexer::ReadIdentifier(), ReadLanguagePack(), Lexer::ReadString(), ReallocT(), ServerNetworkUDPSocketHandler::Receive_CLIENT_DETAIL_INFO(), ReplaceChain(), SmallVector< RefitOption, 32 >::Reset(), SmallMatrix< BaseEdge >::Reset(), ScriptScanner::Reset(), ResetBridges(), ResetCustomAirports(), ResetCustomHouses(), ResetCustomIndustries(), ResetCustomObjects(), ResetCustomStations(), ResetOldNames(), ScriptConfig::ResetSettings(), SmallMatrix< BaseEdge >::Resize(), ScanFile(), ErrorMessageData::SetDParamStr(), StringFilter::SetFilterTerm(), GameOptionsWindow::SetMediaSet(), SetSettingValue(), IniItem::SetValue(), ShutdownGame(), SlError(), SlString(), StationChangeInfo(), VideoDriver_Dedicated::Stop(), MusicDriver_ExtMidi::Stop(), ScriptConfig::StringToSettings(), ContentInfo::TransferFrom(), UnInitWindowSystem(), UnloadWagonOverrides(), ScanProgressWindow::UpdateNewGRFScanStatus(), UpdateOSKOriginalText(), Xunzip(), ReusableBuffer< SpriteLoader::CommonPixel >::ZeroAllocate(), BaseSet< GraphicsSet, MAX_GFT, true >::~BaseSet(), Case::~Case(), ContentInfo::~ContentInfo(), DriverFactoryBase::~DriverFactoryBase(), ErrorMessageData::~ErrorMessageData(), FallbackParagraphLayout::FallbackVisualRun::~FallbackVisualRun(), File::~File(), FileWriter::~FileWriter(), FixedSizeArray< SubArray, 1024 >::~FixedSizeArray(), FreeTypeFontCache::~FreeTypeFontCache(), FreeUnitIDGenerator::~FreeUnitIDGenerator(), Goal::~Goal(), GRFConfig::~GRFConfig(), HeaderFileWriter::~HeaderFileWriter(), IConsoleLine::~IConsoleLine(), IniGroup::~IniGroup(), IniItem::~IniItem(), IniLoadFile::~IniLoadFile(), LangString::~LangString(), LanguageStrings::~LanguageStrings(), Lexer::~Lexer(), NetworkHTTPContentConnecter::~NetworkHTTPContentConnecter(), NetworkHTTPSocketHandler::~NetworkHTTPSocketHandler(), OverrideManagerBase::~OverrideManagerBase(), Packet::~Packet(), PersistentStorageArray< int32, 16 >::~PersistentStorageArray(), QueryString::~QueryString(), ReusableBuffer< SpriteLoader::CommonPixel >::~ReusableBuffer(), ScanProgressWindow::~ScanProgressWindow(), ScriptConfig::~ScriptConfig(), Sign::~Sign(), StoryPage::~StoryPage(), StoryPageElement::~StoryPageElement(), StringData::~StringData(), StringReader::~StringReader(), Town::~Town(), UnmappedChoiceList::~UnmappedChoiceList(), and Window::~Window().

const char* GeneratePath | ( | const char * | dirname,
|  | const char * | filename,
|  | bool | local
| ) |  |

Generate a path from a directory name and a relative filename.

If the file is not local the include directory names will be used instead of the passed parameter with directory name. If the file is local both will be queried where the parameter takes precedence.

Parameters

  dirname | the directory to look in.
  filename | the file to look for.
  local | whether to look locally (in dirname) for the file.

Returns
  the absolute path, or NULL if the file doesn't exist.

Definition at line 508 of file depend.cpp.

References _include_dirs, lastof, PATH_MAX, strecat(), and strecpy().

Referenced by ScanFile().

int main | ( | int | argc,
|  | char * | argv[]
| ) |  |

Entry point.

Arguably the most common function in all applications.

Parameters

  argc | the number of arguments.
  argv | the actual arguments.

Returns
  return value for the caller to tell we succeed or not.

Definition at line 909 of file depend.cpp.

References _defines, _files, _headers, _include_dirs, free(), lastof, PATH_MAX, ScanFile(), strecat(), and strecpy().

Referenced by GetSettingsTree().

void ScanFile | ( | const char * | filename,
|  | const char * | ext,
|  | bool | header,
|  | bool | verbose
| ) |  |

Scan a file for includes, defines and the lot.

Parameters

  filename | the name of the file to scan.
  ext | the extension of the filename.
  header | whether the file is a header or not.
  verbose | whether to give verbose debugging information.

Definition at line 695 of file depend.cpp.

References _defines, _files, _headers, ExpressionOr(), free(), GeneratePath(), File::GetDirname(), Lexer::GetString(), Lexer::GetToken(), IGNORE_UNTIL_ELSE, IGNORE_UNTIL_ENDIF, lastof, Lexer::Lex(), NOT_IGNORE, PATH_MAX, strecat(), strecpy(), TOKEN_DEFINE, TOKEN_ELIF, TOKEN_ELSE, TOKEN_END, TOKEN_ENDIF, TOKEN_EOL, TOKEN_GLOBAL, TOKEN_IDENTIFIER, TOKEN_IF, TOKEN_IFDEF, TOKEN_IFNDEF, TOKEN_INCLUDE, TOKEN_LOCAL, TOKEN_SHARP, and TOKEN_UNDEF.

Referenced by main().

static char* strecat | ( | char * | dst,
|  | const char * | src,
|  | const char * | last
| ) |  |
| static

Appends characters from one string to another.

Appends the source string to the destination string with respect of the terminating null-character and and the last pointer to the last element in the destination buffer. If the last pointer is set to NULL no boundary check is performed.

Note
  usage: strecat(dst, src, lastof(dst));
  lastof() applies only to fixed size arrays

Parameters

  dst | The buffer containing the target string
  src | The buffer containing the string to append
  last | The pointer to the last element of the destination buffer

Returns
  The pointer to the terminating null-character in the destination buffer

Definition at line 99 of file depend.cpp.

References strecpy().

Referenced by TarScanner::AddFile(), BuildWithFullPath(), CloneVehicleName(), DoAutosave(), DrawRoadVehDetails(), FiosBrowseTo(), FormatString(), GeneratePath(), GetDebugString(), GetFileTitle(), GetFullFilename(), KeycodeToString(), ScriptInstance::LoadCompatibilityScripts(), main(), Squirrel::PrintFunc(), ClientNetworkUDPSocketHandler::Receive_SERVER_RESPONSE(), SquirrelStd::require(), SaveKeycodes(), IniFile::SaveToDisk(), ScanFile(), ServerNetworkGameSocketHandler::SendCompanyInfo(), and ScriptConfig::SettingsToString().

char* strecpy | ( | char * | dst,
|  | const char * | src,
|  | const char * | last
| ) |  |

Copies characters from one buffer to another.

Copies the source string to the destination buffer with respect of the terminating null-character and the last pointer to the last element in the destination buffer. If the last pointer is set to NULL no boundary check is performed.

Note
  usage: strecpy(dst, src, lastof(dst));
  lastof() applies only to fixed size arrays

Parameters

  dst | The destination buffer
  src | The buffer containing the string to copy
  last | The pointer to the last element of the destination buffer

Returns
  The pointer to the terminating null-character in the destination buffer

Definition at line 68 of file depend.cpp.

Referenced by ScriptScanner::AddFile(), TarScanner::AddFile(), FiosFileScanner::AddFile(), ScenarioScanner::AddFile(), Textbuf::Assign(), BuildWithFullPath(), ChangeWorkingDirectoryToExecutable(), CloneVehicleName(), DriverFactoryBase::DriverFactoryBase(), DumpDebugFacilityNames(), ExtractTar(), GameScannerInfo::FindInfo(), AIScannerInfo::FindInfo(), FioCreateDirectory(), FioFOpenFile(), FiosGetFileList(), FiosMakeHeightmapName(), FormatNumber(), FormatString(), GamelogRevision(), GeneratePath(), GenerateTownNameString(), NetworkAddress::GetAddressAsString(), ServerNetworkGameSocketHandler::GetClientName(), GetClipboardContents(), GetFileTitle(), GetKeyboardLayout(), GetTextfile(), GRFBuildParamList(), FileStringReader::HandlePragma(), IConsoleAliasExec(), IniLoadSettings(), IniSaveSettings(), IsSameScript(), LoadTranslations(), main(), MakeAustrianTownName(), MakeCatalanTownName(), MakeCzechTownName(), MakeDanishTownName(), MakeDutchTownName(), MakeEnglishAdditionalTownName(), MakeEnglishOriginalTownName(), MakeFinnishTownName(), MakeFrenchTownName(), MakeGermanTownName(), MakeHungarianTownName(), MakeItalianTownName(), MakeNorwegianTownName(), MakePNGImage(), MakePolishTownName(), MakeRomanianTownName(), MakeScreenshot(), MakeScreenshotName(), MakeSillyTownName(), MakeSlovakTownName(), MakeSpanishTownName(), MakeSwedishTownName(), MakeSwissTownName(), MakeTurkishTownName(), mkpath(), NetworkAddChatMessage(), NetworkAddress::NetworkAddress(), NetworkFindBroadcastIPsInternal(), NetworkFindName(), NetworkGameListHandleDelayedInsert(), NetworkSendCommand(), NetworkServerChangeClientName(), NetworkServerSetCompanyPassword(), NetworkUDPQueryServer(), NetworkUpdateClientName(), NetworkGameWindow::OnEditboxChanged(), NetworkStartServerWindow::OnEditboxChanged(), AIDebugWindow::OnEditboxChanged(), NetworkStartServerWindow::OnQueryTextFinished(), CustomCurrencyWindow::OnQueryTextFinished(), ClientNetworkContentSocketHandler::OnReceiveData(), NetworkContentListWindow::OpenExternalSearch(), StringReader::ParseFile(), MusicDriver_Win32::PlaySong(), MusicDriver_ExtMidi::PlaySong(), ReadLanguagePack(), StringListReader::ReadLine(), ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(), ServerNetworkUDPSocketHandler::Receive_CLIENT_GET_NEWGRFS(), ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(), ServerNetworkGameSocketHandler::Receive_CLIENT_SET_NAME(), ClientNetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO(), ReconsiderGameScriptLanguage(), SquirrelStd::require(), NetworkAddress::Resolve(), IniFile::SaveToDisk(), FileScanner::Scan(), ScanFile(), Script_CreateDummy(), DriverFactoryBase::SelectDriverImpl(), ServerNetworkGameSocketHandler::SendCompanyInfo(), TextfileWindow::SetFontNames(), FileToSaveLoad::SetName(), SetSettingValue(), FileToSaveLoad::SetTitle(), ShowHelp(), ShowMissingContentWindow(), strecat(), CrashLog::WriteScreenshot(), and DriverFactoryBase::~DriverFactoryBase().

## Variable Documentation

StringSet _defines
| static

The current 'active' defines.

Definition at line 151 of file depend.cpp.

Referenced by main(), and ScanFile().

StringMap _files
| static

Files that have been parsed/handled with their dependencies.

Definition at line 147 of file depend.cpp.

Referenced by main(), and ScanFile().

StringMap _headers
| static

Dependencies of headers.

Definition at line 149 of file depend.cpp.

Referenced by main(), and ScanFile().

StringSet _include_dirs
| static

Include directory to search in.

Definition at line 145 of file depend.cpp.

Referenced by GeneratePath(), and main().