From 1af28cbfd740c719a9338c8c9d6b7f55bb3ab13a Mon Sep 17 00:00:00 2001 From: dana Date: Sun, 24 Dec 2017 16:21:06 -0600 Subject: 42164: fix digits in format escapes in completion listings --- ChangeLog | 3 +++ Src/Zle/complist.c | 6 +++--- Test/Y01completion.ztst | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3628cfa7..adea4a078 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2018-01-04 Peter Stephenson + * dana: 42164: Src/Zle/complist.c, Test/Y01completion.ztst: + numeric values didn't work in format escapes in completion lists. + * Stephane: 42159: Src/params.c: avoid crash copying empty hash table. * Sebastian: 42188: Src/Modules/system.c: It is necessary to diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index a83daeff9..e768aee5d 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -1097,6 +1097,9 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop) if (*p) { int arg = 0, is_fg; + if (idigit(*p)) + arg = zstrtol(p, &p, 10); + len = MB_METACHARLENCONV(p, &cchar); #ifdef MULTIBYTE_SUPPORT if (cchar == WEOF) @@ -1104,9 +1107,6 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop) #endif p += len; - if (idigit(*p)) - arg = zstrtol(p, &p, 10); - m = 0; switch (cchar) { case ZWC('%'): diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst index 113a45076..b1c0e40e5 100644 --- a/Test/Y01completion.ztst +++ b/Test/Y01completion.ztst @@ -56,6 +56,21 @@ >FI:{file1} >FI:{file2} + # Temporarily modify format set in comptest + comptesteval 'zstyle -s ":completion:*:descriptions" format oldfmt' + comptesteval 'zstyle ":completion:*:descriptions" format \ + ${oldfmt/>*%5F123abc%f %B123abc%b<}' + comptest $': \t' + comptesteval 'zstyle ":completion:*:descriptions" format $oldfmt' +0:custom description with formatting sequences +>line: {: }{} +*>DESCRIPTION:{*123abc*123abc*~*F123*} +>DI:{dir1} +>DI:{dir2} +>FI:{file1} +>FI:{file2} +F:regression test workers/42164 + # Depends on path assignment in comptestinit comptesteval "path=( $ZTST_srcdir:A )" comptest $'zt\t' -- cgit 1.4.1