xref: /OpenGrok/opengrok-indexer/src/test/resources/sources/c/sample.c (revision 2bcacabbe843448903326d34ff21a265b5f37596)
1 // compile me with gcc
2 /* this is sample comment } */
3 #include <stdio.h>
4 #include <string.h>
5 
6 #define TEST(x) (x)
7 
foo(int a,int b)8 int foo(int a, int b) {
9     /* blah blah
10         }
11     */
12 
13     int c;
14     const char *msg = "this is } sample { string";
15     if (a < b) {
16         return strlen(msg);
17     } else {
18         // }}}}} something to return
19         c = TEST(a) + TEST(b);
20     }
21     return c;
22 }
23 
bar(int x)24 int bar(int x /* } */)
25 {
26     // another function
27     int d;
28     int f;
29     printf(TEST("test { message|$#@$!!#"));
30     d = foo(2, 4);
31     f = foo(x, d);
32 
33     /* return
34         some
35          rubish
36     */
37     return d+f;
38 }
39 
40 // main function
main(int argc,char * argv[])41 int main(int argc, char *argv[]) {
42     int res;
43     printf("this is just a {sample}}");
44 
45     res = bar(20);
46     printf("result = {%d}\n", res);
47 
48     return 0; }
49 
50