changeset 517:594f25e4a806 v7.0144

updated for version 7.0144
author vimboss
date Fri, 09 Sep 2005 19:53:42 +0000
parents b7abd41f91da
children 100bdadd7667
files src/eval.c src/proto/tag.pro
diffstat 2 files changed, 61 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -409,6 +409,7 @@ static listitem_T *list_find __ARGS((lis
 static long list_idx_of_item __ARGS((list_T *l, listitem_T *item));
 static void list_append __ARGS((list_T *l, listitem_T *item));
 static int list_append_tv __ARGS((list_T *l, typval_T *tv));
+static int list_append_string __ARGS((list_T *l, char_u *str));
 static int list_insert_tv __ARGS((list_T *l, typval_T *tv, listitem_T *item));
 static int list_extend __ARGS((list_T	*l1, list_T *l2, listitem_T *bef));
 static int list_concat __ARGS((list_T *l1, list_T *l2, typval_T *tv));
@@ -612,6 +613,7 @@ static void f_synIDattr __ARGS((typval_T
 static void f_synIDtrans __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_system __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_taglist __ARGS((typval_T *argvars, typval_T *rettv));
+static void f_tagfiles __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_tempname __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_test __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_tolower __ARGS((typval_T *argvars, typval_T *rettv));
@@ -5178,6 +5180,7 @@ failret:
 
 /*
  * Allocate an empty header for a list.
+ * Caller should take care of the reference count.
  */
     static list_T *
 list_alloc()
@@ -5551,6 +5554,27 @@ list_append_dict(list, dict)
 }
 
 /*
+ * Make a copy of "str" and append it as an item to list "l".
+ * Returns FAIL when out of memory.
+ */
+    static int
+list_append_string(l, str)
+    list_T	*l;
+    char_u	*str;
+{
+    listitem_T *li = listitem_alloc();
+
+    if (li == NULL)
+	return FAIL;
+    list_append(l, li);
+    li->li_tv.v_type = VAR_STRING;
+    li->li_tv.v_lock = 0;
+    if ((li->li_tv.vval.v_string = vim_strsave(str)) == NULL)
+	return FAIL;
+    return OK;
+}
+
+/*
  * Insert typval_T "tv" in list "l" before "item".
  * If "item" is NULL append at the end.
  * Return FAIL when out of memory.
@@ -6854,6 +6878,7 @@ static struct fst
     {"synIDattr",	2, 3, f_synIDattr},
     {"synIDtrans",	1, 1, f_synIDtrans},
     {"system",		1, 2, f_system},
+    {"tagfiles",	0, 0, f_tagfiles},
     {"taglist",		1, 1, f_taglist},
     {"tempname",	0, 0, f_tempname},
     {"test",		1, 1, f_test},
@@ -9195,7 +9220,6 @@ get_buffer_lines(buf, start, end, retlis
 {
     char_u	*p;
     list_T	*l = NULL;
-    listitem_T	*li;
 
     if (retlist)
     {
@@ -9233,16 +9257,8 @@ get_buffer_lines(buf, start, end, retlis
 	if (end > buf->b_ml.ml_line_count)
 	    end = buf->b_ml.ml_line_count;
 	while (start <= end)
-	{
-	    li = listitem_alloc();
-	    if (li == NULL)
-		break;
-	    list_append(l, li);
-	    li->li_tv.v_type = VAR_STRING;
-	    li->li_tv.v_lock = 0;
-	    li->li_tv.vval.v_string =
-		vim_strsave(ml_get_buf(buf, start++, FALSE));
-	}
+	    if (list_append_string(l, ml_get_buf(buf, start++, FALSE)) == FAIL)
+		break;
     }
 }
 
@@ -9685,14 +9701,10 @@ f_getqflist(argvars, rettv)
     l = list_alloc();
     if (l != NULL)
     {
-	if (get_errorlist(l) != FAIL)
-	{
-	    rettv->vval.v_list = l;
-	    rettv->v_type = VAR_LIST;
-	    ++l->lv_refcount;
-	}
-	else
-	    list_free(l);
+	rettv->vval.v_list = l;
+	rettv->v_type = VAR_LIST;
+	++l->lv_refcount;
+	(void)get_errorlist(l);
     }
 #endif
 }
@@ -14452,6 +14464,35 @@ done:
 }
 
 /*
+ * "tagfiles()" function
+ */
+/*ARGSUSED*/
+    static void
+f_tagfiles(argvars, rettv)
+    typval_T	*argvars;
+    typval_T	*rettv;
+{
+    char_u	fname[MAXPATHL + 1];
+    list_T	*l;
+
+    l = list_alloc();
+    if (l == NULL)
+    {
+	rettv->vval.v_number = 0;
+	return;
+    }
+    rettv->vval.v_list = l;
+    rettv->v_type = VAR_LIST;
+    ++l->lv_refcount;
+
+    get_tagfname(TRUE, NULL);
+    for (;;)
+	if (get_tagfname(FALSE, fname) == FAIL
+		|| list_append_string(l, fname) == FAIL)
+	    break;
+}
+
+/*
  * "taglist()" function
  */
     static void
--- a/src/proto/tag.pro
+++ b/src/proto/tag.pro
@@ -4,6 +4,7 @@ void tag_freematch __ARGS((void));
 void do_tags __ARGS((exarg_T *eap));
 int find_tags __ARGS((char_u *pat, int *num_matches, char_u ***matchesp, int flags, int mincount, char_u *buf_ffname));
 void free_tag_stuff __ARGS((void));
+int get_tagfname __ARGS((int first, char_u *buf));
 void simplify_filename __ARGS((char_u *filename));
 int expand_tags __ARGS((int tagnames, char_u *pat, int *num_file, char_u ***file));
 int get_tags __ARGS((list_T *list, char_u *pat));