From: Nicholas Clark Date: Sat, 24 Nov 2007 11:40:28 +0000 (+0000) Subject: Eliminating the duplicate logic in S_method_common() and X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=16815324371ba58b10695db6d57346a07b27a2e5;p=p5sagit%2Fp5-mst-13.2.git Eliminating the duplicate logic in S_method_common() and Perl_gv_fetchmethod_autoload() is clearly TODO. Move the paragraph "strcat(), strcpy(), strncat(), strncpy(), sprintf(), vsprintf()" to the section "Tasks that need a little C knowledge" as it doesn't need any XS knowledge. p4raw-id: //depot/perl@32478 --- diff --git a/gv.c b/gv.c index 9ab582d..88e9993 100644 --- a/gv.c +++ b/gv.c @@ -575,6 +575,17 @@ S_gv_get_super_pkg(pTHX_ const char* name, I32 namelen) return stash; } +/* FIXME. If changing this function note the comment in pp_hot's + S_method_common: + + This code tries to figure out just what went wrong with + gv_fetchmethod. It therefore needs to duplicate a lot of + the internals of that function. ... + + I'd guess that with one more flag bit that could all be moved inside + here. +*/ + GV * Perl_gv_fetchmethod_autoload(pTHX_ HV *stash, const char *name, I32 autoload) { diff --git a/pod/perltodo.pod b/pod/perltodo.pod index 5adc1fb..63da3f9 100644 --- a/pod/perltodo.pod +++ b/pod/perltodo.pod @@ -468,6 +468,18 @@ Jarkko notes that one can things morally equivalent to C<__FUNCTION__> See L if you feel like making C more useful on Win32. +=head2 strcat(), strcpy(), strncat(), strncpy(), sprintf(), vsprintf() + +Maybe create a utility that checks after each libperl.a creation that +none of the above (nor sprintf(), vsprintf(), or *SHUDDER* gets()) +ever creep back to libperl.a. + + nm libperl.a | ./miniperl -alne '$o = $F[0] if /:$/; print "$o $F[1]" if $F[0] eq "U" && $F[1] =~ /^(?:strn?c(?:at|py)|v?sprintf|gets)$/' + +Note, of course, that this will only tell whether B platform +is using those naughty interfaces. + + =head1 Tasks that need a knowledge of XS These tasks would need C knowledge, and roughly the level of knowledge of @@ -547,17 +559,6 @@ system() accepts a LIST syntax (and a PROGRAM LIST syntax) to avoid running a shell. readpipe() (the function behind qx//) could be similarly extended. -=head2 strcat(), strcpy(), strncat(), strncpy(), sprintf(), vsprintf() - -Maybe create a utility that checks after each libperl.a creation that -none of the above (nor sprintf(), vsprintf(), or *SHUDDER* gets()) -ever creep back to libperl.a. - - nm libperl.a | ./miniperl -alne '$o = $F[0] if /:$/; print "$o $F[1]" if $F[0] eq "U" && $F[1] =~ /^(?:strn?c(?:at|py)|v?sprintf|gets)$/' - -Note, of course, that this will only tell whether B platform -is using those naughty interfaces. - =head2 Audit the code for destruction ordering assumptions Change 25773 notes @@ -608,6 +609,25 @@ from to . It should now be possible to propagate const-correctness outwards to C, C and C. +=head2 Duplicate logic in S_method_common() and Perl_gv_fetchmethod_autoload() + +A comment in C notes + + /* This code tries to figure out just what went wrong with + gv_fetchmethod. It therefore needs to duplicate a lot of + the internals of that function. We can't move it inside + Perl_gv_fetchmethod_autoload(), however, since that would + cause UNIVERSAL->can("NoSuchPackage::foo") to croak, and we + don't want that. + */ + +If C gets rewritten to take (more) flag bits, +then it ought to be possible to move the logic from C to +the "right" place. When making this change it would probably be good to also +pass in at least the method name length, if not also pre-computed hash values +when known. (I'm contemplating a plan to pre-compute hash values for common +fixed strings such as C and pass them in to functions.) + =head1 Tasks that need a knowledge of the interpreter