Mercurial > vim
diff src/vim9execute.c @ 22637:4d4042683371 v8.2.1867
patch 8.2.1867: Vim9: argument to add() not checked for blob
Commit: https://github.com/vim/vim/commit/80b0e5ea1132d1d7cf78c77bc14c686c836a0d25
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Oct 19 20:45:36 2020 +0200
patch 8.2.1867: Vim9: argument to add() not checked for blob
Problem: Vim9: argument to add() not checked for blob.
Solution: Add the BLOBAPPEND instruction.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 19 Oct 2020 21:00:04 +0200 |
parents | 6589dae9696c |
children | 6dce588f7a46 |
line wrap: on
line diff
--- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -2312,6 +2312,29 @@ call_def_function( } break; + case ISN_BLOBAPPEND: + { + typval_T *tv1 = STACK_TV_BOT(-2); + typval_T *tv2 = STACK_TV_BOT(-1); + blob_T *b = tv1->vval.v_blob; + int error = FALSE; + varnumber_T n; + + // add a number to a blob + if (b == NULL) + { + SOURCING_LNUM = iptr->isn_lnum; + emsg(_(e_cannot_add_to_null_blob)); + goto on_error; + } + n = tv_get_number_chk(tv2, &error); + if (error) + goto on_error; + ga_append(&b->bv_ga, (int)n); + --ectx.ec_stack.ga_len; + } + break; + // Computation with two arguments of unknown type case ISN_OPANY: { @@ -3432,6 +3455,7 @@ ex_disassemble(exarg_T *eap) case ISN_STRINDEX: smsg("%4d STRINDEX", current); break; case ISN_STRSLICE: smsg("%4d STRSLICE", current); break; case ISN_LISTAPPEND: smsg("%4d LISTAPPEND", current); break; + case ISN_BLOBAPPEND: smsg("%4d BLOBAPPEND", current); break; case ISN_LISTINDEX: smsg("%4d LISTINDEX", current); break; case ISN_LISTSLICE: smsg("%4d LISTSLICE", current); break; case ISN_ANYINDEX: smsg("%4d ANYINDEX", current); break;