Skip to content
Snippets Groups Projects
Commit f446611e authored by Luigi Scarso's avatar Luigi Scarso
Browse files

clean up -- !!! WARNING: WORK IN PROGRESS !!!

parent 6fadd64a
No related branches found
No related tags found
No related merge requests found
......@@ -181,12 +181,10 @@ static int read2dot14(lua_State *L) {
FILE *f = tofile(L);
int a = getc(f);
int b = getc(f);
int c = getc(f);
int d = getc(f);
if (d == EOF) {
if (b == EOF) {
lua_pushnil(L);
} else {
int n = (0x1000000 * a + 0x10000 * b + 0x100 * c + d);
int n = 0x100 * a + b ;
lua_pushnumber(L, (n >> 14) + ((n & 0x3fff) / 16384.0));
}
return 1;
......@@ -377,12 +375,7 @@ static const luaL_Reg fiolib[] = {
{NULL, NULL}
};
int luaopen_fio(lua_State *L) {
luaL_register(L, "fio", fiolib);
#if defined(_MSC_VER)
return luaopen_io(L);
#else
return 1;
#endif /* _MSC_VER */
luaL_register(L, "fio", fiolib);
return 1;
}
/* lstrlibext.c
Copyright 2012 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
......@@ -92,7 +92,7 @@ static int str_split (lua_State *L) {
}
free(orig);
return 1;
}
}
static int characters_aux (lua_State *L) {
size_t ls;
......@@ -152,7 +152,7 @@ static int utfcharacters_aux (lua_State *L) {
}
}
return utf_failed(L,ind+1); /* we found a follow byte! */
}
}
static int str_utfcharacters (lua_State *L) {
......@@ -180,7 +180,7 @@ static int utfvalues_aux (lua_State *L) {
if (i<0x80) {
v = i;
} else if (i>=0xF0) {
if ((ind+3)<(int)ls && ((unsigned)*(s+ind+1))>=0x80
if ((ind+3)<(int)ls && ((unsigned)*(s+ind+1))>=0x80
&& ((unsigned)*(s+ind+2))>=0x80 && ((unsigned)*(s+ind+3))>=0x80) {
numbytes = 4;
j = ((unsigned)*(s+ind+1))-128;
......@@ -237,7 +237,7 @@ static int characterpairs_aux (lua_State *L) {
b[0] = *(s+ind); b[1] = 0;
lua_pushlstring(L, b, 1);
if (ind+1<(int)ls) {
b[0] = *(s+ind+1);
b[0] = *(s+ind+1);
lua_pushlstring(L, b, 1);
} else {
lua_pushlstring(L, b+1, 0);
......@@ -350,7 +350,17 @@ static int str_dump (lua_State *L) {
return 1;
}
static int str_bytetable (lua_State *L) {
size_t l;
int i;
const char *s = luaL_checklstring(L, 1, &l);
lua_createtable(L,l,0);
for (i=0;i<l;i++) {
lua_pushinteger(L,(unsigned char)*(s+i));
lua_rawseti(L,-2,i+1);
}
return 1;
}
static const luaL_Reg strlibext[] = {
{"utfvalues", str_utfvalues},
......@@ -359,6 +369,7 @@ static const luaL_Reg strlibext[] = {
{"characterpairs", str_characterpairs},
{"bytes", str_bytes},
{"bytepairs", str_bytepairs},
{"bytetable", str_bytetable},
{"explode", str_split},
{"dump", str_dump},
{NULL, NULL}
......@@ -374,4 +385,3 @@ void open_strlibext(lua_State * L)
}
lua_pop(L,1);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment