diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-10-09 19:22:54 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-10-09 19:22:54 +0200 |
commit | b89a5f593d0a7739bb196be04af3d6c023f1b1d1 (patch) | |
tree | a03fad09fe50daee9691a2e1080c0321cc2daa63 /src | |
parent | 477f1c2261820633fb66a4435f945d6984210981 (diff) | |
download | feh-b89a5f593d0a7739bb196be04af3d6c023f1b1d1.zip |
slideshow.c: Warn about unknown format specifiers, fix handling of trailing % and \
Diffstat (limited to 'src')
-rw-r--r-- | src/slideshow.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/slideshow.c b/src/slideshow.c index b9d9494..42aaf2e 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -390,7 +390,7 @@ char *feh_printf(char *str, feh_file * file) ret[0] = '\0'; for (c = str; *c != '\0'; c++) { - if (*c == '%') { + if ((*c == '%') && (*(c+1) != '\0')) { c++; switch (*c) { case 'f': @@ -456,18 +456,22 @@ char *feh_printf(char *str, feh_file * file) + 1 : 0); strcat(ret, buf); break; + case '%': + strcat(ret, "%"); + break; default: - strncat(ret, c, 1); + weprintf("Unrecognized format specifier %%%c", *c); + strncat(ret, c - 1, 2); break; } - } else if (*c == '\\') { + } else if ((*c == '\\') && (*(c+1) != '\0')) { c++; switch (*c) { case 'n': strcat(ret, "\n"); break; default: - strncat(ret, c, 1); + strncat(ret, c - 1, 2); break; } } else |