version 1.66, 2009/10/26 08:18:15 |
version 1.68, 2009/10/28 05:08:17 |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
|
|
#include <assert.h> |
#include <assert.h> |
|
#include <ctype.h> |
#include <err.h> |
#include <err.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdarg.h> |
#include <stdarg.h> |
Line 80 static const char *const htmlattrs[ATTR_MAX] = { |
|
Line 81 static const char *const htmlattrs[ATTR_MAX] = { |
|
"valign", |
"valign", |
"target", |
"target", |
"id", |
"id", |
|
"summary", |
}; |
}; |
|
|
#ifdef __linux__ |
#ifdef __linux__ |
Line 647 bufcat_su(struct html *h, const char *p, const struct |
|
Line 649 bufcat_su(struct html *h, const char *p, const struct |
|
buffmt(h, "%s: %d%s;", p, (int)v, u); |
buffmt(h, "%s: %d%s;", p, (int)v, u); |
} |
} |
|
|
|
|
|
void |
|
html_idcpy(char *dst, const char *src, int 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>. */ |
|
|
|
for (i = 0; *dst != '\0' && i < sz - 1; dst++, i++) |
|
/* Jump to end. */ ; |
|
|
|
for ( ; *src != '\0' && i < sz - 1; src++, i++) { |
|
if (isalnum((u_char)*src)) { |
|
*dst++ = *src; |
|
continue; |
|
} |
|
|
|
switch (*src) { |
|
case (';'): |
|
*dst++ = ';'; |
|
break; |
|
case ('-'): |
|
*dst++ = '-'; |
|
break; |
|
case (':'): |
|
*dst++ = ':'; |
|
break; |
|
case ('_'): |
|
/* FALLTHROUGH */ |
|
default: |
|
*dst++ = '_'; |
|
break; |
|
} |
|
} |
|
|
|
*dst = '\0'; |
|
} |