Change 17742 by [EMAIL PROTECTED] on 2002/08/20 14:51:16
Subject: [REVISED PATCH] Magic v-strings
From: John Peacock <[EMAIL PROTECTED]>
Date: Sat, 10 Aug 2002 15:56:22 -0400 (20:56 BST)
Message-id: <[EMAIL PROTECTED]>
plus a bit of cleanup
Affected files ...
.... //depot/perl/dump.c#121 edit
.... //depot/perl/perl.h#469 edit
.... //depot/perl/pod/perlguts.pod#110 edit
.... //depot/perl/sv.c#578 edit
.... //depot/perl/sv.h#121 edit
.... //depot/perl/util.c#355 edit
Differences ...
==== //depot/perl/dump.c#121 (text) ====
Index: perl/dump.c
--- perl/dump.c#120~17728~ Fri Aug 16 19:07:24 2002
+++ perl/dump.c Tue Aug 20 07:51:16 2002
@@ -768,6 +768,7 @@
{ PERL_MAGIC_taint, "taint(t)" },
{ PERL_MAGIC_uvar_elem, "uvar_elem(v)" },
{ PERL_MAGIC_vec, "vec(v)" },
+ { PERL_MAGIC_vstring, "v-string(V)" },
{ PERL_MAGIC_substr, "substr(x)" },
{ PERL_MAGIC_defelem, "defelem(y)" },
{ PERL_MAGIC_ext, "ext(~)" },
==== //depot/perl/perl.h#469 (text) ====
Index: perl/perl.h
--- perl/perl.h#468~17740~ Tue Aug 20 07:07:56 2002
+++ perl/perl.h Tue Aug 20 07:51:16 2002
@@ -2620,6 +2620,7 @@
#define PERL_MAGIC_uvar 'U' /* Available for use by extensions */
#define PERL_MAGIC_uvar_elem 'u' /* Reserved for use by extensions */
#define PERL_MAGIC_vec 'v' /* vec() lvalue */
+#define PERL_MAGIC_vstring 'V' /* SV was vstring literal */
#define PERL_MAGIC_substr 'x' /* substr() lvalue */
#define PERL_MAGIC_defelem 'y' /* Shadow "foreach" iterator variable /
smart parameter vivification */
==== //depot/perl/pod/perlguts.pod#110 (text) ====
Index: perl/pod/perlguts.pod
--- perl/pod/perlguts.pod#109~17031~ Thu Jun 6 04:49:13 2002
+++ perl/pod/perlguts.pod Tue Aug 20 07:51:16 2002
@@ -963,6 +963,7 @@
t PERL_MAGIC_taint vtbl_taint Taintedness
U PERL_MAGIC_uvar vtbl_uvar Available for use by extensions
v PERL_MAGIC_vec vtbl_vec vec() lvalue
+ V PERL_MAGIC_vstring (none) v-string scalars
x PERL_MAGIC_substr vtbl_substr substr() lvalue
y PERL_MAGIC_defelem vtbl_defelem Shadow "foreach" iterator
variable / smart parameter
@@ -974,10 +975,10 @@
~ PERL_MAGIC_ext (none) Available for use by extensions
When an uppercase and lowercase letter both exist in the table, then the
-uppercase letter is used to represent some kind of composite type (a list
-or a hash), and the lowercase letter is used to represent an element of
-that composite type. Some internals code makes use of this case
-relationship.
+uppercase letter is typically used to represent some kind of composite type
+(a list or a hash), and the lowercase letter is used to represent an element
+of that composite type. Some internals code makes use of this case
+relationship. However, 'v' and 'V' (vec and v-string) are in no way related.
The C<PERL_MAGIC_ext> and C<PERL_MAGIC_uvar> magic types are defined
specifically for use by extensions and will not be used by perl itself.
==== //depot/perl/sv.c#578 (text) ====
Index: perl/sv.c
--- perl/sv.c#577~17740~ Tue Aug 20 07:07:56 2002
+++ perl/sv.c Tue Aug 20 07:51:16 2002
@@ -4023,6 +4023,11 @@
SvIsUV_on(dstr);
SvIVX(dstr) = SvIVX(sstr);
}
+ if (SvVOK(sstr)) {
+ MAGIC *mg = SvMAGIC(sstr);
+ sv_magicext(dstr, NULL, PERL_MAGIC_vstring, NULL,
+ mg->mg_ptr, mg->mg_len);
+ }
}
else if (sflags & SVp_IOK) {
if (sflags & SVf_IOK)
==== //depot/perl/sv.h#121 (text) ====
Index: perl/sv.h
--- perl/sv.h#120~17740~ Tue Aug 20 07:07:56 2002
+++ perl/sv.h Tue Aug 20 07:51:16 2002
@@ -578,6 +578,7 @@
#define SvIOK_notUV(sv) ((SvFLAGS(sv) & (SVf_IOK|SVf_IVisUV)) \
== SVf_IOK)
+#define SvVOK(sv) (SvMAGICAL(sv) && mg_find(sv,'V'))
#define SvIsUV(sv) (SvFLAGS(sv) & SVf_IVisUV)
#define SvIsUV_on(sv) (SvFLAGS(sv) |= SVf_IVisUV)
#define SvIsUV_off(sv) (SvFLAGS(sv) &= ~SVf_IVisUV)
==== //depot/perl/util.c#355 (text) ====
Index: perl/util.c
--- perl/util.c#354~17689~ Tue Aug 6 13:45:30 2002
+++ perl/util.c Tue Aug 20 07:51:16 2002
@@ -325,7 +325,7 @@
PerlIO_printf(Perl_debug_log, " . ");
}
}
- PerlIO_printf(Perl_debug_log, "\n");
+ PerlIO_printf(Perl_debug_log, "\n");
}
}
@@ -2861,7 +2861,7 @@
#endif
{
bool seen_dot = 0;
-
+
PL_bufend = s + strlen(s);
while (s < PL_bufend) {
#ifdef MACOS_TRADITIONAL
@@ -4087,21 +4087,20 @@
for (;;) {
rev = 0;
{
- /* this is atoi() that tolerates underscores */
- char *end = pos;
- UV mult = 1;
- if ( s > pos && *(s-1) == '_') {
- mult = 10;
- }
- while (--end >= s) {
- UV orev;
- 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");
- }
+ /* 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)
@@ -4112,13 +4111,13 @@
sv_catpvn(sv, (const char*)tmpbuf, tmpend - tmpbuf);
if (!UNI_IS_INVARIANT(NATIVE_TO_UNI(rev)))
SvUTF8_on(sv);
- if ( (*pos == '.' || *pos == '_') && isDIGIT(pos[1]))
+ if (*pos == '.' && isDIGIT(pos[1]))
s = ++pos;
else {
s = pos;
break;
}
- while (isDIGIT(*pos) )
+ while (isDIGIT(*pos) || *pos == '_')
pos++;
}
SvPOK_on(sv);
End of Patch.