Author: jrieks
Date: Thu Apr 14 06:23:17 2005
New Revision: 7831
Modified:
trunk/classes/scalar.pmc
Log:
[perl #34964] [PATCH] Fix some segfaults due to scalar.pmc/string.pmc
This patch fixes a few operations which are badly inherited by string
from scalar.pmc. increment/decrement have been removed as they aren't
really required for Strings. 'neg' also also suffered from a similar
problem, so this patch also stops this example segfaulting:
.sub test
new $P0, .String
$P0 = "12"
neg $P0
print $P0
print_newline
.end
You may need to do a make clean or similar to get string.c to be
properly built...(?)
[My feeling is that scalar should define set_integer_native,
set_number_native etc. to automatically morph, and then for integer,
float and string to override these to either not morph (for better
performance), or just do their own thing (i.e.
string::set_integer_native to convert the int to a String). That way you
can't get data being changed without its interpretation.]
Courtesy of Nick Glencross <[EMAIL PROTECTED]>
Modified: trunk/classes/scalar.pmc
==============================================================================
--- trunk/classes/scalar.pmc (original)
+++ trunk/classes/scalar.pmc Thu Apr 14 06:23:17 2005
@@ -87,7 +87,6 @@
=item C<STRING *get_string()>
-
=cut
*/
@@ -477,10 +476,7 @@
*/
void neg (PMC* dest) {
- if (dest == SELF)
- PMC_int_val(SELF) = -DYNSELF.get_integer();
- else
- VTABLE_set_integer_native(INTERP, dest, -DYNSELF.get_integer());
+ VTABLE_set_integer_native(INTERP, dest, -DYNSELF.get_integer());
}
/*
@@ -931,33 +927,6 @@
(UINTVAL)value, NULL) );
}
-/*
-
-=item C<void increment()>
-
-Increments the scalar.
-
-=cut
-
-*/
-
- void increment () {
- PMC_int_val(SELF) = DYNSELF.get_integer() + 1;
- }
-
-/*
-
-=item C<void decrement()>
-
-Decrements the scalar.
-
-=cut
-
-*/
-
- void decrement () {
- PMC_int_val(SELF) = DYNSELF.get_integer() - 1;
- }
/*