diff options
Diffstat (limited to 'src/FbTk/Luamm.cc')
-rw-r--r-- | src/FbTk/Luamm.cc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/FbTk/Luamm.cc b/src/FbTk/Luamm.cc index 3de86db..c4ea2e0 100644 --- a/src/FbTk/Luamm.cc +++ b/src/FbTk/Luamm.cc | |||
@@ -145,6 +145,19 @@ namespace lua { | |||
145 | return r ? 3 : 1; | 145 | return r ? 3 : 1; |
146 | } | 146 | } |
147 | 147 | ||
148 | struct reader_data { | ||
149 | const void *s; | ||
150 | size_t len; | ||
151 | }; | ||
152 | |||
153 | const char *string_reader(lua_State *, void *data, size_t *size) | ||
154 | { | ||
155 | reader_data *d = static_cast<reader_data *>(data); | ||
156 | *size = d->len; | ||
157 | d->len = 0; | ||
158 | return static_cast<const char *>(d->s); | ||
159 | } | ||
160 | |||
148 | } | 161 | } |
149 | 162 | ||
150 | std::string exception::get_error_msg(state *L) | 163 | std::string exception::get_error_msg(state *L) |
@@ -336,9 +349,13 @@ namespace lua { | |||
336 | } | 349 | } |
337 | } | 350 | } |
338 | 351 | ||
339 | void state::loadstring(const char *s) throw(lua::syntax_error, std::bad_alloc) | 352 | void |
353 | state::loadstring(const char *s, size_t len, const char *chunkname) | ||
354 | throw(lua::syntax_error, std::bad_alloc) | ||
340 | { | 355 | { |
341 | switch(luaL_loadstring(cobj, s)) { | 356 | reader_data data = { s, len }; |
357 | |||
358 | switch(lua_load(cobj, string_reader, &data, chunkname)) { | ||
342 | case 0: | 359 | case 0: |
343 | return; | 360 | return; |
344 | case LUA_ERRSYNTAX: | 361 | case LUA_ERRSYNTAX: |