diff --git a/runtime/tools/unicode.vim b/runtime/tools/unicode.vim index e0627b644d..88c4c79609 100644 --- a/runtime/tools/unicode.vim +++ b/runtime/tools/unicode.vim @@ -283,6 +283,12 @@ func! BuildEmojiTable(pattern, tableName) call add(alltokens, token) endif + " Characters below 1F000 may be considered single width traditionally, + " making them double width causes problems. + if first < 0x1f000 + continue + endif + " exclude characters that are in the "ambiguous" or "doublewidth" table for ambi in s:ambitable if first >= ambi[0] && first <= ambi[1] diff --git a/src/eval.c b/src/eval.c index 3b9dfb818c..ed1b004930 100644 --- a/src/eval.c +++ b/src/eval.c @@ -7851,10 +7851,50 @@ echo_string( break; case VAR_PARTIAL: - *tofree = NULL; - /* TODO: arguments */ - r = tv->vval.v_partial == NULL ? NULL : tv->vval.v_partial->pt_name; - break; + { + partial_T *pt = tv->vval.v_partial; + char_u *fname = string_quote(pt == NULL ? NULL + : pt->pt_name, FALSE); + garray_T ga; + int i; + char_u *tf; + + ga_init2(&ga, 1, 100); + ga_concat(&ga, (char_u *)"function("); + if (fname != NULL) + { + ga_concat(&ga, fname); + vim_free(fname); + } + if (pt != NULL && pt->pt_argc > 0) + { + ga_concat(&ga, (char_u *)", ["); + for (i = 0; i < pt->pt_argc; ++i) + { + if (i > 0) + ga_concat(&ga, (char_u *)", "); + ga_concat(&ga, + tv2string(&pt->pt_argv[i], &tf, numbuf, copyID)); + vim_free(tf); + } + ga_concat(&ga, (char_u *)"]"); + } + if (pt != NULL && pt->pt_dict != NULL) + { + typval_T dtv; + + ga_concat(&ga, (char_u *)", "); + dtv.v_type = VAR_DICT; + dtv.vval.v_dict = pt->pt_dict; + ga_concat(&ga, tv2string(&dtv, &tf, numbuf, copyID)); + vim_free(tf); + } + ga_concat(&ga, (char_u *)")"); + + *tofree = ga.ga_data; + r = *tofree; + break; + } case VAR_LIST: if (tv->vval.v_list == NULL) @@ -7941,50 +7981,6 @@ tv2string( case VAR_FUNC: *tofree = string_quote(tv->vval.v_string, TRUE); return *tofree; - case VAR_PARTIAL: - { - partial_T *pt = tv->vval.v_partial; - char_u *fname = string_quote(pt == NULL ? NULL - : pt->pt_name, FALSE); - garray_T ga; - int i; - char_u *tf; - - ga_init2(&ga, 1, 100); - ga_concat(&ga, (char_u *)"function("); - if (fname != NULL) - { - ga_concat(&ga, fname); - vim_free(fname); - } - if (pt != NULL && pt->pt_argc > 0) - { - ga_concat(&ga, (char_u *)", ["); - for (i = 0; i < pt->pt_argc; ++i) - { - if (i > 0) - ga_concat(&ga, (char_u *)", "); - ga_concat(&ga, - tv2string(&pt->pt_argv[i], &tf, numbuf, copyID)); - vim_free(tf); - } - ga_concat(&ga, (char_u *)"]"); - } - if (pt != NULL && pt->pt_dict != NULL) - { - typval_T dtv; - - ga_concat(&ga, (char_u *)", "); - dtv.v_type = VAR_DICT; - dtv.vval.v_dict = pt->pt_dict; - ga_concat(&ga, tv2string(&dtv, &tf, numbuf, copyID)); - vim_free(tf); - } - ga_concat(&ga, (char_u *)")"); - - *tofree = ga.ga_data; - return *tofree; - } case VAR_STRING: *tofree = string_quote(tv->vval.v_string, FALSE); return *tofree; @@ -7997,6 +7993,7 @@ tv2string( case VAR_NUMBER: case VAR_LIST: case VAR_DICT: + case VAR_PARTIAL: case VAR_SPECIAL: case VAR_JOB: case VAR_CHANNEL: @@ -19285,7 +19282,8 @@ f_string(typval_T *argvars, typval_T *rettv) char_u numbuf[NUMBUFLEN]; rettv->v_type = VAR_STRING; - rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf, 0); + rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf, + get_copyID()); /* Make a copy if we have a value but it's not in allocated memory. */ if (rettv->vval.v_string != NULL && tofree == NULL) rettv->vval.v_string = vim_strsave(rettv->vval.v_string); @@ -23484,7 +23482,8 @@ ex_function(exarg_T *eap) else arg = fudi.fd_newkey; if (arg != NULL && (fudi.fd_di == NULL - || fudi.fd_di->di_tv.v_type != VAR_FUNC)) + || (fudi.fd_di->di_tv.v_type != VAR_FUNC + && fudi.fd_di->di_tv.v_type != VAR_PARTIAL))) { if (*arg == K_SPECIAL) j = 3; @@ -26467,8 +26466,10 @@ repeat: if (src[*usedlen] == ':' && src[*usedlen + 1] == 'S') { /* vim_strsave_shellescape() needs a NUL terminated string. */ + c = (*fnamep)[*fnamelen]; (*fnamep)[*fnamelen] = NUL; p = vim_strsave_shellescape(*fnamep, FALSE, FALSE); + (*fnamep)[*fnamelen] = c; if (p == NULL) return -1; vim_free(*bufp); diff --git a/src/if_py_both.h b/src/if_py_both.h index 3a80cb4eff..ee882600fc 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -6032,13 +6032,26 @@ ConvertToPyObject(typval_T *tv) case VAR_FUNC: return NEW_FUNCTION(tv->vval.v_string == NULL ? (char_u *)"" : tv->vval.v_string); + case VAR_PARTIAL: + return NEW_FUNCTION(tv->vval.v_partial == NULL + ? (char_u *)"" : tv->vval.v_partial->pt_name); case VAR_UNKNOWN: + case VAR_CHANNEL: + case VAR_JOB: Py_INCREF(Py_None); return Py_None; - default: + case VAR_SPECIAL: + switch (tv->vval.v_number) + { + case VVAL_FALSE: return AlwaysFalse(NULL); + case VVAL_TRUE: return AlwaysTrue(NULL); + case VVAL_NONE: + case VVAL_NULL: return AlwaysNone(NULL); + } PyErr_SET_VIM(N_("internal error: invalid value type")); return NULL; } + return NULL; } typedef struct diff --git a/src/mbyte.c b/src/mbyte.c index e648733835..1b947a6336 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -1445,64 +1445,6 @@ utf_char2cells(int c) * based on http://unicode.org/emoji/charts/emoji-list.html */ static struct interval emoji_width[] = { - {0x203c, 0x203c}, - {0x2049, 0x2049}, - {0x2139, 0x2139}, - {0x21a9, 0x21aa}, - {0x231a, 0x231b}, - {0x2328, 0x2328}, - {0x23cf, 0x23cf}, - {0x23e9, 0x23f3}, - {0x25aa, 0x25ab}, - {0x25fb, 0x25fe}, - {0x2600, 0x2604}, - {0x2611, 0x2611}, - {0x2618, 0x2618}, - {0x261d, 0x261d}, - {0x2620, 0x2620}, - {0x2622, 0x2623}, - {0x2626, 0x2626}, - {0x262a, 0x262a}, - {0x262e, 0x262f}, - {0x2638, 0x263a}, - {0x2648, 0x2653}, - {0x2666, 0x2666}, - {0x267b, 0x267b}, - {0x267f, 0x267f}, - {0x2692, 0x2694}, - {0x2696, 0x2697}, - {0x2699, 0x2699}, - {0x269b, 0x269c}, - {0x26a0, 0x26a1}, - {0x26aa, 0x26ab}, - {0x26b0, 0x26b1}, - {0x26bd, 0x26bd}, - {0x26ce, 0x26ce}, - {0x2702, 0x2702}, - {0x2705, 0x2705}, - {0x2708, 0x270d}, - {0x270f, 0x270f}, - {0x2712, 0x2712}, - {0x2714, 0x2714}, - {0x2716, 0x2716}, - {0x271d, 0x271d}, - {0x2721, 0x2721}, - {0x2728, 0x2728}, - {0x2733, 0x2734}, - {0x2744, 0x2744}, - {0x2747, 0x2747}, - {0x274c, 0x274c}, - {0x274e, 0x274e}, - {0x2753, 0x2755}, - {0x2763, 0x2764}, - {0x2795, 0x2797}, - {0x27a1, 0x27a1}, - {0x27b0, 0x27b0}, - {0x27bf, 0x27bf}, - {0x2934, 0x2935}, - {0x2b05, 0x2b07}, - {0x2b1b, 0x2b1c}, - {0x2b50, 0x2b50}, {0x1f004, 0x1f004}, {0x1f0cf, 0x1f0cf}, {0x1f1e6, 0x1f1ff}, diff --git a/src/testdir/test105.in b/src/testdir/test105.in index 9921d7ed7c..4cc0261445 100644 --- a/src/testdir/test105.in +++ b/src/testdir/test105.in @@ -36,6 +36,7 @@ STARTTEST :Put fnamemodify('abc''%''def', ':S' ) :Put fnamemodify("abc\ndef", ':S' ) :Put expand('%:r:S') == shellescape(expand('%:r')) +:Put join([expand('%:r'), expand('%:r:S'), expand('%')], ',') :set shell=tcsh :Put fnamemodify("abc\ndef", ':S' ) :$put ='vim: ts=8' diff --git a/src/testdir/test105.ok b/src/testdir/test105.ok index 584f0fe6a0..6642bfe4fb 100644 --- a/src/testdir/test105.ok +++ b/src/testdir/test105.ok @@ -26,5 +26,6 @@ fnamemodify('abc'' ''def', ':S' ) '''abc''\'''' ''\''''def''' fnamemodify('abc''%''def', ':S' ) '''abc''\''''%''\''''def''' fnamemodify("abc\ndef", ':S' ) '''abc^@def''' expand('%:r:S') == shellescape(expand('%:r')) 1 +join([expand('%:r'), expand('%:r:S'), expand('%')], ',') 'test105,''test105'',test105.in' fnamemodify("abc\ndef", ':S' ) '''abc\^@def''' vim: ts=8 diff --git a/src/testdir/test_partial.vim b/src/testdir/test_partial.vim index f67bb41dd8..08958de836 100644 --- a/src/testdir/test_partial.vim +++ b/src/testdir/test_partial.vim @@ -180,3 +180,43 @@ func Test_func_unref() unlet obj call assert_false(exists('*{' . funcnumber . '}')) endfunc + +func Test_tostring() + let d = {} + let d.d = d + function d.test3() + echo 42 + endfunction + try + call string(d.test3) + catch + call assert_true(v:false, v:exception) + endtry +endfunc + +func Test_redefine_dict_func() + let d = {} + function d.test4() + endfunction + let d.test4 = d.test4 + try + function! d.test4(name) + endfunction + catch + call assert_true(v:errmsg, v:exception) + endtry +endfunc + +func Test_bind_in_python() + if has('python') + let g:d = {} + function g:d.test2() + endfunction + python import vim + try + call assert_equal(pyeval('vim.bindeval("g:d.test2")'), g:d.test2) + catch + call assert_true(v:false, v:exception) + endtry + endif +endfunc diff --git a/src/version.c b/src/version.c index f4452295ad..35831b843a 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,16 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1646, +/**/ + 1645, +/**/ + 1644, +/**/ + 1643, +/**/ + 1642, /**/ 1641, /**/