still no json
This commit is contained in:
Binary file not shown.
+1
-1
@@ -16,7 +16,7 @@ mkdir bin/assets > /dev/null 2>&1
|
|||||||
mkdir work > /dev/null 2>&1
|
mkdir work > /dev/null 2>&1
|
||||||
|
|
||||||
COMPILER="clang++"
|
COMPILER="clang++"
|
||||||
FLAGS="-g -w -Wall -$OPT_FLAG -std=c++17 -fpermissive -ffast-math"
|
FLAGS="-g -rdynamic -w -Wall -$OPT_FLAG -std=c++17 -fpermissive -ffast-math"
|
||||||
|
|
||||||
LIBS="-ldl -lm -lpthread "
|
LIBS="-ldl -lm -lpthread "
|
||||||
SRCFLAGS="-D EXEC_NAME=\"$GF\" -D PLATFORM_NAME=\"linux\""
|
SRCFLAGS="-D EXEC_NAME=\"$GF\" -D PLATFORM_NAME=\"linux\""
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ OPT_FLAG="O0"
|
|||||||
|
|
||||||
COMPILER="clang++"
|
COMPILER="clang++"
|
||||||
#COMPILER="g++"
|
#COMPILER="g++"
|
||||||
FLAGS="-shared -w -Wall -$OPT_FLAG -std=c++17 -fpermissive -ffast-math -fPIC"
|
FLAGS="-shared -g -rdynamic -w -Wall -$OPT_FLAG -std=c++17 -fpermissive -ffast-math -fPIC"
|
||||||
|
|
||||||
LIBS="-ldl -lm -lpthread "
|
LIBS="-ldl -lm -lpthread "
|
||||||
SRCFLAGS="-D PLATFORM_NAME=\"linux\""
|
SRCFLAGS="-D PLATFORM_NAME=\"linux\""
|
||||||
|
|||||||
+16
-15
@@ -201,34 +201,34 @@ string json_decode_string(string s, u32& i)
|
|||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
case('t'):
|
case('t'):
|
||||||
result.append('\t', 1);
|
result.append(1, '\t');
|
||||||
break;
|
break;
|
||||||
case('n'):
|
case('n'):
|
||||||
result.append('\n', 1);
|
result.append(1, '\n');
|
||||||
break;
|
break;
|
||||||
case('r'):
|
case('r'):
|
||||||
result.append('\r', 1);
|
result.append(1, '\r');
|
||||||
break;
|
break;
|
||||||
case('\\'):
|
case('\\'):
|
||||||
result.append('\\', 1);
|
result.append(1, '\\');
|
||||||
break;
|
break;
|
||||||
case('b'):
|
case('b'):
|
||||||
result.append('\b', 1);
|
result.append(1, '\b');
|
||||||
break;
|
break;
|
||||||
case('f'):
|
case('f'):
|
||||||
result.append('\f', 1);
|
result.append(1, '\f');
|
||||||
break;
|
break;
|
||||||
case('u'):
|
case('u'):
|
||||||
// todo decode
|
// todo decode
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result.append(c, 1);
|
result.append(1, c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result.append(c, 1);
|
result.append(1, c);
|
||||||
}
|
}
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
@@ -252,7 +252,7 @@ string json_decode_keyword(string s, u32& i)
|
|||||||
char c = s[i];
|
char c = s[i];
|
||||||
if(isalnum(c))
|
if(isalnum(c))
|
||||||
{
|
{
|
||||||
result.append(c, 1);
|
result.append(1, c);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -272,7 +272,7 @@ string json_decode_number(string s, u32& i)
|
|||||||
char c = s[i];
|
char c = s[i];
|
||||||
if(isdigit(c) || c == '.')
|
if(isdigit(c) || c == '.')
|
||||||
{
|
{
|
||||||
result.append(c, 1);
|
result.append(1, c);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -289,9 +289,6 @@ DTree json_decode_value(string s, u32& i)
|
|||||||
string value = "";
|
string value = "";
|
||||||
json_consume_space(s, i);
|
json_consume_space(s, i);
|
||||||
char c = s[i];
|
char c = s[i];
|
||||||
result.set("CHAR_");
|
|
||||||
result._string.append(to_string(c));
|
|
||||||
return(result);
|
|
||||||
if(c == '"') // string value
|
if(c == '"') // string value
|
||||||
{
|
{
|
||||||
result.type = 'S';
|
result.type = 'S';
|
||||||
@@ -329,9 +326,9 @@ DTree json_decode_map(string s, u32& i)
|
|||||||
{
|
{
|
||||||
DTree result;
|
DTree result;
|
||||||
string key = "";
|
string key = "";
|
||||||
|
json_consume_space(s, i);
|
||||||
while(i < s.length())
|
while(i < s.length())
|
||||||
{
|
{
|
||||||
json_consume_space(s, i);
|
|
||||||
char c = s[i];
|
char c = s[i];
|
||||||
if(c == '}')
|
if(c == '}')
|
||||||
{
|
{
|
||||||
@@ -348,7 +345,10 @@ DTree json_decode_map(string s, u32& i)
|
|||||||
json_consume_space(s, i);
|
json_consume_space(s, i);
|
||||||
if(s[i] != ':')
|
if(s[i] != ':')
|
||||||
return(result); // malformed
|
return(result); // malformed
|
||||||
result[key] = json_decode_value(s, i);
|
//result[key] = json_decode_value(s, i);
|
||||||
|
printf("%s\n", key.c_str());
|
||||||
|
i += 1;
|
||||||
|
json_consume_space(s, i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -356,6 +356,7 @@ DTree json_decode_map(string s, u32& i)
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
i += 1;
|
i += 1;
|
||||||
|
json_consume_space(s, i);
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,3 +148,19 @@ string expand_path(string path)
|
|||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <execinfo.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
void on_segfault(int sig) {
|
||||||
|
void *array[10];
|
||||||
|
size_t size;
|
||||||
|
|
||||||
|
// get void*'s for all entries on the stack
|
||||||
|
size = backtrace(array, 10);
|
||||||
|
|
||||||
|
// print out all the frames to stderr
|
||||||
|
fprintf(stderr, "SEG FAULT: %d:\n", sig);
|
||||||
|
backtrace_symbols_fd(array, size, STDERR_FILENO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,5 +14,6 @@ Request* context;
|
|||||||
extern "C" void set_current_request(Request* _request)
|
extern "C" void set_current_request(Request* _request)
|
||||||
{
|
{
|
||||||
context = _request;
|
context = _request;
|
||||||
|
signal(SIGSEGV, on_segfault);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ FastCGIServer server;
|
|||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
signal(SIGSEGV, on_segfault);
|
||||||
srand(time());
|
srand(time());
|
||||||
|
|
||||||
// Set up our request handlers
|
// Set up our request handlers
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ RENDER()
|
|||||||
Parsed:
|
Parsed:
|
||||||
|
|
||||||
<pre><?
|
<pre><?
|
||||||
echo(var_dump(json_decode("1")));
|
echo(var_dump(json_decode("{\"abc\": \"valueA\"}")));
|
||||||
?></pre>
|
?></pre>
|
||||||
|
|
||||||
Params
|
Params
|
||||||
|
|||||||
Reference in New Issue
Block a user