File: Improved-debugging-options-handling.patch

package info (click to toggle)
cron 3.0pl1-162
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,204 kB
  • sloc: ansic: 47,007; perl: 733; makefile: 429; sh: 425; python: 36
file content (126 lines) | stat: -rw-r--r-- 2,950 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
From: Christian Kastner <ckk@kvr.at>
Date: Thu, 07 Jan 2016 22:19:41 +0100
Subject: Improved debugging options handling

When building cron with debugging support, include the ability to print the
debug options. When building without support, drop the debugging option
from option parsing.

Forwarded: no
Last-Update: 2016-01-07
Index: cron/config.h
===================================================================
--- cron.orig/config.h
+++ cron/config.h
@@ -29,6 +29,7 @@
  */
 
 #ifndef DEBUGGING
+#error DEBUGGING not defined
 #define DEBUGGING 1	/* 1 or 0 -- do you want debugging code built in? */
 #endif
 
Index: cron/cron.c
===================================================================
--- cron.orig/cron.c
+++ cron/cron.c
@@ -50,7 +50,17 @@ static	void	usage __P((void)),
 
 static void
 usage() {
-	fprintf(stderr, "usage:  %s [-x debugflag[,...]]\n", ProgramName);
+#if DEBUGGING
+	char **dflags;
+
+	fprintf(stderr, "usage:  %s [-x [", ProgramName);
+	for (dflags = DebugFlagNames; *dflags; dflags++) {
+		fprintf(stderr, "%s%s", *dflags, dflags[1] ? "," : "]");
+	}
+	fprintf(stderr, "]\n");
+#else
+	fprintf(stderr, "usage: %s\n", ProgramName);
+#endif
 	exit(ERROR_EXIT);
 }
 
@@ -318,6 +328,12 @@ sighup_handler(int x) {
 }
 
 
+#if DEBUGGING
+const char *getoptarg = "x:";
+#else
+const char *getoptarg = "";
+#endif
+
 static void
 parse_args(argc, argv)
 	int	argc;
@@ -325,14 +341,16 @@ parse_args(argc, argv)
 {
 	int	argch;
 
-	while (EOF != (argch = getopt(argc, argv, "x:"))) {
+	while (EOF != (argch = getopt(argc, argv, getoptarg))) {
 		switch (argch) {
 		default:
 			usage();
+#if DEBUGGING
 		case 'x':
 			if (!set_debug_flags(optarg))
 				usage();
 			break;
+#endif
 		}
 	}
 }
Index: cron/crontab.c
===================================================================
--- cron.orig/crontab.c
+++ cron/crontab.c
@@ -149,7 +149,12 @@ main(argc, argv)
 	exit(exitstatus);
 	/*NOTREACHED*/
 }
-	
+
+#if DEBUGGING
+const char *getoptarg = "u:lerix:";
+#else
+const char *getoptarg = "u:leri";
+#endif
 
 static void
 parse_args(argc, argv)
@@ -172,12 +177,15 @@ parse_args(argc, argv)
 	}
 	Filename[0] = '\0';
 	Option = opt_unknown;
-	while (EOF != (argch = getopt(argc, argv, "u:lerx:"))) {
+
+	while (EOF != (argch = getopt(argc, argv, getoptarg))) {
 		switch (argch) {
+#if DEBUGGING
 		case 'x':
 			if (!set_debug_flags(optarg))
 				usage("bad debug option");
 			break;
+#endif
 		case 'u':
 			if (!(pw = getpwnam(optarg)))
 			{
Index: cron/Makefile
===================================================================
--- cron.orig/Makefile
+++ cron/Makefile
@@ -71,7 +71,9 @@ LINTFLAGS	=	-hbxa $(INCLUDE) $(COMPAT) $
 #<<want to use a nonstandard CC?>>
 #CC		=	vcc
 #<<manifest defines>>
-DEFS		=
+# Allow override from command line
+DEBUG_DEFS	?= -DDEBUGGING=0
+DEFS		= $(DEBUG_DEFS)
 #(SGI IRIX systems need this)
 #DEFS		=	-D_BSD_SIGNALS -Dconst=
 #<<the name of the BSD-like install program>>