📄 perlhack.1
字号:
ramblings on posted bugs..SpIf you want to get the best of both worlds, rsync both the sourcetree for convenience, reliability and ease and rsync the patchesfor reference..RE.Sh "Working with the source".IX Subsection "Working with the source"Because you cannot use the Perforce client, you cannot easily generatediffs against the repository, nor will merges occur when you updatevia rsync. If you edit a file locally and then rsync against thelatest source, changes made in the remote copy will \fIoverwrite\fR yourlocal versions!.PPThe best way to deal with this is to maintain a tree of symlinks tothe rsync'd source. Then, when you want to edit a file, you removethe symlink, copy the real file into the other tree, and edit it. Youcan then diff your edited file against the original to generate apatch, and you can safely update the original tree..PPPerl's \fIConfigure\fR script can generate this tree of symlinks for you.The following example assumes that you have used rsync to pull a copyof the Perl source into the \fIperl-rsync\fR directory. In the directoryabove that one, you can execute the following commands:.PP.Vb 3\& mkdir perl\-dev\& cd perl\-dev\& ../perl\-rsync/Configure \-Dmksymlinks \-Dusedevel \-D"optimize=\-g".Ve.PPThis will start the Perl configuration process. After a few prompts,you should see something like this:.PP.Vb 1\& Symbolic links are supported.\&\& Checking how to test for symbolic links...\& Your builtin \*(Aqtest \-h\*(Aq may be broken.\& Trying external \*(Aq/usr/bin/test \-h\*(Aq.\& You can test for symbolic links with \*(Aq/usr/bin/test \-h\*(Aq.\&\& Creating the symbolic links...\& (First creating the subdirectories...)\& (Then creating the symlinks...).Ve.PPThe specifics may vary based on your operating system, of course.After you see this, you can abort the \fIConfigure\fR script, and youwill see that the directory you are in has a tree of symlinks to the\&\fIperl-rsync\fR directories and files..PPIf you plan to do a lot of work with the Perl source, here are someBourne shell script functions that can make your life easier:.PP.Vb 9\& function edit {\& if [ \-L $1 ]; then\& mv $1 $1.orig\& cp $1.orig $1\& vi $1\& else\& vi $1\& fi\& }\&\& function unedit {\& if [ \-L $1.orig ]; then\& rm $1\& mv $1.orig $1\& fi\& }.Ve.PPReplace \*(L"vi\*(R" with your favorite flavor of editor..PPHere is another function which will quickly generate a patch for thefiles which have been edited in your symlink tree:.PP.Vb 12\& mkpatchorig() {\& local diffopts\& for f in \`find . \-name \*(Aq*.orig\*(Aq | sed s,^\e./,,\`\& do\& case \`echo $f | sed \*(Aqs,.orig$,,;s,.*\e.,,\*(Aq\` in\& c) diffopts=\-p ;;\& pod) diffopts=\*(Aq\-F^=\*(Aq ;;\& *) diffopts= ;;\& esac\& diff \-du $diffopts $f \`echo $f | sed \*(Aqs,.orig$,,\*(Aq\`\& done\& }.Ve.PPThis function produces patches which include enough context to makeyour changes obvious. This makes it easier for the Perl pumpking(s)to review them when you send them to the perl5\-porters list, and thatmeans they're more likely to get applied..PPThis function assumed a \s-1GNU\s0 diff, and may require some tweaking forother diff variants..Sh "Perlbug administration".IX Subsection "Perlbug administration"There is a single remote administrative interface for modifying bug status,category, open issues etc. using the \fB\s-1RT\s0\fR bugtracker system, maintainedby Robert Spier. Become an administrator, and close any bugs you can getyour sticky mitts on:.PP.Vb 1\& http://bugs.perl.org/.Ve.PPTo email the bug system administrators:.PP.Vb 1\& "perlbug\-admin" <perlbug\-admin@perl.org>.Ve.Sh "Submitting patches".IX Subsection "Submitting patches"Always submit patches to \fIperl5\-porters@perl.org\fR. If you'repatching a core module and there's an author listed, send the author acopy (see \*(L"Patching a core module\*(R"). This lets other porters reviewyour patch, which catches a surprising number of errors in patches.Either use the diff program (available in source code form fromftp://ftp.gnu.org/pub/gnu/ , or use Johan Vromans' \fImakepatch\fR(available from \fICPAN/authors/id/JV/\fR). Unified diffs are preferred,but context diffs are accepted. Do not send RCS-style diffs or diffswithout context lines. More information is given in the\&\fIPorting/patching.pod\fR file in the Perl source distribution. Pleasepatch against the latest \fBdevelopment\fR version. (e.g., even if you'refixing a bug in the 5.8 track, patch against the latest \fBdevelopment\fRversion rsynced from rsync://public.activestate.com/perl\-current/ ).PPIf changes are accepted, they are applied to the development branch. Thenthe 5.8 pumpking decides which of those patches is to be backported to themaint branch. Only patches that survive the heat of the developmentbranch get applied to maintenance versions..PPYour patch should update the documentation and test suite. See\&\*(L"Writing a test\*(R". If you have added or removed files in the distribution,edit the \s-1MANIFEST\s0 file accordingly, sort the \s-1MANIFEST\s0 file using\&\f(CW\*(C`make manisort\*(C'\fR, and include those changes as part of your patch..PPPatching documentation also follows the same order: if accepted, a patchis first applied to \fBdevelopment\fR, and if relevant then it's backportedto \fBmaintenance\fR. (With an exception for some patches that documentbehaviour that only appears in the maintenance branch, but which haschanged in the development version.).PPTo report a bug in Perl, use the program \fIperlbug\fR which comes withPerl (if you can't get Perl to work, send mail to the address\&\fIperlbug@perl.org\fR or \fIperlbug@perl.com\fR). Reporting bugs through\&\fIperlbug\fR feeds into the automated bug-tracking system, access towhich is provided through the web at http://rt.perl.org/rt3/ . Itoften pays to check the archives of the perl5\-porters mailing list tosee whether the bug you're reporting has been reported before, and ifso whether it was considered a bug. See above for the location ofthe searchable archives..PPThe \s-1CPAN\s0 testers ( http://testers.cpan.org/ ) are a group ofvolunteers who test \s-1CPAN\s0 modules on a variety of platforms. PerlSmokers ( http://www.nntp.perl.org/group/perl.daily\-build andhttp://www.nntp.perl.org/group/perl.daily\-build.reports/ )automatically test Perl source releases on platforms with variousconfigurations. Both efforts welcome volunteers. In order to getinvolved in smoke testing of the perl itself visit<http://search.cpan.org/dist/Test\-Smoke>. In order to start smoketesting \s-1CPAN\s0 modules visit <http://search.cpan.org/dist/CPAN\-YACSmoke/>or <http://search.cpan.org/dist/POE\-Component\-CPAN\-YACSmoke/> or<http://search.cpan.org/dist/CPAN\-Reporter/>..PPIt's a good idea to read and lurk for a while before chipping in.That way you'll get to see the dynamic of the conversations, learn thepersonalities of the players, and hopefully be better prepared to makea useful contribution when do you speak up..PPIf after all this you still think you want to join the perl5\-portersmailing list, send mail to \fIperl5\-porters\-subscribe@perl.org\fR. Tounsubscribe, send mail to \fIperl5\-porters\-unsubscribe@perl.org\fR..PPTo hack on the Perl guts, you'll need to read the following things:.IP "perlguts" 3.IX Item "perlguts"This is of paramount importance, since it's the documentation of whatgoes where in the Perl source. Read it over a couple of times and itmight start to make sense \- don't worry if it doesn't yet, because thebest way to study it is to read it in conjunction with poking at Perlsource, and we'll do that later on..SpYou might also want to look at Gisle Aas's illustrated perlguts \-there's no guarantee that this will be absolutely up-to-date with thelatest documentation in the Perl core, but the fundamentals will beright. ( http://gisle.aas.no/perl/illguts/ ).IP "perlxstut and perlxs" 3.IX Item "perlxstut and perlxs"A working knowledge of \s-1XSUB\s0 programming is incredibly useful for corehacking; XSUBs use techniques drawn from the \s-1PP\s0 code, the portion of theguts that actually executes a Perl program. It's a lot gentler to learnthose techniques from simple examples and explanation than from the coreitself..IP "perlapi" 3.IX Item "perlapi"The documentation for the Perl \s-1API\s0 explains what some of the internalfunctions do, as well as the many macros used in the source..IP "\fIPorting/pumpkin.pod\fR" 3.IX Item "Porting/pumpkin.pod"This is a collection of words of wisdom for a Perl porter; some of it isonly useful to the pumpkin holder, but most of it applies to anyonewanting to go about Perl development..IP "The perl5\-porters \s-1FAQ\s0" 3.IX Item "The perl5-porters FAQ"This should be available from http://dev.perl.org/perl5/docs/p5p\-faq.html .It contains hints on reading perl5\-porters, information on howperl5\-porters works and how Perl development in general works..Sh "Finding Your Way Around".IX Subsection "Finding Your Way Around"Perl maintenance can be split into a number of areas, and certain people(pumpkins) will have responsibility for each area. These areas sometimescorrespond to files or directories in the source kit. Among the areas are:.IP "Core modules" 3.IX Item "Core modules"Modules shipped as part of the Perl core live in the \fIlib/\fR and \fIext/\fRsubdirectories: \fIlib/\fR is for the pure-Perl modules, and \fIext/\fRcontains the core \s-1XS\s0 modules..IP "Tests" 3.IX Item "Tests"There are tests for nearly all the modules, built-ins and major bitsof functionality. Test files all have a .t suffix. Module tests livein the \fIlib/\fR and \fIext/\fR directories next to the module beingtested. Others live in \fIt/\fR. See \*(L"Writing a test\*(R".IP "Documentation" 3.IX Item "Documentation"Documentation maintenance includes looking after everything in the\&\fIpod/\fR directory, (as well as contributing new documentation) andthe documentation to the modules in core..IP "Configure" 3.IX Item "Configure"The configure process is the way we make Perl portable across themyriad of operating systems it supports. Responsibility for theconfigure, build and installation process, as well as the overallportability of the core code rests with the configure pumpkin \- othershelp out with individual operating systems..SpThe files involved are the operating system directories, (\fIwin32/\fR,\&\fIos2/\fR, \fIvms/\fR and so on) the shell scripts which generate \fIconfig.h\fRand \fIMakefile\fR, as well as the metaconfig files which generate\&\fIConfigure\fR. (metaconfig isn't included in the core distribution.).IP "Interpreter" 3.IX Item "Interpreter"And of course, there's the core of the Perl interpreter itself. Let'shave a look at that in a little more detail..PPBefore we leave looking at the layout, though, don't forget that\&\fI\s-1MANIFEST\s0\fR contains not only the file names in the Perl distribution,but short descriptions of what's in them, too. For an overview of theimportant files, try this:.PP.Vb 1\& perl \-lne \*(Aqprint if /^[^\e/]+\e.[ch]\es+/\*(Aq MANIFEST.Ve.Sh "Elements of the interpreter".IX Subsection "Elements of the interpreter"The work of the interpreter has two main stages: compiling the codeinto the internal representation, or bytecode, and then executing it.\&\*(L"Compiled code\*(R" in perlguts explains exactly how the compilation stagehappens..PPHere is a short breakdown of perl's operation:.IP "Startup" 3.IX Item "Startup"The action begins in \fIperlmain.c\fR. (or \fIminiperlmain.c\fR for miniperl)This is very high-level code, enough to fit on a single screen, and itresembles the code found in perlembed; most of the real action takesplace in \fIperl.c\fR.SpFirst, \fIperlmain.c\fR allocates some memory and constructs a Perlinterpreter:.Sp.Vb 9\& 1 PERL_SYS_INIT3(&argc,&argv,&env);\& 2\& 3 if (!PL_do_undump) {\& 4 my_perl = perl_alloc();\& 5 if (!my_perl)\& 6 exit(1);\& 7 perl_construct(my_perl);\& 8 PL_perl_destruct_level = 0;\& 9 }.Ve.SpLine 1 is a macro, and its definition is dependent on your operatingsystem. Line 3 references \f(CW\*(C`PL_do_undump\*(C'\fR, a global variable \- all
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -