comparison src/typval.c @ 26638:6fd15d82e898 v8.2.3848

patch 8.2.3848: cannot use reduce() for a string Commit: https://github.com/vim/vim/commit/0ccb5842f5fb103763d106c7aa364d758343c35a Author: rbtnn <naru123456789@gmail.com> Date: Sat Dec 18 18:33:46 2021 +0000 patch 8.2.3848: cannot use reduce() for a string Problem: Cannot use reduce() for a string. Solution: Make reduce() work with a string. (Naruhiko Nishino, closes https://github.com/vim/vim/issues/9366)
author Bram Moolenaar <Bram@vim.org>
date Sat, 18 Dec 2021 19:45:03 +0100
parents a28f91b893b2
children 2fc1e528e0e1
comparison
equal deleted inserted replaced
26637:eeac85e187e7 26638:6fd15d82e898
661 } 661 }
662 return OK; 662 return OK;
663 } 663 }
664 664
665 /* 665 /*
666 * Give an error and return FAIL unless "args[idx]" is a string, a list or a
667 * blob.
668 */
669 int
670 check_for_string_or_list_or_blob_arg(typval_T *args, int idx)
671 {
672 if (args[idx].v_type != VAR_STRING
673 && args[idx].v_type != VAR_LIST
674 && args[idx].v_type != VAR_BLOB)
675 {
676 semsg(_(e_string_list_or_blob_required_for_argument_nr), idx + 1);
677 return FAIL;
678 }
679 return OK;
680 }
681
682 /*
666 * Check for an optional string or list argument at 'idx' 683 * Check for an optional string or list argument at 'idx'
667 */ 684 */
668 int 685 int
669 check_for_opt_string_or_list_arg(typval_T *args, int idx) 686 check_for_opt_string_or_list_arg(typval_T *args, int idx)
670 { 687 {
695 { 712 {
696 if (args[idx].v_type != VAR_STRING 713 if (args[idx].v_type != VAR_STRING
697 && args[idx].v_type != VAR_NUMBER 714 && args[idx].v_type != VAR_NUMBER
698 && args[idx].v_type != VAR_LIST) 715 && args[idx].v_type != VAR_LIST)
699 { 716 {
700 if (idx >= 0) 717 semsg(_(e_string_number_or_list_required_for_argument_nr), idx + 1);
701 semsg(_(e_string_number_or_list_required_for_argument_nr), idx + 1);
702 else
703 emsg(_(e_stringreq));
704 return FAIL; 718 return FAIL;
705 } 719 }
706 return OK; 720 return OK;
707 } 721 }
708 722
740 int 754 int
741 check_for_list_or_blob_arg(typval_T *args, int idx) 755 check_for_list_or_blob_arg(typval_T *args, int idx)
742 { 756 {
743 if (args[idx].v_type != VAR_LIST && args[idx].v_type != VAR_BLOB) 757 if (args[idx].v_type != VAR_LIST && args[idx].v_type != VAR_BLOB)
744 { 758 {
745 if (idx >= 0) 759 semsg(_(e_list_or_blob_required_for_argument_nr), idx + 1);
746 semsg(_(e_list_or_blob_required_for_argument_nr), idx + 1);
747 else
748 emsg(_(e_listreq));
749 return FAIL; 760 return FAIL;
750 } 761 }
751 return OK; 762 return OK;
752 } 763 }
753 764