The items() function currently supports a List, Tuple, Dict or a String. Extend it to also support a Blob.
https://github.com/vim/vim/pull/18080
(11 files)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@yegappan pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
+/*+ * "items(blob)" function+ * Converts a Blob into a List of [index, byte] pairs.+ * Caller must have already checked that argvars[0] is a Blob.+ * A null blob behaves like an empty blob.+ */+ void+blob2items(typval_T *argvars, typval_T *rettv)+{+ blob_T *blob = argvars[0].vval.v_blob;++ if (rettv_list_alloc(rettv) == FAIL)+ return;++ for (int i = 0; i < blob_len(blob); i++)+ {+ list_T *l2 = list_alloc();+ if (l2 == NULL)+ return;Memory leak rettv?
++ if (list_append_list(rettv->vval.v_list, l2) == FAIL)+ {+ vim_free(l2);+ return;+ }++ if (list_append_number(l2, i) == FAIL+ || list_append_number(l2, blob_get(blob, i)) == FAIL)+ return;Memory leak l2?
+ }+}
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
thanks
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()