Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / testsuite / gdb.base / run.c
blob25b8a4a4aa41ccf768c99798deaa413471e00005
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 (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 vxmain (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 #ifdef PROTOTYPES
41 int factorial (int);
43 int
44 main (int argc, char **argv, char **envp)
45 #else
46 int
47 main (argc, argv, envp)
48 int argc;
49 char *argv[], **envp;
50 #endif
52 #ifdef usestubs
53 set_debug_traps();
54 breakpoint();
55 #endif
56 #ifdef FAKEARGV
57 printf ("%d\n", factorial (1));
58 #else
59 if (argc != 2) {
60 printf ("usage: factorial <number>\n");
61 return 1;
62 } else {
63 printf ("%d\n", factorial (atoi (argv[1])));
65 #endif
66 return 0;
69 #ifdef PROTOTYPES
70 int factorial (int value)
71 #else
72 int factorial (value) int value;
73 #endif
75 int local_var;
77 if (value > 1) {
78 value *= factorial (value - 1);
80 local_var = value;
81 return (value);