Mercurial > vim
comparison src/vim9execute.c @ 24806:28127371aa18 v8.2.2941
patch 8.2.2941: Vim9: using does not handle a list of strings
Commit: https://github.com/vim/vim/commit/b288ba9f1dd29ba34f236e3099f779d5ab130227
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 5 17:10:55 2021 +0200
patch 8.2.2941: Vim9: using does not handle a list of strings
Problem: Vim9: using does not handle a list of strings.
Solution: Convert a list to a string and escape each item. (closes https://github.com/vim/vim/issues/8310)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 05 Jun 2021 17:15:06 +0200 |
parents | 7c1375eb1636 |
children | 0bc60e26a2b5 |
comparison
equal
deleted
inserted
replaced
24805:f31e7022526e | 24806:28127371aa18 |
---|---|
997 case VAR_BLOB: break; | 997 case VAR_BLOB: break; |
998 | 998 |
999 case VAR_LIST: | 999 case VAR_LIST: |
1000 if (tolerant) | 1000 if (tolerant) |
1001 { | 1001 { |
1002 char_u *p; | 1002 char_u *s, *e, *p; |
1003 | 1003 garray_T ga; |
1004 | |
1005 ga_init2(&ga, sizeof(char_u *), 1); | |
1006 | |
1007 // Convert to NL separated items, then | |
1008 // escape the items and replace the NL with | |
1009 // a space. | |
1004 str = typval2string(tv, TRUE); | 1010 str = typval2string(tv, TRUE); |
1011 if (str == NULL) | |
1012 return FAIL; | |
1013 s = str; | |
1014 while ((e = vim_strchr(s, '\n')) != NULL) | |
1015 { | |
1016 *e = NUL; | |
1017 p = vim_strsave_fnameescape(s, FALSE); | |
1018 if (p != NULL) | |
1019 { | |
1020 ga_concat(&ga, p); | |
1021 ga_concat(&ga, (char_u *)" "); | |
1022 vim_free(p); | |
1023 } | |
1024 s = e + 1; | |
1025 } | |
1026 vim_free(str); | |
1005 clear_tv(tv); | 1027 clear_tv(tv); |
1006 tv->v_type = VAR_STRING; | 1028 tv->v_type = VAR_STRING; |
1007 tv->vval.v_string = str; | 1029 tv->vval.v_string = ga.ga_data; |
1008 // TODO: escaping | |
1009 while ((p = vim_strchr(str, '\n')) != NULL) | |
1010 *p = ' '; | |
1011 return OK; | 1030 return OK; |
1012 } | 1031 } |
1013 // FALLTHROUGH | 1032 // FALLTHROUGH |
1014 default: to_string_error(tv->v_type); | 1033 default: to_string_error(tv->v_type); |
1015 return FAIL; | 1034 return FAIL; |