Mercurial > vim
comparison src/tag.c @ 2770:25672ad7f377 v7.3.161
updated for version 7.3.161
Problem: Items on the stack may be too big.
Solution: Make items static or allocate them.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Mon, 11 Apr 2011 21:35:11 +0200 |
parents | c5e47b752f07 |
children | 52526aec4afb |
comparison
equal
deleted
inserted
replaced
2769:ccce1db172b3 | 2770:25672ad7f377 |
---|---|
773 #if defined(FEAT_QUICKFIX) && defined(FEAT_EVAL) | 773 #if defined(FEAT_QUICKFIX) && defined(FEAT_EVAL) |
774 else if (type == DT_LTAG) | 774 else if (type == DT_LTAG) |
775 { | 775 { |
776 list_T *list; | 776 list_T *list; |
777 char_u tag_name[128 + 1]; | 777 char_u tag_name[128 + 1]; |
778 char_u fname[MAXPATHL + 1]; | 778 char_u *fname; |
779 char_u cmd[CMDBUFFSIZE + 1]; | 779 char_u *cmd; |
780 | 780 |
781 /* | 781 /* |
782 * Add the matching tags to the location list for the current | 782 * Add the matching tags to the location list for the current |
783 * window. | 783 * window. |
784 */ | 784 */ |
785 | 785 |
786 fname = alloc(MAXPATHL + 1); | |
787 cmd = alloc(CMDBUFFSIZE + 1); | |
786 list = list_alloc(); | 788 list = list_alloc(); |
787 if (list == NULL) | 789 if (list == NULL || fname == NULL || cmd == NULL) |
790 { | |
791 vim_free(cmd); | |
792 vim_free(fname); | |
793 if (list != NULL) | |
794 list_free(list, TRUE); | |
788 goto end_do_tag; | 795 goto end_do_tag; |
796 } | |
789 | 797 |
790 for (i = 0; i < num_matches; ++i) | 798 for (i = 0; i < num_matches; ++i) |
791 { | 799 { |
792 int len, cmd_len; | 800 int len, cmd_len; |
793 long lnum; | 801 long lnum; |
909 | 917 |
910 vim_snprintf((char *)IObuff, IOSIZE, "ltag %s", tag); | 918 vim_snprintf((char *)IObuff, IOSIZE, "ltag %s", tag); |
911 set_errorlist(curwin, list, ' ', IObuff); | 919 set_errorlist(curwin, list, ' ', IObuff); |
912 | 920 |
913 list_free(list, TRUE); | 921 list_free(list, TRUE); |
922 vim_free(fname); | |
923 vim_free(cmd); | |
914 | 924 |
915 cur_match = 0; /* Jump to the first tag */ | 925 cur_match = 0; /* Jump to the first tag */ |
916 } | 926 } |
917 #endif | 927 #endif |
918 | 928 |
3775 dict_T *dict; | 3785 dict_T *dict; |
3776 char *field_name; | 3786 char *field_name; |
3777 char_u *start; /* start of the value */ | 3787 char_u *start; /* start of the value */ |
3778 char_u *end; /* after the value; can be NULL */ | 3788 char_u *end; /* after the value; can be NULL */ |
3779 { | 3789 { |
3780 char_u buf[MAXPATHL]; | 3790 char_u *buf; |
3781 int len = 0; | 3791 int len = 0; |
3792 int retval; | |
3782 | 3793 |
3783 /* check that the field name doesn't exist yet */ | 3794 /* check that the field name doesn't exist yet */ |
3784 if (dict_find(dict, (char_u *)field_name, -1) != NULL) | 3795 if (dict_find(dict, (char_u *)field_name, -1) != NULL) |
3785 { | 3796 { |
3786 if (p_verbose > 0) | 3797 if (p_verbose > 0) |
3789 smsg((char_u *)_("Duplicate field name: %s"), field_name); | 3800 smsg((char_u *)_("Duplicate field name: %s"), field_name); |
3790 verbose_leave(); | 3801 verbose_leave(); |
3791 } | 3802 } |
3792 return FAIL; | 3803 return FAIL; |
3793 } | 3804 } |
3805 buf = alloc(MAXPATHL); | |
3806 if (buf == NULL) | |
3807 return FAIL; | |
3794 if (start != NULL) | 3808 if (start != NULL) |
3795 { | 3809 { |
3796 if (end == NULL) | 3810 if (end == NULL) |
3797 { | 3811 { |
3798 end = start + STRLEN(start); | 3812 end = start + STRLEN(start); |
3799 while (end > start && (end[-1] == '\r' || end[-1] == '\n')) | 3813 while (end > start && (end[-1] == '\r' || end[-1] == '\n')) |
3800 --end; | 3814 --end; |
3801 } | 3815 } |
3802 len = (int)(end - start); | 3816 len = (int)(end - start); |
3803 if (len > (int)sizeof(buf) - 1) | 3817 if (len > MAXPATHL - 1) |
3804 len = sizeof(buf) - 1; | 3818 len = MAXPATHL - 1; |
3805 vim_strncpy(buf, start, len); | 3819 vim_strncpy(buf, start, len); |
3806 } | 3820 } |
3807 buf[len] = NUL; | 3821 buf[len] = NUL; |
3808 return dict_add_nr_str(dict, field_name, 0L, buf); | 3822 retval = dict_add_nr_str(dict, field_name, 0L, buf); |
3823 vim_free(buf); | |
3824 return retval; | |
3809 } | 3825 } |
3810 | 3826 |
3811 /* | 3827 /* |
3812 * Add the tags matching the specified pattern to the list "list" | 3828 * Add the tags matching the specified pattern to the list "list" |
3813 * as a dictionary | 3829 * as a dictionary |