From edcc61a6f44525937193056de67fc6d6986a6dd3 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sat, 28 Apr 2012 23:24:25 -0300 Subject: [PATCH] b2/: normalize relative values to 1, not 100 --- b2/eval.c | 6 +++++- b2/param.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/b2/eval.c b/b2/eval.c index 06f317d..8d8e7b5 100644 --- a/b2/eval.c +++ b/b2/eval.c @@ -198,7 +198,11 @@ int eval_rel(const struct format *fmt, const char *s, if (perc) { if (perc[1]) return 0; - return relative(s, perc, &res->u.rel.plus, &res->u.rel.minus); + if (!relative(s, perc, &res->u.rel.plus, &res->u.rel.minus)) + return 0; + res->u.rel.plus /= 100; + res->u.rel.minus /= 100; + return 1; } assert(fmt->u.rel->ops == ¶m_ops_abs); stop = strchr(s, 0); diff --git a/b2/param.h b/b2/param.h index 09acd12..150d393 100644 --- a/b2/param.h +++ b/b2/param.h @@ -63,7 +63,7 @@ struct value { struct bitset set; double abs; struct rel_value { - double plus, minus; + double plus, minus; /* rel: 100% = 1 */ int fract; /* 0: abs. offset; 1: fract. offs. */ } rel; } u;