File: help_messages.patch

package info (click to toggle)
fdutils 5.6-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,540 kB
  • sloc: ansic: 6,334; sh: 3,570; makefile: 262; sed: 4
file content (206 lines) | stat: -rw-r--r-- 5,177 bytes parent folder | download | duplicates (3)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
Description: Fixes related to the help messages
 This patch contains several fixes related to the usage and help
 messages:
 - Do not print "Type <program> --help to get a more complete help"
   any more when invoking program with --help or -h.
 - floppymeter, floppycontrol, diskseekd, diskd: usage messages fixed
   to be consistent with the manpages.
 - superformat: print the usage short message along with the options'
   details when invoking with --help or -h (Closes: #88297).
 - fdlist, fdmount, fdumount, fdmountd: fixed usage printing when
   invoking with --help or -h.
Author: Matteo Cypriani <mcy@lm7.fr>
Bug-Debian: http://bugs.debian.org/88297
Last-Update: 2021-01-30
--- a/src/enh_options.c
+++ b/src/enh_options.c
@@ -58,8 +58,14 @@
 		fprintf(stderr,"] ");
 	}
 	fprintf(stderr,"%s\n", userparams);
+}
+
+void print_usage_exit(char *progname, struct enh_options *eo, char *userparams)
+{
+	print_usage(progname, eo, userparams);
 	fprintf(stderr,"Type %s --help to get a more complete help\n",
 		progname);
+	exit(1);
 }
 
 static void parse_option_table(struct enh_options *eo)
@@ -490,6 +496,7 @@
 
 		switch(ch){
 		case 'h':
+			print_usage(argv[0], eo, userparams);
 			print_help(eo);
 			exit(0);
 		case '?':
--- a/src/setfdprm.c
+++ b/src/setfdprm.c
@@ -41,8 +41,6 @@
 	int mask;
 
 	name = argv[0];
-	if (argc < 3) 
-		print_usage(name, optable, userparams);
 	cmd = FDSETPRM;
 	mcmd = 0;
 	while((c=getopt_enh(argc, argv, optable, 0, &mask, userparams)) != EOF){
@@ -53,6 +51,8 @@
 		printf("unhandled option %d\n", c);
 		exit(1);
 	}
+	if (argc < 3)
+		print_usage_exit(name, optable, userparams);
 
 	argv += optind;
 	argc -= optind;
--- a/src/enh_options.h
+++ b/src/enh_options.h
@@ -53,6 +53,8 @@
 
 void  print_help(struct enh_options *eo);
 
+void print_usage_exit(char *progname, struct enh_options *eo, char *userparams);
+
 void print_usage(char *progname, struct enh_options *eo, char *userparams);
 /* userparams represent the non-option parameters of the command. Printed
  * after the automatically generated list */
--- a/src/superformat.c
+++ b/src/superformat.c
@@ -726,21 +726,18 @@
 	/* sanity checking */
 	if (sizecode < 0 || sizecode >= MAX_SIZECODE) {
 		fprintf(stderr,"Bad sizecode %d\n", sizecode);
-		print_usage(progname,optable, "");
-		exit(1);
+		print_usage_exit(progname,optable, "");
 	}
 
 	if ( gap < 0 ){
 		fprintf(stderr,"Fmt gap too small: %d\n", gap);
-		print_usage(progname,optable, "");
-		exit(1);
+		print_usage_exit(progname,optable, "");
 	}
 
 	if (sectors <= 0 || cylinders <= 0 || heads <= 0) {
 		fprintf(stderr,"bad geometry s=%d h=%d t=%d\n",
 			sectors, heads, cylinders);
-		print_usage(progname,optable, "");
-		exit(1);
+		print_usage_exit(progname,optable, "");
 	}
 
 	argc -= optind;
@@ -753,8 +750,7 @@
 
 	if (! fd[0].name){
 		fprintf(stderr,"Which drive?\n");
-		print_usage(progname,optable, "");
-		exit(1);
+		print_usage_exit(progname,optable, "");
 	}
 
 	while(1) {
@@ -904,8 +900,7 @@
 		
 	if (cylinders > fd[0].drvprm.tracks) {
 		fprintf(stderr,"too many cylinder for this drive\n");
-		print_usage(progname,optable,"");
-		exit(1);
+		print_usage_exit(progname,optable,"");
 	}
 
 	if (! (mask & SET_ENDTRACK ) || end_cylinder > cylinders)
--- a/src/diskd.c
+++ b/src/diskd.c
@@ -77,7 +77,7 @@
 	};
 
 	while((ch=getopt_enh(argc, argv, optable, 
-			     0, &mask, "drive") ) != EOF ){
+			     0, &mask, "") ) != EOF ){
 		if ( ch== '?' ){
 			fprintf(stderr,"exiting\n");
 			exit(1);
--- a/src/diskseekd.c
+++ b/src/diskseekd.c
@@ -78,7 +78,7 @@
 		interval = 0;
 
 	while((ch=getopt_enh(argc, argv, optable, 
-			     0, &mask, "drive") ) != EOF ){
+			     0, &mask, "") ) != EOF ){
 		if ( ch== '?' ){
 			fprintf(stderr,"exiting\n");
 			exit(1);
--- a/src/floppycontrol.c
+++ b/src/floppycontrol.c
@@ -270,7 +270,7 @@
 		
 	fd = -2;
 	while((ch=getopt_enh(argc, argv, optable, 
-			     0, &mask, "drive") ) != EOF ){
+			     0, &mask, "[drive]") ) != EOF ){
 		if ( ch== '?' ){
 			fprintf(stderr,"exiting\n");
 			exit(1);
@@ -289,8 +289,7 @@
 			fd = open("/dev/fd0", 3 | O_NDELAY);
 		if ( fd < 0 ){
 			perror("can't open floppy drive");
-			print_usage(argv[0],optable,"");
-			exit(1);
+			print_usage_exit(argv[0],optable,"[drive]");
 		}
 	}
 	
--- a/src/floppymeter.c
+++ b/src/floppymeter.c
@@ -132,7 +132,7 @@
 	struct reg *reg;
 
 	while((ch=getopt_enh(argc, argv, optable, 
-			     0, &mask, "drive") ) != EOF ){
+			     0, &mask, "[drive]") ) != EOF ){
 		if ( ch== '?' ){
 			fprintf(stderr,"exiting\n");
 			exit(1);
@@ -149,8 +149,7 @@
 	fd = open(name, 3 | O_NDELAY);
 	if ( fd < 0 ){
 		perror("can't open floppy drive");
-		print_usage(argv[0],optable,"");
-		exit(1);
+		print_usage_exit(argv[0],optable,"[drive]");
 	}
 
 	if(!(mask & NON_INTERACTIVE)) {
--- a/src/fdmount.c
+++ b/src/fdmount.c
@@ -1181,6 +1181,10 @@
 	}
     }
 
+    if (opt_help) {
+	syntax();
+    }
+
     mountflags |= opt_noexec | opt_nosuid | opt_nodev;
 
     if (opt_vfat) {
@@ -1229,10 +1233,7 @@
     }
 
     e=0;
-    if (opt_help) {
-	syntax();
-    }
-    else if (opt_list) {
+    if (opt_list) {
 	list_drives();
     }
     else if (opt_daemon) {