Skip to content

Commit fee8fc3

Browse files
committed
mg.c: Add asserts
These two switch() statements handle magic names. We now have a quick way to determine if the first character of a name is magic. Assert that the cases of the switch match. This will tell us if something gets out-of-sync.
1 parent 0eb8960 commit fee8fc3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mg.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,9 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
906906
}
907907

908908
nextchar = *remaining;
909+
910+
assert(generic_isCC_(*mg->mg_ptr, CC_MAGICAL_));
911+
909912
switch (*mg->mg_ptr) {
910913
case '\001': /* ^A */
911914
if (SvOK(PL_bodytarget)) sv_copypv(sv, PL_bodytarget);
@@ -3016,6 +3019,8 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
30163019
return 0;
30173020
}
30183021

3022+
assert(generic_isCC_(*mg->mg_ptr, CC_MAGICAL_));
3023+
30193024
switch (*mg->mg_ptr) {
30203025
case '\001': /* ^A */
30213026
if (SvOK(sv)) sv_copypv(PL_bodytarget, sv);

0 commit comments

Comments
 (0)