diff --git a/NEWS b/NEWS index d52b4b8..5d43f0b 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,11 @@ Changes in 0.5.6, released on XXXX-XX-XX: Failure to open a resource (e.g. a media file) is no longer fatal and operation will continue as far as possible. Idea from dhorton. (Ticket #1585) + * src/playlist.c: + - [MISC] Consider no output from a playlist program to be equivalent to an + empty line, indicating that the end of the playlist is reached. + - [FIX] Do not complain when receiving an empty line from a playlist + program. * examples/: - [NEW] Add a real-world example playlist script with logging feature. diff --git a/src/playlist.c b/src/playlist.c index 3ac461c..7234283 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -499,13 +499,18 @@ playlist_run_program(playlist_t *pl) } if (fgets(buf, (int)sizeof(buf), filep) == NULL) { - if (ferror(filep)) - printf("%s: Error while reading output from program '%s': %s\n", - __progname, pl->filename, strerror(errno)); + int errnum = errno; + pclose(filep); - printf("%s: FATAL: External program '%s' not (or no longer) usable.\n", - __progname, pl->filename); - exit(1); + + if (ferror(filep)) { + printf("%s: Error while reading output from program '%s': %s\n", + __progname, pl->filename, strerror(errnum)); + exit(1); + } + + /* No output (end of playlist.) */ + return (NULL); } pclose(filep); @@ -518,11 +523,9 @@ playlist_run_program(playlist_t *pl) buf[strcspn(buf, "\n")] = '\0'; buf[strcspn(buf, "\r")] = '\0'; - if (buf[0] == '\0') { - printf("%s: Empty line received from program '%s'\n", - __progname, pl->filename); + if (buf[0] == '\0') + /* Empty line (end of playlist.) */ return (NULL); - } if (pl->prog_track != NULL) xfree(pl->prog_track);