Mercurial > vim
diff src/list.c @ 9571:5eaa708ab50d v7.4.2063
commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 17 22:13:49 2016 +0200
patch 7.4.2063
Problem: eval.c is still too big.
Solution: Split off internal functions to evalfunc.c.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 17 Jul 2016 22:30:06 +0200 |
parents | 1e68dfd7931b |
children | 172131507c85 |
line wrap: on
line diff
--- 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) */