Date: Monday March 02, 2020 @ 05:28 Author: argrath Update of /cvsroot/perldocjp/docs/perl/5.20.1 In directory sf-cvs:/tmp/cvs-serv2049/perl/5.20.1 Modified Files: perlguts.pod Log Message: 5.20.1/perlguts =================================================================== File: perlguts.pod Status: Up-to-date Working revision: 1.4 Sun Mar 1 20:28:48 2020 Repository revision: 1.4 /cvsroot/perldocjp/docs/perl/5.20.1/perlguts.pod,v Sticky Options: -kb Existing Tags: No Tags Exist -------------- next part -------------- Index: docs/perl/5.20.1/perlguts.pod diff -u docs/perl/5.20.1/perlguts.pod:1.3 docs/perl/5.20.1/perlguts.pod:1.4 --- docs/perl/5.20.1/perlguts.pod:1.3 Fri Jul 27 23:41:46 2018 +++ docs/perl/5.20.1/perlguts.pod Mon Mar 2 05:28:48 2020 @@ -390,13 +390,13 @@ =end original -If you want to write to an existing SV's buffer and set its value to a -string, use SvPV_force() or one of its variants to force the SV to be -a PV. This will remove any of various types of non-stringness from -the SV while preserving the content of the SV in the PV. This can be -used, for example, to append data from an API function to a buffer -without extra copying: -(TBT) +¤â¤·´û¸¤Î SV ¤Î¥Ð¥Ã¥Õ¥¡¤Ë½ñ¤¹þ¤ß¤¿¤¯¤Æ¡¢¤½¤ÎÃͤòʸ»úÎó¤ËÀßÄꤷ¤¿¤¤¤Ê¤é¡¢ +SV ¤ò PV ¤Ë¶¯À©¤¹¤ë¤¿¤á¤Ë +SvPV_force() ¤Þ¤¿¤Ï¤½¤ÎÊѼï¤Î°ì¤Ä¤ò»È¤Ã¤Æ¤¯¤À¤µ¤¤¡£ +¤³¤ì¤Ï SV ¤«¤éÍÍ¡¹¤Ê¼ïÎà¤ÎÈóʸ»úÎóÀ¤ò½üµî¤¹¤ë°ìÊý¡¢PV ¤ÎÃæ¤Î SV ¤Î +ÆâÍƤÏÊݸ¤·¤Þ¤¹¡£ +¤³¤ì¤Ï¡¢Î㤨¤Ð¡¢ÄɲäΥ³¥Ô¡¼¤Ê¤·¤Ë API ´Ø¿ô¤«¤é¥Ð¥Ã¥Õ¥¡¤Ë¥Ç¡¼¥¿¤ò +Äɲ乤ë¤Î¤Ë»È¤¨¤Þ¤¹: (void)SvPVbyte_force(sv, len); s = SvGROW(sv, len + needlen + 1); @@ -419,11 +419,10 @@ =end original -If you already have the data in memory or if you want to keep your -code simple, you can use one of the sv_cat*() variants, such as -sv_catpvn(). If you want to insert anywhere in the string you can use -sv_insert() or sv_insert_flags(). -(TBT) +´û¤Ë¥á¥â¥ê¤Ë¥Ç¡¼¥¿¤ò»ý¤Ã¤Æ¤¤¤ë¾ì¹ç¤ä¡¢¥³¡¼¥É¤òñ½ã¤ËÊݤÁ¤¿¤¤¾ì¹ç¤Ï¡¢ +sv_catpvn() ¤Î¤è¤¦¤Ê sv_cat*() ¤ÎÊѼï¤Î°ì¤Ä¤ò»È¤¨¤Þ¤¹¡£ +¤â¤·Ê¸»úÎóÃæ¤Î¤É¤³¤«¤ËÁÞÆþ¤·¤¿¤¤¤Ê¤é¡¢sv_insert() ¤ä +sv_insert_flags() ¤¬»È¤¨¤Þ¤¹¡£ =begin original @@ -432,9 +431,8 @@ =end original -If you don't need the existing content of the SV, you can avoid some -copying with: -(TBT) +SV ¤Î´û¸¤ÎÆâÍƤ¬É¬ÍפǤʤ¤¤Ê¤é¡¢¼¡¤Î¤è¤¦¤Ë¤·¤Æ°ìÉô¤Î¥³¥Ô¡¼¤ò +²óÈò¤Ç¤¤Þ¤¹: sv_setpvn(sv, "", 0); s = SvGROW(sv, needlen + 1); @@ -454,9 +452,8 @@ =end original -Again, if you already have the data in memory or want to avoid the -complexity of the above, you can use sv_setpvn(). -(TBT) +ºÆ¤Ó¡¢´û¤Ë¥á¥â¥ê¤Ë¥Ç¡¼¥¿¤ò»ý¤Ã¤Æ¤¤¤ë¾ì¹ç¤ä¡¢Á°½Ò¤Î¤è¤¦¤ÊÊ£»¨¤µ¤ò +Èò¤±¤¿¤¤¾ì¹ç¤Ï¡¢sv_setpvn() ¤¬»È¤¨¤Þ¤¹¡£ =begin original @@ -467,11 +464,11 @@ =end original -If you have a buffer allocated with Newx() and want to set that as the -SV's value, you can use sv_usepvn_flags(). That has some requirements -if you want to avoid perl re-allocating the buffer to fit the trailing -NUL: -(TBT) +If you have a buffer allocated with +Newx() ¤Ç³ä¤êÅö¤Æ¤é¤ì¤¿¥Ð¥Ã¥Õ¥¡¤ò»ý¤Ã¤Æ¤¤¤Æ¡¢¤½¤ì¤ò SV ¤ÎÃͤȤ·¤Æ +ÀßÄꤷ¤¿¤¤¤Ê¤é¡¢sv_usepvn_flags() ¤¬»È¤¨¤Þ¤¹¡£ +perl ¤¬ËöÈø¤Î NUL ¤Ë¼ý¤Þ¤ë¤è¤¦¤Ë¥Ð¥Ã¥Õ¥¡¤òºÆÇÛÃÖ¤¹¤ë¤Î¤òÈò¤±¤¿¤¤¤Ê¤é¡¢ +¤¤¤¯¤Ä¤«¤ÎÍ×µá»ö¹à¤¬¤¢¤ê¤Þ¤¹: Newx(buf, somesize+1, char); /* ... fill in buf ... */ @@ -486,8 +483,9 @@ =end original -¼ê¸µ¤Ë¤¢¤ë SV ¤Î¡¢Perl ¤«¤é¸«¤¿¥Ç¡¼¥¿¤Î¼ïÎà¤òÃΤꤿ¤¤¤È¤¤Ë¤Ï¡¢ -¤½¤Î SV ¤Î·¿¤ò¥Á¥§¥Ã¥¯¤¹¤ë¤Î¤Ë +¤¢¤ë SV ¤¬¤¢¤Ã¤Æ¡¢¤½¤ì¤ËÊݴɤµ¤ì¤Æ¤¤¤ë¥Ç¡¼¥¿¤Î¼ïÎब²¿¤Ç¤¢¤ë¤È +Perl ¤¬¹Í¤¨¤Æ¤¤¤ë¤«¤òÃΤꤿ¤¤¤Ê¤é¡¢ +¤½¤Î SV ¤Î·¿¤ò¥Á¥§¥Ã¥¯¤¹¤ë¤Î¤Ë¼¡¤Î¤è¤¦¤Ê¥Þ¥¯¥í¤¬»È¤¨¤Þ¤¹¡£ SvIOK(SV*) SvNOK(SV*) @@ -2395,12 +2393,11 @@ =end original -Perl implements a copy-on-write (COW) mechanism for scalars, in which -string copies are not immediately made when requested, but are deferred -until made necessary by one or the other scalar changing. This is mostly -transparent, but one must take care not to modify string buffers that are -shared by multiple SVs. -(TBT) +Perl ¤Ï¡¢¥¹¥«¥é¤Ë´Ø¤·¤Æ¥³¥Ô¡¼¥ª¥ó¥é¥¤¥È (COW) µ¡¹½¤ò¼ÂÁõ¤·¤Æ¤¤¤Þ¤¹; +¤³¤ì¤Ï¡¢Ê¸»úÎó¤Î¥³¥Ô¡¼¤ÏÍ׵ᤵ¤ì¤¿¤È¤¤Ë¤¹¤°¤Ë¹Ô¤¦¤Î¤Ç¤Ï¤Ê¤¯¡¢ +¤É¤Á¤é¤«¤Î¥¹¥«¥é¤¬Êѹ¹¤µ¤ì¤ë¤³¤È¤Ë¤è¤Ã¤ÆɬÍפˤʤë¤Þ¤ÇÃٱ䤵¤»¤Þ¤¹¡£ +¤³¤ì¤Ï¤Û¤È¤ó¤ÉÆ©²á¤Ç¤¹¤¬¡¢Ê£¿ô¤Î SV ¤Ç¶¦Í¤µ¤ì¤Æ¤¤¤ëʸ»úÎó¥Ð¥Ã¥Õ¥¡¤ò +Êѹ¹¤·¤Ê¤¤¤è¤¦¤ËÃí°Õ¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ =begin original @@ -2408,8 +2405,8 @@ =end original -You can test whether an SV is using copy-on-write with C<SvIsCOW(sv)>. -(TBT) +¤¢¤ë SV ¤¬¥³¥Ô¡¼¥ª¥ó¥é¥¤¥È¤ò»È¤Ã¤Æ¤¤¤ë¤«¤É¤¦¤«¤Ï C<SvIsCOW(sv)> ¤Ç +¥Æ¥¹¥È¤Ç¤¤Þ¤¹¡£ =begin original @@ -2417,8 +2414,8 @@ =end original -You can force an SV to make its own copy of its string buffer by calling C<sv_force_normal(sv)> or SvPV_force_nolen(sv). -(TBT) +C<sv_force_normal(sv)> ¤« SvPV_force_nolen(sv) ¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤Ç¡¢ +SV ¤¬Ê¸»úÎó¤Ë´Ø¤·¤Æ¼«Ê¬¼«¿È¤Î¥³¥Ô¡¼¤ò»ý¤Ä¤è¤¦¤Ë¶¯À©¤Ç¤¤Þ¤¹¡£ =begin original @@ -2428,10 +2425,9 @@ =end original -If you want to make the SV drop its string buffer, use -C<sv_force_normal_flags(sv, SV_COW_DROP_PV)> or simply -C<sv_setsv(sv, NULL)>. -(TBT) +SV ¤Ë¼«Ê¬¼«¿È¤Îʸ»úÎó¥Ð¥Ã¥Õ¥¡¤ò¼Î¤Æ¤µ¤»¤¿¤¤¾ì¹ç¤Ï¡¢ +C<sv_force_normal_flags(sv, SV_COW_DROP_PV)> ¤«¡¢Ã±¤Ë +C<sv_setsv(sv, NULL)> ¤ò»È¤¤¤Þ¤¹¡£ =begin original @@ -2440,9 +2436,8 @@ =end original -All of these functions will croak on read-only scalars (see the previous -section for more on those). -(TBT) +¤³¤ì¤éÁ´¤Æ¤Î´Ø¿ô¤Ï¡¢Æɤ߹þ¤ßÀìÍÑ¥¹¥«¥é¤ËÂФ·¤Æ¤Ï croak ¤·¤Þ¤¹ +(¤³¤ì¤Ë´Ø¤¹¤ë¾ÜºÙ¤ÏÁ°¤ÎÀá¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤)¡£ =begin original @@ -2454,12 +2449,12 @@ =end original -To test that your code is behaving correctly and not modifying COW buffers, -on systems that support L<mmap(2)> (i.e., Unix) you can configure perl with -C<-Accflags=-DPERL_DEBUG_READONLY_COW> and it will turn buffer violations -into crashes. You will find it to be marvellously slow, so you may want to -skip perl's own tests. -(TBT) +¤¢¤Ê¤¿¤Î¥³¡¼¥É¤¬Àµ¤·¤¯¿¶¤ëÉñ¤Ã¤Æ¡¢COW ¥Ð¥Ã¥Õ¥¡¤òÊѹ¹¤·¤Æ¤¤¤Ê¤¤¤³¤È¤ò +¥Æ¥¹¥È¤¹¤ë¤Ë¤Ï¡¢ +L<mmap(2)> ¤ËÂбþ¤·¤Æ¤¤¤ë¥·¥¹¥Æ¥à (Î㤨¤Ð Unix) ¤Ç¤Ï¡¢ +C<-Accflags=-DPERL_DEBUG_READONLY_COW> ¤ò͸ú¤Ë¤·¤¿ perl ¤òÀßÄꤹ¤ë¤È¡¢ +¥Ð¥Ã¥Õ¥¡°ãÈ¿¤Ç¥¯¥é¥Ã¥·¥å¤¹¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£ +¤³¤ì¤Ï¶Ã¤¯¤Û¤ÉÃÙ¤¤¤Î¤Ç¡¢perl ¼«¿È¤Î¥Æ¥¹¥È¤ÏÈô¤Ð¤·¤¿Êý¤¬Îɤ¤¤Ç¤·¤ç¤¦¡£ =head2 Magic Variables @@ -7118,7 +7113,7 @@ Translate: KIMURA Koichi Update: Kentaro Shirakata <argra****@ub32*****> (5.10.0-) -Status: in progress +Status: completed =end meta