ext/mkdio.c in rdiscount-2.1.7.1 vs ext/mkdio.c in rdiscount-2.1.8

- old
+ new

@@ -213,25 +213,38 @@ */ void mkd_string_to_anchor(char *s, int len, mkd_sta_function_t outchar, void *out, int labelformat) { +#if WITH_URLENCODED_ANCHOR + static const unsigned char hexchars[] = "0123456789abcdef"; +#endif unsigned char c; int i, size; char *line; size = mkd_line(s, len, &line, IS_LABEL); +#if !WITH_URLENCODED_ANCHOR if ( labelformat && (size>0) && !isalpha(line[0]) ) (*outchar)('L',out); +#endif for ( i=0; i < size ; i++ ) { c = line[i]; if ( labelformat ) { if ( isalnum(c) || (c == '_') || (c == ':') || (c == '-') || (c == '.' ) ) (*outchar)(c, out); else +#if WITH_URLENCODED_ANCHOR + { + (*outchar)('%', out); + (*outchar)(hexchars[c >> 4 & 0xf], out); + (*outchar)(hexchars[c & 0xf], out); + } +#else (*outchar)('.', out); +#endif } else (*outchar)(c,out); }