commit ec254ccf06b80f3f276d8dc0120f4f7e6ba6141f
parent 964846003dbd9de9771ff292c4191413796dcbe2
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 2 Aug 2015 15:07:03 +0200
sfeed_frames: normalizepath: dont start with replaced -, just ignore
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sfeed_frames.c b/sfeed_frames.c
@@ -49,15 +49,15 @@ printcontent(const char *s, FILE *fp)
static size_t
normalizepath(const char *path, char *buf, size_t bufsiz)
{
- size_t i = 0, r = 0;
+ size_t i, r = 0;
- for (; *path && i < bufsiz; path++) {
+ for (i = 0; *path && i < bufsiz; path++) {
if (isalpha((int)*path) || isdigit((int)*path)) {
buf[i++] = tolower((int)*path);
r = 0;
} else {
- /* don't repeat '-' */
- if (!r)
+ /* don't repeat '-', don't start with '-' */
+ if (!r && i)
buf[i++] = '-';
r++;
}