Commit b89a5f59 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

slideshow.c: Warn about unknown format specifiers, fix handling of trailing % and \

parent 477f1c22
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -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