|
Ninja
|
#include "util.h"#include <assert.h>#include <errno.h>#include <fcntl.h>#include <stdarg.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/stat.h>#include <sys/types.h>#include <unistd.h>#include <sys/time.h>#include <algorithm>#include <vector>#include "edit_distance.h"
Go to the source code of this file.
Functions | |
| void | CanonicalizePath (char *path, size_t *len, uint64_t *slash_bits) |
| void | CanonicalizePath (string *path, uint64_t *slash_bits) |
| void | Error (const char *msg, va_list ap) |
| void | Error (const char *msg,...) |
| Log an error message. More... | |
| void | Fatal (const char *msg,...) |
| Log a fatal message and exit. More... | |
| double | GetLoadAverage () |
| int | GetProcessorCount () |
| void | GetShellEscapedString (const string &input, string *result) |
| void | GetWin32EscapedString (const string &input, string *result) |
| std::string | GetWorkingDirectory () |
| a wrapper for getcwd() More... | |
| void | Info (const char *msg, va_list ap) |
| void | Info (const char *msg,...) |
| Log an informational message. More... | |
| static bool | IsKnownShellSafeCharacter (char ch) |
| static bool | IsKnownWin32SafeCharacter (char ch) |
| bool | islatinalpha (int c) |
| static bool | IsPathSeparator (char c) |
| int | platformAwareUnlink (const char *filename) |
| int | ReadFile (const string &path, string *contents, string *err) |
| void | SetCloseOnExec (int fd) |
| Mark a file descriptor to not be inherited on exec()s. More... | |
| const char * | SpellcheckString (const char *text,...) |
| Like SpellcheckStringV, but takes a NULL-terminated list. More... | |
| const char * | SpellcheckStringV (const string &text, const vector< const char * > &words) |
| static bool | StringNeedsShellEscaping (const string &input) |
| static bool | StringNeedsWin32Escaping (const string &input) |
| string | StripAnsiEscapeCodes (const string &in) |
| bool | Truncate (const string &path, size_t size, string *err) |
| void | Warning (const char *msg, va_list ap) |
| void | Warning (const char *msg,...) |
| Log a warning message. More... | |
| void CanonicalizePath | ( | char * | path, |
| size_t * | len, | ||
| uint64_t * | slash_bits | ||
| ) |
Definition at line 141 of file util.cc.
References IsPathSeparator(), and NINJA_FALLTHROUGH.
| void CanonicalizePath | ( | string * | path, |
| uint64_t * | slash_bits | ||
| ) |
Definition at line 124 of file util.cc.
Referenced by Cleaner::CleanTargets(), Builder::ExtractDeps(), ImplicitDepLoader::LoadDepFile(), main(), IncludesNormalize::Normalize(), CLParser::Parse(), ManifestParser::ParseDefault(), DyndepParser::ParseEdge(), ManifestParser::ParseEdge(), ImplicitDepLoader::ProcessDepfileDeps(), and TEST().
| void Error | ( | const char * | msg, |
| va_list | ap | ||
| ) |
Definition at line 98 of file util.cc.
Referenced by Cleaner::CleanRule(), Cleaner::CleanRules(), Cleaner::CleanTarget(), Cleaner::CleanTargets(), Error(), Cleaner::FileExists(), RealDiskInterface::MakeDir(), DiskInterface::MakeDirs(), Lexer::ReadEvalString(), RealDiskInterface::RemoveFile(), and RealDiskInterface::WriteFile().
| void Error | ( | const char * | msg, |
| ... | |||
| ) |
| void Fatal | ( | const char * | msg, |
| ... | |||
| ) |
Log a fatal message and exit.
Definition at line 67 of file util.cc.
Referenced by CheckNinjaVersion(), ScopedTempDir::Cleanup(), ScopedTempDir::CreateAndEnter(), Builder::ExtractDeps(), StatusPrinter::FormatProgressStatus(), GetWorkingDirectory(), IncludesNormalize::IncludesNormalize(), EdgeEnv::LookupVariable(), main(), MSVCHelperMain(), Subprocess::OnPipeReady(), CLWrapper::Run(), Subprocess::Start(), SubprocessSet::SubprocessSet(), Subprocess::TryFinish(), and SubprocessSet::~SubprocessSet().
| double GetLoadAverage | ( | ) |
Definition at line 981 of file util.cc.
Referenced by RealCommandRunner::CanRunMore().
| int GetProcessorCount | ( | ) |
| void GetShellEscapedString | ( | const string & | input, |
| string * | result | ||
| ) |
Definition at line 353 of file util.cc.
References StringNeedsShellEscaping().
Referenced by InputsCollector::GetInputsAsStrings(), EdgeEnv::MakePathList(), and TEST().
| void GetWin32EscapedString | ( | const string & | input, |
| string * | result | ||
| ) |
Definition at line 380 of file util.cc.
References StringNeedsWin32Escaping().
Referenced by InputsCollector::GetInputsAsStrings(), EdgeEnv::MakePathList(), and TEST().
| std::string GetWorkingDirectory | ( | ) |
| void Info | ( | const char * | msg, |
| va_list | ap | ||
| ) |
| void Info | ( | const char * | msg, |
| ... | |||
| ) |
|
inlinestatic |
Definition at line 312 of file util.cc.
Referenced by StringNeedsShellEscaping().
|
inlinestatic |
Definition at line 329 of file util.cc.
Referenced by StringNeedsWin32Escaping().
| bool islatinalpha | ( | int | c | ) |
Definition at line 566 of file util.cc.
Referenced by StripAnsiEscapeCodes().
|
static |
Definition at line 133 of file util.cc.
Referenced by CanonicalizePath().
| int platformAwareUnlink | ( | const char * | filename | ) |
Definition at line 1025 of file util.cc.
Referenced by DepsLog::Load(), BuildLog::Load(), main(), BuildLog::Recompact(), DepsLog::Recompact(), BuildLog::Restat(), and ScopedFilePath::~ScopedFilePath().
| int ReadFile | ( | const string & | path, |
| string * | contents, | ||
| string * | err | ||
| ) |
Definition at line 415 of file util.cc.
Referenced by main(), MSVCHelperMain(), RealDiskInterface::ReadFile(), and CLWrapper::Run().
| void SetCloseOnExec | ( | int | fd | ) |
Mark a file descriptor to not be inherited on exec()s.
Definition at line 480 of file util.cc.
Referenced by BuildLog::OpenForWriteIfNeeded(), DepsLog::OpenForWriteIfNeeded(), and Subprocess::Start().
| const char* SpellcheckString | ( | const char * | text, |
| ... | |||
| ) |
Like SpellcheckStringV, but takes a NULL-terminated list.
Definition at line 517 of file util.cc.
References SpellcheckStringV().
| const char* SpellcheckStringV | ( | const string & | text, |
| const vector< const char * > & | words | ||
| ) |
Definition at line 498 of file util.cc.
References EditDistance().
Referenced by SpellcheckString().
|
inlinestatic |
Definition at line 339 of file util.cc.
References IsKnownShellSafeCharacter().
Referenced by GetShellEscapedString().
|
inlinestatic |
Definition at line 346 of file util.cc.
References IsKnownWin32SafeCharacter().
Referenced by GetWin32EscapedString().
| string StripAnsiEscapeCodes | ( | const string & | in | ) |
Definition at line 571 of file util.cc.
References islatinalpha().
Referenced by StatusPrinter::BuildEdgeFinished(), and TEST().
| bool Truncate | ( | const string & | path, |
| size_t | size, | ||
| string * | err | ||
| ) |
Definition at line 1007 of file util.cc.
Referenced by DepsLog::Load().
| void Warning | ( | const char * | msg, |
| va_list | ap | ||
| ) |
Definition at line 85 of file util.cc.
Referenced by GraphViz::AddTarget(), CheckNinjaVersion(), ManifestParser::ParseEdge(), and Warning().