summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2017-09-18 06:00:05 -0400
committerMichael Sevakis <jethead71@rockbox.org>2017-11-21 05:01:14 -0500
commitaced667f48c29a160aa4e5c0a8df037092b28189 (patch)
tree66e48e4a27daaf36f01d7ff1ed6876a7de38b0c0 /apps/plugins
parent5c9688961ef9166cec5225db50d5f73691d8292d (diff)
downloadrockbox-aced667f48c29a160aa4e5c0a8df037092b28189.zip
rockbox-aced667f48c29a160aa4e5c0a8df037092b28189.tar.gz
rockbox-aced667f48c29a160aa4e5c0a8df037092b28189.tar.bz2
rockbox-aced667f48c29a160aa4e5c0a8df037092b28189.tar.xz
Undo hacks to meant to get around string formatting limitations
The new vuprintf makes unnecessary workarounds due to formatting limitations. I checked grep output for whatever appeared to fit but it's possible I missed some instances because they weren't so obvious. Also, this means sound settings can dynamically work with any number of decimals rather than the current assumption of one or two. Add an ipow() function to help and take advantage of dynamic field width and precision. Consolidate string formatting of sound settings. Change-Id: I46caf534859dfd1916cd440cd25e5206b192fcd8
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/doom/hu_stuff.c8
-rw-r--r--apps/plugins/doom/wi_stuff.c9
-rw-r--r--apps/plugins/otp.c22
3 files changed, 17 insertions, 22 deletions
diff --git a/apps/plugins/doom/hu_stuff.c b/apps/plugins/doom/hu_stuff.c
index 639c963..6a1b07b 100644
--- a/apps/plugins/doom/hu_stuff.c
+++ b/apps/plugins/doom/hu_stuff.c
@@ -311,14 +311,14 @@ void HU_Init(void)
{
snprintf(buffer, sizeof(buffer), "DIG%d",j-48);
R_SetPatchNum(hu_font2 +i, buffer);
- snprintf(buffer, sizeof(buffer), "STCFN%s%d", (j/10>0?"0":"00"), j); //NOTE ROCKHACK: "STCFN%.3d"
+ snprintf(buffer, sizeof(buffer), "STCFN%.3d", j);
R_SetPatchNum(&hu_font[i], buffer);
}
else if ('A'<=j && j<='Z')
{
snprintf(buffer, sizeof(buffer), "DIG%c",j);
R_SetPatchNum(hu_font2 +i, buffer);
- snprintf(buffer, sizeof(buffer), "STCFN%s%d", (j/10>0?"0":"00"), j); //NOTE ROCKHACK: "STCFN%.3d"
+ snprintf(buffer, sizeof(buffer), "STCFN%.3d", j);
R_SetPatchNum(&hu_font[i], buffer);
}
else if (j=='-')
@@ -348,14 +348,14 @@ void HU_Init(void)
}
else if (j<97)
{
- snprintf(buffer, sizeof(buffer), "STCFN%s%d", (j/10>0?"0":"00"), j); //NOTE ROCKHACK: "STCFN%.3d"
+ snprintf(buffer, sizeof(buffer), "STCFN%.3d", j);
R_SetPatchNum(hu_font2 +i, buffer);
R_SetPatchNum(&hu_font[i], buffer);
//jff 2/23/98 make all font chars defined, useful or not
}
else if (j>122)
{
- snprintf(buffer, sizeof(buffer), "STBR%d", j); //NOTE: "STBR%.3d"
+ snprintf(buffer, sizeof(buffer), "STBR%.3d", j);
R_SetPatchNum(hu_font2 +i, buffer);
R_SetPatchNum(&hu_font[i], buffer);
}
diff --git a/apps/plugins/doom/wi_stuff.c b/apps/plugins/doom/wi_stuff.c
index 7c7831d..b73839f 100644
--- a/apps/plugins/doom/wi_stuff.c
+++ b/apps/plugins/doom/wi_stuff.c
@@ -397,8 +397,7 @@ void WI_unloadData(void);
void WI_levelNameLump(int epis, int map, char* buf, int bsize)
{
if (gamemode == commercial) {
- snprintf(buf, bsize,"CWILV%s%d",(map/10>0?"":"0"), map); //ANOTHER ROCKHACK "CWILV%2.2d"
- //snprintf(buf,bsize, "CWILV%2.2d", map);
+ snprintf(buf,bsize, "CWILV%2.2d", map);
} else {
snprintf(buf,bsize, "WILV%d%d", epis, map);
}
@@ -1829,8 +1828,7 @@ void WI_loadData(void)
if (wbs->epsd != 1 || j != 8)
{
// animations
- snprintf(name, sizeof(name),"WIA%d%s%d%s%d", wbs->epsd, (j/10>0?"":"0"), j,(i/10>0?"":"0"), i); //ANOTHER ROCKHACK
- //snprintf(name, sizeof(name),"WIA%d%.2d%.2d", wbs->epsd, j, i);
+ snprintf(name, sizeof(name),"WIA%d%.2d%.2d", wbs->epsd, j, i);
a->p[i] = W_CacheLumpName(name);
}
else
@@ -1872,8 +1870,7 @@ void WI_unloadData(void)
// MONDO HACK!
if (wbs->epsd != 1 || j != 8) {
// animations
- snprintf(name, sizeof(name),"WIA%d%s%d%s%d", wbs->epsd, (j/10>0?"":"0"), j,(i/10>0?"":"0"), i); //ANOTHER ROCKHACK
- //snprintf(name,sizeof(name), "WIA%d%.2d%.2d", wbs->epsd, j, i);
+ snprintf(name,sizeof(name), "WIA%d%.2d%.2d", wbs->epsd, j, i);
W_UnlockLumpName(name);
}
}
diff --git a/apps/plugins/otp.c b/apps/plugins/otp.c
index 69cb8b7..6dece4a 100644
--- a/apps/plugins/otp.c
+++ b/apps/plugins/otp.c
@@ -516,25 +516,23 @@ static void add_acct(void)
static void show_code(int acct)
{
- /* rockbox's printf doesn't support a variable field width afaik */
- char format_buf[64];
if(!accounts[acct].is_totp)
{
- rb->snprintf(format_buf, sizeof(format_buf), "%%0%dd", accounts[acct].digits);
- rb->splashf(0, format_buf, HOTP(accounts[acct].secret,
- accounts[acct].sec_len,
- accounts[acct].hotp_counter,
- accounts[acct].digits));
+ rb->splashf(0, "%0*d", accounts[acct].digits,
+ HOTP(accounts[acct].secret,
+ accounts[acct].sec_len,
+ accounts[acct].hotp_counter,
+ accounts[acct].digits));
++accounts[acct].hotp_counter;
}
#if CONFIG_RTC
else
{
- rb->snprintf(format_buf, sizeof(format_buf), "%%0%dd (%%ld second(s) left)", accounts[acct].digits);
- rb->splashf(0, format_buf, TOTP(accounts[acct].secret,
- accounts[acct].sec_len,
- accounts[acct].totp_period,
- accounts[acct].digits),
+ rb->splashf(0, "%0*d (%ld seconds(s) left)", accounts[acct].digits,
+ TOTP(accounts[acct].secret,
+ accounts[acct].sec_len,
+ accounts[acct].totp_period,
+ accounts[acct].digits),
accounts[acct].totp_period - get_utc() % accounts[acct].totp_period);
}
#else