summaryrefslogtreecommitdiffstats
path: root/src/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/list.c')
-rw-r--r--src/list.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/list.c b/src/list.c
index e3794b6973..13f920039c 100644
--- a/src/list.c
+++ b/src/list.c
@@ -884,4 +884,44 @@ failret:
return OK;
}
-#endif /* defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) */
+/*
+ * Write list of strings to file
+ */
+ int
+write_list(FILE *fd, list_T *list, int binary)
+{
+ listitem_T *li;
+ int c;
+ int ret = OK;
+ char_u *s;
+
+ for (li = list->lv_first; li != NULL; li = li->li_next)
+ {
+ for (s = get_tv_string(&li->li_tv); *s != NUL; ++s)
+ {
+ if (*s == '\n')
+ c = putc(NUL, fd);
+ else
+ c = putc(*s, fd);
+ if (c == EOF)
+ {
+ ret = FAIL;
+ break;
+ }
+ }
+ if (!binary || li->li_next != NULL)
+ if (putc('\n', fd) == EOF)
+ {
+ ret = FAIL;
+ break;
+ }
+ if (ret == FAIL)
+ {
+ EMSG(_(e_write));
+ break;
+ }
+ }
+ return ret;
+}
+
+#endif /* defined(FEAT_EVAL) */