CONTRIBUTE 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. _ _ ____ _
  2. ___| | | | _ \| |
  3. / __| | | | |_) | |
  4. | (__| |_| | _ <| |___
  5. \___|\___/|_| \_\_____|
  6. To Think About When Contributing Source Code
  7. This document is intended to offer some simple guidelines that can be useful
  8. to keep in mind when you decide to contribute to the project. This concerns
  9. new features as well as corrections to existing flaws or bugs.
  10. Join the Community
  11. Skip over to http://curl.haxx.se/mail/ and join the appropriate mailing
  12. list(s). Read up on details before you post questions. Read this file before
  13. you start sending patches! We prefer patches and discussions being held on
  14. the mailing list(s), not sent to individuals.
  15. The License Issue
  16. When contributing with code, you agree to put your changes and new code under
  17. the same license curl and libcurl is already using unless stated otherwise.
  18. If you add a larger piece of code, you can opt to make that file or set of
  19. files to use a different license as long as they don't enforce any changes to
  20. the rest of the package and they make sense. Such "separate parts" can not be
  21. GPL (as we don't want the GPL virus to attack users of libcurl) but they must
  22. use "GPL compatible" licenses.
  23. What To Read
  24. Source code, the man pages, the INTERNALS document, the TODO, the most recent
  25. CHANGES. Just lurking on the libcurl mailing list is gonna give you a lot of
  26. insights on what's going on right now. Asking there is a good idea too.
  27. Naming
  28. Try using a non-confusing naming scheme for your new functions and variable
  29. names. It doesn't necessarily have to mean that you should use the same as in
  30. other places of the code, just that the names should be logical,
  31. understandable and be named according to what they're used for. File-local
  32. functions should be made static. We like lower case names.
  33. See the INTERNALS document on how we name non-exported library-global
  34. symbols.
  35. Indenting
  36. Please try using the same indenting levels and bracing method as all the
  37. other code already does. It makes the source code a lot easier to follow if
  38. all of it is written using the same style. We don't ask you to like it, we
  39. just ask you to follow the tradition! ;-) This mainly means: 2-level indents,
  40. using spaces only (no tabs) and having the opening brace ({) on the same line
  41. as the if() or while().
  42. Commenting
  43. Comment your source code extensively using C comments (/* comment */), DO NOT
  44. use C++ comments (// this style). Commented code is quality code and enables
  45. future modifications much more. Uncommented code risk having to be completely
  46. replaced when someone wants to extend things, since other persons' source
  47. code can get quite hard to read.
  48. General Style
  49. Keep your functions small. If they're small you avoid a lot of mistakes and
  50. you don't accidentally mix up variables etc.
  51. Non-clobbering All Over
  52. When you write new functionality or fix bugs, it is important that you don't
  53. fiddle all over the source files and functions. Remember that it is likely
  54. that other people have done changes in the same source files as you have and
  55. possibly even in the same functions. If you bring completely new
  56. functionality, try writing it in a new source file. If you fix bugs, try to
  57. fix one bug at a time and send them as separate patches.
  58. Platform Dependent Code
  59. Use #ifdef HAVE_FEATURE to do conditional code. We avoid checking for
  60. particular operating systems or hardware in the #ifdef lines. The
  61. HAVE_FEATURE shall be generated by the configure script for unix-like systems
  62. and they are hard-coded in the config-[system].h files for the others.
  63. Separate Patches
  64. It is annoying when you get a huge patch from someone that is said to fix 511
  65. odd problems, but discussions and opinions don't agree with 510 of them - or
  66. 509 of them were already fixed in a different way. Then the patcher needs to
  67. extract the single interesting patch from somewhere within the huge pile of
  68. source, and that gives a lot of extra work. Preferably, all fixes that
  69. correct different problems should be in their own patch with an attached
  70. description exactly what they correct so that all patches can be selectively
  71. applied by the maintainer or other interested parties.
  72. Patch Against Recent Sources
  73. Please try to get the latest available sources to make your patches
  74. against. It makes the life of the developers so much easier. The very best is
  75. if you get the most up-to-date sources from the CVS repository, but the
  76. latest release archive is quite OK as well!
  77. Document
  78. Writing docs is dead boring and one of the big problems with many open source
  79. projects. Someone's gotta do it. It makes it a lot easier if you submit a
  80. small description of your fix or your new features with every contribution so
  81. that it can be swiftly added to the package documentation.
  82. The documentation is always made in man pages (nroff formatted) or plain
  83. ASCII files. All HTML files on the web site and in the release archives are
  84. generated from the nroff/ASCII versions.
  85. Write Access to CVS Repository
  86. If you are a frequent contributor, or have another good reason, you can of
  87. course get write access to the CVS repository and then you'll be able to
  88. check-in all your changes straight into the CVS tree instead of sending all
  89. changes by mail as patches. Just ask if this is what you'd want. You will be
  90. required to have posted a few quality patches first, before you can be
  91. granted write access.
  92. Test Cases
  93. Since the introduction of the test suite, we can quickly verify that the main
  94. features are working as they're supposed to. To maintain this situation and
  95. improve it, all new features and functions that are added need to be tested
  96. in the test suite. Every feature that is added should get at least one valid
  97. test case that verifies that it works as documented. If every submitter also
  98. posts a few test cases, it won't end up as a heavy burden on a single person!
  99. How To Make a Patch
  100. Keep a copy of the unmodified curl sources. Make your changes in a separate
  101. source tree. When you think you have something that you want to offer the
  102. curl community, use GNU diff to generate patches.
  103. If you have modified a single file, try something like:
  104. diff -u unmodified-file.c my-changed-one.c > my-fixes.diff
  105. If you have modified several files, possibly in different directories, you
  106. can use diff recursively:
  107. diff -ur curl-original-dir curl-modified-sources-dir > my-fixes.diff
  108. The GNU diff and GNU patch tools exist for virtually all platforms, including
  109. all kinds of Unixes and Windows:
  110. For unix-like operating systems:
  111. http://www.fsf.org/software/patch/patch.html
  112. http://www.gnu.org/directory/diffutils.html
  113. For Windows:
  114. http://gnuwin32.sourceforge.net/packages/patch.htm
  115. http://gnuwin32.sourceforge.net/packages/diffutils.htm