-/* $Id: html.c,v 1.61 2009/10/07 15:27:11 kristaps Exp $ */
+/* $Id: html.c,v 1.62 2009/10/09 06:54:11 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
void
bufcat_su(struct html *h, const char *p, const struct roffsu *su)
{
- int v;
+ double v;
char *u;
v = su->scale;
break;
}
- buffmt(h, "%s: %d%s;", p, v, u);
+ if (su->pt)
+ buffmt(h, "%s: %f%s;", p, v, u);
+ else
+ /* LINTED */
+ buffmt(h, "%s: %d%s;", p, (int)v, u);
}
-/* $Id: out.c,v 1.3 2009/10/07 12:35:24 kristaps Exp $ */
+/* $Id: out.c,v 1.4 2009/10/09 06:54:11 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
*
int
a2roffsu(const char *src, struct roffsu *dst)
{
- char buf[BUFSIZ], *p;
+ char buf[BUFSIZ], hasd;
int i;
enum roffscale unit;
- for (p = buf, i = 0; i < BUFSIZ && isdigit((u_char)*src); i++)
- *p++ = *src++;
+ i = hasd = 0;
+
+ switch (*src) {
+ case ('+'):
+ src++;
+ break;
+ case ('-'):
+ buf[i++] = *src++;
+ break;
+ default:
+ break;
+ }
+
+ while (i < BUFSIZ) {
+ if ( ! isdigit((u_char)*src)) {
+ if ('.' != *src)
+ break;
+ else if (hasd)
+ break;
+ else
+ hasd = 1;
+ }
+ buf[i++] = *src++;
+ }
if (BUFSIZ == i || (*src && *(src + 1)))
return(0);
- *p = '\0';
+ buf[i] = '\0';
switch (*src) {
case ('c'):
return(0);
}
- if ((dst->scale = atoi(buf)) < 0)
+ if ((dst->scale = atof(buf)) < 0)
dst->scale = 0;
dst->unit = unit;
+ dst->pt = hasd;
+
return(1);
}
-/* $Id: out.h,v 1.3 2009/10/07 12:35:24 kristaps Exp $ */
+/* $Id: out.h,v 1.4 2009/10/09 06:54:11 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
*
struct roffsu {
enum roffscale unit;
- int scale;
+ double scale;
+ int pt;
};
#define SCALE_INVERT(p) \
do { (p)->scale = -(p)->scale; } while (/*CONSTCOND*/0)
#define SCALE_VS_INIT(p, v) \
do { (p)->unit = SCALE_VS; \
- (p)->scale = (v); } while (/*CONSTCOND*/0)
+ (p)->scale = (v); \
+ (p)->pt = 0; } while (/*CONSTCOND*/0)
#define SCALE_HS_INIT(p, v) \
do { (p)->unit = SCALE_BU; \
- (p)->scale = (v); } while (/*CONSTCOND*/0)
+ (p)->scale = (v); \
+ (p)->pt = 0; } while (/*CONSTCOND*/0)
int a2roffsu(const char *, struct roffsu *);