Mercurial > vim
comparison src/eval.c @ 448:dd9db57ee7ce v7.0118
updated for version 7.0118
author | vimboss |
---|---|
date | Thu, 28 Jul 2005 22:36:45 +0000 |
parents | 7472c565592a |
children | 3709cf52b9b5 |
comparison
equal
deleted
inserted
replaced
447:8347d456f7e5 | 448:dd9db57ee7ce |
---|---|
641 static void free_tv __ARGS((typval_T *varp)); | 641 static void free_tv __ARGS((typval_T *varp)); |
642 static void init_tv __ARGS((typval_T *varp)); | 642 static void init_tv __ARGS((typval_T *varp)); |
643 static long get_tv_number __ARGS((typval_T *varp)); | 643 static long get_tv_number __ARGS((typval_T *varp)); |
644 static long get_tv_number_chk __ARGS((typval_T *varp, int *denote)); | 644 static long get_tv_number_chk __ARGS((typval_T *varp, int *denote)); |
645 static linenr_T get_tv_lnum __ARGS((typval_T *argvars)); | 645 static linenr_T get_tv_lnum __ARGS((typval_T *argvars)); |
646 static linenr_T get_tv_lnum_buf __ARGS((typval_T *argvars, buf_T *buf)); | |
646 static char_u *get_tv_string __ARGS((typval_T *varp)); | 647 static char_u *get_tv_string __ARGS((typval_T *varp)); |
647 static char_u *get_tv_string_buf __ARGS((typval_T *varp, char_u *buf)); | 648 static char_u *get_tv_string_buf __ARGS((typval_T *varp, char_u *buf)); |
648 static char_u *get_tv_string_chk __ARGS((typval_T *varp)); | 649 static char_u *get_tv_string_chk __ARGS((typval_T *varp)); |
649 static char_u *get_tv_string_buf_chk __ARGS((typval_T *varp, char_u *buf)); | 650 static char_u *get_tv_string_buf_chk __ARGS((typval_T *varp, char_u *buf)); |
650 static dictitem_T *find_var __ARGS((char_u *name, hashtab_T **htp)); | 651 static dictitem_T *find_var __ARGS((char_u *name, hashtab_T **htp)); |
9185 (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */ | 9186 (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */ |
9186 ++emsg_off; | 9187 ++emsg_off; |
9187 buf = get_buf_tv(&argvars[0]); | 9188 buf = get_buf_tv(&argvars[0]); |
9188 --emsg_off; | 9189 --emsg_off; |
9189 | 9190 |
9190 lnum = get_tv_lnum(&argvars[1]); | 9191 lnum = get_tv_lnum_buf(&argvars[1], buf); |
9191 if (argvars[2].v_type == VAR_UNKNOWN) | 9192 if (argvars[2].v_type == VAR_UNKNOWN) |
9192 end = lnum; | 9193 end = lnum; |
9193 else | 9194 else |
9194 end = get_tv_lnum(&argvars[2]); | 9195 end = get_tv_lnum_buf(&argvars[2], buf); |
9196 | |
9195 get_buffer_lines(buf, lnum, end, TRUE, rettv); | 9197 get_buffer_lines(buf, lnum, end, TRUE, rettv); |
9196 } | 9198 } |
9197 | 9199 |
9198 /* | 9200 /* |
9199 * "getbufvar()" function | 9201 * "getbufvar()" function |
15649 *denote = TRUE; | 15651 *denote = TRUE; |
15650 return n; | 15652 return n; |
15651 } | 15653 } |
15652 | 15654 |
15653 /* | 15655 /* |
15654 * Get the lnum from the first argument. Also accepts ".", "$", etc. | 15656 * Get the lnum from the first argument. |
15657 * Also accepts ".", "$", etc., but that only works for the current buffer. | |
15655 * Returns -1 on error. | 15658 * Returns -1 on error. |
15656 */ | 15659 */ |
15657 static linenr_T | 15660 static linenr_T |
15658 get_tv_lnum(argvars) | 15661 get_tv_lnum(argvars) |
15659 typval_T *argvars; | 15662 typval_T *argvars; |
15668 f_line(argvars, &rettv); | 15671 f_line(argvars, &rettv); |
15669 lnum = rettv.vval.v_number; | 15672 lnum = rettv.vval.v_number; |
15670 clear_tv(&rettv); | 15673 clear_tv(&rettv); |
15671 } | 15674 } |
15672 return lnum; | 15675 return lnum; |
15676 } | |
15677 | |
15678 /* | |
15679 * Get the lnum from the first argument. | |
15680 * Also accepts "$", then "buf" is used. | |
15681 * Returns 0 on error. | |
15682 */ | |
15683 static linenr_T | |
15684 get_tv_lnum_buf(argvars, buf) | |
15685 typval_T *argvars; | |
15686 buf_T *buf; | |
15687 { | |
15688 if (argvars[0].v_type == VAR_STRING | |
15689 && argvars[0].vval.v_string != NULL | |
15690 && argvars[0].vval.v_string[0] == '$' | |
15691 && buf != NULL) | |
15692 return buf->b_ml.ml_line_count; | |
15693 return get_tv_number_chk(&argvars[0], NULL); | |
15673 } | 15694 } |
15674 | 15695 |
15675 /* | 15696 /* |
15676 * Get the string value of a variable. | 15697 * Get the string value of a variable. |
15677 * If it is a Number variable, the number is converted into a string. | 15698 * If it is a Number variable, the number is converted into a string. |
18676 } | 18697 } |
18677 return OK; | 18698 return OK; |
18678 } | 18699 } |
18679 #endif | 18700 #endif |
18680 | 18701 |
18702 /* | |
18703 * Display script name where an item was last set. | |
18704 * Should only be invoked when 'verbose' is non-zero. | |
18705 */ | |
18706 void | |
18707 last_set_msg(scriptID) | |
18708 scid_T scriptID; | |
18709 { | |
18710 if (scriptID != 0) | |
18711 { | |
18712 verbose_enter(); | |
18713 MSG_PUTS(_("\n\tLast set from ")); | |
18714 MSG_PUTS(get_scriptname(scriptID)); | |
18715 verbose_leave(); | |
18716 } | |
18717 } | |
18718 | |
18681 #endif /* FEAT_EVAL */ | 18719 #endif /* FEAT_EVAL */ |
18682 | 18720 |
18683 #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) || defined(PROTO) | 18721 #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) || defined(PROTO) |
18684 | 18722 |
18685 | 18723 |