mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
Fix some broken builds and broken hearts
This commit is contained in:
parent
c0b325bafa
commit
331fdd1d29
2 changed files with 19 additions and 8 deletions
|
@ -16,7 +16,9 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/thread/thread.h"
|
||||
|
||||
|
@ -36,3 +38,9 @@ TEST(pthread_key_create, testRunsDtors_becauseNoLeakReport) {
|
|||
EXPECT_EQ(0, pthread_setspecific(key, x));
|
||||
EXPECT_EQ(x, pthread_getspecific(key));
|
||||
}
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
if (IsTiny()) {
|
||||
__enable_tls();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,11 +18,13 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/likely.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/str/tpenc.h"
|
||||
#include "libc/str/utf16.h"
|
||||
#include "third_party/double-conversion/wrapper.h"
|
||||
#include "third_party/lua/lauxlib.h"
|
||||
#include "third_party/lua/ltests.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
|
||||
struct Rc {
|
||||
|
@ -56,8 +58,8 @@ static struct Rc Parse(struct lua_State *L, const char *p, const char *e) {
|
|||
|
||||
case ':': // present only in object after key
|
||||
if (LUA_TSTRING != lua_type(L, -1)) {
|
||||
luaL_error(L, "unexpected ':'\n");
|
||||
return (struct Rc){-1, p};
|
||||
luaL_error(L, "unexpected ':'\n");
|
||||
return (struct Rc){-1, p};
|
||||
}
|
||||
a = p;
|
||||
break;
|
||||
|
@ -128,7 +130,7 @@ static struct Rc Parse(struct lua_State *L, const char *p, const char *e) {
|
|||
lua_rawseti(L, -2, i++ + 1);
|
||||
}
|
||||
} while (r.t);
|
||||
if (*(p-1) != ']') {
|
||||
if (*(p - 1) != ']') {
|
||||
luaL_error(L, "invalid list\n");
|
||||
return (struct Rc){-1, p};
|
||||
}
|
||||
|
@ -146,9 +148,9 @@ static struct Rc Parse(struct lua_State *L, const char *p, const char *e) {
|
|||
p = r.p;
|
||||
if (r.t) {
|
||||
if (LUA_TSTRING != lua_type(L, -1)) {
|
||||
/* json keys can only be strings */
|
||||
lua_settop(L, -2);
|
||||
break;
|
||||
/* json keys can only be strings */
|
||||
lua_settop(L, -2);
|
||||
break;
|
||||
}
|
||||
r = Parse(L, p, e);
|
||||
p = r.p;
|
||||
|
@ -168,7 +170,7 @@ static struct Rc Parse(struct lua_State *L, const char *p, const char *e) {
|
|||
lua_pushboolean(L, true);
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
if (*(p-1) != '}') {
|
||||
if (*(p - 1) != '}') {
|
||||
luaL_error(L, "invalid object\n");
|
||||
return (struct Rc){-1, p};
|
||||
}
|
||||
|
@ -314,5 +316,6 @@ static struct Rc Parse(struct lua_State *L, const char *p, const char *e) {
|
|||
*/
|
||||
int DecodeJson(struct lua_State *L, const char *p, size_t n) {
|
||||
if (n == -1) n = p ? strlen(p) : 0;
|
||||
lua_checkstack(L, 128);
|
||||
return Parse(L, p, p + n).t;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue