diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-07-27 21:35:54 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-07-27 21:35:54 -0700 |
commit | 62cb38bf8a826125fba0034221343aa70dd3d415 (patch) | |
tree | 67348fa88068e1fdb2fca04d74c0ce60072bd280 /src/houdini_href_e.c | |
parent | aca7161e53ec40f6979d024d84afeb36fa911292 (diff) |
Use clang-format, llvm style, for formatting.
* Reformatted all source files.
* Added 'format' target to Makefile.
* Removed 'astyle' target.
* Updated .editorconfig.
Diffstat (limited to 'src/houdini_href_e.c')
-rw-r--r-- | src/houdini_href_e.c | 107 |
1 files changed, 50 insertions, 57 deletions
diff --git a/src/houdini_href_e.c b/src/houdini_href_e.c index 7fb958a..9152803 100644 --- a/src/houdini_href_e.c +++ b/src/houdini_href_e.c @@ -30,78 +30,71 @@ * */ static const char HREF_SAFE[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0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f *ob, const uint8_t *src, bufsize_t size) -{ - static const uint8_t hex_chars[] = "0123456789ABCDEF"; - bufsize_t i = 0, org; - uint8_t hex_str[3]; +int houdini_escape_href(cmark_strbuf *ob, const uint8_t *src, bufsize_t size) { + static const uint8_t hex_chars[] = "0123456789ABCDEF"; + bufsize_t i = 0, org; + uint8_t hex_str[3]; - hex_str[0] = '%'; + hex_str[0] = '%'; - while (i < size) { - org = i; - while (i < size && HREF_SAFE[src[i]] != 0) - i++; + while (i < size) { + org = i; + while (i < size && HREF_SAFE[src[i]] != 0) + i++; - if (likely(i > org)) - cmark_strbuf_put(ob, src + org, i - org); + if (likely(i > org)) + cmark_strbuf_put(ob, src + org, i - org); - /* escaping */ - if (i >= size) - break; + /* escaping */ + if (i >= size) + break; - switch (src[i]) { - /* amp appears all the time in URLs, but needs - * HTML-entity escaping to be inside an href */ - case '&': - cmark_strbuf_puts(ob, "&"); - break; + switch (src[i]) { + /* amp appears all the time in URLs, but needs + * HTML-entity escaping to be inside an href */ + case '&': + cmark_strbuf_puts(ob, "&"); + break; - /* the single quote is a valid URL character - * according to the standard; it needs HTML - * entity escaping too */ - case '\'': - cmark_strbuf_puts(ob, "'"); - break; + /* the single quote is a valid URL character + * according to the standard; it needs HTML + * entity escaping too */ + case '\'': + cmark_strbuf_puts(ob, "'"); + break; - /* the space can be escaped to %20 or a plus - * sign. we're going with the generic escape - * for now. the plus thing is more commonly seen - * when building GET strings */ +/* the space can be escaped to %20 or a plus + * sign. we're going with the generic escape + * for now. the plus thing is more commonly seen + * when building GET strings */ #if 0 case ' ': cmark_strbuf_putc(ob, '+'); break; #endif - /* every other character goes with a %XX escaping */ - default: - hex_str[1] = hex_chars[(src[i] >> 4) & 0xF]; - hex_str[2] = hex_chars[src[i] & 0xF]; - cmark_strbuf_put(ob, hex_str, 3); - } + /* every other character goes with a %XX escaping */ + default: + hex_str[1] = hex_chars[(src[i] >> 4) & 0xF]; + hex_str[2] = hex_chars[src[i] & 0xF]; + cmark_strbuf_put(ob, hex_str, 3); + } - i++; - } + i++; + } - return 1; + return 1; } |