version 1.141, 2011/05/17 11:19:45 |
version 1.142, 2011/05/17 11:34:31 |
Line 713 bufcat_su(struct html *h, const char *p, const struct |
|
Line 713 bufcat_su(struct html *h, const char *p, const struct |
|
} |
} |
|
|
void |
void |
html_idcat(char *dst, const char *src, int sz) |
bufcat_id(struct html *h, const char *src) |
{ |
{ |
int ssz; |
|
|
|
assert(sz > 2); |
|
|
|
/* Cf. <http://www.w3.org/TR/html4/types.html#h-6.2>. */ |
/* Cf. <http://www.w3.org/TR/html4/types.html#h-6.2>. */ |
|
|
/* We can't start with a number (bah). */ |
if (0 == h->buflen) |
|
bufcat(h, "#x"); |
if ('#' == *dst) { |
while ('\0' != *src) |
dst++; |
bufcat_fmt(h, "%.2x", *src++); |
sz--; |
|
} |
|
if ('\0' == *dst) { |
|
*dst++ = 'x'; |
|
*dst = '\0'; |
|
sz--; |
|
} |
|
|
|
for ( ; *dst != '\0' && sz; dst++, sz--) |
|
/* Jump to end. */ ; |
|
|
|
for ( ; *src != '\0' && sz > 1; src++) { |
|
ssz = snprintf(dst, (size_t)sz, "%.2x", *src); |
|
sz -= ssz; |
|
dst += ssz; |
|
} |
|
} |
} |