* Use a proper namespace.

* Optimise header file usage a bit.
* Compile the parser as C++.
This commit is contained in:
Eelco Dolstra 2006-09-04 21:06:23 +00:00
parent aab8812732
commit 75068e7d75
61 changed files with 650 additions and 268 deletions

View file

@ -40,6 +40,11 @@ my $initFun = "init";
open HEADER, ">$ARGV[0]";
open IMPL, ">$ARGV[1]";
print HEADER "#ifdef __cplusplus\n";
print HEADER "namespace nix {\n";
print HEADER "#endif\n\n\n";
print IMPL "namespace nix {\n";
while (<STDIN>) {
next if (/^\s*$/);
@ -162,5 +167,10 @@ print IMPL "void $initFun() {\n";
print IMPL "$init";
print IMPL "}\n";
print HEADER "#ifdef __cplusplus\n";
print HEADER "}\n";
print HEADER "#endif\n\n\n";
print IMPL "}\n";
close HEADER;
close IMPL;

View file

@ -2,13 +2,13 @@ pkglib_LTLIBRARIES = libexpr.la
libexpr_la_SOURCES = nixexpr.cc nixexpr.hh parser.cc parser.hh \
eval.cc eval.hh primops.cc \
lexer-tab.c lexer-tab.h parser-tab.c parser-tab.h \
lexer-tab.c lexer-tab.h parser-tab.cc parser-tab.hh \
get-drvs.cc get-drvs.hh \
attr-path.cc attr-path.hh \
expr-to-xml.cc expr-to-xml.hh
BUILT_SOURCES = nixexpr-ast.cc nixexpr-ast.hh \
parser-tab.h lexer-tab.h parser-tab.c lexer-tab.c
parser-tab.hh lexer-tab.h parser-tab.cc lexer-tab.c
EXTRA_DIST = lexer.l parser.y nixexpr-ast.def nixexpr-ast.cc
@ -21,8 +21,8 @@ AM_CFLAGS = \
# Parser generation.
parser-tab.c parser-tab.h: parser.y
$(bison) -v -o parser-tab.c $(srcdir)/parser.y -d
parser-tab.cc parser-tab.hh: parser.y
$(bison) -v -o parser-tab.cc $(srcdir)/parser.y -d
lexer-tab.c lexer-tab.h: lexer.l
$(flex) --outfile lexer-tab.c --header-file=lexer-tab.h $(srcdir)/lexer.l

View file

@ -1,5 +1,9 @@
#include "attr-path.hh"
#include "nixexpr-ast.hh"
#include "util.hh"
namespace nix {
bool isAttrs(EvalState & state, Expr e, ATermMap & attrs)
@ -73,3 +77,6 @@ Expr findAlongAttrPath(EvalState & state, const string & attrPath,
return e;
}
}

View file

@ -7,8 +7,14 @@
#include "eval.hh"
namespace nix {
Expr findAlongAttrPath(EvalState & state, const string & attrPath,
const ATermMap & autoArgs, Expr e);
}
#endif /* !__ATTR_PATH_H */

View file

@ -1,8 +1,13 @@
#include "eval.hh"
#include "parser.hh"
#include "hash.hh"
#include "util.hh"
#include "nixexpr-ast.hh"
namespace nix {
EvalState::EvalState()
: normalForms(32768), primOps(128)
{
@ -271,7 +276,7 @@ Expr wrapInContext(ATermList context, Expr e)
static ATerm concatStrings(EvalState & state, const ATermVector & args)
{
ATermList context = ATempty;
ostringstream s;
std::ostringstream s;
bool isPath = false;
for (ATermVector::const_iterator i = args.begin(); i != args.end(); ++i) {
@ -666,3 +671,6 @@ void printEvalStats(EvalState & state)
if (showStats)
printATermMapStats();
}
}

View file

@ -4,16 +4,21 @@
#include <map>
#include "aterm.hh"
#include "hash.hh"
#include "nixexpr.hh"
typedef map<Path, PathSet> DrvRoots;
typedef map<Path, Hash> DrvHashes;
namespace nix {
class Hash;
typedef std::map<Path, PathSet> DrvRoots;
typedef std::map<Path, Hash> DrvHashes;
/* Cache for calls to addToStore(); maps source paths to the store
paths. */
typedef map<Path, Path> SrcToStore;
typedef std::map<Path, Path> SrcToStore;
struct EvalState;
@ -75,4 +80,7 @@ Expr autoCallFunction(Expr e, const ATermMap & args);
void printEvalStats(EvalState & state);
}
#endif /* !__EVAL_H */

View file

@ -1,10 +1,12 @@
#include "expr-to-xml.hh"
#include "xml-writer.hh"
#include "nixexpr-ast.hh"
#include "aterm.hh"
namespace nix {
static XMLAttrs singletonAttrs(const string & name, const string & value)
{
XMLAttrs attrs;
@ -84,9 +86,12 @@ static void printTermAsXML(Expr e, XMLWriter & doc)
}
void printTermAsXML(Expr e, ostream & out)
void printTermAsXML(Expr e, std::ostream & out)
{
XMLWriter doc(true, out);
XMLOpenElement root(doc, "expr");
printTermAsXML(e, doc);
}
}

View file

@ -6,8 +6,10 @@
#include "nixexpr.hh"
namespace nix {
void printTermAsXML(Expr e, ostream & out);
void printTermAsXML(Expr e, std::ostream & out);
}
#endif /* !__EXPR_TO_XML_H */

View file

@ -1,5 +1,9 @@
#include "get-drvs.hh"
#include "nixexpr-ast.hh"
#include "util.hh"
namespace nix {
string DrvInfo::queryDrvPath(EvalState & state) const
@ -66,7 +70,7 @@ static bool getDerivation(EvalState & state, Expr e,
e = evalExpr(state, e);
if (!matchAttrs(e, es)) return true;
shared_ptr<ATermMap> attrs(new ATermMap(32)); /* !!! */
boost::shared_ptr<ATermMap> attrs(new ATermMap(32)); /* !!! */
queryAllAttrs(e, *attrs, false);
Expr a = attrs->get(toATerm("type"));
@ -183,3 +187,6 @@ void getDerivations(EvalState & state, Expr e, const string & pathPrefix,
Exprs doneExprs;
getDerivations(state, e, pathPrefix, autoArgs, drvs, doneExprs);
}
}

View file

@ -9,7 +9,10 @@
#include "eval.hh"
typedef map<string, string> MetaInfo;
namespace nix {
typedef std::map<string, string> MetaInfo;
struct DrvInfo
@ -23,7 +26,7 @@ public:
string attrPath; /* path towards the derivation */
string system;
shared_ptr<ATermMap> attrs;
boost::shared_ptr<ATermMap> attrs;
string queryDrvPath(EvalState & state) const;
string queryOutPath(EvalState & state) const;
@ -53,4 +56,7 @@ void getDerivations(EvalState & state, Expr e, const string & pathPrefix,
const ATermMap & autoArgs, DrvInfos & drvs);
}
#endif /* !__GET_DRVS_H */

View file

@ -9,7 +9,7 @@
%{
#include <string.h>
#include <aterm2.h>
#include "parser-tab.h"
#include "parser-tab.hh"
static void initLoc(YYLTYPE * loc)
{
@ -35,7 +35,11 @@ static void adjustLoc(YYLTYPE * loc, const char * s, size_t len)
}
}
ATerm toATerm(const char * s);
ATerm toATerm(const char * s)
{
return (ATerm) ATmakeAppl0(ATmakeAFun((char *) s, 0, ATtrue));
}
ATerm unescapeStr(const char * s);
#define YY_USER_INIT initLoc(yylloc)

View file

@ -1,11 +1,14 @@
#include "nixexpr.hh"
#include "derivations.hh"
#include "util.hh"
#include "nixexpr-ast.hh"
#include "nixexpr-ast.cc"
namespace nix {
string showPos(ATerm pos)
{
ATerm path;
@ -332,3 +335,6 @@ string showValue(Expr e)
/* !!! incomplete */
return "<unknown>";
}
}

View file

@ -6,7 +6,10 @@
#include <aterm2.h>
#include "aterm-map.hh"
#include "util.hh"
#include "types.hh"
namespace nix {
MakeError(EvalError, Error)
@ -96,4 +99,7 @@ string showType(Expr e);
string showValue(Expr e);
}
#endif /* !__NIXEXPR_H */

View file

@ -1,3 +1,8 @@
#include "parser.hh"
#include "aterm.hh"
#include "util.hh"
#include "nixexpr-ast.hh"
#include <sstream>
#include <sys/types.h>
@ -5,9 +10,15 @@
#include <fcntl.h>
#include <unistd.h>
#include "aterm.hh"
#include "parser.hh"
#include "nixexpr-ast.hh"
extern "C" {
#include "parser-tab.hh"
#include "lexer-tab.h"
}
namespace nix {
struct ParseData
@ -18,15 +29,14 @@ struct ParseData
string error;
};
}
extern "C" {
#include "parser-tab.h"
#include "lexer-tab.h"
int yyparse(yyscan_t scanner, nix::ParseData * data);
namespace nix {
/* Callbacks for getting from C to C++. Due to a (small) bug in the
GLR code of Bison we cannot currently compile the parser as C++
code. */
void setParseResult(ParseData * data, ATerm t)
{
@ -71,6 +81,7 @@ const char * getPath(ParseData * data)
return data->path.c_str();
}
extern "C" {
Expr unescapeStr(const char * s)
{
string t;
@ -93,11 +104,7 @@ Expr unescapeStr(const char * s)
}
return makeStr(toATerm(t));
}
int yyparse(yyscan_t scanner, ParseData * data);
} /* end of C functions */
}
static void checkAttrs(ATermMap & names, ATermList bnds)
@ -232,3 +239,6 @@ Expr parseExprFromString(EvalState & state,
{
return parse(state, s.c_str(), "(string)", basePath);
}
}

View file

@ -4,6 +4,9 @@
#include "eval.hh"
namespace nix {
/* Parse a Nix expression from the specified file. If `path' refers
to a directory, the "/default.nix" is appended. */
Expr parseExprFromFile(EvalState & state, Path path);
@ -13,4 +16,7 @@ Expr parseExprFromString(EvalState & state, const string & s,
const Path & basePath);
}
#endif /* !__PARSER_H */

View file

@ -3,7 +3,7 @@
%locations
%error-verbose
%parse-param { yyscan_t scanner }
%parse-param { void * data }
%parse-param { ParseData * data }
%lex-param { yyscan_t scanner }
%{
@ -12,34 +12,47 @@
#include <string.h>
#include <aterm2.h>
#include "parser-tab.h"
#include "parser-tab.hh"
extern "C" {
#include "lexer-tab.h"
}
typedef ATerm Expr;
typedef ATerm ValidValues;
typedef ATerm DefaultValue;
typedef ATerm Pos;
#include "aterm.hh"
#include "nixexpr.hh"
#include "nixexpr-ast.hh"
void setParseResult(void * data, ATerm t);
void parseError(void * data, char * error, int line, int column);
ATerm absParsedPath(void * data, ATerm t);
ATerm fixAttrs(int recursive, ATermList as);
const char * getPath(void * data);
void backToString(yyscan_t scanner);
using namespace nix;
void yyerror(YYLTYPE * loc, yyscan_t scanner, void * data, char * s)
namespace nix {
struct ParseData
{
Expr result;
Path basePath;
Path path;
string error;
};
void setParseResult(ParseData * data, ATerm t);
void parseError(ParseData * data, char * error, int line, int column);
ATerm absParsedPath(ParseData * data, ATerm t);
ATerm fixAttrs(int recursive, ATermList as);
const char * getPath(ParseData * data);
Expr unescapeStr(const char * s);
extern "C" {
void backToString(yyscan_t scanner);
}
}
void yyerror(YYLTYPE * loc, yyscan_t scanner, ParseData * data, char * s)
{
parseError(data, s, loc->first_line, loc->first_column);
}
ATerm toATerm(const char * s)
{
return (ATerm) ATmakeAppl0(ATmakeAFun((char *) s, 0, ATtrue));
}
static Pos makeCurPos(YYLTYPE * loc, void * data)
static Pos makeCurPos(YYLTYPE * loc, ParseData * data)
{
return makePos(toATerm(getPath(data)),
loc->first_line, loc->first_column);

View file

@ -1,11 +1,16 @@
#include <algorithm>
#include "build.hh"
#include "misc.hh"
#include "eval.hh"
#include "globals.hh"
#include "nixexpr-ast.hh"
#include "store.hh"
#include "util.hh"
#include "expr-to-xml.hh"
#include "nixexpr-ast.hh"
#include <algorithm>
namespace nix {
static Expr primBuiltins(EvalState & state, const ATermVector & args)
@ -472,7 +477,7 @@ static Expr primToString(EvalState & state, const ATermVector & args)
be sensibly or completely represented (e.g., functions). */
static Expr primToXML(EvalState & state, const ATermVector & args)
{
ostringstream out;
std::ostringstream out;
printTermAsXML(strictEvalExpr(state, args[0]), out);
return makeStr(toATerm(out.str()));
}
@ -746,3 +751,6 @@ void EvalState::addPrimOps()
addPrimOp("removeAttrs", 2, primRemoveAttrs);
addPrimOp("relativise", 2, primRelativise);
}
}

View file

@ -1,3 +1,11 @@
#include "shared.hh"
#include "globals.hh"
#include "gc.hh"
#include "store.hh"
#include "util.hh"
#include "config.h"
#include <iostream>
#include <cctype>
@ -12,12 +20,8 @@ extern "C" {
#include <aterm2.h>
}
#include "globals.hh"
#include "gc.hh"
#include "store.hh"
#include "shared.hh"
#include "config.h"
namespace nix {
volatile sig_atomic_t blockInt = 0;
@ -173,7 +177,7 @@ static void initAndRun(int argc, char * * argv)
return;
}
else if (arg == "--version") {
cout << format("%1% (Nix) %2%") % programId % NIX_VERSION << endl;
std::cout << format("%1% (Nix) %2%") % programId % NIX_VERSION << std::endl;
return;
}
else if (arg == "--keep-failed" || arg == "-K")
@ -338,10 +342,15 @@ void switchToNixUser()
}
}
static char buf[1024];
int main(int argc, char * * argv)
{
using namespace nix;
/* If we are setuid root, we have to get rid of the excess
privileges ASAP. */
switchToNixUser();
@ -352,7 +361,7 @@ int main(int argc, char * * argv)
/* Turn on buffering for cerr. */
#if HAVE_PUBSETBUF
cerr.rdbuf()->pubsetbuf(buf, sizeof(buf));
std::cerr.rdbuf()->pubsetbuf(buf, sizeof(buf));
#endif
try {
@ -377,10 +386,12 @@ int main(int argc, char * * argv)
} catch (Error & e) {
printMsg(lvlError, format("error: %1%") % e.msg());
return 1;
} catch (exception & e) {
} catch (std::exception & e) {
printMsg(lvlError, format("error: %1%") % e.what());
return 1;
}
return 0;
}

View file

@ -1,9 +1,7 @@
#ifndef __SHARED_H
#define __SHARED_H
#include <string>
#include "util.hh"
#include "types.hh"
/* These are not implemented here, but must be implemented by a
@ -12,17 +10,21 @@
/* Main program. Called by main() after the ATerm library has been
initialised and some default arguments have been processed (and
removed from `args'). main() will catch all exceptions. */
void run(Strings args);
void run(nix::Strings args);
/* Should print a help message to stdout and return. */
void printHelp();
extern std::string programId;
namespace nix {
/* Ugh. No better place to put this. */
Path makeRootName(const Path & gcRoot, int & counter);
void printGCWarning();
extern string programId;
}
#endif /* !__SHARED_H */

View file

@ -1,3 +1,13 @@
#include "build.hh"
#include "references.hh"
#include "pathlocks.hh"
#include "misc.hh"
#include "globals.hh"
#include "gc.hh"
#include "store.hh"
#include "db.hh"
#include "util.hh"
#include <map>
#include <iostream>
#include <sstream>
@ -15,12 +25,10 @@
#include <pwd.h>
#include <grp.h>
#include "build.hh"
#include "references.hh"
#include "pathlocks.hh"
#include "misc.hh"
#include "globals.hh"
#include "gc.hh"
namespace nix {
using std::map;
/* !!! TODO derivationFromPath shouldn't be used here */
@ -38,8 +46,8 @@ class Worker;
/* A pointer to a goal. */
class Goal;
typedef shared_ptr<Goal> GoalPtr;
typedef weak_ptr<Goal> WeakGoalPtr;
typedef boost::shared_ptr<Goal> GoalPtr;
typedef boost::weak_ptr<Goal> WeakGoalPtr;
/* Set of goals. */
typedef set<GoalPtr> Goals;
@ -50,7 +58,7 @@ typedef map<Path, WeakGoalPtr> WeakGoalMap;
class Goal : public enable_shared_from_this<Goal>
class Goal : public boost::enable_shared_from_this<Goal>
{
public:
typedef enum {ecBusy, ecSuccess, ecFailed} ExitCode;
@ -447,8 +455,8 @@ static void killUser(uid_t uid)
if (kill(-1, SIGKILL) == -1)
throw SysError(format("cannot kill processes for UID `%1%'") % uid);
} catch (exception & e) {
cerr << format("build error: %1%\n") % e.what();
} catch (std::exception & e) {
std::cerr << format("build error: %1%\n") % e.what();
quickExit(1);
}
quickExit(0);
@ -930,8 +938,8 @@ DerivationGoal::HookReply DerivationGoal::tryBuildHook()
throw SysError(format("executing `%1%'") % buildHook);
} catch (exception & e) {
cerr << format("build error: %1%\n") % e.what();
} catch (std::exception & e) {
std::cerr << format("build error: %1%\n") % e.what();
}
quickExit(1);
}
@ -1326,8 +1334,8 @@ void DerivationGoal::startBuilder()
throw SysError(format("executing `%1%'")
% drv.builder);
} catch (exception & e) {
cerr << format("build error: %1%\n") % e.what();
} catch (std::exception & e) {
std::cerr << format("build error: %1%\n") % e.what();
}
quickExit(1);
}
@ -1593,7 +1601,7 @@ private:
Pid pid;
/* Lock on the store path. */
shared_ptr<PathLocks> outputLock;
boost::shared_ptr<PathLocks> outputLock;
typedef void (SubstitutionGoal::*GoalState)();
GoalState state;
@ -1719,7 +1727,7 @@ void SubstitutionGoal::tryToRun()
}
/* Acquire a lock on the output path. */
outputLock = shared_ptr<PathLocks>(new PathLocks);
outputLock = boost::shared_ptr<PathLocks>(new PathLocks);
outputLock->lockPaths(singleton<PathSet>(storePath),
(format("waiting for lock on `%1%'") % storePath).str());
@ -1767,8 +1775,8 @@ void SubstitutionGoal::tryToRun()
throw SysError(format("executing `%1%'") % sub.program);
} catch (exception & e) {
cerr << format("substitute error: %1%\n") % e.what();
} catch (std::exception & e) {
std::cerr << format("substitute error: %1%\n") % e.what();
}
quickExit(1);
}
@ -1930,8 +1938,8 @@ static void removeGoal(GoalPtr goal, WeakGoalMap & goalMap)
void Worker::removeGoal(GoalPtr goal)
{
::removeGoal(goal, derivationGoals);
::removeGoal(goal, substitutionGoals);
nix::removeGoal(goal, derivationGoals);
nix::removeGoal(goal, substitutionGoals);
if (topGoals.find(goal) != topGoals.end()) {
topGoals.erase(goal);
/* If a top-level goal failed, then kill all other goals
@ -2160,3 +2168,6 @@ void ensurePath(const Path & path)
if (goal->getExitCode() != Goal::ecSuccess)
throw Error(format("path `%1%' does not exist and cannot be created") % path);
}
}

View file

@ -1,7 +1,12 @@
#ifndef __BUILD_H
#define __BUILD_H
#include "derivations.hh"
#include "types.hh"
namespace nix {
/* Ensure that the output paths of the derivation are valid. If they
are already valid, this is a no-op. Otherwise, validity can
@ -16,5 +21,7 @@ void buildDerivations(const PathSet & drvPaths);
void ensurePath(const Path & storePath);
}
#endif /* !__BUILD_H */

View file

@ -1,3 +1,7 @@
#include "db.hh"
#include "util.hh"
#include "pathlocks.hh"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@ -7,9 +11,8 @@
#include <db_cxx.h>
#include "db.hh"
#include "util.hh"
#include "pathlocks.hh"
namespace nix {
/* Wrapper class to ensure proper destruction. */
@ -112,7 +115,7 @@ Db * Database::getDb(TableId table)
if (table == 0)
throw Error("database table is not open "
"(maybe you don't have sufficient permission?)");
map<TableId, Db *>::iterator i = tables.find(table);
std::map<TableId, Db *>::iterator i = tables.find(table);
if (i == tables.end())
throw Error("unknown table id");
return i->second;
@ -263,10 +266,10 @@ void Database::close()
try {
for (map<TableId, Db *>::iterator i = tables.begin();
for (std::map<TableId, Db *>::iterator i = tables.begin();
i != tables.end(); )
{
map<TableId, Db *>::iterator j = i;
std::map<TableId, Db *>::iterator j = i;
++j;
closeTable(i->first);
i = j;
@ -433,3 +436,6 @@ void Database::enumTable(const Transaction & txn, TableId table,
} catch (DbException e) { rethrow(e); }
}
}

View file

@ -1,14 +1,10 @@
#ifndef __DB_H
#define __DB_H
#include <string>
#include <list>
#include "types.hh"
#include <map>
#include "util.hh"
using namespace std;
/* Defined externally. */
class DbTxn;
@ -16,6 +12,9 @@ class DbEnv;
class Db;
namespace nix {
class Database;
@ -53,7 +52,7 @@ private:
DbEnv * env;
TableId nextId;
map<TableId, Db *> tables;
std::map<TableId, Db *> tables;
void requireEnv();
@ -100,4 +99,7 @@ public:
};
}
#endif /* !__DB_H */

View file

@ -1,11 +1,13 @@
#include "derivations.hh"
#include "globals.hh"
#include "store.hh"
#include "derivations-ast.hh"
#include "derivations-ast.cc"
namespace nix {
Hash hashTerm(ATerm t)
{
return hashString(htSHA256, atPrint(t));
@ -170,3 +172,6 @@ bool isDerivation(const string & fileName)
fileName.size() >= drvExtension.size() &&
string(fileName, fileName.size() - drvExtension.size()) == drvExtension;
}
}

View file

@ -2,7 +2,12 @@
#define __DERIVATIONS_H
#include "aterm.hh"
#include "store.hh"
#include "hash.hh"
#include <map>
namespace nix {
/* Extension of derivations in the Nix store. */
@ -27,13 +32,13 @@ struct DerivationOutput
}
};
typedef map<string, DerivationOutput> DerivationOutputs;
typedef std::map<string, DerivationOutput> DerivationOutputs;
/* For inputs that are sub-derivations, we specify exactly which
output IDs we are interested in. */
typedef map<Path, StringSet> DerivationInputs;
typedef std::map<Path, StringSet> DerivationInputs;
typedef map<string, string> StringPairs;
typedef std::map<string, string> StringPairs;
struct Derivation
{
@ -64,4 +69,7 @@ ATerm unparseDerivation(const Derivation & drv);
bool isDerivation(const string & fileName);
}
#endif /* !__DERIVATIONS_H */

View file

@ -1,7 +1,10 @@
#include "globals.hh"
#include "gc.hh"
#include "globals.hh"
#include "misc.hh"
#include "pathlocks.hh"
#include "store.hh"
#include "db.hh"
#include "util.hh"
#include <boost/shared_ptr.hpp>
@ -17,6 +20,9 @@
#endif
namespace nix {
static string gcLockName = "gc.lock";
static string tempRootsDir = "temproots";
static string gcRootsDir = "gcroots";
@ -192,7 +198,7 @@ void removeTempRoots()
}
typedef shared_ptr<AutoCloseFD> FDPtr;
typedef boost::shared_ptr<AutoCloseFD> FDPtr;
typedef list<FDPtr> FDs;
@ -558,3 +564,6 @@ void collectGarbage(GCAction action, const PathSet & pathsToDelete,
}
}
}
}

