version 1.68, 2009/10/28 05:08:17 |
version 1.71, 2009/10/30 04:57:17 |
Line 391 print_ctag(struct html *h, enum htmltag tag) |
|
Line 391 print_ctag(struct html *h, enum htmltag tag) |
|
{ |
{ |
|
|
printf("</%s>", htmltags[tag].name); |
printf("</%s>", htmltags[tag].name); |
if (HTML_CLRLINE & htmltags[tag].flags) |
if (HTML_CLRLINE & htmltags[tag].flags) { |
h->flags |= HTML_NOSPACE; |
h->flags |= HTML_NOSPACE; |
if (HTML_CLRLINE & htmltags[tag].flags) |
|
h->flags |= HTML_NEWLINE; |
h->flags |= HTML_NEWLINE; |
else |
printf("\n"); |
|
} else |
h->flags &= ~HTML_NEWLINE; |
h->flags &= ~HTML_NEWLINE; |
} |
} |
|
|
Line 651 bufcat_su(struct html *h, const char *p, const struct |
|
Line 651 bufcat_su(struct html *h, const char *p, const struct |
|
|
|
|
|
void |
void |
html_idcpy(char *dst, const char *src, int sz) |
html_idcat(char *dst, const char *src, int sz) |
{ |
{ |
|
int ssz; |
|
|
assert(sz); |
assert(sz); |
dst[0] = '\0'; |
|
html_idcat(dst, src, sz); |
|
} |
|
|
|
|
|
void |
|
html_idcat(char *dst, const char *src, int sz) |
|
{ |
|
int i; |
|
|
|
/* Cf. <http://www.w3.org/TR/html4/types.html#h-6.2>. */ |
/* Cf. <http://www.w3.org/TR/html4/types.html#h-6.2>. */ |
|
|
for (i = 0; *dst != '\0' && i < sz - 1; dst++, i++) |
for ( ; *dst != '\0' && sz; dst++, sz--) |
/* Jump to end. */ ; |
/* Jump to end. */ ; |
|
|
for ( ; *src != '\0' && i < sz - 1; src++, i++) { |
assert(sz > 2); |
if (isalnum((u_char)*src)) { |
|
*dst++ = *src; |
|
continue; |
|
} |
|
|
|
switch (*src) { |
/* We can't start with a number (bah). */ |
case (';'): |
|
*dst++ = ';'; |
|
break; |
|
case ('-'): |
|
*dst++ = '-'; |
|
break; |
|
case (':'): |
|
*dst++ = ':'; |
|
break; |
|
case ('_'): |
|
/* FALLTHROUGH */ |
|
default: |
|
*dst++ = '_'; |
|
break; |
|
} |
|
} |
|
|
|
|
*dst++ = 'x'; |
*dst = '\0'; |
*dst = '\0'; |
|
sz--; |
|
|
|
for ( ; *src != '\0' && sz > 1; src++) { |
|
ssz = snprintf(dst, sz, "%.2x", *src); |
|
sz -= ssz; |
|
dst += ssz; |
|
} |
} |
} |