still no json
This commit is contained in:
parent
80093190d4
commit
3749077413
Binary file not shown.
@ -16,7 +16,7 @@ mkdir bin/assets > /dev/null 2>&1
|
||||
mkdir work > /dev/null 2>&1
|
||||
|
||||
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 "
|
||||
SRCFLAGS="-D EXEC_NAME=\"$GF\" -D PLATFORM_NAME=\"linux\""
|
||||
|
||||
@ -24,7 +24,7 @@ OPT_FLAG="O0"
|
||||
|
||||
COMPILER="clang++"
|
||||
#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 "
|
||||
SRCFLAGS="-D PLATFORM_NAME=\"linux\""
|
||||
|
||||
@ -201,34 +201,34 @@ string json_decode_string(string s, u32& i)
|
||||
switch(c)
|
||||
{
|
||||
case('t'):
|
||||
result.append('\t', 1);
|
||||
result.append(1, '\t');
|
||||
break;
|
||||
case('n'):
|
||||
result.append('\n', 1);
|
||||
result.append(1, '\n');
|
||||
break;
|
||||
case('r'):
|
||||
result.append('\r', 1);
|
||||
result.append(1, '\r');
|
||||
break;
|
||||
case('\\'):
|
||||
result.append('\\', 1);
|
||||
result.append(1, '\\');
|
||||
break;
|
||||
case('b'):
|
||||
result.append('\b', 1);
|
||||
result.append(1, '\b');
|
||||
break;
|
||||
case('f'):
|
||||
result.append('\f', 1);
|
||||
result.append(1, '\f');
|
||||
break;
|
||||
case('u'):
|
||||
// todo decode
|
||||
break;
|
||||
default:
|
||||
result.append(c, 1);
|
||||
result.append(1, c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append(c, 1);
|
||||
result.append(1, c);
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
@ -252,7 +252,7 @@ string json_decode_keyword(string s, u32& i)
|
||||
char c = s[i];
|
||||
if(isalnum(c))
|
||||
{
|
||||
result.append(c, 1);
|
||||
result.append(1, c);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -272,7 +272,7 @@ string json_decode_number(string s, u32& i)
|
||||
char c = s[i];
|
||||
if(isdigit(c) || c == '.')
|
||||
{
|
||||
result.append(c, 1);
|
||||
result.append(1, c);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -289,9 +289,6 @@ DTree json_decode_value(string s, u32& i)
|
||||
string value = "";
|
||||
json_consume_space(s, i);
|
||||
char c = s[i];
|
||||
result.set("CHAR_");
|
||||
result._string.append(to_string(c));
|
||||
return(result);
|
||||
if(c == '"') // string value
|
||||
{
|
||||
result.type = 'S';
|
||||
@ -329,9 +326,9 @@ DTree json_decode_map(string s, u32& i)
|
||||
{
|
||||
DTree result;
|
||||
string key = "";
|
||||
json_consume_space(s, i);
|
||||
while(i < s.length())
|
||||
{
|
||||
json_consume_space(s, i);
|
||||
char c = s[i];
|
||||
if(c == '}')
|
||||
{
|
||||
@ -348,7 +345,10 @@ DTree json_decode_map(string s, u32& i)
|
||||
json_consume_space(s, i);
|
||||
if(s[i] != ':')
|
||||
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
|
||||
{
|
||||
@ -356,6 +356,7 @@ DTree json_decode_map(string s, u32& i)
|
||||
return(result);
|
||||
}
|
||||
i += 1;
|
||||
json_consume_space(s, i);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
@ -148,3 +148,19 @@ string expand_path(string path)
|
||||
}
|
||||
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)
|
||||
{
|
||||
context = _request;
|
||||
signal(SIGSEGV, on_segfault);
|
||||
}
|
||||
|
||||
|
||||
@ -89,6 +89,7 @@ FastCGIServer server;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
signal(SIGSEGV, on_segfault);
|
||||
srand(time());
|
||||
|
||||
// Set up our request handlers
|
||||
|
||||
@ -34,7 +34,7 @@ RENDER()
|
||||
Parsed:
|
||||
|
||||
<pre><?
|
||||
echo(var_dump(json_decode("1")));
|
||||
echo(var_dump(json_decode("{\"abc\": \"valueA\"}")));
|
||||
?></pre>
|
||||
|
||||
Params
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user