Mercurial > vim
comparison src/list.c @ 32417:3c2c1cb61004 v9.0.1540
patch 9.0.1540: reverse() on string doesn't work in compiled function
Commit: https://github.com/vim/vim/commit/f9dc278946d52235a0025fd347bd9ff571258470
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Thu May 11 15:02:56 2023 +0100
patch 9.0.1540: reverse() on string doesn't work in compiled function
Problem: reverse() on string doesn't work in compiled function.
Solution: Accept string in argument type check. (Yegappan Lakshmanan,
closes #12377)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 11 May 2023 16:15:08 +0200 |
parents | d5e673b941cd |
children | 448aef880252 |
comparison
equal
deleted
inserted
replaced
32416:06997bf5e6a8 | 32417:3c2c1cb61004 |
---|---|
2992 * "reverse({list})" function | 2992 * "reverse({list})" function |
2993 */ | 2993 */ |
2994 void | 2994 void |
2995 f_reverse(typval_T *argvars, typval_T *rettv) | 2995 f_reverse(typval_T *argvars, typval_T *rettv) |
2996 { | 2996 { |
2997 if (in_vim9script() && check_for_list_or_blob_arg(argvars, 0) == FAIL) | 2997 if (check_for_string_or_list_or_blob_arg(argvars, 0) == FAIL) |
2998 return; | 2998 return; |
2999 | 2999 |
3000 if (argvars[0].v_type == VAR_BLOB) | 3000 if (argvars[0].v_type == VAR_BLOB) |
3001 blob_reverse(argvars[0].vval.v_blob, rettv); | 3001 blob_reverse(argvars[0].vval.v_blob, rettv); |
3002 else if (argvars[0].v_type == VAR_STRING) | 3002 else if (argvars[0].v_type == VAR_STRING) |
3003 string_reverse(argvars[0].vval.v_string, rettv); | 3003 string_reverse(argvars[0].vval.v_string, rettv); |
3004 else if (argvars[0].v_type != VAR_LIST) | 3004 else if (argvars[0].v_type == VAR_LIST) |
3005 semsg(_(e_argument_of_str_must_be_list_or_blob), "reverse()"); | |
3006 else | |
3007 list_reverse(argvars[0].vval.v_list, rettv); | 3005 list_reverse(argvars[0].vval.v_list, rettv); |
3008 } | 3006 } |
3009 | 3007 |
3010 /* | 3008 /* |
3011 * Implementation of reduce() for list "argvars[0]", using the function "expr" | 3009 * Implementation of reduce() for list "argvars[0]", using the function "expr" |