conf: allow escaping single quote with backslash in key bindings
authorMax Kellermann <max@musicpd.org>
Mon, 19 Aug 2019 11:42:26 +0000 (13:42 +0200)
committerMax Kellermann <max@musicpd.org>
Mon, 19 Aug 2019 11:44:01 +0000 (13:44 +0200)
Fixing part of https://github.com/MusicPlayerDaemon/ncmpc/issues/51

NEWS
src/conf.cxx

diff --git a/NEWS b/NEWS
index cdf88f2..7b0b081 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 ncmpc 0.35 - not yet released
 * fall back to "AlbumArtist" tag in the default format
 * fix crash with a very narrow terminal window
+* config: allow escaping single quote with backslash in key bindings
 
 ncmpc 0.34 - (2019-04-10)
 * show total duration of range selection in status bar
index 040c9d8..c0187ee 100644 (file)
@@ -146,6 +146,13 @@ static int
 parse_key_value(char *str, char **end)
 {
        if (*str == '\'') {
+               if (str[1] == '\\' && str[2] == '\'' && str[3] == '\'') {
+                       /* the single quote can be escaped with a
+                          backslash */
+                       *end = str + 4;
+                       return str[2];
+               }
+
                if (str[1] == '\'' || str[2] != '\'') {
                        print_error(_("Malformed hotkey definition"), str);
                        return -1;