MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fx_parseQueryPlus

Function fx_parseQueryPlus

modules/data/url/url.c:1786–1823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1784}
1785
1786void fx_parseQueryPlus(txMachine* the, txSlot* string, txInteger from, txInteger to)
1787{
1788 txString src;
1789 txString limit;
1790 txInteger length;
1791 txInteger c, d;
1792 txString dst;
1793 src = string->value.string + from;
1794 limit = string->value.string + to;
1795 length = 0;
1796 while (src < limit) {
1797 c = c_read8(src++);
1798 if (c == '%')
1799 fxParseHexEscape(&src, &d);
1800 length++;
1801 }
1802 length += 1;
1803 mxPushUndefined();
1804 the->stack->value.string = fxNewChunk(the, length);
1805 the->stack->kind = XS_STRING_KIND;
1806 src = string->value.string + from;
1807 limit = string->value.string + to;
1808 dst = the->stack->value.string;
1809 while ((src < limit)) {
1810 c = c_read8(src++);
1811 if (c == '%') {
1812 if (fxParseHexEscape(&src, &d))
1813 *dst++ = (char)d;
1814 else
1815 *dst++ = '%';
1816 }
1817 else if (c == '+')
1818 *dst++ = ' ';
1819 else
1820 *dst++ = (char)c;
1821 }
1822 *dst = 0;
1823}
1824
1825void fx_serializeQuery(txMachine* the)
1826{

Callers 1

fx_parseQueryFunction · 0.85

Calls 2

fxParseHexEscapeFunction · 0.85
fxNewChunkFunction · 0.85

Tested by

no test coverage detected