aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-11-05 16:20:57 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-11-05 16:20:57 +0000
commite17e95a82892b31c8063f2ace1b21c79e82e6f6d (patch)
tree3e2475f7cb04ea24286656eb05d8c180188d3a07 /src
parent80bb477cc4ea5226ae760726730b3e09d21559de (diff)
* Print a shared textual ATerm if the term if very large. Due to
substitutions, Fix terms are very large when printed as trees (in memory, they are quite compact due to sharing).
Diffstat (limited to 'src')
-rw-r--r--src/libnix/expr.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libnix/expr.cc b/src/libnix/expr.cc
index cead80342..9bbe80ab4 100644
--- a/src/libnix/expr.cc
+++ b/src/libnix/expr.cc
@@ -6,13 +6,21 @@
string printTerm(ATerm t)
{
char * s = ATwriteToString(t);
+ if (!s) throw Error("cannot print term");
return s;
}
Error badTerm(const format & f, ATerm t)
{
- return Error(format("%1%, in `%2%'") % f.str() % printTerm(t));
+ char * s = ATwriteToString(t);
+ if (!s) throw Error("cannot print term");
+ if (strlen(s) > 1000) {
+ int len;
+ s = ATwriteToSharedString(t, &len);
+ if (!s) throw Error("cannot print term");
+ }
+ return Error(format("%1%, in `%2%'") % f.str() % (string) s);
}