View file

@ -1,7 +1,10 @@
#ifndef __GC_H
#define __GC_H
#include "util.hh"
#include "types.hh"
namespace nix {
/* Garbage collector operation. */
@ -39,4 +42,7 @@ Path addPermRoot(const Path & storePath, const Path & gcRoot,
bool indirect);
}
#endif /* !__GC_H */

View file

@ -1,9 +1,13 @@
#include "globals.hh"
#include "util.hh"
#include <map>
#include <algorithm>
namespace nix {
string nixStore = "/UNINIT";
string nixDataDir = "/UNINIT";
string nixLogDir = "/UNINIT";
@ -23,7 +27,7 @@ string thisSystem = "unset";
static bool settingsRead = false;
static map<string, Strings> settings;
static std::map<string, Strings> settings;
string & at(Strings & ss, unsigned int n)
@ -72,7 +76,7 @@ static void readSettings()
Strings querySetting(const string & name, const Strings & def)
{
if (!settingsRead) readSettings();
map<string, Strings>::iterator i = settings.find(name);
std::map<string, Strings>::iterator i = settings.find(name);
return i == settings.end() ? def : i->second;
}
@ -98,3 +102,6 @@ bool queryBoolSetting(const string & name, bool def)
else throw Error(format("configuration option `%1%' should be either `true' or `false', not `%2%'")
% name % v);
}
}

View file

@ -1,11 +1,11 @@
#ifndef __GLOBALS_H
#define __GLOBALS_H
#include <string>
#include <set>
#include "util.hh"
#include "types.hh"
namespace nix {
using namespace std;
/* Path names. */
@ -68,4 +68,7 @@ string querySetting(const string & name, const string & def);
bool queryBoolSetting(const string & name, bool def);
}
#endif /* !__GLOBALS_H */

View file

@ -1,4 +1,10 @@
#include "misc.hh"
#include "store.hh"
#include "build.hh"
#include "db.hh"
namespace nix {
Derivation derivationFromPath(const Path & drvPath)
@ -81,3 +87,6 @@ void queryMissing(const PathSet & targets,
}
}
}
}

View file

@ -4,6 +4,9 @@
#include "derivations.hh"
namespace nix {
/* Read a derivation, after ensuring its existence through
ensurePath(). */
Derivation derivationFromPath(const Path & drvPath);
@ -29,4 +32,7 @@ void queryMissing(const PathSet & targets,
PathSet & willBuild, PathSet & willSubstitute);
}
#endif /* !__MISC_H */

View file

@ -1,17 +1,21 @@
#include "pathlocks.hh"
#include "util.hh"
#include <cerrno>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "pathlocks.hh"
#ifdef __CYGWIN__
#include <windows.h>
#include <sys/cygwin.h>
#endif
namespace nix {
int openLockFile(const Path & path, bool create)
{
AutoCloseFD fd;
@ -220,3 +224,6 @@ void PathLocks::setDeletion(bool deletePaths)
{
this->deletePaths = deletePaths;
}
}

View file

@ -1,7 +1,10 @@
#ifndef __PATHLOCKS_H
#define __PATHLOCKS_H
#include "util.hh"
#include "types.hh"
namespace nix {
/* Open (possibly create) a lock file and return the file descriptor.
@ -22,7 +25,7 @@ bool lockFile(int fd, LockType lockType, bool wait);
class PathLocks
{
private:
typedef pair<int, Path> FDPair;
typedef std::pair<int, Path> FDPair;
list<FDPair> fds;
bool deletePaths;
@ -37,4 +40,7 @@ public:
};
}
#endif /* !__PATHLOCKS_H */

View file

@ -1,3 +1,7 @@
#include "references.hh"
#include "hash.hh"
#include "util.hh"
#include <cerrno>
#include <map>
@ -7,8 +11,8 @@
#include <dirent.h>
#include <fcntl.h>
#include "references.hh"
#include "hash.hh"
namespace nix {
static unsigned int refLength = 32; /* characters */
@ -90,7 +94,7 @@ void checkPath(const string & path,
PathSet scanForReferences(const string & path, const PathSet & paths)
{
map<string, Path> backMap;
std::map<string, Path> backMap;
StringSet ids;
StringSet seen;
@ -114,10 +118,13 @@ PathSet scanForReferences(const string & path, const PathSet & paths)
PathSet found;
for (StringSet::iterator i = seen.begin(); i != seen.end(); i++) {
map<string, Path>::iterator j;
std::map<string, Path>::iterator j;
if ((j = backMap.find(*i)) == backMap.end()) abort();
found.insert(j->second);
}
return found;
}
}

View file

@ -1,10 +1,12 @@
#ifndef __REFERENCES_H
#define __REFERENCES_H
#include "util.hh"
#include "types.hh"
namespace nix {
PathSet scanForReferences(const Path & path, const PathSet & refs);
}
#endif /* !__REFERENCES_H */

View file

@ -1,3 +1,13 @@
#include "store.hh"
#include "util.hh"
#include "globals.hh"
#include "db.hh"
#include "archive.hh"
#include "pathlocks.hh"
#include "gc.hh"
#include "aterm.hh"
#include "derivations-ast.hh"
#include <iostream>
#include <algorithm>
@ -6,12 +16,7 @@
#include <unistd.h>
#include <utime.h>
#include "store.hh"
#include "globals.hh"
#include "db.hh"
#include "archive.hh"
#include "pathlocks.hh"
#include "gc.hh"
namespace nix {
/* Nix database. */
@ -956,10 +961,6 @@ void verifyStore(bool checkContents)
}
#include "aterm.hh"
#include "derivations-ast.hh"
/* Upgrade from schema 1 (Nix <= 0.7) to schema 2 (Nix >= 0.8). */
static void upgradeStore07()
{
@ -971,7 +972,7 @@ static void upgradeStore07()
nixDB.enumTable(txn, dbValidPaths, validPaths2);
PathSet validPaths(validPaths2.begin(), validPaths2.end());
cerr << "hashing paths...";
std::cerr << "hashing paths...";
int n = 0;
for (PathSet::iterator i = validPaths.begin(); i != validPaths.end(); ++i) {
checkInterrupt();
@ -980,20 +981,20 @@ static void upgradeStore07()
if (s == "") {
Hash hash = hashPath(htSHA256, *i);
setHash(txn, *i, hash);
cerr << ".";
std::cerr << ".";
if (++n % 1000 == 0) {
txn.commit();
txn.begin(nixDB);
}
}
}
cerr << "\n";
std::cerr << std::endl;
txn.commit();
txn.begin(nixDB);
cerr << "processing closures...";
std::cerr << "processing closures...";
for (PathSet::iterator i = validPaths.begin(); i != validPaths.end(); ++i) {
checkInterrupt();
if (i->size() > 6 && string(*i, i->size() - 6) == ".store") {
@ -1037,10 +1038,10 @@ static void upgradeStore07()
setReferences(txn, path, references);
}
cerr << ".";
std::cerr << ".";
}
}
cerr << "\n";
std::cerr << std::endl;
/* !!! maybe this transaction is way too big */
txn.commit();
@ -1061,7 +1062,7 @@ static void upgradeStore09()
Transaction txn(nixDB);
cerr << "converting referers to referrers...";
std::cerr << "converting referers to referrers...";
TableId dbReferers = nixDB.openTable("referers"); /* sic! */
@ -1080,16 +1081,19 @@ static void upgradeStore09()
if (++n % 1000 == 0) {
txn.commit();
txn.begin(nixDB);
cerr << "|";
std::cerr << "|";
}
cerr << ".";
std::cerr << ".";
}
txn.commit();
cerr << "\n";
std::cerr << std::endl;
nixDB.closeTable(dbReferers);
nixDB.deleteTable("referers");
}
}

View file

@ -4,9 +4,12 @@
#include <string>
#include "hash.hh"
#include "db.hh"
using namespace std;
namespace nix {
class Transaction;
/* Nix store and database schema version. Version 1 (or 0) was Nix <=
@ -169,4 +172,7 @@ void deleteFromStore(const Path & path, unsigned long long & bytesFreed);
void verifyStore(bool checkContents);
}
#endif /* !__STORE_H */

View file

@ -3,7 +3,8 @@ pkglib_LTLIBRARIES = libutil.la
libutil_la_SOURCES = util.cc util.hh hash.cc hash.hh \
archive.cc archive.hh aterm.cc aterm.hh \
aterm-map.cc aterm-map.hh \
xml-writer.cc xml-writer.hh
xml-writer.cc xml-writer.hh \
types.hh
if !HAVE_OPENSSL
libutil_la_SOURCES += \

View file

@ -12,6 +12,9 @@
#include "util.hh"
namespace nix {
static string archiveVersion1 = "nix-archive-1";
@ -319,3 +322,5 @@ void restorePath(const Path & path, RestoreSource & source)
restore(path, source);
}
}

View file

@ -1,6 +1,10 @@
#include <string>
#ifndef __ARCHIVE_H
#define __ARCHIVE_H
#include "util.hh"
#include "types.hh"
namespace nix {
/* dumpPath creates a Nix archive of the specified path. The format
@ -61,3 +65,9 @@ struct RestoreSource
};
void restorePath(const Path & path, RestoreSource & source);
}
#endif /* !__ARCHIVE_H */

View file

@ -1,9 +1,14 @@
#include "aterm-map.hh"
#include <iostream>
#include <assert.h>
#include <stdlib.h>
namespace nix {
static const unsigned int maxLoadFactor = /* 1 / */ 3;
static unsigned int nrResizes = 0;
static unsigned int sizeTotalAlloc = 0;
@ -214,10 +219,11 @@ unsigned int ATermMap::size()
}
#include <iostream>
void printATermMapStats()
{
using std::cerr;
using std::endl;
cerr << "RESIZES: " << nrResizes << " "
<< sizeTotalAlloc << " "
<< sizeCurAlloc << " "
@ -319,3 +325,6 @@ int main(int argc, char * * argv)
printATermMapStats();
}
#endif
}

