Skip to content

Commit

Permalink
Fix the fix
Browse files Browse the repository at this point in the history
  • Loading branch information
flori committed Mar 21, 2012
1 parent 8fd84e6 commit 59f51d2
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions ext/json/ext/generator/generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,27 +854,12 @@ static VALUE cState_partial_generate(VALUE self, VALUE obj)

static int isArrayOrObject(VALUE string)
{
char c, *q, *p = RSTRING_PTR(string), *pend = p + RSTRING_LEN(string);

while (p < pend) {
if (isspace(*p)) {
p++;
continue;
}
if (*p == '[') c = ']';
else if (*p == '{') c = '}';
else return 0;
q = pend - 1;
while (q > p) {
if (isspace(*q)) {
q--;
continue;
}
if (*q == c) return 1;
}
return 0;
}
return 0;
long string_len = RSTRING_LEN(string);
char c, *p = RSTRING_PTR(string), *q = p + string_len - 1;
if (string_len < 2) return 0;
for (; p < q && isspace(*p); p++);
for (; q > p && isspace(*q); q--);
return *p == '[' && *q == ']' || *p == '{' && *q == '}';
}

/*
Expand Down

0 comments on commit 59f51d2

Please sign in to comment.