CONTRIBUTE 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. _ _ ____ _
  2. ___| | | | _ \| |
  3. / __| | | | |_) | |
  4. | (__| |_| | _ <| |___
  5. \___|\___/|_| \_\_____|
  6. When Contributing Source Code
  7. This document is intended to offer guidelines that can be useful to keep in
  8. mind when you decide to contribute to the project. This concerns new features
  9. as well as corrections to existing flaws or bugs.
  10. 1. Learning cURL
  11. 1.1 Join the Community
  12. 1.2 License
  13. 1.3 What To Read
  14. 2. cURL Coding Standards
  15. 2.1 Naming
  16. 2.2 Indenting
  17. 2.3 Commenting
  18. 2.4 Line Lengths
  19. 2.5 General Style
  20. 2.6 Non-clobbering All Over
  21. 2.7 Platform Dependent Code
  22. 2.8 Write Separate Patches
  23. 2.9 Patch Against Recent Sources
  24. 2.10 Document
  25. 2.11 Test Cases
  26. 3. Pushing Out Your Changes
  27. 3.1 Write Access to CVS Repository
  28. 3.2 How To Make a Patch
  29. 3.3 How to get your changes into the main sources
  30. ==============================================================================
  31. 1. Learning cURL
  32. 1.1 Join the Community
  33. Skip over to http://curl.haxx.se/mail/ and join the appropriate mailing
  34. list(s). Read up on details before you post questions. Read this file before
  35. you start sending patches! We prefer patches and discussions being held on
  36. the mailing list(s), not sent to individuals.
  37. Before posting to one of the curl mailing lists, please read up on the mailing
  38. list etiquette: http://curl.haxx.se/mail/etiquette.html
  39. We also hang out on IRC in #curl on irc.freenode.net
  40. 1.2. License
  41. When contributing with code, you agree to put your changes and new code under
  42. the same license curl and libcurl is already using unless stated and agreed
  43. otherwise.
  44. If you add a larger piece of code, you can opt to make that file or set of
  45. files to use a different license as long as they don't enforce any changes to
  46. the rest of the package and they make sense. Such "separate parts" can not be
  47. GPL licensed (as we don't want copyleft to affect users of libcurl) but they
  48. must use "GPL compatible" licenses (as we want to allow users to use libcurl
  49. properly in GPL licensed environments).
  50. When changing existing source code, you do not alter the copyright of the
  51. original file(s). The copyright will still be owned by the original
  52. creator(s) or those who have been assigned copyright by the original
  53. author(s).
  54. By submitting a patch to the curl project, you are assumed to have the right
  55. to the code and to be allowed by your employer or whatever to hand over that
  56. patch/code to us. We will credit you for your changes as far as possible, to
  57. give credit but also to keep a trace back to who made what changes. Please
  58. always provide us with your full real name when contributing!
  59. 1.3 What To Read
  60. Source code, the man pages, the INTERNALS document, TODO, KNOWN_BUGS, the
  61. most recent CHANGES. Just lurking on the libcurl mailing list is gonna give
  62. you a lot of insights on what's going on right now. Asking there is a good
  63. idea too.
  64. 2. cURL Coding Standards
  65. 2.1 Naming
  66. Try using a non-confusing naming scheme for your new functions and variable
  67. names. It doesn't necessarily have to mean that you should use the same as in
  68. other places of the code, just that the names should be logical,
  69. understandable and be named according to what they're used for. File-local
  70. functions should be made static. We like lower case names.
  71. See the INTERNALS document on how we name non-exported library-global
  72. symbols.
  73. 2.2 Indenting
  74. Please try using the same indenting levels and bracing method as all the
  75. other code already does. It makes the source code a lot easier to follow if
  76. all of it is written using the same style. We don't ask you to like it, we
  77. just ask you to follow the tradition! ;-) This mainly means: 2-level indents,
  78. using spaces only (no tabs) and having the opening brace ({) on the same line
  79. as the if() or while().
  80. Also note that we use if() and while() with no space before the parenthesis.
  81. 2.3 Commenting
  82. Comment your source code extensively using C comments (/* comment */), DO NOT
  83. use C++ comments (// this style). Commented code is quality code and enables
  84. future modifications much more. Uncommented code risk having to be completely
  85. replaced when someone wants to extend things, since other persons' source
  86. code can get quite hard to read.
  87. 2.4 Line Lengths
  88. We try to keep source lines shorter than 80 columns.
  89. 2.5 General Style
  90. Keep your functions small. If they're small you avoid a lot of mistakes and
  91. you don't accidentally mix up variables etc.
  92. 2.6 Non-clobbering All Over
  93. When you write new functionality or fix bugs, it is important that you don't
  94. fiddle all over the source files and functions. Remember that it is likely
  95. that other people have done changes in the same source files as you have and
  96. possibly even in the same functions. If you bring completely new
  97. functionality, try writing it in a new source file. If you fix bugs, try to
  98. fix one bug at a time and send them as separate patches.
  99. 2.7 Platform Dependent Code
  100. Use #ifdef HAVE_FEATURE to do conditional code. We avoid checking for
  101. particular operating systems or hardware in the #ifdef lines. The
  102. HAVE_FEATURE shall be generated by the configure script for unix-like systems
  103. and they are hard-coded in the config-[system].h files for the others.
  104. 2.8 Write Separate Patches
  105. It is annoying when you get a huge patch from someone that is said to fix 511
  106. odd problems, but discussions and opinions don't agree with 510 of them - or
  107. 509 of them were already fixed in a different way. Then the patcher needs to
  108. extract the single interesting patch from somewhere within the huge pile of
  109. source, and that gives a lot of extra work. Preferably, all fixes that
  110. correct different problems should be in their own patch with an attached
  111. description exactly what they correct so that all patches can be selectively
  112. applied by the maintainer or other interested parties.
  113. 2.9 Patch Against Recent Sources
  114. Please try to get the latest available sources to make your patches
  115. against. It makes the life of the developers so much easier. The very best is
  116. if you get the most up-to-date sources from the CVS repository, but the
  117. latest release archive is quite OK as well!
  118. 2.10 Document
  119. Writing docs is dead boring and one of the big problems with many open source
  120. projects. Someone's gotta do it. It makes it a lot easier if you submit a
  121. small description of your fix or your new features with every contribution so
  122. that it can be swiftly added to the package documentation.
  123. The documentation is always made in man pages (nroff formatted) or plain
  124. ASCII files. All HTML files on the web site and in the release archives are
  125. generated from the nroff/ASCII versions.
  126. 2.11 Test Cases
  127. Since the introduction of the test suite, we can quickly verify that the main
  128. features are working as they're supposed to. To maintain this situation and
  129. improve it, all new features and functions that are added need to be tested
  130. in the test suite. Every feature that is added should get at least one valid
  131. test case that verifies that it works as documented. If every submitter also
  132. posts a few test cases, it won't end up as a heavy burden on a single person!
  133. 3. Pushing Out Your Changes
  134. 3.1 Write Access to CVS Repository
  135. If you are a frequent contributor, or have another good reason, you can of
  136. course get write access to the CVS repository and then you'll be able to
  137. check-in all your changes straight into the CVS tree instead of sending all
  138. changes by mail as patches. Just ask if this is what you'd want. You will be
  139. required to have posted a few quality patches first, before you can be
  140. granted write access.
  141. 3.2 How To Make a Patch
  142. Keep a copy of the unmodified curl sources. Make your changes in a separate
  143. source tree. When you think you have something that you want to offer the
  144. curl community, use GNU diff to generate patches.
  145. If you have modified a single file, try something like:
  146. diff -u unmodified-file.c my-changed-one.c > my-fixes.diff
  147. If you have modified several files, possibly in different directories, you
  148. can use diff recursively:
  149. diff -ur curl-original-dir curl-modified-sources-dir > my-fixes.diff
  150. The GNU diff and GNU patch tools exist for virtually all platforms, including
  151. all kinds of Unixes and Windows:
  152. For unix-like operating systems:
  153. http://www.gnu.org/software/patch/patch.html
  154. http://www.gnu.org/directory/diffutils.html
  155. For Windows:
  156. http://gnuwin32.sourceforge.net/packages/patch.htm
  157. http://gnuwin32.sourceforge.net/packages/diffutils.htm
  158. 3.3 How to get your changes into the main sources
  159. 1. Submit your patch to the curl-library mailing list
  160. 2. Make the patch against as recent sources as possible.
  161. 3. Make sure your patch adheres to the source indent and coding style of
  162. already existing source code. Failing to do so just adds more work for me.
  163. 4. Respond to replies on the list about the patch and answer questions and/or
  164. fix nits/flaws. This is very important. I will take lack of replies as a
  165. sign that you're not very anxious to get your patch accepted and I tend to
  166. simply drop such patches from my TODO list.
  167. 5. If you've followed the above mentioned paragraphs and your patch still
  168. hasn't been incorporated after some weeks, consider resubmitting it to the
  169. list.