25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

103 lines
2.1 KiB

  1. /* $Id$ */
  2. /** \page libcaca-style Libcaca coding style
  3. \section sty1 General guidelines
  4. A pretty safe rule of thumb is: look at what has already been done and
  5. try to do the same.
  6. - Tabulations should be avoided and replaced with \e eight spaces.
  7. - Indentation is generally 4 spaces.
  8. - Lines should wrap at most at 79 characters.
  9. - Do not leave whitespace at the end of lines.
  10. - Do not use multiple spaces for anything else than indentation.
  11. - Code qui fait des warnings == code de porc == deux baffes dans ta gueule
  12. \section sty2 C coding style
  13. Try to use short names whenever possible (\c i for indices, \c w for width,
  14. \c cv for canvas...). Macros are always uppercase, variable and function
  15. names are always lowercase. Use the underscore to separate words within
  16. names:
  17. \code
  18. #define BROKEN 0
  19. #define MAX(x, y) ((x > y) ? (x) : (y))
  20. unsigned int x, y, w, h;
  21. char *font_name;
  22. void frobulate_every_three_seconds(void);
  23. \endcode
  24. \c const is a \e suffix. It's \c char \c const \c *foo, not \c const \c char
  25. \c *foo.
  26. Use spaces after commas and between operators. Do not use spaces after an
  27. opening parenthesis or before a closing one:
  28. \code
  29. a += 2;
  30. b = (a * (c + d));
  31. x = min(x1, x2, x3);
  32. \endcode
  33. Do not put a space between functions and the corresponding opening
  34. parenthesis:
  35. \code
  36. int function(int);
  37. \endcode
  38. A space can be inserted after keywords such as \c for, \c while or \c if,
  39. but consistency with the rest of the page is encouraged:
  40. \code
  41. if(a == b)
  42. return;
  43. if (p == NULL)
  44. \endcode
  45. Do not put parentheses around return values:
  46. \code
  47. return a + (b & x) + d[10];
  48. \endcode
  49. Opening braces should be on a line of their own, aligned with the
  50. current block. Braces are optional for one-liners:
  51. \code
  52. int function(int a)
  53. {
  54. if(a & 0x84)
  55. return a;
  56. if(a < 0)
  57. {
  58. return -a;
  59. }
  60. else
  61. {
  62. a /= 2;
  63. switch(a)
  64. {
  65. case 0:
  66. case 1:
  67. return -1;
  68. break;
  69. default:
  70. return a;
  71. }
  72. }
  73. }
  74. \endcode
  75. \section sty3 C++ coding style
  76. Nothing here yet.
  77. */