Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

lua print fixed

git-svn-id: https://svn.opensource.yandex.net/xscript/trunk@729 b01ef89b-65f2-463d-9415-e8412542ae63
  • Loading branch information...
commit aa668c5ecd20fdea223eec0be03cd5377eec9fb1 1 parent 3e7e9b7
golubtsov authored
View
7 debian/changelog
@@ -1,3 +1,10 @@
+xscript (5.53-2) unstable; urgency=low
+
+ * lua print fixed
+ * added empty lua node to result in case of empty lua code
+
+ -- Ilya Golubtsov (Ilya) <golubtsov@yandex-team.ru> Fri, 30 Jan 2009 11:29:08 +0300
+
xscript (5.53-1) unstable; urgency=low
* set_state_domain fixed
View
6 lua-block/test_lua.cpp
@@ -90,7 +90,7 @@ LuaTest::testPrint() {
CPPUNIT_ASSERT(NULL != doc.get());
CPPUNIT_ASSERT(XmlUtils::xpathExists(doc.get(), "/page/lua"));
CPPUNIT_ASSERT_EQUAL(
- std::string("Hello\n&nbsp;\nWorld!\n"),
+ std::string("Hello\n&nbsp;\nWorld!"),
XmlUtils::xpathValue(doc.get(), "/page/lua", "Bye")
);
}
@@ -293,7 +293,7 @@ LuaTest::testEncode() {
CPPUNIT_ASSERT(NULL != doc.get());
CPPUNIT_ASSERT(XmlUtils::xpathExists(doc.get(), "/page/lua"));
CPPUNIT_ASSERT_EQUAL(
- std::string("%CF%F0%E5%E2%E5%E4\nПревед\n%D0%9F%D1%80%D0%B5%D0%B2%D0%B5%D0%B4\nПревед\n"),
+ std::string("%CF%F0%E5%E2%E5%E4\nПревед\n%D0%9F%D1%80%D0%B5%D0%B2%D0%B5%D0%B4\nПревед"),
XmlUtils::xpathValue(doc.get(), "/page/lua", "Bye")
);
}
@@ -385,7 +385,7 @@ LuaTest::testMD5() {
CPPUNIT_ASSERT(NULL != doc.get());
CPPUNIT_ASSERT(XmlUtils::xpathExists(doc.get(), "/page/lua"));
CPPUNIT_ASSERT_EQUAL(
- std::string("5946210c9e93ae37891dfe96c3e39614\n"),
+ std::string("5946210c9e93ae37891dfe96c3e39614"),
XmlUtils::xpathValue(doc.get(), "/page/lua", "foo")
);
}
View
13 lua-block/xscript_methods.cpp
@@ -41,6 +41,7 @@ static int luaPrint (lua_State *lua) {
//std::string* buf = output_buffer_.get();
lua_getglobal(lua, "tostring");
+ std::string local_buf;
for (i=1; i<=n; i++) {
const char *s;
lua_pushvalue(lua, -1); /* function to be called */
@@ -50,11 +51,17 @@ static int luaPrint (lua_State *lua) {
if (s == NULL)
return luaL_error(lua, LUA_QL("tostring") " must return a string to "
LUA_QL("print"));
- if (i>1) buf->append("\t");
- buf->append(s);
+ if (i>1) local_buf.push_back('\t');
+ local_buf.append(s);
lua_pop(lua, 1); /* pop result */
}
- buf->append("\n");
+ if (local_buf.empty()) {
+ buf->push_back('\n');
+ }
+ else {
+ if (!buf->empty()) buf->push_back('\n');
+ buf->append(local_buf);
+ }
}
catch (const std::exception &e) {
log()->error("caught exception in [xscript:print]: %s", e.what());

0 comments on commit aa668c5

Please sign in to comment.
Something went wrong with that request. Please try again.