1
0
mirror of https://github.com/janet-lang/janet synced 2024-06-25 22:53:16 +00:00

Update Makefile, json native module,

and test suite 2.
This commit is contained in:
Calvin Rose 2018-10-04 17:25:46 -04:00
parent f41dab8f6c
commit e8a4e83a0d
3 changed files with 10 additions and 9 deletions

View File

@ -28,10 +28,6 @@ INCLUDEDIR=$(PREFIX)/include/janet
LIBDIR=$(PREFIX)/lib
BINDIR=$(PREFIX)/bin
# CFLAGS=-std=c99 -Wall -Wextra -Isrc/include -Wl,--dynamic-list=src/exported.list -s -O3
# TODO - when api is finalized, only export public symbols instead of using rdynamic
# which exports all symbols. Saves a few KB in binary.
#CFLAGS=-std=c99 -Wall -Wextra -Isrc/include -fpic -g
CFLAGS=-std=c99 -Wall -Wextra -Isrc/include -fpic -O2 -fvisibility=hidden
CLIBS=-lm -ldl

View File

@ -57,7 +57,7 @@ static int hexdig(char dig) {
}
/* Read the hex value for a unicode escape */
static char *decode_utf16_escape(const char *p, uint32_t *outpoint) {
static const char *decode_utf16_escape(const char *p, uint32_t *outpoint) {
if (!p[0] || !p[1] || !p[2] || !p[3])
return "unexpected end of source";
int d1 = hexdig(p[0]);
@ -72,7 +72,7 @@ static char *decode_utf16_escape(const char *p, uint32_t *outpoint) {
/* Parse a string. Also handles the conversion of utf-16 to
* utf-8. */
const char *decode_string(const char **p, Janet *out) {
static const char *decode_string(const char **p, Janet *out) {
JanetBuffer *buffer = janet_buffer(0);
const char *cp = *p;
while (*cp != '"') {
@ -353,9 +353,12 @@ typedef struct {
static const char *encode_newline(Encoder *e) {
if (janet_buffer_push_bytes(e->buffer, e->newline, e->newlinelen))
return "buffer overflow";
for (int32_t i = 0; i < e->indent; i++)
if (janet_buffer_push_bytes(e->buffer, e->tab, e->tablen))
return "buffer overflow";
/* Skip loop if no tab string */
if (e->tablen) {
for (int32_t i = 0; i < e->indent; i++)
if (janet_buffer_push_bytes(e->buffer, e->tab, e->tablen))
return "buffer overflow";
}
return NULL;
}

View File

@ -71,6 +71,8 @@
(assert (= (string.join @[] "hi") "") "string.join 4")
(assert (deep= (string.split "," "one,two,three") @["one" "two" "three"]) "string.split 1")
(assert (deep= (string.split "," "onetwothree") @["onetwothree"]) "string.split 2")
(assert (deep= (string.find-all "e" "onetwothree") @[2 9 10]) "string.find-all 1")
(assert (deep= (string.find-all "," "onetwothree") @[]) "string.find-all 2")
(end-suite)