View file

@ -4,7 +4,8 @@
#include <aterm2.h>
#include <assert.h>
using namespace std;
namespace nix {
class ATermMap
@ -122,4 +123,7 @@ private:
void printATermMapStats();
}
#endif /* !__ATERM_MAP_H */

View file

@ -1,7 +1,9 @@
#include "aterm.hh"
using std::string;
string atPrint(ATerm t)
string nix::atPrint(ATerm t)
{
if (!t) throw Error("attempt to print null aterm");
char * s = ATwriteToString(t);
@ -10,13 +12,13 @@ string atPrint(ATerm t)
}
ostream & operator << (ostream & stream, ATerm e)
std::ostream & operator << (std::ostream & stream, ATerm e)
{
return stream << atPrint(e);
return stream << nix::atPrint(e);
}
Error badTerm(const format & f, ATerm t)
nix::Error nix::badTerm(const format & f, ATerm t)
{
char * s = ATwriteToString(t);
if (!s) throw Error("cannot print term");
@ -29,13 +31,13 @@ Error badTerm(const format & f, ATerm t)
}
ATerm toATerm(const char * s)
ATerm nix::toATerm(const char * s)
{
return (ATerm) ATmakeAppl0(ATmakeAFun((char *) s, 0, ATtrue));
}
ATerm toATerm(const string & s)
ATerm nix::toATerm(const string & s)
{
return toATerm(s.c_str());
}

