xkb: correcting mathematical nonsense in XkbGeomFPText
Fixes formatting of negative numbers, so they don't show minus sign after the decimal point. (cherry picked from xorg/lib/libxkbfile@d2ec504fec2550f4fd046e801b34317ef4a4bab9) Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1821>
This commit is contained in:
parent
60419d8e4a
commit
7a23010232
|
@ -622,7 +622,7 @@ XkbGeomFPText(int val, unsigned format)
|
||||||
{
|
{
|
||||||
int whole, frac;
|
int whole, frac;
|
||||||
char *buf;
|
char *buf;
|
||||||
const int bufsize = 12;
|
const int bufsize = 13;
|
||||||
|
|
||||||
buf = tbGetBuffer(bufsize);
|
buf = tbGetBuffer(bufsize);
|
||||||
if (format == XkbCFile) {
|
if (format == XkbCFile) {
|
||||||
|
@ -630,9 +630,17 @@ XkbGeomFPText(int val, unsigned format)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
whole = val / XkbGeomPtsPerMM;
|
whole = val / XkbGeomPtsPerMM;
|
||||||
frac = val % XkbGeomPtsPerMM;
|
frac = abs(val % XkbGeomPtsPerMM);
|
||||||
if (frac != 0)
|
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);
|
snprintf(buf, bufsize, "%d.%d", whole, frac);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
snprintf(buf, bufsize, "%d", whole);
|
snprintf(buf, bufsize, "%d", whole);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue