=encoding utf8 =for comment Consistent formatting of this file is achieved with: perl ./Porting/podtidy pod/perlhack.pod =head1 NAME =begin original perlhack - How to hack on Perl =end original perlhack - Perl をハックする方法 =head1 DESCRIPTION =begin original This document explains how Perl development works. It includes details about the Perl 5 Porters email list, the Perl repository, the Perlbug bug tracker, patch guidelines, and commentary on Perl development philosophy. =end original This document explains how Perl development works. It includes details about the Perl 5 Porters email list, the Perl repository, the Perlbug bug tracker, patch guidelines, and commentary on Perl development philosophy. (TBT) =head1 SUPER QUICK PATCH GUIDE =begin original If you just want to submit a single small patch like a pod fix, a test for a bug, comment fixes, etc., it's easy! Here's how: =end original If you just want to submit a single small patch like a pod fix, a test for a bug, comment fixes, etc., it's easy! Here's how: (TBT) =over 4 =item * Check out the source repository =begin original The perl source is in a git repository. You can clone the repository with the following command: =end original The perl source is in a git repository. You can clone the repository with the following command: (TBT) % git clone git://perl5.git.perl.org/perl.git perl =item * Make your change =begin original Hack, hack, hack. =end original Hack, hack, hack. (TBT) =item * Test your change =begin original You can run all the tests with the following commands: =end original You can run all the tests with the following commands: (TBT) % ./Configure -des -Dusedevel % make test =begin original Keep hacking until the tests pass. =end original Keep hacking until the tests pass. (TBT) =item * Commit your change =begin original Committing your work will save the change I: =end original Committing your work will save the change I: (TBT) % git commit -a -m 'Commit message goes here' =begin original Make sure the commit message describes your change in a single sentence. For example, "Fixed spelling errors in perlhack.pod". =end original Make sure the commit message describes your change in a single sentence. For example, "Fixed spelling errors in perlhack.pod". (TBT) =item * Send your change to perlbug =begin original The next step is to submit your patch to the Perl core ticket system via email. =end original The next step is to submit your patch to the Perl core ticket system via email. (TBT) =begin original Assuming your patch consists of a single git commit, you can send it to perlbug with this command line: =end original Assuming your patch consists of a single git commit, you can send it to perlbug with this command line: (TBT) % git format-patch HEAD^1..HEAD % perlbug -s '[PATCH] `git log --pretty=format:%s HEAD^1..HEAD`' -f 0001-*.patch =begin original The perlbug program will ask you a few questions about your email address and the patch you're submitting. Once you've answered them you can submit your patch. =end original The perlbug program will ask you a few questions about your email address and the patch you're submitting. Once you've answered them you can submit your patch. (TBT) =item * Thank you =begin original The porters appreciate the time you spent helping to make Perl better. Thank you! =end original The porters appreciate the time you spent helping to make Perl better. Thank you! (TBT) =back =head1 BUG REPORTING =begin original If you want to report a bug in Perl, you must use the F command line tool. This tool will ensure that your bug report includes all the relevant system and configuration information. =end original If you want to report a bug in Perl, you must use the F command line tool. This tool will ensure that your bug report includes all the relevant system and configuration information. (TBT) =begin original To browse existing Perl bugs and patches, you can use the web interface at L. =end original To browse existing Perl bugs and patches, you can use the web interface at L. (TBT) =begin original Please check the archive of the perl5-porters list (see below) and/or the bug tracking system before submitting a bug report. Often, you'll find that the bug has been reported already. =end original Please check the archive of the perl5-porters list (see below) and/or the bug tracking system before submitting a bug report. Often, you'll find that the bug has been reported already. (TBT) =begin original You can log in to the bug tracking system and comment on existing bug reports. If you have additional information regarding an existing bug, please add it. This will help the porters fix the bug. =end original You can log in to the bug tracking system and comment on existing bug reports. If you have additional information regarding an existing bug, please add it. This will help the porters fix the bug. (TBT) =head1 PERL 5 PORTERS =begin original The perl5-porters (p5p) mailing list is where the Perl standard distribution is maintained and developed. The people who maintain Perl are also referred to as the "Perl 5 Porters", or just the "porters". =end original The perl5-porters (p5p) mailing list is where the Perl standard distribution is maintained and developed. The people who maintain Perl are also referred to as the "Perl 5 Porters", or just the "porters". (TBT) =begin original A searchable archive of the list is available at L. There is also another archive at L. =end original A searchable archive of the list is available at L. There is also another archive at L. (TBT) =head2 perl-changes mailing list =begin original The perl5-changes mailing list receives a copy of each patch that gets submitted to the maintenance and development branches of the perl repository. See L for subscription and archive information. =end original The perl5-changes mailing list receives a copy of each patch that gets submitted to the maintenance and development branches of the perl repository. See L for subscription and archive information. (TBT) =head1 GETTING THE PERL SOURCE =begin original All of Perl's source code is kept centrally in a Git repository at I. The repository contains many Perl revisions from Perl 1 onwards and all the revisions from Perforce, the previous version control system. =end original Perlのソースコードはすべて、I の Git リポジトリに 集中管理されています。 このリポジトリには、Perl 1 以降の多くの Perl リビジョンと、 以前使用していたバージョン管理システムである Perforce のすべての リビジョンが含まれています。 =begin original For much more detail on using git with the Perl repository, please see L. =end original For much more detail on using git with the Perl repository, please see L. (TBT) =head2 Read access via Git (Git 経由の読み込みアクセス) =begin original You will need a copy of Git for your computer. You can fetch a copy of the repository using the git protocol: =end original あなたのコンピュータ用の Git が必要です。 git プロトコルを使用して、リポジトリのコピーを フェッチできます。 % git clone git://perl5.git.perl.org/perl.git perl =begin original This clones the repository and makes a local copy in the F directory. =end original これにより、リポジトリが複製され、F ディレクトリに ローカルコピーが作成されます。 =begin original If you cannot use the git protocol for firewall reasons, you can also clone via http, though this is much slower: =end original ファイアウォールの関係で git プロトコルが使えない場合、 http 経由でもクローンできますが、はるかに遅いです: % git clone http://perl5.git.perl.org/perl.git perl =head2 Read access via the web (Web 経由の読み込みアクセス) =begin original You may access the repository over the web. This allows you to browse the tree, see recent commits, subscribe to RSS feeds for the changes, search for particular commits and more. You may access it at L. A mirror of the repository is found at L. =end original Web 経由でリポジトリにアクセスできます。 これにより、ツリーの参照、最近のコミットの表示、変更の RSS フィードの購読、 特定のコミットの検索などが可能になります。 次の場所からアクセスできます: L. リポジトリのミラーは以下にあります found at L. =head2 Read access via rsync =begin original You can also choose to use rsync to get a copy of the current source tree for the bleadperl branch and all maintenance branches: =end original You can also choose to use rsync to get a copy of the current source tree for the bleadperl branch and all maintenance branches: (TBT) % rsync -avz rsync://perl5.git.perl.org/perl-current . % rsync -avz rsync://perl5.git.perl.org/perl-5.12.x . % rsync -avz rsync://perl5.git.perl.org/perl-5.10.x . % rsync -avz rsync://perl5.git.perl.org/perl-5.8.x . % rsync -avz rsync://perl5.git.perl.org/perl-5.6.x . % rsync -avz rsync://perl5.git.perl.org/perl-5.005xx . =begin original (Add the C<--delete> option to remove leftover files.) =end original (Add the C<--delete> option to remove leftover files.) (TBT) =begin original To get a full list of the available sync points: =end original To get a full list of the available sync points: (TBT) % rsync perl5.git.perl.org:: =head2 Write access via git =begin original If you have a commit bit, please see L for more details on using git. =end original If you have a commit bit, please see L for more details on using git. (TBT) =head1 PATCHING PERL =begin original If you're planning to do more extensive work than a single small fix, we encourage you to read the documentation below. This will help you focus your work and make your patches easier to incorporate into the Perl source. =end original If you're planning to do more extensive work than a single small fix, we encourage you to read the documentation below. This will help you focus your work and make your patches easier to incorporate into the Perl source. (TBT) =head2 Submitting patches =begin original If you have a small patch to submit, please submit it via perlbug. You can also send email directly to perlbug@perl.org. Please note that messages sent to perlbug may be held in a moderation queue, so you won't receive a response immediately. =end original If you have a small patch to submit, please submit it via perlbug. You can also send email directly to perlbug@perl.org. Please note that messages sent to perlbug may be held in a moderation queue, so you won't receive a response immediately. (TBT) =begin original You'll know your submission has been processed when you receive an email from our ticket tracking system. This email will give you a ticket number. Once your patch has made it to the ticket tracking system, it will also be sent to the perl5-porters@perl.org list. =end original You'll know your submission has been processed when you receive an email from our ticket tracking system. This email will give you a ticket number. Once your patch has made it to the ticket tracking system, it will also be sent to the perl5-porters@perl.org list. (TBT) =begin original Patches are reviewed and discussed on the p5p list. Simple, uncontroversial patches will usually be applied without any discussion. When the patch is applied, the ticket will be updated and you will receive email. In addition, an email will be sent to the p5p list. =end original Patches are reviewed and discussed on the p5p list. Simple, uncontroversial patches will usually be applied without any discussion. When the patch is applied, the ticket will be updated and you will receive email. In addition, an email will be sent to the p5p list. (TBT) =begin original In other cases, the patch will need more work or discussion. That will happen on the p5p list. =end original In other cases, the patch will need more work or discussion. That will happen on the p5p list. (TBT) =begin original You are encouraged to participate in the discussion and advocate for your patch. Sometimes your patch may get lost in the shuffle. It's appropriate to send a reminder email to p5p if no action has been taken in a month. Please remember that the Perl 5 developers are all volunteers, and be polite. =end original You are encouraged to participate in the discussion and advocate for your patch. Sometimes your patch may get lost in the shuffle. It's appropriate to send a reminder email to p5p if no action has been taken in a month. Please remember that the Perl 5 developers are all volunteers, and be polite. (TBT) =begin original Changes are always applied directly to the main development branch, called "blead". Some patches may be backported to a maintenance branch. If you think your patch is appropriate for the maintenance branch, please explain why when you submit it. =end original Changes are always applied directly to the main development branch, called "blead". Some patches may be backported to a maintenance branch. If you think your patch is appropriate for the maintenance branch, please explain why when you submit it. (TBT) =head2 Getting your patch accepted (あなたのパッチを受け入れてもらうために) =begin original If you are submitting a code patch there are several things that you can do to help the Perl 5 Porters accept your patch. =end original コードパッチを送信する場合は、Perl 5 Porters があなたのパッチを 受け入れるのを助けるためにできることがいくつかあります。 =head3 Patch style =begin original If you used git to check out the Perl source, then using C will produce a patch in a style suitable for Perl. The C command produces one patch file for each commit you made. If you prefer to send a single patch for all commits, you can use C. =end original If you used git to check out the Perl source, then using C will produce a patch in a style suitable for Perl. The C command produces one patch file for each commit you made. If you prefer to send a single patch for all commits, you can use C. (TBT) % git co blead % git pull % git diff blead my-branch-name =begin original This produces a patch based on the difference between blead and your current branch. It's important to make sure that blead is up to date before producing the diff, that's why we call C first. =end original This produces a patch based on the difference between blead and your current branch. It's important to make sure that blead is up to date before producing the diff, that's why we call C first. (TBT) =begin original We strongly recommend that you use git if possible. It will make your life easier, and ours as well. =end original We strongly recommend that you use git if possible. It will make your life easier, and ours as well. (TBT) =begin original However, if you're not using git, you can still produce a suitable patch. You'll need a pristine copy of the Perl source to diff against. The porters prefer unified diffs. Using GNU C, you can produce a diff like this: =end original However, if you're not using git, you can still produce a suitable patch. You'll need a pristine copy of the Perl source to diff against. The porters prefer unified diffs. Using GNU C, you can produce a diff like this: (TBT) % diff -Npurd perl.pristine perl.mine =begin original Make sure that you C in your copy of Perl to remove any build artifacts, or you may get a confusing result. =end original Make sure that you C in your copy of Perl to remove any build artifacts, or you may get a confusing result. (TBT) =head3 Commit message =begin original As you craft each patch you intend to submit to the Perl core, it's important to write a good commit message. This is especially important if your submission will consist of a series of commits. =end original Perl コアに投稿しようとするパッチを作成する際には、 適切なコミットメッセージを作成することが重要です。 This is especially important if your submission will consist of a series of commits. (TBT) =begin original The first line of the commit message should be a short description without a period. It should be no longer than the subject line of an email, 50 characters being a good rule of thumb. =end original The first line of the commit message should be a short description without a period. It should be no longer than the subject line of an email, 50 characters being a good rule of thumb. (TBT) =begin original A lot of Git tools (Gitweb, GitHub, git log --pretty=oneline, ...) will only display the first line (cut off at 50 characters) when presenting commit summaries. =end original A lot of Git tools (Gitweb, GitHub, git log --pretty=oneline, ...) will only display the first line (cut off at 50 characters) when presenting commit summaries. (TBT) =begin original The commit message should include a description of the problem that the patch corrects or new functionality that the patch adds. =end original コミットメッセージは、パッチによって修正される問題の説明、または パッチによって追加される新機能の説明を含む必要があります。 =begin original As a general rule of thumb, your commit message should help a programmer who knows the Perl core quickly understand what you were trying to do, how you were trying to do it, and why the change matters to Perl. =end original 一般的な経験則として、コミットメッセージによって、Perl コアを 知っているプログラマーは、何をしようとしているのか、 どのようにしようとしているのか、そしてなぜ変更が Perl にとって 重要なのかをすぐに理解する助けになるはずです。 =over 4 =item * Why =begin original Your commit message should describe why the change you are making is important. When someone looks at your change in six months or six years, your intent should be clear. =end original コミットメッセージに、 自分が行っている変更がなぜ重要なのかを記述すべきだということです。 6 ヶ月や6 年後に誰かがあなたの変更を見たとき、 あなたの意図は明確であるべきです。 =begin original If you're deprecating a feature with the intent of later simplifying another bit of code, say so. If you're fixing a performance problem or adding a new feature to support some other bit of the core, mention that. =end original 後で別のコードを単純化するために機能を非推奨にしているのであれば、 そう書いてください。 パフォーマンスの問題を修正したり、コアの他の部分をサポートするための 新機能を追加しているのであれば、そのことに言及してください。 =item * What =begin original Your commit message should describe what part of the Perl core you're changing and what you expect your patch to do. =end original コミットメッセージには、Perlコアのどの部分を変更しようとしているのか、 パッチに何を期待しているのかを記述する必要があります。 =item * How =begin original While it's not necessary for documentation changes, new tests or trivial patches, it's often worth explaining how your change works. Even if it's clear to you today, it may not be clear to a porter next month or next year. =end original 文書の変更、新しいテスト、簡単なパッチなどでは必要ありませんが、 変更がどのように機能するかを説明する価値があることがよくあります。 今日ははっきりしていても、来月や来年にははっきりしないかもしれません。 =back =begin original A commit message isn't intended to take the place of comments in your code. Commit messages should describe the change you made, while code comments should describe the current state of the code. =end original コミットメッセージは、コード内のコメントに代わるものではありません。 コミットメッセージには変更内容が記述され、コードコメントにはコードの 現在の状態が記述されます。 =begin original If you've just implemented a new feature, complete with doc, tests and well-commented code, a brief commit message will often suffice. If, however, you've just changed a single character deep in the parser or lexer, you might need to write a small novel to ensure that future readers understand what you did and why you did it. =end original 新機能を実装したばかりで、文書、テスト、コメント付きのコードが 揃っている場合は、簡単なコミットメッセージで十分なことがよくあります。 ただし、パーサや字句解析器の奥深くにある 1 文字を変更しただけの場合は、 将来の読者が自分のしたこととその理由を確実に理解できるように、 短い小説を書く必要があるかもしれません。 =head3 Comments, Comments, Comments (コメント、コメント、コメント) =begin original Be sure to adequately comment your code. While commenting every line is unnecessary, anything that takes advantage of side effects of operators, that creates changes that will be felt outside of the function being patched, or that others may find confusing should be documented. If you are going to err, it is better to err on the side of adding too many comments than too few. =end original コードに適切なコメントを付けるようにしてください。 すべての行にコメントを付ける必要はありませんが、演算子の副作用を利用するもの、 パッチされている関数の外部で感じられる変更を生成するもの、 または他の人が混乱を感じる可能性のあるものはすべて 文書化する必要があります。 過ちを起こす場合は、コメントの数が少なすぎる過ちよりも、 コメントの数が多すぎる過ちの方がましです。 =begin original The best comments explain I the code does what it does, not I. =end original The best comments explain I the code does what it does, not I. (TBT) =head3 Style (スタイル) =begin original In general, please follow the particular style of the code you are patching. =end original 一般に、パッチを適用するコードは特定のスタイルに従ってください。 =begin original In particular, follow these general guidelines for patching Perl sources: =end original 特に、Perl ソースにパッチを適用する場合は、次の一般的なガイドラインに 従ってください: =over 4 =item * =begin original 8-wide tabs (no exceptions!) =end original 8-wide tabs (no exceptions!) (TBT) =item * =begin original 4-wide indents for code, 2-wide indents for nested CPP #defines =end original 4-wide indents for code, 2-wide indents for nested CPP #defines (TBT) =item * =begin original Try hard not to exceed 79-columns =end original Try hard not to exceed 79-columns (TBT) =item * =begin original ANSI C prototypes =end original ANSI C prototypes (TBT) =item * =begin original Uncuddled elses and "K&R" style for indenting control constructs =end original Uncuddled elses and "K&R" style for indenting control constructs (TBT) =item * =begin original No C++ style (//) comments =end original No C++ style (//) comments (TBT) =item * =begin original Mark places that need to be revisited with XXX (and revisit often!) =end original Mark places that need to be revisited with XXX (and revisit often!) (TBT) =item * =begin original Opening brace lines up with "if" when conditional spans multiple lines; should be at end-of-line otherwise =end original Opening brace lines up with "if" when conditional spans multiple lines; should be at end-of-line otherwise (TBT) =item * =begin original In function definitions, name starts in column 0 (return value is on previous line) =end original In function definitions, name starts in column 0 (return value is on previous line) (TBT) =item * =begin original Single space after keywords that are followed by parens, no space between function name and following paren =end original Single space after keywords that are followed by parens, no space between function name and following paren (TBT) =item * =begin original Avoid assignments in conditionals, but if they're unavoidable, use extra paren, e.g. "if (a && (b = c)) ..." =end original Avoid assignments in conditionals, but if they're unavoidable, use extra paren, e.g. "if (a && (b = c)) ..." (TBT) =item * =begin original "return foo;" rather than "return(foo);" =end original "return foo;" rather than "return(foo);" (TBT) =item * =begin original "if (!foo) ..." rather than "if (foo == FALSE) ..." etc. =end original "if (!foo) ..." rather than "if (foo == FALSE) ..." etc. (TBT) =back =head3 Test suite (テストスイート) =begin original If your patch changes code (rather than just changing documentation), you should also include one or more test cases which illustrate the bug you're fixing or validate the new functionality you're adding. In general, you should update an existing test file rather than create a new one. =end original パッチによってコードが変更された場合(単なる文書の変更ではなく)、 修正しようとしているバグを説明するか、 追加しようとしている新機能を検証するテストケースを一つ以上含める 必要があります。 一般的には、新しいテストファイルを作成するのではなく、 既存のテストファイルを更新するべきです。 =begin original Your test suite additions should generally follow these guidelines (courtesy of Gurusamy Sarathy ): =end original テストスイートの追加は、一般的に次のガイドラインに従う必要があります (Gurusamy Sarthy による): =over 4 =item * =begin original Know what you're testing. Read the docs, and the source. =end original Know what you're testing. Read the docs, and the source. (TBT) =item * =begin original Tend to fail, not succeed. =end original Tend to fail, not succeed. (TBT) =item * =begin original Interpret results strictly. =end original Interpret results strictly. (TBT) =item * =begin original Use unrelated features (this will flush out bizarre interactions). =end original Use unrelated features (this will flush out bizarre interactions). (TBT) =item * =begin original Use non-standard idioms (otherwise you are not testing TIMTOWTDI). =end original Use non-standard idioms (otherwise you are not testing TIMTOWTDI). (TBT) =item * =begin original Avoid using hardcoded test numbers whenever possible (the EXPECTED/GOT found in t/op/tie.t is much more maintainable, and gives better failure reports). =end original Avoid using hardcoded test numbers whenever possible (the EXPECTED/GOT found in t/op/tie.t is much more maintainable, and gives better failure reports). (TBT) =item * =begin original Give meaningful error messages when a test fails. =end original Give meaningful error messages when a test fails. (TBT) =item * =begin original Avoid using qx// and system() unless you are testing for them. If you do use them, make sure that you cover _all_ perl platforms. =end original Avoid using qx// and system() unless you are testing for them. If you do use them, make sure that you cover _all_ perl platforms. (TBT) =item * =begin original Unlink any temporary files you create. =end original Unlink any temporary files you create. (TBT) =item * =begin original Promote unforeseen warnings to errors with $SIG{__WARN__}. =end original Promote unforeseen warnings to errors with $SIG{__WARN__}. (TBT) =item * =begin original Be sure to use the libraries and modules shipped with the version being tested, not those that were already installed. =end original Be sure to use the libraries and modules shipped with the version being tested, not those that were already installed. (TBT) =item * =begin original Add comments to the code explaining what you are testing for. =end original Add comments to the code explaining what you are testing for. (TBT) =item * =begin original Make updating the '1..42' string unnecessary. Or make sure that you update it. =end original Make updating the '1..42' string unnecessary. Or make sure that you update it. (TBT) =item * =begin original Test _all_ behaviors of a given operator, library, or function. =end original Test _all_ behaviors of a given operator, library, or function. (TBT) =begin original Test all optional arguments. =end original Test all optional arguments. (TBT) =begin original Test return values in various contexts (boolean, scalar, list, lvalue). =end original Test return values in various contexts (boolean, scalar, list, lvalue). (TBT) =begin original Use both global and lexical variables. =end original Use both global and lexical variables. (TBT) =begin original Don't forget the exceptional, pathological cases. =end original Don't forget the exceptional, pathological cases. (TBT) =back =head2 Patching a core module (コアモジュールにパッチを当てる) =begin original This works just like patching anything else, with one extra consideration. =end original これは他のパッチと同じように動作しますが、一つ特別な注意が必要です。 =begin original Some core modules also live on CPAN and are maintained outside of the Perl core. When the author updates the module, the updates are simply copied into the core. =end original Some core modules also live on CPAN and are maintained outside of the Perl core. When the author updates the module, the updates are simply copied into the core. (TBT) =begin original Modules in the F directory of the source tree are maintained outside of the Perl core. See that module's listing on documentation or its listing on L for more information on reporting bugs and submitting patches. =end original Modules in the F directory of the source tree are maintained outside of the Perl core. See that module's listing on documentation or its listing on L for more information on reporting bugs and submitting patches. (TBT) =begin original In contrast, modules in the F directory are maintained in the core. =end original In contrast, modules in the F directory are maintained in the core. (TBT) =head2 Updating perldelta =begin original For changes significant enough to warrant a F entry, the porters will greatly appreciate it if you submit a delta entry along with your actual change. Significant changes include, but are not limited to: =end original For changes significant enough to warrant a F entry, the porters will greatly appreciate it if you submit a delta entry along with your actual change. Significant changes include, but are not limited to: (TBT) =over 4 =item * =begin original Adding, deprecating, or removing core features =end original Adding, deprecating, or removing core features (TBT) =item * =begin original Adding, deprecating, removing, or upgrading core or dual-life modules =end original Adding, deprecating, removing, or upgrading core or dual-life modules (TBT) =item * =begin original Adding new core tests =end original Adding new core tests (TBT) =item * =begin original Fixing security issues and user-visible bugs in the core =end original Fixing security issues and user-visible bugs in the core (TBT) =item * =begin original Changes that might break existing code, either on the perl or C level =end original Changes that might break existing code, either on the perl or C level (TBT) =item * =begin original Significant performance improvements =end original Significant performance improvements (TBT) =item * =begin original Adding, removing, or significantly changing documentation in the F directory =end original Adding, removing, or significantly changing documentation in the F directory (TBT) =item * =begin original Important platform-specific changes =end original Important platform-specific changes (TBT) =back =begin original Please make sure you add the perldelta entry to the right section within F. More information on how to write good perldelta entries is available in the C