MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

support ternary and tail span checks

+15 -7
+1 -1
meson/ant.version
··· 1 - 0.6.0 1 + 0.6.1
+13 -5
src/ant.c
··· 12439 12439 jsoff_t skip = skip_comment_or_string(code, clen, p); 12440 12440 if (skip) { p = skip - 1; continue; } 12441 12441 switch (code[p]) { 12442 - case '(': case '[': depth++; break; 12443 - case ')': case ']': depth--; break; 12442 + case '(': case '[': case '{': depth++; break; 12443 + case ')': case ']': case '}': depth--; break; 12444 12444 case '?': if (!depth) nesting++; break; 12445 12445 case ':': if (!depth && nesting-- == 0) return p; break; 12446 12446 } ··· 12450 12450 12451 12451 static enum tail_scan scan_tail_span(const char *code, jsoff_t clen, jsoff_t start, jsoff_t end) { 12452 12452 jsoff_t p = skiptonext(code, end, start, NULL); 12453 - int depth = 0, bdepth = 0; jsoff_t last_paren_close = 0; 12453 + int depth = 0, bdepth = 0, cdepth = 0; 12454 + 12455 + jsoff_t last_paren_close = 0; 12454 12456 bool seen_binop = false; 12455 12457 12456 12458 while (p < end) { 12457 12459 jsoff_t skip = skip_comment_or_string(code, end, p); 12458 12460 if (skip) { p = skip; continue; } 12459 12461 char c = code[p]; 12462 + if (c == '{') { cdepth++; p++; continue; } 12463 + if (c == '}') { 12464 + cdepth--; p++; 12465 + if (cdepth < 0) return TAIL_UNSAFE; 12466 + continue; 12467 + } 12460 12468 if (c == '[') { bdepth++; p++; continue; } 12461 12469 if (c == ']') { 12462 12470 bdepth--; p++; ··· 12467 12475 if (c == ')') { 12468 12476 depth--; p++; 12469 12477 if (depth < 0) return TAIL_UNSAFE; 12470 - if (depth == 0 && bdepth == 0) last_paren_close = p; 12478 + if (depth == 0 && bdepth == 0 && cdepth == 0) last_paren_close = p; 12471 12479 continue; 12472 12480 } 12473 - if (depth == 0 && bdepth == 0) { 12481 + if (depth == 0 && bdepth == 0 && cdepth == 0) { 12474 12482 if (c == '?') { 12475 12483 p++; 12476 12484 jsoff_t colon = find_ternary_colon(code, end, p);
+1 -1
src/modules/io.c
··· 181 181 case 'A': if (memcmp(p + 2, "syncFunction", 7) == 0) { EMIT_UNTIL(']', JSON_FUNC) } break; 182 182 case 'b': if (memcmp(p + 2, "yte", 3) == 0 || memcmp(p + 2, "uffer]", 6) == 0) { EMIT_UNTIL(']', JSON_STRING) } break; 183 183 case 'F': if (memcmp(p + 2, "unction", 7) == 0) { EMIT_UNTIL(']', JSON_FUNC) } break; 184 - case 'n': if (memcmp(p + 2, "ative code]", 11) == 0) { EMIT_UNTIL(']', JSON_FUNC) } break; 184 + case 'n': if (memcmp(p + 2, "ative code", 10) == 0) { EMIT_UNTIL(']', JSON_FUNC) } break; 185 185 case 'C': if (memcmp(p + 2, "ircular", 7) == 0) { EMIT_UNTIL(']', JSON_REF) } break; 186 186 case 'G': if (memcmp(p + 2, "etter/Setter]", 13) == 0 || memcmp(p + 2, "etter]", 6) == 0) { EMIT_UNTIL(']', JSON_FUNC) } break; 187 187 case 'S': if (memcmp(p + 2, "etter]", 6) == 0) { EMIT_UNTIL(']', JSON_FUNC) } break;