summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2011-11-08 20:14:02 +0100
committerLars-Dominik Braun <lars@6xq.net>2011-11-08 20:14:02 +0100
commit208731ffa981e3c0a448be23ccd58ae1b5acca4d (patch)
tree8855891ad395896a9171401afcd6ddb5ce7afa46 /src
parentffe3ed8bbfc5ed658b8d16c9510b7fb57208c788 (diff)
downloadpianobar-208731ffa981e3c0a448be23ccd58ae1b5acca4d.tar.gz
pianobar-208731ffa981e3c0a448be23ccd58ae1b5acca4d.tar.bz2
pianobar-208731ffa981e3c0a448be23ccd58ae1b5acca4d.zip
Back to snprintf
Fixes #169.
Diffstat (limited to 'src')
-rw-r--r--src/ui.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/ui.c b/src/ui.c
index 1857170..7c80079 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -727,20 +727,6 @@ inline void BarUiPrintSong (const BarSettings_t *settings,
BarUiMsg (settings, MSG_PLAYING, outstr);
}
-/* Incremets two digit ASCII counter
- */
-static void BarUiIncDigits (char digits[3]) {
- ++digits[1];
- if (digits[1] == ':') {
- digits[1] = '0';
- digits[0] |= 0x30;
- ++digits[0];
- if (digits[0] == ':') {
- digits[0] = ' ';
- }
- }
-}
-
/* Print list of songs
* @param pianobar settings
* @param linked list of songs
@@ -750,7 +736,7 @@ static void BarUiIncDigits (char digits[3]) {
size_t BarUiListSongs (const BarSettings_t *settings,
const PianoSong_t *song, const char *filter) {
size_t i = 0;
- char digits[3] = " 0";
+ char digits[4];
while (song != NULL) {
if (filter == NULL ||
@@ -761,13 +747,13 @@ size_t BarUiListSongs (const BarSettings_t *settings,
(song->rating == PIANO_RATE_LOVE) ? settings->loveIcon :
((song->rating == PIANO_RATE_BAN) ? settings->banIcon : "")};
+ snprintf (digits, sizeof (digits) / sizeof (*digits), "%2zu", i);
BarUiCustomFormat (outstr, sizeof (outstr), settings->listSongFormat,
"iatr", vals);
BarUiAppendNewline (outstr, sizeof (outstr));
BarUiMsg (settings, MSG_LIST, outstr);
}
i++;
- BarUiIncDigits (digits);
song = song->next;
}