aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2008-06-18 15:20:33 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2008-06-18 15:20:33 +0000
commit5af84139a8d04ad9fdb2c02bc242ce5cd50b87b9 (patch)
tree4c8292835dd77eac32e06ffa28bf7c89d1ae12ed
parentd3aa183beb774c20cb77052248cf45e684d134fb (diff)
* --max-freed: support values >= 4 GB.
-rw-r--r--src/libmain/shared.cc4
-rw-r--r--src/libmain/shared.hh2
-rw-r--r--src/libutil/util.cc8
-rw-r--r--src/libutil/util.hh1
4 files changed, 12 insertions, 3 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index 76d510efe..d6f299d6b 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -58,12 +58,12 @@ static void setLogType(string lt)
}
-unsigned int getIntArg(const string & opt,
+unsigned long long getIntArg(const string & opt,
Strings::iterator & i, const Strings::iterator & end)
{
++i;
if (i == end) throw UsageError(format("`%1%' requires an argument") % opt);
- int n;
+ long long n;
if (!string2Int(*i, n) || n < 0)
throw UsageError(format("`%1%' requires a non-negative integer") % opt);
return n;
diff --git a/src/libmain/shared.hh b/src/libmain/shared.hh
index c38eeaf48..95d80bacd 100644
--- a/src/libmain/shared.hh
+++ b/src/libmain/shared.hh
@@ -26,7 +26,7 @@ namespace nix {
Path makeRootName(const Path & gcRoot, int & counter);
void printGCWarning();
-unsigned int getIntArg(const string & opt,
+unsigned long long getIntArg(const string & opt,
Strings::iterator & i, const Strings::iterator & end);
/* Whether we're running setuid. */
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 1873ccfe5..4f6c367da 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -1020,6 +1020,14 @@ bool string2Int(const string & s, int & n)
}
+bool string2Int(const string & s, long long & n)
+{
+ std::istringstream str(s);
+ str >> n;
+ return str && str.get() == EOF;
+}
+
+
void ignoreException()
{
try {
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index d1e30fa6b..5d28a8308 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -287,6 +287,7 @@ bool statusOk(int status);
/* Parse a string into an integer. */
string int2String(int n);
bool string2Int(const string & s, int & n);
+bool string2Int(const string & s, long long & n);
/* Exception handling in destructors: print an error message, then