Skip to content

Commit 527686b

Browse files
author
serg@sergbook.mylan
committed
more dbug fixups to get a nicer manual (w/o my_pthread specifics)
use my_main.c for the actual build, and main.c for the manual
1 parent c79f4c0 commit 527686b

File tree

3 files changed

+56
-27
lines changed

3 files changed

+56
-27
lines changed

dbug/Makefile.am

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ noinst_HEADERS = dbug_long.h
2222
libdbug_a_SOURCES = dbug.c sanity.c
2323
EXTRA_DIST = example1.c example2.c example3.c \
2424
user.r monty.doc readme.prof dbug_add_tags.pl \
25-
main.c factorial.c dbug_analyze.c
25+
my_main.c main.c factorial.c dbug_analyze.c
2626
NROFF_INC = example1.r example2.r example3.r main.r \
2727
factorial.r output1.r output2.r output3.r \
2828
output4.r output5.r
2929

3030

3131
# Must be linked with libs that are not compiled yet
3232
noinst_PROGRAMS = factorial dbug_analyze
33-
factorial_SOURCES = main.c factorial.c
33+
factorial_SOURCES = my_main.c factorial.c
3434
dbug_analyze_SOURCES = dbug_analyze.c
3535

3636
all: user.t user.ps

dbug/main.c

+15-25
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,24 @@
1-
#ifdef DBUG_OFF /* We are testing dbug */
2-
#undef DBUG_OFF
3-
#endif
4-
5-
#include <my_global.h> /* This includes dbug.h */
1+
#include <dbug_long.h>
62

73
int main (argc, argv)
84
int argc;
95
char *argv[];
106
{
11-
register int result, ix;
7+
int result, ix;
128
extern int factorial(int);
13-
#if defined(HAVE_PTHREAD_INIT) && defined(THREAD)
14-
pthread_init(); /* Must be called before DBUG_ENTER */
15-
#endif
16-
my_thread_global_init();
17-
{
18-
DBUG_ENTER ("main");
19-
DBUG_PROCESS (argv[0]);
20-
for (ix = 1; ix < argc && argv[ix][0] == '-'; ix++) {
21-
switch (argv[ix][1]) {
22-
case '#':
23-
DBUG_PUSH (&(argv[ix][2]));
24-
break;
25-
}
26-
}
27-
for (; ix < argc; ix++) {
28-
DBUG_PRINT ("args", ("argv[%d] = %s", ix, argv[ix]));
29-
result = factorial (atoi(argv[ix]));
30-
printf ("%d\n", result);
9+
DBUG_ENTER ("main");
10+
DBUG_PROCESS (argv[0]);
11+
for (ix = 1; ix < argc && argv[ix][0] == '-'; ix++) {
12+
switch (argv[ix][1]) {
13+
case '#':
14+
DBUG_PUSH (&(argv[ix][2]));
15+
break;
3116
}
32-
DBUG_RETURN (0);
3317
}
18+
for (; ix < argc; ix++) {
19+
DBUG_PRINT ("args", ("argv[%d] = %s", ix, argv[ix]));
20+
result = factorial (atoi(argv[ix]));
21+
printf ("%d\n", result);
22+
}
23+
DBUG_RETURN (0);
3424
}

dbug/my_main.c

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
this is modified version of the original example main.c
3+
fixed so that it could compile and run in MySQL source tree
4+
*/
5+
6+
#ifdef DBUG_OFF /* We are testing dbug */
7+
#undef DBUG_OFF
8+
#endif
9+
10+
#include <my_global.h> /* This includes dbug.h */
11+
12+
int main (argc, argv)
13+
int argc;
14+
char *argv[];
15+
{
16+
register int result, ix;
17+
extern int factorial(int);
18+
#if defined(HAVE_PTHREAD_INIT) && defined(THREAD)
19+
pthread_init(); /* Must be called before DBUG_ENTER */
20+
#endif
21+
my_thread_global_init();
22+
{
23+
DBUG_ENTER ("main");
24+
DBUG_PROCESS (argv[0]);
25+
for (ix = 1; ix < argc && argv[ix][0] == '-'; ix++) {
26+
switch (argv[ix][1]) {
27+
case '#':
28+
DBUG_PUSH (&(argv[ix][2]));
29+
break;
30+
}
31+
}
32+
for (; ix < argc; ix++) {
33+
DBUG_PRINT ("args", ("argv[%d] = %s", ix, argv[ix]));
34+
result = factorial (atoi(argv[ix]));
35+
printf ("%d\n", result);
36+
}
37+
DBUG_RETURN (0);
38+
}
39+
}

0 commit comments

Comments
 (0)