From fa6c8990ff1cd60c5e574a7b520dd33f912455d4 Mon Sep 17 00:00:00 2001 From: Geoff Langdale Date: Wed, 26 Sep 2018 13:20:08 +1000 Subject: [PATCH] Added a terrifying hack to append a idx-to-0-char to stage 2 output. --- src/stage34_unified.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/stage34_unified.cpp b/src/stage34_unified.cpp index ee0b69c3b..2bba58fbb 100644 --- a/src/stage34_unified.cpp +++ b/src/stage34_unified.cpp @@ -13,7 +13,7 @@ #include "jsonparser/simdjson_internal.h" #include -//#define DEBUG +#define DEBUG #define PATH_SEP '/' #if defined(DEBUG) && !defined(DEBUG_PRINTF) @@ -592,6 +592,14 @@ bool unified_machine(const u8 *buf, UNUSED size_t len, ParsedJson &pj) { pj.init(); + // add a sentinel to the end to avoid premature exit + // need to be able to find the \0 at the 'padded length' end of the buffer + // FIXME: TERRIFYING! + size_t j; + for (j = len; buf[j] != 0; j++) + ; + pj.structural_indexes[pj.n_structural_indexes++] = j; + #define UPDATE_CHAR() { idx = pj.structural_indexes[i++]; c = buf[idx]; DEBUG_PRINTF("Got %c at %d (%d offset)\n", c, idx, i-1);} #define OPEN_SCOPE() { \ @@ -610,8 +618,6 @@ bool unified_machine(const u8 *buf, UNUSED size_t len, ParsedJson &pj) { goto SITE_LABEL; \ } - // TODO: add a sentinel to the end to avoid premature exit - // need to be able to find the \0 at the 'padded length' end of the buffer ////////////////////////////// START STATE ///////////////////////////// @@ -827,12 +833,11 @@ array_continue: succeed: DEBUG_PRINTF("in succeed\n"); -// pj.dump_tapes(); + pj.dump_tapes(); return true; fail: DEBUG_PRINTF("in fail\n"); -// pj.dump_tapes(); - return true; // just to see performance - //return false; + pj.dump_tapes(); + return false; }