Sha256: 285cda599a5e7cf8a89bf024e64be0fbb4390e5c5d19b8f859a8fb8c649fc4d7
Contents?: true
Size: 797 Bytes
Versions: 54
Compression:
Stored size: 797 Bytes
Contents
#include <assert.h> #include <stdio.h> #include <string.h> #include "houdini.h" int houdini_unescape_js(gh_buf *ob, const uint8_t *src, size_t size) { size_t i = 0, org, ch; while (i < size) { org = i; while (i < size && src[i] != '\\') i++; if (likely(i > org)) { if (unlikely(org == 0)) { if (i >= size) return 0; gh_buf_grow(ob, HOUDINI_UNESCAPED_SIZE(size)); } gh_buf_put(ob, src + org, i - org); } /* escaping */ if (i == size) break; if (++i == size) { gh_buf_putc(ob, '\\'); break; } ch = src[i]; switch (ch) { case 'n': ch = '\n'; /* pass through */ case '\\': case '\'': case '\"': case '/': gh_buf_putc(ob, ch); i++; break; default: gh_buf_putc(ob, '\\'); break; } } return 1; }
Version data entries
54 entries across 54 versions & 4 rubygems