Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Properly remove trailing whitespace from config file entries.

  • Loading branch information...
commit 79a063031649db537c4c1f4bca85941c43a0f6ae 1 parent 93ca069
Tilman Sauerbeck authored
Showing with 13 additions and 2 deletions.
  1. +13 −2 src/xmms2-scrobbler.c
15 src/xmms2-scrobbler.c
View
@@ -26,6 +26,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
+#include <ctype.h>
#include <poll.h>
#include <xmmsclient/xmmsclient.h>
#include <pthread.h>
@@ -546,6 +547,17 @@ on_disconnect (void *udata)
}
static void
+strchomp (char *s, size_t *length)
+{
+ size_t l = *length;
+
+ while (l > 0 && isspace (s[l - 1]))
+ s[--l] = 0;
+
+ *length = l;
+}
+
+static void
for_each_line (FILE *fp,
void (*callback) (const char *line, void *user_data),
void *user_data)
@@ -558,8 +570,7 @@ for_each_line (FILE *fp,
if (length < 2)
continue;
- /* cut the trailing newline */
- buf[length - 1] = 0;
+ strchomp (buf, &length);
callback (buf, user_data);
}
Please sign in to comment.
Something went wrong with that request. Please try again.