From 5ff972cafe67dbaad7deafa2de60513f763732f6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 18 Nov 2021 09:55:59 +0800 Subject: vim-patch:8.2.3522: cannot use \x and \u when setting 'listchars' (#16049) Problem: Cannot use \x and \u when setting 'listchars'. Solution: Support hex and unicode in hex form. (closes vim/vim#9006) https://github.com/vim/vim/commit/93ff6720fe4427341bc426b6d46e6324f226c270 --- src/nvim/charset.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/nvim/charset.c') diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 5e18f9d86e..eb0903b594 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1642,6 +1642,16 @@ int hex2nr(int c) return c - '0'; } +/// Convert two hex characters to a byte. +/// Return -1 if one of the characters is not hex. +int hexhex2nr(char_u *p) +{ + if (!ascii_isxdigit(p[0]) || !ascii_isxdigit(p[1])) { + return -1; + } + return (hex2nr(p[0]) << 4) + hex2nr(p[1]); +} + /// Check that "str" starts with a backslash that should be removed. /// For Windows this is only done when the character after the /// backslash is not a normal file name character. -- cgit