Mercurial > vim
comparison src/eval.c @ 1317:45bae37de037 v7.1.031
updated for version 7.1-031
author | vimboss |
---|---|
date | Tue, 17 Jul 2007 14:32:23 +0000 |
parents | b686fb4898d1 |
children | 1f9e2c8e642a |
comparison
equal
deleted
inserted
replaced
1316:469c42f90fda | 1317:45bae37de037 |
---|---|
670 static void f_winsaveview __ARGS((typval_T *argvars, typval_T *rettv)); | 670 static void f_winsaveview __ARGS((typval_T *argvars, typval_T *rettv)); |
671 static void f_winwidth __ARGS((typval_T *argvars, typval_T *rettv)); | 671 static void f_winwidth __ARGS((typval_T *argvars, typval_T *rettv)); |
672 static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv)); | 672 static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv)); |
673 | 673 |
674 static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump)); | 674 static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump)); |
675 static pos_T *var2fpos __ARGS((typval_T *varp, int lnum, int *fnum)); | 675 static pos_T *var2fpos __ARGS((typval_T *varp, int dollar_lnum, int *fnum)); |
676 static int get_env_len __ARGS((char_u **arg)); | 676 static int get_env_len __ARGS((char_u **arg)); |
677 static int get_id_len __ARGS((char_u **arg)); | 677 static int get_id_len __ARGS((char_u **arg)); |
678 static int get_name_len __ARGS((char_u **arg, char_u **alias, int evaluate, int verbose)); | 678 static int get_name_len __ARGS((char_u **arg, char_u **alias, int evaluate, int verbose)); |
679 static char_u *find_name_end __ARGS((char_u *arg, char_u **expr_start, char_u **expr_end, int flags)); | 679 static char_u *find_name_end __ARGS((char_u *arg, char_u **expr_start, char_u **expr_end, int flags)); |
680 #define FNE_INCL_BR 1 /* find_name_end(): include [] in name */ | 680 #define FNE_INCL_BR 1 /* find_name_end(): include [] in name */ |
16503 /* | 16503 /* |
16504 * Translate a String variable into a position. | 16504 * Translate a String variable into a position. |
16505 * Returns NULL when there is an error. | 16505 * Returns NULL when there is an error. |
16506 */ | 16506 */ |
16507 static pos_T * | 16507 static pos_T * |
16508 var2fpos(varp, lnum, fnum) | 16508 var2fpos(varp, dollar_lnum, fnum) |
16509 typval_T *varp; | 16509 typval_T *varp; |
16510 int lnum; /* TRUE when $ is last line */ | 16510 int dollar_lnum; /* TRUE when $ is last line */ |
16511 int *fnum; /* set to fnum for '0, 'A, etc. */ | 16511 int *fnum; /* set to fnum for '0, 'A, etc. */ |
16512 { | 16512 { |
16513 char_u *name; | 16513 char_u *name; |
16514 static pos_T pos; | 16514 static pos_T pos; |
16515 pos_T *pp; | 16515 pos_T *pp; |
16518 if (varp->v_type == VAR_LIST) | 16518 if (varp->v_type == VAR_LIST) |
16519 { | 16519 { |
16520 list_T *l; | 16520 list_T *l; |
16521 int len; | 16521 int len; |
16522 int error = FALSE; | 16522 int error = FALSE; |
16523 listitem_T *li; | |
16523 | 16524 |
16524 l = varp->vval.v_list; | 16525 l = varp->vval.v_list; |
16525 if (l == NULL) | 16526 if (l == NULL) |
16526 return NULL; | 16527 return NULL; |
16527 | 16528 |
16533 /* Get the column number */ | 16534 /* Get the column number */ |
16534 pos.col = list_find_nr(l, 1L, &error); | 16535 pos.col = list_find_nr(l, 1L, &error); |
16535 if (error) | 16536 if (error) |
16536 return NULL; | 16537 return NULL; |
16537 len = (long)STRLEN(ml_get(pos.lnum)); | 16538 len = (long)STRLEN(ml_get(pos.lnum)); |
16539 | |
16540 /* We accept "$" for the column number: last column. */ | |
16541 li = list_find(l, 1L); | |
16542 if (li != NULL && li->li_tv.v_type == VAR_STRING | |
16543 && li->li_tv.vval.v_string != NULL | |
16544 && STRCMP(li->li_tv.vval.v_string, "$") == 0) | |
16545 pos.col = len + 1; | |
16546 | |
16538 /* Accept a position up to the NUL after the line. */ | 16547 /* Accept a position up to the NUL after the line. */ |
16539 if (pos.col == 0 || (int)pos.col > len + 1) | 16548 if (pos.col == 0 || (int)pos.col > len + 1) |
16540 return NULL; /* invalid column number */ | 16549 return NULL; /* invalid column number */ |
16541 --pos.col; | 16550 --pos.col; |
16542 | 16551 |
16565 | 16574 |
16566 #ifdef FEAT_VIRTUALEDIT | 16575 #ifdef FEAT_VIRTUALEDIT |
16567 pos.coladd = 0; | 16576 pos.coladd = 0; |
16568 #endif | 16577 #endif |
16569 | 16578 |
16570 if (name[0] == 'w' && lnum) | 16579 if (name[0] == 'w' && dollar_lnum) |
16571 { | 16580 { |
16572 pos.col = 0; | 16581 pos.col = 0; |
16573 if (name[1] == '0') /* "w0": first visible line */ | 16582 if (name[1] == '0') /* "w0": first visible line */ |
16574 { | 16583 { |
16575 update_topline(); | 16584 update_topline(); |
16583 return &pos; | 16592 return &pos; |
16584 } | 16593 } |
16585 } | 16594 } |
16586 else if (name[0] == '$') /* last column or line */ | 16595 else if (name[0] == '$') /* last column or line */ |
16587 { | 16596 { |
16588 if (lnum) | 16597 if (dollar_lnum) |
16589 { | 16598 { |
16590 pos.lnum = curbuf->b_ml.ml_line_count; | 16599 pos.lnum = curbuf->b_ml.ml_line_count; |
16591 pos.col = 0; | 16600 pos.col = 0; |
16592 } | 16601 } |
16593 else | 16602 else |