Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-kde
Path: blob/main/japanese/FreeWnn-server/files/patch-Wnn-etc-getopt1.c
16461 views
1
Index: Wnn/etc/getopt1.c
2
===================================================================
3
RCS file: /home/cvs/private/hrs/freewnn/Wnn/etc/getopt1.c,v
4
retrieving revision 1.1.1.1
5
retrieving revision 1.2
6
diff -u -p -r1.1.1.1 -r1.2
7
--- Wnn/etc/getopt1.c 20 Dec 2008 07:13:30 -0000 1.1.1.1
8
+++ Wnn/etc/getopt1.c 20 Dec 2008 15:22:40 -0000 1.2
9
@@ -66,14 +66,13 @@
10
#endif
11
12
int
13
-getopt_long (argc, argv, options, long_options, opt_index)
14
- int argc;
15
- char *const *argv;
16
- const char *options;
17
- const struct option *long_options;
18
- int *opt_index;
19
+getopt_long(int argc,
20
+ char * const *argv,
21
+ const char *options,
22
+ const struct option *long_options,
23
+ int *opt_index)
24
{
25
- return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
26
+ return _getopt_internal(argc, argv, options, long_options, opt_index, 0);
27
}
28
29
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
30
@@ -82,14 +81,13 @@ getopt_long (argc, argv, options, long_o
31
instead. */
32
33
int
34
-getopt_long_only (argc, argv, options, long_options, opt_index)
35
- int argc;
36
- char *const *argv;
37
- const char *options;
38
- const struct option *long_options;
39
- int *opt_index;
40
+getopt_long_only(int argc,
41
+ char * const *argv,
42
+ const char *options,
43
+ const struct option *long_options,
44
+ int *opt_index)
45
{
46
- return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
47
+ return _getopt_internal(argc, argv, options, long_options, opt_index, 1);
48
}
49
50
51
@@ -100,91 +98,87 @@ getopt_long_only (argc, argv, options, l
52
#include <stdio.h>
53
54
int
55
-main (argc, argv)
56
- int argc;
57
- char **argv;
58
+main(int argc, char **argv)
59
{
60
- int c;
61
- int digit_optind = 0;
62
+ int c;
63
+ int digit_optind = 0;
64
65
- while (1)
66
- {
67
- int this_option_optind = optind ? optind : 1;
68
- int option_index = 0;
69
- static struct option long_options[] =
70
- {
71
- {"add", 1, 0, 0},
72
- {"append", 0, 0, 0},
73
- {"delete", 1, 0, 0},
74
- {"verbose", 0, 0, 0},
75
- {"create", 0, 0, 0},
76
- {"file", 1, 0, 0},
77
- {0, 0, 0, 0}
78
- };
79
-
80
- c = getopt_long (argc, argv, "abc:d:0123456789",
81
- long_options, &option_index);
82
- if (c == -1)
83
- break;
84
-
85
- switch (c)
86
- {
87
- case 0:
88
- printf ("option %s", long_options[option_index].name);
89
- if (optarg)
90
- printf (" with arg %s", optarg);
91
- printf ("\n");
92
- break;
93
-
94
- case '0':
95
- case '1':
96
- case '2':
97
- case '3':
98
- case '4':
99
- case '5':
100
- case '6':
101
- case '7':
102
- case '8':
103
- case '9':
104
- if (digit_optind != 0 && digit_optind != this_option_optind)
105
- printf ("digits occur in two different argv-elements.\n");
106
- digit_optind = this_option_optind;
107
- printf ("option %c\n", c);
108
- break;
109
-
110
- case 'a':
111
- printf ("option a\n");
112
- break;
113
-
114
- case 'b':
115
- printf ("option b\n");
116
- break;
117
-
118
- case 'c':
119
- printf ("option c with value `%s'\n", optarg);
120
- break;
121
-
122
- case 'd':
123
- printf ("option d with value `%s'\n", optarg);
124
- break;
125
+ while (1) {
126
+ int this_option_optind = optind ? optind : 1;
127
+ int option_index = 0;
128
+ static struct option long_options[] = {
129
+ {"add", 1, 0, 0},
130
+ {"append", 0, 0, 0},
131
+ {"delete", 1, 0, 0},
132
+ {"verbose", 0, 0, 0},
133
+ {"create", 0, 0, 0},
134
+ {"file", 1, 0, 0},
135
+ {0, 0, 0, 0}
136
+ };
137
+
138
+ c = getopt_long(argc, argv, "abc:d:0123456789",
139
+ long_options, &option_index);
140
+
141
+ if (c == -1)
142
+ break;
143
+
144
+ switch (c) {
145
+ case 0:
146
+ printf ("option %s", long_options[option_index].name);
147
+ if (optarg)
148
+ printf (" with arg %s", optarg);
149
+
150
+ printf ("\n");
151
+ break;
152
+ case '0':
153
+ case '1':
154
+ case '2':
155
+ case '3':
156
+ case '4':
157
+ case '5':
158
+ case '6':
159
+ case '7':
160
+ case '8':
161
+ case '9':
162
+ if (digit_optind != 0 && digit_optind != this_option_optind)
163
+ printf ("digits occur in two different argv-elements.\n");
164
+ digit_optind = this_option_optind;
165
+ printf ("option %c\n", c);
166
+ break;
167
+
168
+ case 'a':
169
+ printf ("option a\n");
170
+ break;
171
+
172
+ case 'b':
173
+ printf ("option b\n");
174
+ break;
175
+
176
+ case 'c':
177
+ printf ("option c with value `%s'\n", optarg);
178
+ break;
179
+
180
+ case 'd':
181
+ printf ("option d with value `%s'\n", optarg);
182
+ break;
183
+
184
+ case '?':
185
+ break;
186
+
187
+ default:
188
+ printf ("?? getopt returned character code 0%o ??\n", c);
189
+ }
190
+ }
191
192
- case '?':
193
- break;
194
+ if (optind < argc) {
195
+ printf ("non-option ARGV-elements: ");
196
197
- default:
198
- printf ("?? getopt returned character code 0%o ??\n", c);
199
+ while (optind < argc)
200
+ printf ("%s ", argv[optind++]);
201
+ printf ("\n");
202
}
203
- }
204
-
205
- if (optind < argc)
206
- {
207
- printf ("non-option ARGV-elements: ");
208
- while (optind < argc)
209
- printf ("%s ", argv[optind++]);
210
- printf ("\n");
211
- }
212
213
- exit (0);
214
+ exit(0);
215
}
216
217
#endif /* TEST */
218
219