1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-10-21 08:57:39 +00:00

Eliminate calls to sprintf

Apple Xcode has started giving `-Wdeprecated-declarations` warnings
for `sprintf`, and suggesting that people migrate to `snprintf` instead.
This is silly, but the warnings are spam and need to be silenced
somehow. Migrating to `snprintf` and/or `hr::format` is the path of
least resistance.
This commit is contained in:
Arthur O'Dwyer
2023-08-21 10:14:19 -07:00
parent ced3bbcad4
commit 10d0ed8900
11 changed files with 22 additions and 39 deletions

View File

@@ -53,13 +53,13 @@ EX always_false in;
static int id;
id++; id %= 10;
if(divby == 1) {
sprintf(buf[id], "%d", val); return buf[id];
snprintf(buf[id], 20, "%d", val); return buf[id];
}
else if(divby <= 10) {
sprintf(buf[id], "%.1f", val*1./divby); return buf[id];
snprintf(buf[id], 20, "%.1f", val*1./divby); return buf[id];
}
else {
sprintf(buf[id], "%.2f", val*1./divby); return buf[id];
snprintf(buf[id], 20, "%.2f", val*1./divby); return buf[id];
}
}
@@ -78,7 +78,7 @@ EX always_false in;
else fill = 0xFFFFFFFF;
}
sprintf(buf, "style=\"stroke:#%06x;stroke-opacity:%.3" PLDF ";stroke-width:%" PLDF "px;fill:#%06x;fill-opacity:%.3" PLDF "\"",
snprintf(buf, 600, "style=\"stroke:#%06x;stroke-opacity:%.3" PLDF ";stroke-width:%" PLDF "px;fill:#%06x;fill-opacity:%.3" PLDF "\"",
(stroke>>8) & 0xFFFFFF, cta(stroke),
width/divby,
(fill>>8) & 0xFFFFFF, cta(fill)