Mercurial > vim
comparison src/if_perl.xs @ 15454:1d2b5c016f17 v8.1.0735
patch 8.1.0735: cannot handle binary data
commit https://github.com/vim/vim/commit/6e5ea8d2a995b32bbc5972edc4f827b959f2702f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 12 22:47:31 2019 +0100
patch 8.1.0735: cannot handle binary data
Problem: Cannot handle binary data.
Solution: Add the Blob type. (Yasuhiro Matsumoto, closes https://github.com/vim/vim/issues/3638)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 12 Jan 2019 23:00:06 +0100 |
parents | d823dfb273c6 |
children | 55ccc2d353bd |
comparison
equal
deleted
inserted
replaced
15453:cdee6e827112 | 15454:1d2b5c016f17 |
---|---|
234 # define Perl_sv_2pv_flags dll_Perl_sv_2pv_flags | 234 # define Perl_sv_2pv_flags dll_Perl_sv_2pv_flags |
235 # define Perl_sv_2pv_nolen dll_Perl_sv_2pv_nolen | 235 # define Perl_sv_2pv_nolen dll_Perl_sv_2pv_nolen |
236 # else | 236 # else |
237 # define Perl_sv_2pv dll_Perl_sv_2pv | 237 # define Perl_sv_2pv dll_Perl_sv_2pv |
238 # endif | 238 # endif |
239 # define Perl_sv_2pvbyte dll_Perl_sv_2pvbyte | |
239 # define Perl_sv_bless dll_Perl_sv_bless | 240 # define Perl_sv_bless dll_Perl_sv_bless |
240 # if (PERL_REVISION == 5) && (PERL_VERSION >= 8) | 241 # if (PERL_REVISION == 5) && (PERL_VERSION >= 8) |
241 # define Perl_sv_catpvn_flags dll_Perl_sv_catpvn_flags | 242 # define Perl_sv_catpvn_flags dll_Perl_sv_catpvn_flags |
242 # else | 243 # else |
243 # define Perl_sv_catpvn dll_Perl_sv_catpvn | 244 # define Perl_sv_catpvn dll_Perl_sv_catpvn |
386 static char* (*Perl_sv_2pv_flags)(pTHX_ SV*, STRLEN*, I32); | 387 static char* (*Perl_sv_2pv_flags)(pTHX_ SV*, STRLEN*, I32); |
387 static char* (*Perl_sv_2pv_nolen)(pTHX_ SV*); | 388 static char* (*Perl_sv_2pv_nolen)(pTHX_ SV*); |
388 # else | 389 # else |
389 static char* (*Perl_sv_2pv)(pTHX_ SV*, STRLEN*); | 390 static char* (*Perl_sv_2pv)(pTHX_ SV*, STRLEN*); |
390 # endif | 391 # endif |
392 static char* (*Perl_sv_2pvbyte)(pTHX_ SV*, STRLEN*); | |
391 static SV* (*Perl_sv_bless)(pTHX_ SV*, HV*); | 393 static SV* (*Perl_sv_bless)(pTHX_ SV*, HV*); |
392 # if (PERL_REVISION == 5) && (PERL_VERSION >= 8) | 394 # if (PERL_REVISION == 5) && (PERL_VERSION >= 8) |
393 static void (*Perl_sv_catpvn_flags)(pTHX_ SV* , const char*, STRLEN, I32); | 395 static void (*Perl_sv_catpvn_flags)(pTHX_ SV* , const char*, STRLEN, I32); |
394 # else | 396 # else |
395 static void (*Perl_sv_catpvn)(pTHX_ SV*, const char*, STRLEN); | 397 static void (*Perl_sv_catpvn)(pTHX_ SV*, const char*, STRLEN); |
541 {"Perl_sv_2pv_flags", (PERL_PROC*)&Perl_sv_2pv_flags}, | 543 {"Perl_sv_2pv_flags", (PERL_PROC*)&Perl_sv_2pv_flags}, |
542 {"Perl_sv_2pv_nolen", (PERL_PROC*)&Perl_sv_2pv_nolen}, | 544 {"Perl_sv_2pv_nolen", (PERL_PROC*)&Perl_sv_2pv_nolen}, |
543 # else | 545 # else |
544 {"Perl_sv_2pv", (PERL_PROC*)&Perl_sv_2pv}, | 546 {"Perl_sv_2pv", (PERL_PROC*)&Perl_sv_2pv}, |
545 # endif | 547 # endif |
548 {"Perl_sv_2pvbyte", (PERL_PROC*)&Perl_sv_2pvbyte}, | |
546 # ifdef PERL589_OR_LATER | 549 # ifdef PERL589_OR_LATER |
547 {"Perl_sv_2iv_flags", (PERL_PROC*)&Perl_sv_2iv_flags}, | 550 {"Perl_sv_2iv_flags", (PERL_PROC*)&Perl_sv_2iv_flags}, |
548 {"Perl_newXS_flags", (PERL_PROC*)&Perl_newXS_flags}, | 551 {"Perl_newXS_flags", (PERL_PROC*)&Perl_newXS_flags}, |
549 # endif | 552 # endif |
550 {"Perl_sv_bless", (PERL_PROC*)&Perl_sv_bless}, | 553 {"Perl_sv_bless", (PERL_PROC*)&Perl_sv_bless}, |
1554 XPUSHs(sv_2mortal(newSViv(1))); | 1557 XPUSHs(sv_2mortal(newSViv(1))); |
1555 XPUSHs(sv_2mortal(newSVpv((char *)value, 0))); | 1558 XPUSHs(sv_2mortal(newSVpv((char *)value, 0))); |
1556 vim_free(value); | 1559 vim_free(value); |
1557 } | 1560 } |
1558 | 1561 |
1562 SV* | |
1563 Blob(SV* sv) | |
1564 PREINIT: | |
1565 STRLEN len; | |
1566 char *s; | |
1567 int i; | |
1568 char buf[3]; | |
1569 SV* newsv; | |
1570 | |
1571 CODE: | |
1572 s = SvPVbyte(sv, len); | |
1573 newsv = newSVpv("0z", 2); | |
1574 for (i = 0; i < len; i++) | |
1575 { | |
1576 sprintf(buf, "%02X", s[i]); | |
1577 sv_catpvn(newsv, buf, 2); | |
1578 } | |
1579 RETVAL = newsv; | |
1580 OUTPUT: | |
1581 RETVAL | |
1582 | |
1559 void | 1583 void |
1560 Buffers(...) | 1584 Buffers(...) |
1561 | 1585 |
1562 PREINIT: | 1586 PREINIT: |
1563 buf_T *vimbuf; | 1587 buf_T *vimbuf; |