Mercurial > vim
comparison src/list.c @ 26877:06a137af96f8 v8.2.3967
patch 8.2.3967: error messages are spread out
Commit: https://github.com/vim/vim/commit/460ae5dfca31fa627531c263184849976755cf6b
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 1 14:19:49 2022 +0000
patch 8.2.3967: error messages are spread out
Problem: Error messages are spread out.
Solution: Move more errors to errors.h.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 01 Jan 2022 15:30:05 +0100 |
parents | bce848ec8b1b |
children | 612339679616 |
comparison
equal
deleted
inserted
replaced
26876:601a973ac16c | 26877:06a137af96f8 |
---|---|
522 listitem_T *li; | 522 listitem_T *li; |
523 | 523 |
524 li = list_find(l, idx - 1); | 524 li = list_find(l, idx - 1); |
525 if (li == NULL) | 525 if (li == NULL) |
526 { | 526 { |
527 semsg(_(e_listidx), idx); | 527 semsg(_(e_list_index_out_of_range_nr), idx); |
528 return NULL; | 528 return NULL; |
529 } | 529 } |
530 return tv_get_string(&li->li_tv); | 530 return tv_get_string(&li->li_tv); |
531 } | 531 } |
532 | 532 |
780 li = list_find_index(l, n1); | 780 li = list_find_index(l, n1); |
781 } | 781 } |
782 if (li == NULL) | 782 if (li == NULL) |
783 { | 783 { |
784 if (!quiet) | 784 if (!quiet) |
785 semsg(_(e_listidx), *n1); | 785 semsg(_(e_list_index_out_of_range_nr), *n1); |
786 return NULL; | 786 return NULL; |
787 } | 787 } |
788 } | 788 } |
789 return li; | 789 return li; |
790 } | 790 } |
808 listitem_T *ni = list_find(l, *n2); | 808 listitem_T *ni = list_find(l, *n2); |
809 | 809 |
810 if (ni == NULL) | 810 if (ni == NULL) |
811 { | 811 { |
812 if (!quiet) | 812 if (!quiet) |
813 semsg(_(e_listidx), *n2); | 813 semsg(_(e_list_index_out_of_range_nr), *n2); |
814 return FAIL; | 814 return FAIL; |
815 } | 815 } |
816 *n2 = list_idx_of_item(l, ni); | 816 *n2 = list_idx_of_item(l, ni); |
817 } | 817 } |
818 | 818 |
820 if (*n1 < 0) | 820 if (*n1 < 0) |
821 *n1 = list_idx_of_item(l, li1); | 821 *n1 = list_idx_of_item(l, li1); |
822 if (*n2 < *n1) | 822 if (*n2 < *n1) |
823 { | 823 { |
824 if (!quiet) | 824 if (!quiet) |
825 semsg(_(e_listidx), *n2); | 825 semsg(_(e_list_index_out_of_range_nr), *n2); |
826 return FAIL; | 826 return FAIL; |
827 } | 827 } |
828 return OK; | 828 return OK; |
829 } | 829 } |
830 | 830 |
1161 // empty list, for Vim9 script start at the first item. | 1161 // empty list, for Vim9 script start at the first item. |
1162 // A list index out of range is an error. | 1162 // A list index out of range is an error. |
1163 if (!range) | 1163 if (!range) |
1164 { | 1164 { |
1165 if (verbose) | 1165 if (verbose) |
1166 semsg(_(e_listidx), (long)n1_arg); | 1166 semsg(_(e_list_index_out_of_range_nr), (long)n1_arg); |
1167 return FAIL; | 1167 return FAIL; |
1168 } | 1168 } |
1169 if (in_vim9script()) | 1169 if (in_vim9script()) |
1170 n1 = n1 < 0 ? 0 : len; | 1170 n1 = n1 < 0 ? 0 : len; |
1171 else | 1171 else |
1447 || check_for_opt_string_arg(argvars, 1) == FAIL)) | 1447 || check_for_opt_string_arg(argvars, 1) == FAIL)) |
1448 return; | 1448 return; |
1449 | 1449 |
1450 if (argvars[0].v_type != VAR_LIST) | 1450 if (argvars[0].v_type != VAR_LIST) |
1451 { | 1451 { |
1452 emsg(_(e_listreq)); | 1452 emsg(_(e_list_required)); |
1453 return; | 1453 return; |
1454 } | 1454 } |
1455 rettv->v_type = VAR_STRING; | 1455 rettv->v_type = VAR_STRING; |
1456 if (argvars[0].vval.v_list == NULL) | 1456 if (argvars[0].vval.v_list == NULL) |
1457 return; | 1457 return; |
1549 } | 1549 } |
1550 | 1550 |
1551 if (**arg != ']') | 1551 if (**arg != ']') |
1552 { | 1552 { |
1553 if (do_error) | 1553 if (do_error) |
1554 semsg(_(e_list_end), *arg); | 1554 semsg(_(e_missing_end_of_list_rsb_str), *arg); |
1555 failret: | 1555 failret: |
1556 if (evaluate) | 1556 if (evaluate) |
1557 list_free(l); | 1557 list_free(l); |
1558 return FAIL; | 1558 return FAIL; |
1559 } | 1559 } |
1723 if (error) | 1723 if (error) |
1724 return; // type error: do nothing, errmsg already given | 1724 return; // type error: do nothing, errmsg already given |
1725 | 1725 |
1726 if ((item = list_find(l, idx)) == NULL) | 1726 if ((item = list_find(l, idx)) == NULL) |
1727 { | 1727 { |
1728 semsg(_(e_listidx), idx); | 1728 semsg(_(e_list_index_out_of_range_nr), idx); |
1729 return; | 1729 return; |
1730 } | 1730 } |
1731 | 1731 |
1732 if (argvars[2].v_type == VAR_UNKNOWN) | 1732 if (argvars[2].v_type == VAR_UNKNOWN) |
1733 { | 1733 { |
1743 if (error) | 1743 if (error) |
1744 return; // type error: do nothing | 1744 return; // type error: do nothing |
1745 | 1745 |
1746 if ((item2 = list_find(l, end)) == NULL) | 1746 if ((item2 = list_find(l, end)) == NULL) |
1747 { | 1747 { |
1748 semsg(_(e_listidx), end); | 1748 semsg(_(e_list_index_out_of_range_nr), end); |
1749 return; | 1749 return; |
1750 } | 1750 } |
1751 | 1751 |
1752 for (li = item; li != NULL; li = li->li_next) | 1752 for (li = item; li != NULL; li = li->li_next) |
1753 { | 1753 { |
2172 if (argvars[2].v_type != VAR_UNKNOWN) | 2172 if (argvars[2].v_type != VAR_UNKNOWN) |
2173 { | 2173 { |
2174 // optional third argument: {dict} | 2174 // optional third argument: {dict} |
2175 if (argvars[2].v_type != VAR_DICT) | 2175 if (argvars[2].v_type != VAR_DICT) |
2176 { | 2176 { |
2177 emsg(_(e_dictreq)); | 2177 emsg(_(e_dictionary_required)); |
2178 return FAIL; | 2178 return FAIL; |
2179 } | 2179 } |
2180 info->item_compare_selfdict = argvars[2].vval.v_dict; | 2180 info->item_compare_selfdict = argvars[2].vval.v_dict; |
2181 } | 2181 } |
2182 | 2182 |
2596 if (argvars[0].v_type == VAR_LIST) | 2596 if (argvars[0].v_type == VAR_LIST) |
2597 list_add(argvars, rettv); | 2597 list_add(argvars, rettv); |
2598 else if (argvars[0].v_type == VAR_BLOB) | 2598 else if (argvars[0].v_type == VAR_BLOB) |
2599 blob_add(argvars, rettv); | 2599 blob_add(argvars, rettv); |
2600 else | 2600 else |
2601 emsg(_(e_listblobreq)); | 2601 emsg(_(e_list_or_blob_required)); |
2602 } | 2602 } |
2603 | 2603 |
2604 /* | 2604 /* |
2605 * Count the number of times item "needle" occurs in List "l" starting at index | 2605 * Count the number of times item "needle" occurs in List "l" starting at index |
2606 * "idx". Case is ignored if "ic" is TRUE. | 2606 * "idx". Case is ignored if "ic" is TRUE. |
2620 return 0; | 2620 return 0; |
2621 | 2621 |
2622 li = list_find(l, idx); | 2622 li = list_find(l, idx); |
2623 if (li == NULL) | 2623 if (li == NULL) |
2624 { | 2624 { |
2625 semsg(_(e_listidx), idx); | 2625 semsg(_(e_list_index_out_of_range_nr), idx); |
2626 return 0; | 2626 return 0; |
2627 } | 2627 } |
2628 | 2628 |
2629 for ( ; li != NULL; li = li->li_next) | 2629 for ( ; li != NULL; li = li->li_next) |
2630 if (tv_equal(&li->li_tv, needle, ic, FALSE)) | 2630 if (tv_equal(&li->li_tv, needle, ic, FALSE)) |
2673 emsg(_(e_invalid_argument)); | 2673 emsg(_(e_invalid_argument)); |
2674 else | 2674 else |
2675 n = dict_count(argvars[0].vval.v_dict, &argvars[1], ic); | 2675 n = dict_count(argvars[0].vval.v_dict, &argvars[1], ic); |
2676 } | 2676 } |
2677 else | 2677 else |
2678 semsg(_(e_listdictarg), "count()"); | 2678 semsg(_(e_argument_of_str_must_be_list_or_dictionary), "count()"); |
2679 rettv->vval.v_number = n; | 2679 rettv->vval.v_number = n; |
2680 } | 2680 } |
2681 | 2681 |
2682 /* | 2682 /* |
2683 * extend() a List. Append List argvars[1] to List argvars[0] before index | 2683 * extend() a List. Append List argvars[1] to List argvars[0] before index |
2726 else | 2726 else |
2727 { | 2727 { |
2728 item = list_find(l1, before); | 2728 item = list_find(l1, before); |
2729 if (item == NULL) | 2729 if (item == NULL) |
2730 { | 2730 { |
2731 semsg(_(e_listidx), before); | 2731 semsg(_(e_list_index_out_of_range_nr), before); |
2732 return; | 2732 return; |
2733 } | 2733 } |
2734 } | 2734 } |
2735 } | 2735 } |
2736 else | 2736 else |
2771 if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_LIST) | 2771 if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_LIST) |
2772 list_extend_func(argvars, type, func_name, arg_errmsg, is_new, rettv); | 2772 list_extend_func(argvars, type, func_name, arg_errmsg, is_new, rettv); |
2773 else if (argvars[0].v_type == VAR_DICT && argvars[1].v_type == VAR_DICT) | 2773 else if (argvars[0].v_type == VAR_DICT && argvars[1].v_type == VAR_DICT) |
2774 dict_extend_func(argvars, type, func_name, arg_errmsg, is_new, rettv); | 2774 dict_extend_func(argvars, type, func_name, arg_errmsg, is_new, rettv); |
2775 else | 2775 else |
2776 semsg(_(e_listdictarg), func_name); | 2776 semsg(_(e_argument_of_str_must_be_list_or_dictionary), func_name); |
2777 | 2777 |
2778 if (type != NULL) | 2778 if (type != NULL) |
2779 clear_type_list(&type_list); | 2779 clear_type_list(&type_list); |
2780 } | 2780 } |
2781 | 2781 |
2831 else | 2831 else |
2832 { | 2832 { |
2833 item = list_find(l, before); | 2833 item = list_find(l, before); |
2834 if (item == NULL) | 2834 if (item == NULL) |
2835 { | 2835 { |
2836 semsg(_(e_listidx), before); | 2836 semsg(_(e_list_index_out_of_range_nr), before); |
2837 l = NULL; | 2837 l = NULL; |
2838 } | 2838 } |
2839 } | 2839 } |
2840 if (l != NULL) | 2840 if (l != NULL) |
2841 { | 2841 { |
2888 else if (argvars[0].v_type == VAR_BLOB) | 2888 else if (argvars[0].v_type == VAR_BLOB) |
2889 blob_remove(argvars, rettv, arg_errmsg); | 2889 blob_remove(argvars, rettv, arg_errmsg); |
2890 else if (argvars[0].v_type == VAR_LIST) | 2890 else if (argvars[0].v_type == VAR_LIST) |
2891 list_remove(argvars, rettv, arg_errmsg); | 2891 list_remove(argvars, rettv, arg_errmsg); |
2892 else | 2892 else |
2893 semsg(_(e_listdictblobarg), "remove()"); | 2893 semsg(_(e_argument_of_str_must_be_list_dictionary_or_blob), "remove()"); |
2894 } | 2894 } |
2895 | 2895 |
2896 static void | 2896 static void |
2897 list_reverse(list_T *l, typval_T *rettv) | 2897 list_reverse(list_T *l, typval_T *rettv) |
2898 { | 2898 { |
2967 CHECK_LIST_MATERIALIZE(l); | 2967 CHECK_LIST_MATERIALIZE(l); |
2968 if (argvars[2].v_type == VAR_UNKNOWN) | 2968 if (argvars[2].v_type == VAR_UNKNOWN) |
2969 { | 2969 { |
2970 if (l == NULL || l->lv_first == NULL) | 2970 if (l == NULL || l->lv_first == NULL) |
2971 { | 2971 { |
2972 semsg(_(e_reduceempty), "List"); | 2972 semsg(_(e_reduce_of_an_empty_str_with_no_initial_value), "List"); |
2973 return; | 2973 return; |
2974 } | 2974 } |
2975 initial = l->lv_first->li_tv; | 2975 initial = l->lv_first->li_tv; |
2976 li = l->lv_first->li_next; | 2976 li = l->lv_first->li_next; |
2977 } | 2977 } |