diff --git a/js0n.c b/js0n.c index a436983..9d65168 100644 --- a/js0n.c +++ b/js0n.c @@ -1,14 +1,20 @@ // by jeremie miller - 2010 // public domain, contributions/improvements welcome via github at https://github.com/quartzjer/js0n -// gcc started warning for the init syntax used here, is not helpful so don't generate the spam +// gcc started warning for the init syntax used here, is not helpful so don't generate the spam, supressing the warning is really inconsistently supported across versions +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #pragma GCC diagnostic push +#endif +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#pragma GCC diagnostic ignored "-Wpragmas" #pragma GCC diagnostic ignored "-Winitializer-overrides" +#pragma GCC diagnostic ignored "-Woverride-init" // opportunity to further optimize would be having different jump tables for higher depths #define PUSH(i) if(depth == 1) prev = *out++ = ((cur+i) - js) #define CAP(i) if(depth == 1) prev = *out++ = ((cur+i) - (js + prev) + 1) +// this makes a single pass across the json bytes, using each byte as an index into a jump table to build an index and transition state int js0n(const unsigned char *js, unsigned int len, unsigned short *out, unsigned int olen) { unsigned short prev = 0, *oend; @@ -131,4 +137,6 @@ int js0n(const unsigned char *js, unsigned int len, unsigned short *out, unsigne } +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #pragma GCC diagnostic pop +#endif \ No newline at end of file