Change 20092 by [EMAIL PROTECTED] on 2003/07/09 11:41:01
Integrate:
[ 20084]
Subject: Re: [REPATCH] was Re: [perl #16010] v-strings left of a => don't get
quoted.
From: John Peacock <[EMAIL PROTECTED]>
Date: Wed, 09 Jul 2003 01:05:38 -0700
Message-ID: <[EMAIL PROTECTED]>
[ 20085]
Test the vX => ... fix.
[ 20086]
Document the v-string change in perldelta.
[ 20087]
perldelta clarification.
[ 20088]
Document the vXX => change in perldata, too.
[ 20089]
Rework the perldata vXX => ... entry a bit.
Affected files ...
... //depot/maint-5.8/perl/embed.fnc#36 integrate
... //depot/maint-5.8/perl/pod/perlapi.pod#15 integrate
... //depot/maint-5.8/perl/pod/perldata.pod#6 integrate
... //depot/maint-5.8/perl/t/op/ver.t#4 integrate
... //depot/maint-5.8/perl/toke.c#23 integrate
... //depot/maint-5.8/perl/util.c#26 integrate
Differences ...
==== //depot/maint-5.8/perl/embed.fnc#36 (text) ====
Index: perl/embed.fnc
--- perl/embed.fnc#35~20091~ Wed Jul 9 01:23:20 2003
+++ perl/embed.fnc Wed Jul 9 04:41:01 2003
@@ -549,7 +549,7 @@
|I32 whileline|OP* expr|OP* block|OP* cont
Ap |PERL_SI*|new_stackinfo|I32 stitems|I32 cxitems
-Apd |char* |scan_vstring |char *vstr|SV *sv
+Ap |char* |scan_vstring |char *vstr|SV *sv
p |PerlIO*|nextargv |GV* gv
Ap |char* |ninstr |const char* big|const char* bigend \
|const char* little|const char* lend
==== //depot/maint-5.8/perl/pod/perlapi.pod#15 (text+w) ====
Index: perl/pod/perlapi.pod
--- perl/pod/perlapi.pod#14~19951~ Thu Jul 3 01:47:35 2003
+++ perl/pod/perlapi.pod Wed Jul 9 04:41:01 2003
@@ -1797,6 +1797,39 @@
=for hackers
Found in file handy.h
+=item sv_nolocking
+
+Dummy routine which "locks" an SV when there is no locking module present.
+Exists to avoid test for a NULL function pointer and because it could potentially
warn under
+some level of strict-ness.
+
+ void sv_nolocking(SV *)
+
+=for hackers
+Found in file util.c
+
+=item sv_nosharing
+
+Dummy routine which "shares" an SV when there is no sharing module present.
+Exists to avoid test for a NULL function pointer and because it could potentially
warn under
+some level of strict-ness.
+
+ void sv_nosharing(SV *)
+
+=for hackers
+Found in file util.c
+
+=item sv_nounlocking
+
+Dummy routine which "unlocks" an SV when there is no locking module present.
+Exists to avoid test for a NULL function pointer and because it could potentially
warn under
+some level of strict-ness.
+
+ void sv_nounlocking(SV *)
+
+=for hackers
+Found in file util.c
+
=back
@@ -2595,24 +2628,6 @@
=for hackers
Found in file sv.c
-=item new_vstring
-
-Returns a pointer to the next character after the parsed
-vstring, as well as updating the passed in sv.
-
-Function must be called like
-
- sv = NEWSV(92,5);
- s = new_vstring(s,sv);
-
-The sv must already be large enough to store the vstring
-passed in.
-
- char* new_vstring(char *vstr, SV *sv)
-
-=for hackers
-Found in file util.c
-
=item SvCUR
Returns the length of the string which is in the SV. See C<SvLEN>.
@@ -3936,39 +3951,6 @@
=for hackers
Found in file sv.c
-
-=item sv_nolocking
-
-Dummy routine which "locks" an SV when there is no locking module present.
-Exists to avoid test for a NULL function pointer and because it could potentially
warn under
-some level of strict-ness.
-
- void sv_nolocking(SV *)
-
-=for hackers
-Found in file util.c
-
-=item sv_nosharing
-
-Dummy routine which "shares" an SV when there is no sharing module present.
-Exists to avoid test for a NULL function pointer and because it could potentially
warn under
-some level of strict-ness.
-
- void sv_nosharing(SV *)
-
-=for hackers
-Found in file util.c
-
-=item sv_nounlocking
-
-Dummy routine which "unlocks" an SV when there is no locking module present.
-Exists to avoid test for a NULL function pointer and because it could potentially
warn under
-some level of strict-ness.
-
- void sv_nounlocking(SV *)
-
-=for hackers
-Found in file util.c
=item sv_nv
==== //depot/maint-5.8/perl/pod/perldata.pod#6 (text) ====
Index: perl/pod/perldata.pod
--- perl/pod/perldata.pod#5~19704~ Fri Jun 6 22:24:27 2003
+++ perl/pod/perldata.pod Wed Jul 9 04:41:01 2003
@@ -360,6 +360,14 @@
Note that using the v-strings for IPv4 addresses is not portable unless
you also use the inet_aton()/inet_ntoa() routines of the Socket package.
+Note that since Perl 5.8.1 the single-number v-strings (like C<v65>)
+are not v-strings before the C<< => >> operator (which is used to
+separate a hash key from a hash value), instead they are interpreted
+as literal strings ('v65'). They were v-strings from Perl 5.6.0 to
+Perl 5.8.0, but that caused more confusion and breakage than good.
+Multi-number v-strings like C<v65.66> and C<65.66.67> continue to
+be v-strings always.
+
=head3 Special Literals
The special literals __FILE__, __LINE__, and __PACKAGE__
==== //depot/maint-5.8/perl/t/op/ver.t#4 (xtext) ====
Index: perl/t/op/ver.t
--- perl/t/op/ver.t#3~18850~ Fri Mar 7 12:38:51 2003
+++ perl/t/op/ver.t Wed Jul 9 04:41:01 2003
@@ -11,7 +11,7 @@
use Config;
require "test.pl";
-plan( tests => 50 );
+plan( tests => 53 );
eval 'use v5.5.640';
is( $@, '', "use v5.5.640; $@");
@@ -254,3 +254,13 @@
$v = v1.2_3;
is( ref(\$v), 'SCALAR', 'v-strings with v are just scalars' );
is( sprintf("%vd", $v), '1.23', 'v-string ignores underscores' );
+
+# [perl #16010]
+%h = (v65 => 42);
+ok( exists $h{v65}, "v-stringness is not engaged for vX" );
+%h = (v65.66 => 42);
+ok( exists $h{chr(65).chr(66)}, "v-stringness is engaged for vX.Y" );
+%h = (65.66.67 => 42);
+ok( exists $h{chr(65).chr(66).chr(67)}, "v-stringness is engaged for X.Y.Z" );
+
+
==== //depot/maint-5.8/perl/toke.c#23 (text) ====
Index: perl/toke.c
--- perl/toke.c#22~20064~ Mon Jul 7 22:01:15 2003
+++ perl/toke.c Wed Jul 9 04:41:01 2003
@@ -7944,3 +7944,90 @@
}
#endif
+/*
+Returns a pointer to the next character after the parsed
+vstring, as well as updating the passed in sv.
+
+Function must be called like
+
+ sv = NEWSV(92,5);
+ s = scan_vstring(s,sv);
+
+The sv should already be large enough to store the vstring
+passed in, for performance reasons.
+
+*/
+
+char *
+Perl_scan_vstring(pTHX_ char *s, SV *sv)
+{
+ char *pos = s;
+ char *start = s;
+ if (*pos == 'v') pos++; /* get past 'v' */
+ while (isDIGIT(*pos) || *pos == '_')
+ pos++;
+ if ( *pos != '.') {
+ /* this may not be a v-string if followed by => */
+ start = pos;
+ if (isSPACE(*start))
+ start = skipspace(start);
+ if ( *start == '=' && start[1] == '>' )
+ {
+ /* return string not v-string */
+ sv_setpvn(sv,(char *)s,pos-s);
+ return pos;
+ }
+ }
+
+ if (!isALPHA(*pos)) {
+ UV rev;
+ U8 tmpbuf[UTF8_MAXLEN+1];
+ U8 *tmpend;
+
+ if (*s == 'v') s++; /* get past 'v' */
+
+ sv_setpvn(sv, "", 0);
+
+ for (;;) {
+ rev = 0;
+ {
+ /* this is atoi() that tolerates underscores */
+ char *end = pos;
+ UV mult = 1;
+ while (--end >= s) {
+ UV orev;
+ if (*end == '_')
+ continue;
+ orev = rev;
+ rev += (*end - '0') * mult;
+ mult *= 10;
+ if (orev > rev && ckWARN_d(WARN_OVERFLOW))
+ Perl_warner(aTHX_ packWARN(WARN_OVERFLOW),
+ "Integer overflow in decimal number");
+ }
+ }
+#ifdef EBCDIC
+ if (rev > 0x7FFFFFFF)
+ Perl_croak(aTHX_ "In EBCDIC the v-string components cannot exceed
2147483647");
+#endif
+ /* Append native character for the rev point */
+ tmpend = uvchr_to_utf8(tmpbuf, rev);
+ sv_catpvn(sv, (const char*)tmpbuf, tmpend - tmpbuf);
+ if (!UNI_IS_INVARIANT(NATIVE_TO_UNI(rev)))
+ SvUTF8_on(sv);
+ if (*pos == '.' && isDIGIT(pos[1]))
+ s = ++pos;
+ else {
+ s = pos;
+ break;
+ }
+ while (isDIGIT(*pos) || *pos == '_')
+ pos++;
+ }
+ SvPOK_on(sv);
+ sv_magic(sv,NULL,PERL_MAGIC_vstring,(const char*)start, pos-start);
+ SvRMAGICAL_on(sv);
+ }
+ return s;
+}
+
==== //depot/maint-5.8/perl/util.c#26 (text) ====
Index: perl/util.c
--- perl/util.c#25~20064~ Mon Jul 7 22:01:15 2003
+++ perl/util.c Wed Jul 9 04:41:01 2003
@@ -3923,85 +3923,6 @@
#endif
}
-/*
-=head1 SV Manipulation Functions
-
-=for apidoc scan_vstring
-
-Returns a pointer to the next character after the parsed
-vstring, as well as updating the passed in sv.
-
-Function must be called like
-
- sv = NEWSV(92,5);
- s = scan_vstring(s,sv);
-
-The sv must already be large enough to store the vstring
-passed in.
-
-=cut
-*/
-
-char *
-Perl_scan_vstring(pTHX_ char *s, SV *sv)
-{
- char *pos = s;
- char *start = s;
- if (*pos == 'v') pos++; /* get past 'v' */
- while (isDIGIT(*pos) || *pos == '_')
- pos++;
- if (!isALPHA(*pos)) {
- UV rev;
- U8 tmpbuf[UTF8_MAXLEN+1];
- U8 *tmpend;
-
- if (*s == 'v') s++; /* get past 'v' */
-
- sv_setpvn(sv, "", 0);
-
- for (;;) {
- rev = 0;
- {
- /* this is atoi() that tolerates underscores */
- char *end = pos;
- UV mult = 1;
- while (--end >= s) {
- UV orev;
- if (*end == '_' )
- continue;
- orev = rev;
- rev += (*end - '0') * mult;
- mult *= 10;
- if (orev > rev && ckWARN_d(WARN_OVERFLOW))
- Perl_warner(aTHX_ packWARN(WARN_OVERFLOW),
- "Integer overflow in decimal number");
- }
- }
-#ifdef EBCDIC
- if (rev > 0x7FFFFFFF)
- Perl_croak(aTHX_ "In EBCDIC the v-string components cannot exceed
2147483647");
-#endif
- /* Append native character for the rev point */
- tmpend = uvchr_to_utf8(tmpbuf, rev);
- sv_catpvn(sv, (const char*)tmpbuf, tmpend - tmpbuf);
- if (!UNI_IS_INVARIANT(NATIVE_TO_UNI(rev)))
- SvUTF8_on(sv);
- if ( *pos == '.' && isDIGIT(pos[1]) )
- s = ++pos;
- else {
- s = pos;
- break;
- }
- while ( isDIGIT(*pos) || *pos == '_' )
- pos++;
- }
- SvPOK_on(sv);
- sv_magic(sv,NULL,PERL_MAGIC_vstring,(const char*)start, pos-start);
- SvRMAGICAL_on(sv);
- }
- return s;
-}
-
#if !defined(HAS_SOCKETPAIR) && defined(HAS_SOCKET) && defined(AF_INET) &&
defined(PF_INET) && defined(SOCK_DGRAM) && defined(HAS_SELECT)
# define EMULATE_SOCKETPAIR_UDP
#endif
End of Patch.