View file

@ -5,15 +5,15 @@ extern "C" {
#include <aterm2.h>
}
#include "util.hh"
#include "types.hh"
namespace nix {
/* Print an ATerm. */
string atPrint(ATerm t);
/* Write an ATerm to an output stream. */
ostream & operator << (ostream & stream, ATerm e);
class ATermIterator
{
ATermList t;
@ -46,4 +46,11 @@ ATerm toATerm(const char * s);
ATerm toATerm(const string & s);
}
/* Write an ATerm to an output stream. */
std::ostream & operator << (std::ostream & stream, ATerm e);
#endif /* !__ATERM_H */

View file

@ -15,12 +15,16 @@ extern "C" {
#include "hash.hh"
#include "archive.hh"
#include "util.hh"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
namespace nix {
Hash::Hash()
{
type = htUnknown;
@ -89,9 +93,9 @@ Hash parseHash(HashType ht, const string & s)
string s2(s, i * 2, 2);
if (!isxdigit(s2[0]) || !isxdigit(s2[1]))
throw Error(format("invalid hash `%1%'") % s);
istringstream str(s2);
std::istringstream str(s2);
int n;
str >> hex >> n;
str >> std::hex >> n;
hash.hash[i] = n;
}
return hash;
@ -313,3 +317,6 @@ HashType parseHashType(const string & s)
else if (s == "sha256") return htSHA256;
else return htUnknown;
}
}

View file

@ -1,11 +1,10 @@
#ifndef __HASH_H
#define __HASH_H
#include <string>
#include "types.hh"
#include "util.hh"
using namespace std;
namespace nix {
typedef enum { htUnknown, htMD5, htSHA1, htSHA256 } HashType;
@ -77,4 +76,7 @@ Hash compressHash(const Hash & hash, unsigned int newSize);
HashType parseHashType(const string & s);
}
#endif /* !__HASH_H */

73
src/libutil/types.hh Normal file
View file

@ -0,0 +1,73 @@
#ifndef __TYPES_H
#define __TYPES_H
#include <string>
#include <list>
#include <set>
#include <boost/format.hpp>
namespace nix {
/* Inherit some names from other namespaces for convenience. */
using std::string;
using std::list;
using std::set;
using std::vector;
using boost::format;
class Error : public std::exception
{
protected:
string err;
public:
Error(const format & f);
~Error() throw () { };
const char * what() const throw () { return err.c_str(); }
const string & msg() const throw () { return err; }
Error & addPrefix(const format & f);
};
class SysError : public Error
{
public:
SysError(const format & f);
};
#define MakeError(newClass, superClass) \
class newClass : public superClass \
{ \
public: \
newClass(const format & f) : superClass(f) { }; \
};
MakeError(UsageError, Error)
typedef list<string> Strings;
typedef set<string> StringSet;
/* Paths are just strings. */
typedef string Path;
typedef list<Path> Paths;
typedef set<Path> PathSet;
typedef enum {
lvlError,
lvlInfo,
lvlTalkative,
lvlChatty,
lvlDebug,
lvlVomit
} Verbosity;
}
#endif /* !__TYPES_H */

View file

@ -9,17 +9,16 @@
#include <cstdio>
#include <sstream>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#include <signal.h>
#include "util.hh"
namespace nix {
Error::Error(const format & f)
{
err = f.str();
@ -368,7 +367,7 @@ void Nest::open(Verbosity level, const format & f)
{
if (level <= verbosity) {
if (logType == ltEscapes)
cerr << "\033[" << escVerbosity(level) << "p"
std::cerr << "\033[" << escVerbosity(level) << "p"
<< f.str() << "\n";
else
printMsg_(level, f);
@ -383,7 +382,7 @@ void Nest::close()
if (nest) {
nestingLevel--;
if (logType == ltEscapes)
cerr << "\033[q";
std::cerr << "\033[q";
nest = false;
}
}
@ -697,8 +696,8 @@ string runProgram(Path program)
execl(program.c_str(), program.c_str(), (char *) 0);
throw SysError(format("executing `%1%'") % program);
} catch (exception & e) {
cerr << "error: " << e.what() << endl;
} catch (std::exception & e) {
std::cerr << "error: " << e.what() << std::endl;
}
quickExit(1);
}
@ -743,7 +742,7 @@ void _interrupted()
/* Block user interrupts while an exception is being handled.
Throwing an exception while another exception is being handled
kills the program! */
if (!uncaught_exception()) {
if (!std::uncaught_exception()) {
_isInterrupted = 0;
throw Error("interrupted by the user");
}
@ -837,7 +836,7 @@ bool statusOk(int status)
string int2String(int n)
{
ostringstream str;
std::ostringstream str;
str << n;
return str.str();
}
@ -845,7 +844,10 @@ string int2String(int n)
bool string2Int(const string & s, int & n)
{
istringstream str(s);
std::istringstream str(s);
str >> n;
return str && str.get() == EOF;
}
}

View file

@ -1,58 +1,15 @@
#ifndef __UTIL_H
#define __UTIL_H
#include <string>
#include <list>
#include <set>
#include <sstream>
#include "types.hh"
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
#include <signal.h>
#include <boost/format.hpp>
using namespace std;
using namespace boost;
class Error : public exception
{
protected:
string err;
public:
Error(const format & f);
~Error() throw () { };
const char * what() const throw () { return err.c_str(); }
const string & msg() const throw () { return err; }
Error & addPrefix(const format & f);
};
class SysError : public Error
{
public:
SysError(const format & f);
};
#define MakeError(newClass, superClass) \
class newClass : public superClass \
{ \
public: \
newClass(const format & f) : superClass(f) { }; \
};
MakeError(UsageError, Error)
typedef list<string> Strings;
typedef set<string> StringSet;
/* Paths are just strings. */
typedef string Path;
typedef list<Path> Paths;
typedef set<Path> PathSet;
namespace nix {
/* Return an environment variable. */
@ -138,15 +95,6 @@ typedef enum {
ltFlat /* no nesting */
} LogType;
typedef enum {
lvlError,
lvlInfo,
lvlTalkative,
lvlChatty,
lvlDebug,
lvlVomit
} Verbosity;
extern LogType logType;
extern Verbosity verbosity; /* suppress msgs > this */
@ -308,4 +256,7 @@ struct SwitchToOriginalUser
};
}
#endif /* !__UTIL_H */

View file

@ -3,7 +3,10 @@
#include "xml-writer.hh"
XMLWriter::XMLWriter(bool indent, ostream & output)
namespace nix {
XMLWriter::XMLWriter(bool indent, std::ostream & output)
: output(output), indent(indent)
{
output << "<?xml version='1.0' encoding='utf-8'?>\n";
@ -122,3 +125,6 @@ int main(int argc, char * * argv)
return 0;
}
#endif
}

View file

@ -6,7 +6,12 @@
#include <list>
#include <map>
using namespace std;
namespace nix {
using std::string;
using std::map;
using std::list;
typedef map<string, string> XMLAttrs;
@ -16,7 +21,7 @@ class XMLWriter
{
private:
ostream & output;
std::ostream & output;
bool indent;
bool closed;
@ -25,7 +30,7 @@ private:
public:
XMLWriter(bool indent, ostream & output);
XMLWriter(bool indent, std::ostream & output);
~XMLWriter();
void close();
@ -64,4 +69,7 @@ public:
};
}
#endif /* !__XML_WRITER_H */

View file

@ -13,6 +13,9 @@
#include "attr-path.hh"
#include "pathlocks.hh"
#include "xml-writer.hh"
#include "store.hh"
#include "db.hh"
#include "util.hh"
#include <cerrno>
#include <ctime>
@ -23,6 +26,10 @@
#include <unistd.h>
using namespace nix;
using std::cout;
typedef enum {
srcNixExprDrvs,
srcNixExprs,
@ -224,7 +231,7 @@ static DrvInfos filterBySelector(EvalState & state,
for (DrvNames::iterator i = selectors.begin();
i != selectors.end(); ++i)
{
typedef list<pair<DrvInfo, unsigned int> > Matches;
typedef list<std::pair<DrvInfo, unsigned int> > Matches;
Matches matches;
unsigned int n = 0;
for (DrvInfos::const_iterator j = allElems.begin();
@ -233,7 +240,7 @@ static DrvInfos filterBySelector(EvalState & state,
DrvName drvName(j->name);
if (i->matches(drvName)) {
i->hits++;
matches.push_back(pair<DrvInfo, unsigned int>(*j, n));
matches.push_back(std::pair<DrvInfo, unsigned int>(*j, n));
}
}
@ -244,7 +251,7 @@ static DrvInfos filterBySelector(EvalState & state,
if (newestOnly) {
/* Map from package names to derivations. */
typedef map<string, pair<DrvInfo, unsigned int> > Newest;
typedef map<string, std::pair<DrvInfo, unsigned int> > Newest;
Newest newest;
StringSet multiple;
@ -350,7 +357,7 @@ static void queryInstSources(EvalState & state,
assertStorePath(*i);
DrvInfo elem;
elem.attrs = shared_ptr<ATermMap>(new ATermMap(0)); /* ugh... */
elem.attrs = boost::shared_ptr<ATermMap>(new ATermMap(0)); /* ugh... */
string name = baseNameOf(*i);
string::size_type dash = name.find('-');
if (dash != string::npos)
@ -667,7 +674,7 @@ void printTable(Table & table)
if (column < nrColumns - 1)
cout << string(widths[column] - j->size() + 2, ' ');
}
cout << endl;
cout << std::endl;
}
}
@ -801,7 +808,7 @@ static void opQuery(Globals & globals,
/* Print the desired columns, or XML output. */
Table table;
ostringstream dummy;
std::ostringstream dummy;
XMLWriter xml(true, *(xmlOutput ? &cout : &dummy));
XMLOpenElement xmlRoot(xml, "items");

View file

@ -1,4 +1,8 @@
#include "names.hh"
#include "util.hh"
namespace nix {
DrvName::DrvName()
@ -115,3 +119,6 @@ DrvNames drvNamesFromArgs(const Strings & opArgs)
result.push_back(DrvName(*i));
return result;
}
}

View file

@ -1,10 +1,10 @@
#ifndef __NAMES_H
#define __NAMES_H
#include <string>
#include <list>
#include "types.hh"
#include "util.hh"
namespace nix {
struct DrvName
@ -27,4 +27,7 @@ int compareVersions(const string & v1, const string & v2);
DrvNames drvNamesFromArgs(const Strings & opArgs);
}
#endif /* !__NAMES_H */

View file

@ -1,4 +1,5 @@
#include "profiles.hh"
#include "util.hh"
#include <sys/types.h>
#include <sys/stat.h>
@ -7,6 +8,9 @@
#include <stdio.h>
namespace nix {
static bool cmpGensByNumber(const Generation & a, const Generation & b)
{
return a.number < b.number;
@ -126,3 +130,7 @@ void switchLink(Path link, Path target)
if (rename(tmp.c_str(), link.c_str()) != 0)
throw SysError(format("renaming `%1%' to `%2%'") % tmp % link);
}
}

View file

@ -1,9 +1,10 @@
#ifndef __PROFILES_H
#define __PROFILES_H
#include <string>
#include "types.hh"
#include "util.hh"
namespace nix {
struct Generation
@ -35,4 +36,7 @@ void deleteGeneration(const Path & profile, unsigned int gen);
void switchLink(Path link, Path target);
}
#endif /* !__PROFILES_H */

View file

@ -5,9 +5,12 @@
#include "help.txt.hh"
using namespace nix;
void printHelp()
{
cout << string((char *) helpText, sizeof helpText);
std::cout << string((char *) helpText, sizeof helpText);
}
@ -43,7 +46,7 @@ void run(Strings args)
for (Strings::iterator i = ss.begin(); i != ss.end(); ++i) {
Hash h = flat ? hashFile(ht, *i) : hashPath(ht, *i);
if (truncate && h.hashSize > 20) h = compressHash(h, 20);
cout << format("%1%\n") %
std::cout << format("%1%\n") %
(base32 ? printHash32(h) : printHash(h));
}
}
@ -51,7 +54,7 @@ void run(Strings args)
else {
for (Strings::iterator i = ss.begin(); i != ss.end(); ++i) {
Hash h = op == opTo16 ? parseHash32(ht, *i) : parseHash(ht, *i);
cout << format("%1%\n") %
std::cout << format("%1%\n") %
(op == opTo16 ? printHash(h) : printHash32(h));
}
}

View file

@ -10,12 +10,17 @@
#include "get-drvs.hh"
#include "attr-path.hh"
#include "expr-to-xml.hh"
#include "util.hh"
#include "store.hh"
#include "help.txt.hh"
using namespace nix;
void printHelp()
{
cout << string((char *) helpText, sizeof helpText);
std::cout << string((char *) helpText, sizeof helpText);
}
@ -23,7 +28,7 @@ static Expr parseStdin(EvalState & state)
{
startNest(nest, lvlTalkative, format("parsing standard input"));
string s, s2;
while (getline(cin, s2)) s += s2 + "\n";
while (getline(std::cin, s2)) s += s2 + "\n";
return parseExprFromString(state, s, absPath("."));
}
@ -38,9 +43,9 @@ static void printResult(EvalState & state, Expr e,
{
if (evalOnly)
if (xmlOutput)
printTermAsXML(e, cout);
printTermAsXML(e, std::cout);
else
cout << format("%1%\n") % e;
std::cout << format("%1%\n") % e;
else {
DrvInfos drvs;
@ -53,7 +58,7 @@ static void printResult(EvalState & state, Expr e,
drvPath = addPermRoot(drvPath,
makeRootName(gcRoot, rootNr),
indirectRoot);
cout << format("%1%\n") % drvPath;
std::cout << format("%1%\n") % drvPath;
}
}
}

View file

@ -1,7 +1,14 @@
#include "dotgraph.hh"
#include "util.hh"
#include "store.hh"
#include "db.hh"
#include <iostream>
#include "dotgraph.hh"
#include "build.hh"
using std::cout;
namespace nix {
static string dotQuote(const string & s)
@ -151,3 +158,6 @@ void printDotGraph(const PathSet & roots)
cout << "}\n";
}
}

View file

@ -1,8 +1,12 @@
#ifndef __DOTGRAPH_H
#define __DOTGRAPH_H
#include "util.hh"
#include "types.hh"
namespace nix {
void printDotGraph(const PathSet & roots);
}
#endif /* !__DOTGRAPH_H */

View file

@ -8,9 +8,17 @@
#include "archive.hh"
#include "shared.hh"
#include "dotgraph.hh"
#include "store.hh"
#include "db.hh"
#include "util.hh"
#include "help.txt.hh"
using namespace nix;
using std::cin;
using std::cout;
typedef void (* Operation) (Strings opFlags, Strings opArgs);
@ -528,7 +536,7 @@ static void opGC(Strings opFlags, Strings opArgs)
if (action != gcDeleteDead) {
for (PathSet::iterator i = result.begin(); i != result.end(); ++i)
cout << *i << endl;
cout << *i << std::endl;
}
}