diff Core/Lua/LuaContext.cpp @ 1465:905842836ad4

sample Lua script to write DICOM series to disk
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 27 Jul 2015 17:33:47 +0200
parents 3f7722179467
children f967bdf8534e
line wrap: on
line diff
--- a/Core/Lua/LuaContext.cpp	Fri Jul 03 10:03:40 2015 +0200
+++ b/Core/Lua/LuaContext.cpp	Mon Jul 27 17:33:47 2015 +0200
@@ -137,7 +137,7 @@
 
     Json::FastWriter writer;
     std::string s = writer.write(json);
-    lua_pushstring(state, s.c_str());
+    lua_pushlstring(state, s.c_str(), s.size());
 
     return 1;
   }
@@ -181,7 +181,7 @@
     }
 
     // Return the result of the HTTP request
-    lua_pushstring(state, str.c_str());
+    lua_pushlstring(state, str.c_str(), str.size());
 
     return true;
   }
@@ -307,7 +307,8 @@
   {
     if (value.isString())
     {
-      lua_pushstring(lua_, value.asCString());
+      const std::string s = value.asString();
+      lua_pushlstring(lua_, s.c_str(), s.size());
     }
     else if (value.isDouble())
     {
@@ -356,7 +357,7 @@
              it = members.begin(); it != members.end(); ++it)
       {
         // Push the index of the cell
-        lua_pushstring(lua_, it->c_str());
+        lua_pushlstring(lua_, it->c_str(), it->size());
 
         // Push the value of the cell
         PushJson(value[*it]);