=================================================================== RCS file: /cvs/mandoc/html.c,v retrieving revision 1.67 retrieving revision 1.70 diff -u -p -r1.67 -r1.70 --- mandoc/html.c 2009/10/27 04:50:14 1.67 +++ mandoc/html.c 2009/10/28 08:00:18 1.70 @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.67 2009/10/27 04:50:14 kristaps Exp $ */ +/* $Id: html.c,v 1.70 2009/10/28 08:00:18 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -648,3 +649,30 @@ bufcat_su(struct html *h, const char *p, const struct buffmt(h, "%s: %d%s;", p, (int)v, u); } + +void +html_idcat(char *dst, const char *src, int sz) +{ + int ssz; + + assert(sz); + + /* Cf. . */ + + for ( ; *dst != '\0' && sz; dst++, sz--) + /* Jump to end. */ ; + + assert(sz > 2); + + /* We can't start with a number (bah). */ + + *dst++ = 'x'; + *dst = '\0'; + sz--; + + for ( ; *src != '\0' && sz > 1; src++) { + ssz = snprintf(dst, sz, "%.2x", *src); + sz -= ssz; + dst += ssz; + } +}