Merge branch 'master' into v2.1

This commit is contained in:
Mike Pall 2013-03-04 13:34:01 +01:00
commit b2edd5cf28

View File

@ -17,6 +17,7 @@
#include "lualib.h" #include "lualib.h"
#include "lj_obj.h" #include "lj_obj.h"
#include "lj_gc.h"
#include "lj_err.h" #include "lj_err.h"
#include "lj_buf.h" #include "lj_buf.h"
#include "lj_str.h" #include "lj_str.h"
@ -153,6 +154,7 @@ static int io_file_readline(lua_State *L, FILE *fp, MSize chop)
if (n >= m - 64) m += m; if (n >= m - 64) m += m;
} }
setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n));
lj_gc_check(L);
return (int)ok; return (int)ok;
} }
@ -164,6 +166,7 @@ static void io_file_readall(lua_State *L, FILE *fp)
n += (MSize)fread(buf+n, 1, m-n, fp); n += (MSize)fread(buf+n, 1, m-n, fp);
if (n != m) { if (n != m) {
setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n));
lj_gc_check(L);
return; return;
} }
} }
@ -175,6 +178,7 @@ static int io_file_readlen(lua_State *L, FILE *fp, MSize m)
char *buf = lj_buf_tmp(L, m); char *buf = lj_buf_tmp(L, m);
MSize n = (MSize)fread(buf, 1, m, fp); MSize n = (MSize)fread(buf, 1, m, fp);
setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n));
lj_gc_check(L);
return (n > 0 || m == 0); return (n > 0 || m == 0);
} else { } else {
int c = getc(fp); int c = getc(fp);