summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burggraf <TSO@gmx.net>2015-08-13 21:16:40 +0200
committerAlan Coopersmith <alan.coopersmith@oracle.com>2018-03-24 11:43:51 -0700
commitd2ec504fec2550f4fd046e801b34317ef4a4bab9 (patch)
tree5cdf111428b7bdff55ace925631fee735adbc766
parent1c070d1153e293169909b0fc8e9ff65be9121fa0 (diff)
downloadxorg-lib-libxkbfile-d2ec504fec2550f4fd046e801b34317ef4a4bab9.tar.gz
correcting mathematical nonsense
V2: Fixing the issue with numbers between 0 -1 Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/xkbtext.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/xkbtext.c b/src/xkbtext.c
index 013cdef..6741d1a 100644
--- a/src/xkbtext.c
+++ b/src/xkbtext.c
@@ -758,9 +758,17 @@ XkbGeomFPText(int val, unsigned format)
}
else {
whole = val / XkbGeomPtsPerMM;
- frac = val % XkbGeomPtsPerMM;
- if (frac != 0)
- snprintf(buf, bufsize, "%d.%d", whole, frac);
+ frac = abs(val % XkbGeomPtsPerMM);
+ if (frac != 0) {
+ if (val < 0)
+ {
+ int wholeabs;
+ wholeabs = abs(whole);
+ snprintf(buf, bufsize, "-%d.%d", wholeabs, frac);
+ }
+ else
+ snprintf(buf, bufsize, "%d.%d", whole, frac);
+ }
else
snprintf(buf, bufsize, "%d", whole);
}