* mdocml: Clarity with respect to floating point handling: Write double
@ 2014-08-01 19:25 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-08-01 19:25 UTC (permalink / raw)
To: source
Log Message:
-----------
Clarity with respect to floating point handling:
Write double constants as double rather than integer literals.
Remove useless explicit (double) cast done at one place and nowhere else.
No functional change.
Modified Files:
--------------
mdocml:
man_html.c
mdoc_html.c
out.c
term.c
term_ascii.c
term_ps.c
Revision Data
-------------
Index: term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.c,v
retrieving revision 1.224
retrieving revision 1.225
diff -Lterm.c -Lterm.c -u -p -r1.224 -r1.225
--- term.c
+++ term.c
@@ -769,25 +769,25 @@ term_vspan(const struct termp *p, const
switch (su->unit) {
case SCALE_CM:
- r = su->scale * 2;
+ r = su->scale * 2.0;
break;
case SCALE_IN:
- r = su->scale * 6;
+ r = su->scale * 6.0;
break;
case SCALE_PC:
r = su->scale;
break;
case SCALE_PT:
- r = su->scale / 8;
+ r = su->scale / 8.0;
break;
case SCALE_MM:
- r = su->scale / 1000;
+ r = su->scale / 1000.0;
break;
case SCALE_VS:
r = su->scale;
break;
default:
- r = su->scale - 1;
+ r = su->scale - 1.0;
break;
}
@@ -801,7 +801,7 @@ term_hspan(const struct termp *p, const
{
double v;
- v = ((*p->hspan)(p, su));
+ v = (*p->hspan)(p, su);
if (v < 0.0)
v = 0.0;
return((size_t)v);
Index: out.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/out.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -Lout.c -Lout.c -u -p -r1.48 -r1.49
--- out.c
+++ out.c
@@ -128,8 +128,8 @@ a2roffsu(const char *src, struct roffsu
}
/* FIXME: do this in the caller. */
- if ((dst->scale = atof(buf)) < 0)
- dst->scale = 0;
+ if ((dst->scale = atof(buf)) < 0.0)
+ dst->scale = 0.0;
dst->unit = unit;
return(1);
}
Index: man_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_html.c,v
retrieving revision 1.95
retrieving revision 1.96
diff -Lman_html.c -Lman_html.c -u -p -r1.95 -r1.96
--- man_html.c
+++ man_html.c
@@ -388,7 +388,7 @@ man_br_pre(MAN_ARGS)
if ( ! a2roffsu(n->string, &su, SCALE_VS))
SCALE_VS_INIT(&su, atoi(n->string));
} else
- su.scale = 0;
+ su.scale = 0.0;
bufinit(h);
bufcat_su(h, "height", &su);
Index: term_ascii.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ascii.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -Lterm_ascii.c -Lterm_ascii.c -u -p -r1.26 -r1.27
--- term_ascii.c
+++ term_ascii.c
@@ -238,22 +238,22 @@ ascii_hspan(const struct termp *p, const
switch (su->unit) {
case SCALE_CM:
- r = 4 * su->scale;
+ r = su->scale * 4.0;
break;
case SCALE_IN:
- r = 10 * su->scale;
+ r = su->scale * 10.0;
break;
case SCALE_PC:
- r = (10 * su->scale) / 6;
+ r = (su->scale * 10.0) / 6.0;
break;
case SCALE_PT:
- r = (10 * su->scale) / 72;
+ r = (su->scale * 10.0) / 72.0;
break;
case SCALE_MM:
- r = su->scale / 1000;
+ r = su->scale / 1000.0;
break;
case SCALE_VS:
- r = su->scale * 2 - 1;
+ r = su->scale * 2.0 - 1.0;
break;
default:
r = su->scale;
Index: mdoc_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_html.c,v
retrieving revision 1.193
retrieving revision 1.194
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.193 -r1.194
--- mdoc_html.c
+++ mdoc_html.c
@@ -699,7 +699,7 @@ mdoc_nm_pre(MDOC_ARGS)
if (0 == len && meta->name)
len = html_strlen(meta->name);
- SCALE_HS_INIT(&su, (double)len);
+ SCALE_HS_INIT(&su, len);
bufinit(h);
bufcat_su(h, "width", &su);
PAIR_STYLE_INIT(&tag, h);
@@ -1565,7 +1565,7 @@ mdoc_sp_pre(MDOC_ARGS)
if ( ! a2roffsu(n->string, &su, SCALE_VS))
SCALE_VS_INIT(&su, atoi(n->string));
} else
- su.scale = 0;
+ su.scale = 0.0;
bufinit(h);
bufcat_su(h, "height", &su);
Index: term_ps.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ps.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -Lterm_ps.c -Lterm_ps.c -u -p -r1.61 -r1.62
--- term_ps.c
+++ term_ps.c
@@ -1123,13 +1123,13 @@ ps_hspan(const struct termp *p, const st
r = PNT2AFM(p, su->scale * 28.34);
break;
case SCALE_IN:
- r = PNT2AFM(p, su->scale * 72);
+ r = PNT2AFM(p, su->scale * 72.0);
break;
case SCALE_PC:
- r = PNT2AFM(p, su->scale * 12);
+ r = PNT2AFM(p, su->scale * 12.0);
break;
case SCALE_PT:
- r = PNT2AFM(p, su->scale * 100);
+ r = PNT2AFM(p, su->scale * 100.0);
break;
case SCALE_EM:
r = su->scale *
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-08-01 19:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-01 19:25 mdocml: Clarity with respect to floating point handling: Write double schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).