… | |
… | |
655 | PPCODE: |
655 | PPCODE: |
656 | { |
656 | { |
657 | STRLEN svlen; |
657 | STRLEN svlen; |
658 | char *svptr = SvPVbyte (data, svlen); |
658 | char *svptr = SvPVbyte (data, svlen); |
659 | UV len = SvUV (length); |
659 | UV len = SvUV (length); |
|
|
660 | int fd; |
|
|
661 | |
|
|
662 | if (SvTYPE (data) > SVt_PVMG) |
|
|
663 | croak ("illegal data argument '%s', must be plain scalar string", SvPV_nolen (data)); |
660 | |
664 | |
661 | SvUPGRADE (data, SVt_PV); |
665 | SvUPGRADE (data, SVt_PV); |
662 | SvPOK_on (data); |
666 | SvPOK_only (data); |
663 | |
667 | |
664 | if (dataoffset < 0) |
668 | if (dataoffset < 0) |
665 | dataoffset += svlen; |
669 | dataoffset += svlen; |
666 | |
670 | |
667 | if (dataoffset < 0 || dataoffset > svlen) |
671 | if (dataoffset < 0 || dataoffset > svlen) |
… | |
… | |
680 | } |
684 | } |
681 | |
685 | |
682 | if (len < 0) |
686 | if (len < 0) |
683 | croak ("length must not be negative"); |
687 | croak ("length must not be negative"); |
684 | |
688 | |
|
|
689 | fd = PerlIO_fileno (ix == EIO_READ ? IoIFP (sv_2io (fh)) |
|
|
690 | : IoOFP (sv_2io (fh))); |
|
|
691 | |
|
|
692 | if (fd < 0) |
|
|
693 | croak ("illegal fh argument, either not an OS file or read/write mode mismatch"); |
|
|
694 | |
685 | { |
695 | { |
686 | dREQ; |
696 | dREQ; |
687 | |
697 | |
688 | req->type = ix; |
698 | req->type = ix; |
689 | req->sv1 = newSVsv (fh); |
699 | req->sv1 = newSVsv (fh); |
690 | req->int1 = PerlIO_fileno (ix == EIO_READ ? IoIFP (sv_2io (fh)) |
700 | req->int1 = df; |
691 | : IoOFP (sv_2io (fh))); |
|
|
692 | req->offs = SvOK (offset) ? SvVAL64 (offset) : -1; |
701 | req->offs = SvOK (offset) ? SvVAL64 (offset) : -1; |
693 | req->size = len; |
702 | req->size = len; |
694 | req->sv2 = SvREFCNT_inc (data); |
703 | req->sv2 = SvREFCNT_inc (data); |
695 | req->ptr2 = (char *)svptr + dataoffset; |
704 | req->ptr2 = (char *)svptr + dataoffset; |
696 | req->stroffset = dataoffset; |
705 | req->stroffset = dataoffset; |