summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-10-29 09:20:42 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-10-29 10:28:12 +0100
commitb8fa5abe491939fcbbf641188a37671631768cad (patch)
tree8970ba30d92a704a6e53537e64225e6fdacb8064 /crawl-ref
parent84b73c76a3ef163f74823af3b791fe3830236931 (diff)
downloadcrawl-ref-b8fa5abe491939fcbbf641188a37671631768cad.tar.gz
crawl-ref-b8fa5abe491939fcbbf641188a37671631768cad.zip
Fix handling of empty input lines.
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/luaterp.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/crawl-ref/source/luaterp.cc b/crawl-ref/source/luaterp.cc
index 1b60e1d013..8eeae9fe39 100644
--- a/crawl-ref/source/luaterp.cc
+++ b/crawl-ref/source/luaterp.cc
@@ -45,12 +45,12 @@ static int _pushline(lua_State *ls, int firstline)
if (cancelable_get_line_autohist(buffer, sizeof(buffer)))
return (0);
l = strlen(b);
- if (l == 0)
- return (1);
+ // XXX: get line doesn't return newline?
if (l > 0 && b[l-1] == '\n') // line ends with newline?
b[l-1] = '\0'; // remove it
- if (firstline && b[0] == '=') // first line starts with `=' ?
+
+ if (firstline && l > 0 && b[0] == '=') // first line starts with `=' ?
lua_pushfstring(ls, "return %s", b+1); // change it to `return'
else
lua_pushstring(ls, b);