PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/input/c/freebsd.c

http://github.com/bengardner/uncrustify
C | 136 lines | 88 code | 20 blank | 28 comment | 27 complexity | fa2f42f432cde049f437e5d802ec932c MD5 | raw file
Possible License(s): GPL-2.0
  1. /* Make the structure name match the typedef. */
  2. typedef struct bar {
  3. int level;
  4. } BAR;
  5. typedef int foo; /* This is foo. */
  6. typedef const long baz; /* This is baz. */
  7. static char *function(int _arg, const char *_arg2, struct foo *_arg3,
  8. struct bar *_arg4);
  9. static void usage(void);
  10. /*
  11. * All major routines should have a comment briefly describing what
  12. * they do. The comment before the "main" routine should describe
  13. * what the program does.
  14. */
  15. int
  16. main(int argc, char *argv[])
  17. {
  18. char *ep;
  19. long num;
  20. int ch;
  21. while ((ch = getopt(argc, argv, "abNn:")) != -1)
  22. switch (ch) { /* Indent the switch. */
  23. case 'a': /* Don't indent the case. */
  24. aflag = 1; /* Indent case body one tab. */
  25. /* FALLTHROUGH */
  26. case 'b':
  27. bflag = 1;
  28. break;
  29. case 'N':
  30. Nflag = 1;
  31. break;
  32. case 'n':
  33. num = strtol(optarg, &ep, 10);
  34. if (num <= 0 || *ep != '\0') {
  35. warnx("illegal number, -n argument -- %s",
  36. optarg);
  37. usage();
  38. }
  39. break;
  40. case '?':
  41. default:
  42. usage();
  43. /* NOTREACHED */
  44. }
  45. argc -= optind;
  46. argv += optind;
  47. for (p = buf; *p != '\0'; ++p)
  48. ; /* nothing */
  49. for (;;)
  50. stmt;
  51. for (;;) {
  52. zed = a + really + long + statement + that + needs +
  53. two + lines + gets + indented + four + spaces +
  54. on + the + second + and + subsequent + lines;
  55. }
  56. for (;;) {
  57. if (cond)
  58. stmt;
  59. }
  60. if (val != NULL)
  61. val = realloc(val, newsize);
  62. fcn_call(with, a, really, long, list, of, parameters,
  63. that, spans, two, lines);
  64. for (; cnt < 15; cnt++) {
  65. stmt1;
  66. stmt2;
  67. }
  68. almod = (chunk_is_single_line_comment(pc) &&
  69. cpd.settings[UO_indent_relative_single_line_comments].b) ?
  70. ALMODE_KEEP_REL : ALMODE_KEEP_ABS;
  71. /* Indentation is an 8 character tab. Second level indents are four spaces.
  72. * If you have to wrap a long statement, put the operator at the end of the
  73. * line.
  74. */
  75. while (cnt < 20 && this_variable_name_is_too_long &&
  76. ep != NULL)
  77. zappy = a + really + long + statement + that + needs
  78. + two + lines + gets + indented + four + spaces +
  79. on + the + second + and + subsequent + lines;
  80. // Do not add whitespace at the end of a line, and only use tabs followed by
  81. // spaces to form the indentation. Do not use more spaces than a tab will
  82. // produce and do not use spaces in front of tabs.
  83. //
  84. // Closing and opening braces go on the same line as the else. Braces that
  85. // are not necessary may be left out.
  86. if (test)
  87. stmt;
  88. else if (bar) {
  89. stmt;
  90. stmt;
  91. } else
  92. stmt;
  93. // No spaces after function names. Commas have a space after them. No spa-
  94. // ces after `(' or `[' or preceding `]' or `)' characters.
  95. error = function(a1, a2);
  96. if (error != 0)
  97. exit(error);
  98. // Unary operators do not require spaces, binary operators do. Do not use
  99. // parentheses unless they are required for precedence or unless the state-
  100. // ment is confusing without them. Remember that other people may confuse
  101. // easier than you. Do YOU understand the following?
  102. a = b->c[0] + ~d == (e || f) || g && h ? i : j >> 1;
  103. k = !(l & FLAGS);
  104. // Exits should be 0 on success, or 1 on failure.
  105. exit(0); /*
  106. * Avoid obvious comments such as
  107. * "Exit 0 on success."
  108. */
  109. }
  110. static char *
  111. function(a1, a2, fl, a4)
  112. int a1, a2; /* Declare ints, too, don't default them. */
  113. float fl; /* Beware double vs. float prototype differences. */
  114. int a4; /* List in order declared. */
  115. {
  116. }