X-Git-Url: https://git.danieliu.xyz/?p=smdp.git;a=blobdiff_plain;f=src%2Furl.c;h=c5ffd4b72d6309a7a0b27ea57c55dc006af7d186;hp=68725032a4bd1a11d9e36610f2a6b51ea41a22ed;hb=e9663e348e5e5d36b36ec38a582df7df1fc9126b;hpb=7b546f2a11460bed09b61116c8be38f8decf0440 diff --git a/src/url.c b/src/url.c index 6872503..c5ffd4b 100644 --- a/src/url.c +++ b/src/url.c @@ -156,3 +156,25 @@ int url_count_inline(const char *line) { return count; } + +int url_len_inline(const char *text) { + int count = 0; + const char *i = text; + + for (; *i; i++) { + if (*i == '\\') { + i++; + } else if ( *i == '[' && *(i+1) != ']') { + while (*i && *i != ']') i++; + i++; + if (*i == '(' && strchr(i, ')')) { + while (*i && *i != ')') { + count++; + i++; + } + } + } + } + + return count; +}