manned/lib/ManUtils/ManUtils.xs
Yorhel 746889851c A few more HTML conversion improvements
- Fix segfault on empty output (bug was in XS code)
- Still better end-of-URL detection
- Recognize a few common multicharacter sections in man references
2017-01-15 20:27:16 +01:00

28 lines
576 B
Text

#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
struct StringWrap {
char *buf;
unsigned long long len, cap;
};
struct StringWrap grotty2html_wrap(const char *, unsigned long long);
void grotty2html_free(struct StringWrap);
MODULE = ManUtils PACKAGE = ManUtils
SV *
html(str)
SV *str
CODE:
STRLEN len;
char *inbuf = SvPV(str, len);
struct StringWrap buf = grotty2html_wrap(inbuf, len);
SV *dest = buf.len ? newSVpv(buf.buf, buf.len) : newSVpv("", 0);
grotty2html_free(buf);
SvUTF8_on(dest);
RETVAL = dest;
OUTPUT:
RETVAL