From: Jonathan Neuschäfer Date: Sat, 3 Apr 2010 19:35:34 +0000 (+0200) Subject: screen_lyrics.c: wrapped some duplicate code X-Git-Tag: release-0.17~15 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=67decc18c8d7930c9b3dc67e5e1026f2478798f2;p=ncmpc.git screen_lyrics.c: wrapped some duplicate code --- diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c index ba197a0..6cb7b46 100644 --- a/src/screen_lyrics.c +++ b/src/screen_lyrics.c @@ -87,14 +87,21 @@ lyrics_repaint_if_active(void) } } +static void +path_lyr_file(char *path, size_t size, + const char *artist, const char *title) +{ + snprintf(path, size, "%s/.lyrics/%s - %s.txt", + getenv("HOME"), artist, title); +} + static bool exists_lyr_file(const char *artist, const char *title) { char path[1024]; struct stat result; - snprintf(path, 1024, "%s/.lyrics/%s - %s.txt", - getenv("HOME"), artist, title); + path_lyr_file(path, 1024, artist, title); return (stat(path, &result) == 0); } @@ -108,8 +115,7 @@ create_lyr_file(const char *artist, const char *title) getenv("HOME")); mkdir(path, S_IRWXU); - snprintf(path, 1024, "%s/.lyrics/%s - %s.txt", - getenv("HOME"), artist, title); + path_lyr_file(path, 1024, artist, title); return fopen(path, "w"); }