summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2007-08-07 15:00:13 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2007-08-07 15:00:13 +0000
commitd71cc503a6f50f8c576eb8665ce3cf08d74e035b (patch)
treecfc26dcfff6c006ba76d715e8018428b1e66feac /src
parent4cad125e088576035ea8f7955d7770278aa6ed24 (diff)
downloadguix-d71cc503a6f50f8c576eb8665ce3cf08d74e035b.tar.gz
* Don't allocate input files on the stack.
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/parser.y16
1 files changed, 2 insertions, 14 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index 1c06240fda..82b24cd073 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -383,20 +383,8 @@ Expr parseExprFromFile(EvalState & state, Path path)
     if (S_ISDIR(st.st_mode))
         path = canonPath(path + "/default.nix");
 
-    /* Read the input file.  We can't use SGparseFile() because it's
-       broken, so we read the input ourselves and call
-       SGparseString(). */
-    AutoCloseFD fd = open(path.c_str(), O_RDONLY);
-    if (fd == -1) throw SysError(format("opening `%1%'") % path);
-
-    if (fstat(fd, &st) == -1)
-        throw SysError(format("statting `%1%'") % path);
-
-    char text[st.st_size + 1];
-    readFull(fd, (unsigned char *) text, st.st_size);
-    text[st.st_size] = 0;
-
-    return parse(state, text, path, dirOf(path));
+    /* Read and parse the input file. */
+    return parse(state, readFile(path).c_str(), path, dirOf(path));
 }