mirror of
https://github.com/janet-lang/janet
synced 2024-11-24 17:27:18 +00:00
Update Makefile, json native module,
and test suite 2.
This commit is contained in:
parent
f41dab8f6c
commit
e8a4e83a0d
4
Makefile
4
Makefile
@ -28,10 +28,6 @@ INCLUDEDIR=$(PREFIX)/include/janet
|
|||||||
LIBDIR=$(PREFIX)/lib
|
LIBDIR=$(PREFIX)/lib
|
||||||
BINDIR=$(PREFIX)/bin
|
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 -g
|
||||||
CFLAGS=-std=c99 -Wall -Wextra -Isrc/include -fpic -O2 -fvisibility=hidden
|
CFLAGS=-std=c99 -Wall -Wextra -Isrc/include -fpic -O2 -fvisibility=hidden
|
||||||
CLIBS=-lm -ldl
|
CLIBS=-lm -ldl
|
||||||
|
@ -57,7 +57,7 @@ static int hexdig(char dig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read the hex value for a unicode escape */
|
/* 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])
|
if (!p[0] || !p[1] || !p[2] || !p[3])
|
||||||
return "unexpected end of source";
|
return "unexpected end of source";
|
||||||
int d1 = hexdig(p[0]);
|
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
|
/* Parse a string. Also handles the conversion of utf-16 to
|
||||||
* utf-8. */
|
* 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);
|
JanetBuffer *buffer = janet_buffer(0);
|
||||||
const char *cp = *p;
|
const char *cp = *p;
|
||||||
while (*cp != '"') {
|
while (*cp != '"') {
|
||||||
@ -353,9 +353,12 @@ typedef struct {
|
|||||||
static const char *encode_newline(Encoder *e) {
|
static const char *encode_newline(Encoder *e) {
|
||||||
if (janet_buffer_push_bytes(e->buffer, e->newline, e->newlinelen))
|
if (janet_buffer_push_bytes(e->buffer, e->newline, e->newlinelen))
|
||||||
return "buffer overflow";
|
return "buffer overflow";
|
||||||
|
/* Skip loop if no tab string */
|
||||||
|
if (e->tablen) {
|
||||||
for (int32_t i = 0; i < e->indent; i++)
|
for (int32_t i = 0; i < e->indent; i++)
|
||||||
if (janet_buffer_push_bytes(e->buffer, e->tab, e->tablen))
|
if (janet_buffer_push_bytes(e->buffer, e->tab, e->tablen))
|
||||||
return "buffer overflow";
|
return "buffer overflow";
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +71,8 @@
|
|||||||
(assert (= (string.join @[] "hi") "") "string.join 4")
|
(assert (= (string.join @[] "hi") "") "string.join 4")
|
||||||
(assert (deep= (string.split "," "one,two,three") @["one" "two" "three"]) "string.split 1")
|
(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.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)
|
(end-suite)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user