mirror of
https://gitlab.xiph.org/xiph/ezstream.git
synced 2024-11-03 04:17:18 -05:00
Use a better \n and \r trimming idiom after fgets().
git-svn-id: https://svn.xiph.org/trunk/ezstream@13457 0101bb08-14d6-0310-b084-bc0e0c8e3800
This commit is contained in:
parent
539100e6fc
commit
086b61a190
@ -533,10 +533,8 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
||||
printf("%s: Warning: Metadata string received via '%s' is too long and has been truncated\n",
|
||||
__progname, command);
|
||||
|
||||
if (buf[0] != '\0' && buf[strlen(buf) - 1] == '\n')
|
||||
buf[strlen(buf) - 1] = '\0';
|
||||
if (buf[0] != '\0' && buf[strlen(buf) - 1] == '\r')
|
||||
buf[strlen(buf) - 1] = '\0';
|
||||
buf[strcspn(buf, "\n")] = '\0';
|
||||
buf[strcspn(buf, "\r")] = '\0';
|
||||
|
||||
switch (md_req) {
|
||||
case METADATA_STRING:
|
||||
|
@ -171,10 +171,8 @@ playlist_read(const char *filename)
|
||||
continue;
|
||||
|
||||
/* Trim any trailing newlines and carriage returns. */
|
||||
if (buf[strlen(buf) - 1] == '\n')
|
||||
buf[strlen(buf) - 1] = '\0';
|
||||
if (buf[0] != '\0' && buf[strlen(buf) - 1] == '\r')
|
||||
buf[strlen(buf) - 1] = '\0';
|
||||
buf[strcspn(buf, "\n")] = '\0';
|
||||
buf[strcspn(buf, "\r")] = '\0';
|
||||
|
||||
/* Skip lines that are empty after the trimming. */
|
||||
if (buf[0] == '\0')
|
||||
@ -521,10 +519,8 @@ playlist_run_program(playlist_t *pl)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (buf[0] != '\0' && buf[strlen(buf) - 1] == '\n')
|
||||
buf[strlen(buf) - 1] = '\0';
|
||||
if (buf[0] != '\0' && buf[strlen(buf) - 1] == '\r')
|
||||
buf[strlen(buf) - 1] = '\0';
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user