aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/ldo.c b/ldo.c
index a0e00229..e9f91384 100644
--- a/ldo.c
+++ b/ldo.c
@@ -977,7 +977,7 @@ struct SParser { /* data to 'f_parser' */
977 977
978 978
979static void checkmode (lua_State *L, const char *mode, const char *x) { 979static void checkmode (lua_State *L, const char *mode, const char *x) {
980 if (mode && strchr(mode, x[0]) == NULL) { 980 if (strchr(mode, x[0]) == NULL) {
981 luaO_pushfstring(L, 981 luaO_pushfstring(L,
982 "attempt to load a %s chunk (mode is '%s')", x, mode); 982 "attempt to load a %s chunk (mode is '%s')", x, mode);
983 luaD_throw(L, LUA_ERRSYNTAX); 983 luaD_throw(L, LUA_ERRSYNTAX);
@@ -988,13 +988,18 @@ static void checkmode (lua_State *L, const char *mode, const char *x) {
988static void f_parser (lua_State *L, void *ud) { 988static void f_parser (lua_State *L, void *ud) {
989 LClosure *cl; 989 LClosure *cl;
990 struct SParser *p = cast(struct SParser *, ud); 990 struct SParser *p = cast(struct SParser *, ud);
991 const char *mode = p->mode ? p->mode : "bt";
991 int c = zgetc(p->z); /* read first character */ 992 int c = zgetc(p->z); /* read first character */
992 if (c == LUA_SIGNATURE[0]) { 993 if (c == LUA_SIGNATURE[0]) {
993 checkmode(L, p->mode, "binary"); 994 int fixed = 0;
994 cl = luaU_undump(L, p->z, p->name); 995 if (strchr(mode, 'B') != NULL)
996 fixed = 1;
997 else
998 checkmode(L, mode, "binary");
999 cl = luaU_undump(L, p->z, p->name, fixed);
995 } 1000 }
996 else { 1001 else {
997 checkmode(L, p->mode, "text"); 1002 checkmode(L, mode, "text");
998 cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c); 1003 cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c);
999 } 1004 }
1000 lua_assert(cl->nupvalues == cl->p->sizeupvalues); 1005 lua_assert(cl->nupvalues == cl->p->sizeupvalues);