Mercurial > vim
comparison src/eval.c @ 5794:a63d0cd691dc v7.4.241
updated for version 7.4.241
Problem: The string returned by submatch() does not distinguish between a
NL from a line break and a NL that stands for a NUL character.
Solution: Add a second argument to return a list. (ZyX)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 02 Apr 2014 19:00:58 +0200 |
parents | 71b165a378ad |
children | f084024c0ddb |
comparison
equal
deleted
inserted
replaced
5793:3b08d14e08a3 | 5794:a63d0cd691dc |
---|---|
8127 {"strlen", 1, 1, f_strlen}, | 8127 {"strlen", 1, 1, f_strlen}, |
8128 {"strpart", 2, 3, f_strpart}, | 8128 {"strpart", 2, 3, f_strpart}, |
8129 {"strridx", 2, 3, f_strridx}, | 8129 {"strridx", 2, 3, f_strridx}, |
8130 {"strtrans", 1, 1, f_strtrans}, | 8130 {"strtrans", 1, 1, f_strtrans}, |
8131 {"strwidth", 1, 1, f_strwidth}, | 8131 {"strwidth", 1, 1, f_strwidth}, |
8132 {"submatch", 1, 1, f_submatch}, | 8132 {"submatch", 1, 2, f_submatch}, |
8133 {"substitute", 4, 4, f_substitute}, | 8133 {"substitute", 4, 4, f_substitute}, |
8134 {"synID", 3, 3, f_synID}, | 8134 {"synID", 3, 3, f_synID}, |
8135 {"synIDattr", 2, 3, f_synIDattr}, | 8135 {"synIDattr", 2, 3, f_synIDattr}, |
8136 {"synIDtrans", 1, 1, f_synIDtrans}, | 8136 {"synIDtrans", 1, 1, f_synIDtrans}, |
8137 {"synconcealed", 2, 2, f_synconcealed}, | 8137 {"synconcealed", 2, 2, f_synconcealed}, |
17888 static void | 17888 static void |
17889 f_submatch(argvars, rettv) | 17889 f_submatch(argvars, rettv) |
17890 typval_T *argvars; | 17890 typval_T *argvars; |
17891 typval_T *rettv; | 17891 typval_T *rettv; |
17892 { | 17892 { |
17893 rettv->v_type = VAR_STRING; | 17893 int error = FALSE; |
17894 rettv->vval.v_string = | 17894 char_u **match; |
17895 reg_submatch((int)get_tv_number_chk(&argvars[0], NULL)); | 17895 char_u **s; |
17896 listitem_T *li; | |
17897 int no; | |
17898 int retList = 0; | |
17899 | |
17900 no = (int)get_tv_number_chk(&argvars[0], &error); | |
17901 if (error) | |
17902 return; | |
17903 error = FALSE; | |
17904 if (argvars[1].v_type != VAR_UNKNOWN) | |
17905 retList = get_tv_number_chk(&argvars[1], &error); | |
17906 if (error) | |
17907 return; | |
17908 | |
17909 if (retList == 0) | |
17910 { | |
17911 rettv->v_type = VAR_STRING; | |
17912 rettv->vval.v_string = reg_submatch(no); | |
17913 } | |
17914 else | |
17915 { | |
17916 rettv->v_type = VAR_LIST; | |
17917 rettv->vval.v_list = reg_submatch_list(no); | |
17918 } | |
17896 } | 17919 } |
17897 | 17920 |
17898 /* | 17921 /* |
17899 * "substitute()" function | 17922 * "substitute()" function |
17900 */ | 17923 */ |