Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / testsuite / gdb.hp / gdb.aCC / run.c
blob6bff81ad7ee199181b0c625594b1ccd0f57fc5c0
1 /*
2 * This simple classical example of recursion is useful for
3 * testing stack backtraces and such.
4 */
6 #ifdef vxworks
8 # include <stdio.h>
10 /* VxWorks does not supply atoi. */
11 static int
12 atoi (char *z)
13 /* char *z;*/
15 int i = 0;
17 while (*z >= '0' && *z <= '9')
18 i = i * 10 + (*z++ - '0');
19 return i;
22 /* I don't know of any way to pass an array to VxWorks. This function
23 can be called directly from gdb. */
25 void vxmain (char *arg)
26 /*char *arg;*/
28 char *argv[2];
30 argv[0] = "";
31 argv[1] = arg;
32 main (2, argv, (char **) 0);
35 #else /* ! vxworks */
36 # include <stdio.h>
37 # include <stdlib.h>
38 #endif /* ! vxworks */
40 int main (int argc, char *argv[], char **envp)
41 /*int argc;
42 char *argv[], **envp;*/
44 int factorial (int);
45 #ifdef usestubs
46 set_debug_traps();
47 breakpoint();
48 #endif
49 #ifdef FAKEARGV
50 printf ("%d\n", factorial (1));
51 #else
52 if (argc != 2) {
53 printf ("usage: factorial <number>\n");
54 return 1;
55 } else {
56 printf ("%d\n", factorial (atoi (argv[1])));
58 #endif
59 return 0;
62 int factorial (int value)
63 /*int value;*/
65 int local_var;
67 if (value > 1) {
68 value *= factorial (value - 1);
70 local_var = value;
71 return (value);