diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2006-04-20 11:04:20 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2006-04-20 11:04:20 +0000 |
commit | 7fce993162fce0fe07a193ad93a5f2b33e3a71a3 (patch) | |
tree | db385152b7776b7d4fc10e003b90b6e26a9bbab5 /dmake/dbug | |
parent | de8bfa766603261ed5655b7f77cea6be0e6d66a1 (diff) |
INTEGRATION: CWS dmake43p01 (1.1.2); FILE ADDED
2005/09/26 00:43:27 vq 1.1.2.1: #i55070# Restore the documentation for Fred Fish's "C Program Debugging
Package" DBUG.
Diffstat (limited to 'dmake/dbug')
-rwxr-xr-x | dmake/dbug/dbug/example3.c | 16 | ||||
-rwxr-xr-x | dmake/dbug/dbug/factorial.c | 15 | ||||
-rwxr-xr-x | dmake/dbug/dbug/main.c | 27 |
3 files changed, 58 insertions, 0 deletions
diff --git a/dmake/dbug/dbug/example3.c b/dmake/dbug/dbug/example3.c new file mode 100755 index 000000000000..0eeb75e7f377 --- /dev/null +++ b/dmake/dbug/dbug/example3.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +main (argc, argv) +int argc; +char *argv[]; +{ +# ifdef DEBUG + printf ("argv[0] = %d\n", argv[0]); +# endif + /* + * Rest of program + */ +# ifdef DEBUG + printf ("== done ==\n"); +# endif +} diff --git a/dmake/dbug/dbug/factorial.c b/dmake/dbug/dbug/factorial.c new file mode 100755 index 000000000000..42a4d848014e --- /dev/null +++ b/dmake/dbug/dbug/factorial.c @@ -0,0 +1,15 @@ +#include <stdio.h> +/* User programs should use <local/dbug.h> */ +#include "dbug.h" + +int factorial (value) + register int value; +{ + DBUG_ENTER ("factorial"); + DBUG_PRINT ("find", ("find %d factorial", value)); + if (value > 1) { + value *= factorial (value - 1); + } + DBUG_PRINT ("result", ("result is %d", value)); + DBUG_RETURN (value); +} diff --git a/dmake/dbug/dbug/main.c b/dmake/dbug/dbug/main.c new file mode 100755 index 000000000000..d7c4267d4767 --- /dev/null +++ b/dmake/dbug/dbug/main.c @@ -0,0 +1,27 @@ +#include <stdio.h> +/* User programs should use <local/dbug.h> */ +#include "dbug.h" + +int main (argc, argv) + int argc; + char *argv[]; +{ + register int result, ix; + extern int factorial (), atoi (); + + DBUG_ENTER ("main"); + DBUG_PROCESS (argv[0]); + for (ix = 1; ix < argc && argv[ix][0] == '-'; ix++) { + switch (argv[ix][1]) { + case '#': + DBUG_PUSH (&(argv[ix][2])); + break; + } + } + for (; ix < argc; ix++) { + DBUG_PRINT ("args", ("argv[%d] = %s", ix, argv[ix])); + result = factorial (atoi (argv[ix])); + printf ("%d\n", result); + } + DBUG_RETURN (0); +} |