mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-01-03 14:00:13 +01:00
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>
(cherry picked from commit 7a23010232)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1895>
This commit is contained in:
parent
ed54cc2a03
commit
bd43d90cd1
1 changed files with 12 additions and 4 deletions
|
|
@ -623,7 +623,7 @@ XkbGeomFPText(int val, unsigned format)
|
|||
{
|
||||
int whole, frac;
|
||||
char *buf;
|
||||
const int bufsize = 12;
|
||||
const int bufsize = 13;
|
||||
|
||||
buf = tbGetBuffer(bufsize);
|
||||
if (format == XkbCFile) {
|
||||
|
|
@ -631,9 +631,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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue