Subversion Repositories tendra.SVN

Rev

Rev 5 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 6
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
Line 60... Line 90...
60
#include "gen-errors.h"
90
#include "gen-errors.h"
61
 
91
 
62
/*--------------------------------------------------------------------------*/
92
/*--------------------------------------------------------------------------*/
63
 
93
 
64
void
94
void
65
arg_parse_intern_descriptions PROTO_N ((arg_list))
95
arg_parse_intern_descriptions(ArgListP arg_list)
66
			      PROTO_T (ArgListP arg_list)
-
 
67
{
96
{
68
    while ((arg_list->name != NIL (CStringP)) ||
97
    while ((arg_list->name != NIL(CStringP)) ||
69
	   (arg_list->short_name != '\0')) {
98
	   (arg_list->short_name != '\0')) {
70
	EStringP estring = error_lookup_string (arg_list->u.name);
99
	EStringP estring = error_lookup_string(arg_list->u.name);
71
 
100
 
72
	ASSERT (estring != NIL (EStringP));
101
	ASSERT(estring != NIL(EStringP));
73
	arg_list->u.message = estring;
102
	arg_list->u.message = estring;
74
	arg_list ++;
103
	arg_list++;
75
    }
104
    }
76
}
105
}
77
 
106
 
78
int
107
int
79
arg_parse_arguments PROTO_N ((arg_list, usage, argc, argv))
108
arg_parse_arguments(ArgListP arg_list, EStringP usage, int argc, char **argv)
80
		    PROTO_T (ArgListP arg_list X
-
 
81
			     EStringP usage X
-
 
82
			     int      argc X
-
 
83
			     char   **argv)
-
 
84
{
109
{
85
    int       tmp_argc = argc;
110
    int       tmp_argc = argc;
86
    char    **tmp_argv = argv;
111
    char    **tmp_argv = argv;
87
    ArgUsageT closure;
112
    ArgUsageT closure;
88
 
113
 
89
    closure.usage    = error_string_contents (usage);
114
    closure.usage    = error_string_contents(usage);
90
    closure.arg_list = arg_list;
115
    closure.arg_list = arg_list;
91
    while (tmp_argc) {
116
    while (tmp_argc) {
92
	CStringP option = (tmp_argv [0]);
117
	CStringP option = (tmp_argv[0]);
93
	char     c      = (option [0]);
118
	char     c      = (option[0]);
94
 
119
 
95
	if ((((c == '-') && (option [1] == '-')) ||
120
	if ((((c == '-') && (option[1] == '-')) ||
96
	     ((c == '+') && (option [1] == '+'))) && (option [2] == '\0')) {
121
	    ((c == '+') && (option[1] == '+'))) && (option[2] == '\0')) {
97
	    return (argc - tmp_argc + 1);
122
	    return(argc - tmp_argc + 1);
98
	} else if (((c == '-') && (option [1] == '-')) ||
123
	} else if (((c == '-') && (option[1] == '-')) ||
99
		   ((c == '+') && (option [1] == '+'))) {
124
		   ((c == '+') && (option[1] == '+'))) {
100
	    ArgListP tmp_list  = arg_list;
125
	    ArgListP tmp_list  = arg_list;
101
	    ArgListP chosen    = NIL (ArgListP);
126
	    ArgListP chosen    = NIL(ArgListP);
102
	    unsigned matches   = 0;
127
	    unsigned matches   = 0;
103
	    CStringP immediate = NIL (CStringP);
128
	    CStringP immediate = NIL(CStringP);
104
 
129
 
105
	    while ((tmp_list->name != NIL (CStringP)) ||
130
	    while ((tmp_list->name != NIL(CStringP)) ||
106
		   (tmp_list->short_name != '\0')) {
131
		   (tmp_list->short_name != '\0')) {
107
		CStringP opt = (tmp_list->name);
132
		CStringP opt = (tmp_list->name);
108
		CStringP arg = (&(option [2]));
133
		CStringP arg = (&(option[2]));
109
 
134
 
110
		if (opt != NIL (CStringP)) {
135
		if (opt != NIL(CStringP)) {
111
		    char optch;
136
		    char optch;
112
		    char argch;
137
		    char argch;
113
 
138
 
114
		    do {
139
		    do {
115
			optch = (*opt ++);
140
			optch = (*opt++);
116
			argch = (*arg ++);
141
			argch = (*arg++);
117
		    } while (optch && argch && (optch == argch));
142
		    } while (optch && argch && (optch == argch));
118
		    if (optch == argch) {
143
		    if (optch == argch) {
119
			chosen    = tmp_list;
144
			chosen    = tmp_list;
120
			matches   = 1;
145
			matches   = 1;
121
			immediate = (arg - 1);
146
			immediate = (arg - 1);
Line 127... Line 152...
127
			matches   = 1;
152
			matches   = 1;
128
			immediate = (arg - 1);
153
			immediate = (arg - 1);
129
			break;
154
			break;
130
		    } else if (argch == '\0') {
155
		    } else if (argch == '\0') {
131
			chosen = tmp_list;
156
			chosen = tmp_list;
132
			matches ++;
157
			matches++;
133
		    }
158
		    }
134
		}
159
		}
135
		tmp_list ++;
160
		tmp_list++;
136
	    }
161
	    }
137
	    if (matches == 0) {
162
	    if (matches == 0) {
138
		E_arg_parse_unknown_option (option, &closure);
163
		E_arg_parse_unknown_option(option, &closure);
139
		UNREACHED;
164
		UNREACHED;
140
	    } else if (matches > 1) {
165
	    } else if (matches > 1) {
141
		E_arg_parse_ambiguous_option (option, &closure);
166
		E_arg_parse_ambiguous_option(option, &closure);
142
		UNREACHED;
167
		UNREACHED;
143
	    } else {
168
	    } else {
144
		switch (chosen->type) EXHAUSTIVE {
169
		switch (chosen->type)EXHAUSTIVE {
145
		  case AT_SWITCH:
170
		  case AT_SWITCH:
146
		    (*((BoolP) (chosen->closure))) = (c == '-');
171
		   (*((BoolP)(chosen->closure))) = (c == '-');
147
		    break;
172
		    break;
148
		  case AT_NEG_SWITCH:
173
		  case AT_NEG_SWITCH:
149
		    (*((BoolP) (chosen->closure))) = (c == '+');
174
		   (*((BoolP)(chosen->closure))) = (c == '+');
150
		    break;
175
		    break;
151
		  case AT_PROC_SWITCH:
176
		  case AT_PROC_SWITCH:
152
		    (*(chosen->proc)) (option, &closure, chosen->closure,
177
		   (*(chosen->proc))(option, &closure, chosen->closure,
153
				       c == '-');
178
				     c == '-');
154
		    break;
179
		    break;
155
		  case AT_IMMEDIATE:
180
		  case AT_IMMEDIATE:
156
		    if (immediate != NIL (CStringP)) {
181
		    if (immediate != NIL(CStringP)) {
157
			(*(chosen->proc)) (option, &closure, chosen->closure,
182
			(*(chosen->proc))(option, &closure, chosen->closure,
158
					   immediate);
183
					   immediate);
159
		    } else {
184
		    } else {
160
			E_arg_parse_unknown_option (option, &closure);
185
			E_arg_parse_unknown_option(option, &closure);
161
			UNREACHED;
186
			UNREACHED;
162
		    }
187
		    }
163
		    break;
188
		    break;
164
		  case AT_EITHER:
189
		  case AT_EITHER:
165
		    if (immediate != NIL (CStringP)) {
190
		    if (immediate != NIL(CStringP)) {
166
			if (immediate [0] != '\0') {
191
			if (immediate[0]!= '\0') {
167
			    (*(chosen->proc)) (option, &closure,
192
			   (*(chosen->proc))(option, &closure,
168
					       chosen->closure, immediate);
193
					     chosen->closure, immediate);
169
			} else if (tmp_argc > 1) {
194
			} else if (tmp_argc > 1) {
170
			    tmp_argv ++;
195
			    tmp_argv++;
171
			    tmp_argc --;
196
			    tmp_argc--;
172
			    (*(chosen->proc)) (option, &closure,
197
			   (*(chosen->proc))(option, &closure,
173
					       chosen->closure, tmp_argv [0]);
198
					     chosen->closure, tmp_argv[0]);
174
			} else {
199
			} else {
175
			    E_arg_parse_missing_argument (option, &closure);
200
			    E_arg_parse_missing_argument(option, &closure);
176
			    UNREACHED;
201
			    UNREACHED;
177
			}
202
			}
178
		    } else {
203
		    } else {
179
			E_arg_parse_unknown_option (option, &closure);
204
			E_arg_parse_unknown_option(option, &closure);
180
			UNREACHED;
205
			UNREACHED;
181
		    }
206
		    }
182
		    break;
207
		    break;
183
		  case AT_FOLLOWING:
208
		  case AT_FOLLOWING:
184
		    if (tmp_argc > 1) {
209
		    if (tmp_argc > 1) {
185
			tmp_argv ++;
210
			tmp_argv++;
186
			tmp_argc --;
211
			tmp_argc--;
187
			(*(chosen->proc)) (option, &closure, chosen->closure,
212
			(*(chosen->proc))(option, &closure, chosen->closure,
188
					   tmp_argv [0]);
213
					  tmp_argv[0]);
189
		    } else {
214
		    } else {
190
			E_arg_parse_missing_argument (option, &closure);
215
			E_arg_parse_missing_argument(option, &closure);
191
			UNREACHED;
216
			UNREACHED;
192
		    }
217
		    }
193
		    break;
218
		    break;
194
		  case AT_EMPTY:
219
		  case AT_EMPTY:
195
		    (*(chosen->proc)) (option, &closure, chosen->closure);
220
		   (*(chosen->proc))(option, &closure, chosen->closure);
196
		    break;
221
		    break;
197
		  case AT_FOLLOWING2:
222
		  case AT_FOLLOWING2:
198
		    if (tmp_argc > 2) {
223
		    if (tmp_argc > 2) {
199
			tmp_argv += 2;
224
			tmp_argv += 2;
200
			tmp_argc -= 2;
225
			tmp_argc -= 2;
201
			(*(chosen->proc)) (option, &closure, chosen->closure,
226
			(*(chosen->proc))(option, &closure, chosen->closure,
202
					   tmp_argv [-1], tmp_argv [0]);
227
					  tmp_argv[-1], tmp_argv[0]);
203
		    } else {
228
		    } else {
204
			E_arg_parse_missing_argument (option, &closure);
229
			E_arg_parse_missing_argument(option, &closure);
205
			UNREACHED;
230
			UNREACHED;
206
		    }
231
		    }
207
		    break;
232
		    break;
208
		  case AT_FOLLOWING3:
233
		  case AT_FOLLOWING3:
209
		    if (tmp_argc > 3) {
234
		    if (tmp_argc > 3) {
210
			tmp_argv += 3;
235
			tmp_argv += 3;
211
			tmp_argc -= 3;
236
			tmp_argc -= 3;
212
			(*(chosen->proc)) (option, &closure, chosen->closure,
237
			(*(chosen->proc))(option, &closure, chosen->closure,
213
					   tmp_argv [-2], tmp_argv [-1],
238
					  tmp_argv[-2], tmp_argv[-1],
214
					   tmp_argv [0]);
239
					  tmp_argv[0]);
215
		    } else {
240
		    } else {
216
			E_arg_parse_missing_argument (option, &closure);
241
			E_arg_parse_missing_argument(option, &closure);
217
			UNREACHED;
242
			UNREACHED;
218
		    }
243
		    }
219
		    break;
244
		    break;
220
		}
245
		}
221
	    }
246
	    }
222
	} else if (((c == '-') && (option [1] == '+')) ||
247
	} else if (((c == '-') && (option[1] == '+')) ||
223
		   ((c == '+') && (option [1] == '-')) ||
248
		   ((c == '+') && (option[1] == '-')) ||
224
		   ((c == '-') && (option [1] == '\0')) ||
249
		   ((c == '-') && (option[1] == '\0')) ||
225
		   ((c == '+') && (option [1] == '\0'))) {
250
		   ((c == '+') && (option[1] == '\0'))) {
226
	    E_arg_parse_unknown_option (option, &closure);
251
	    E_arg_parse_unknown_option(option, &closure);
227
	    UNREACHED;
252
	    UNREACHED;
228
	} else if ((c == '-') || (c == '+')) {
253
	} else if ((c == '-') || (c == '+')) {
229
	    CStringP opt = &(option [1]);
254
	    CStringP opt = &(option[1]);
230
 
255
 
231
	    while ((opt != NIL (CStringP)) && (*opt != '\0')) {
256
	    while ((opt != NIL(CStringP)) && (*opt != '\0')) {
232
		ArgListP tmp_list = arg_list;
257
		ArgListP tmp_list = arg_list;
233
		ArgListP chosen   = NIL (ArgListP);
258
		ArgListP chosen   = NIL(ArgListP);
234
 
259
 
235
		while ((tmp_list->name != NIL (CStringP)) ||
260
		while ((tmp_list->name != NIL(CStringP)) ||
236
		       (tmp_list->short_name != '\0')) {
261
		       (tmp_list->short_name != '\0')) {
237
		    if (tmp_list->short_name == *opt) {
262
		    if (tmp_list->short_name == *opt) {
238
			chosen = tmp_list;
263
			chosen = tmp_list;
239
			break;
264
			break;
240
		    }
265
		    }
241
		    tmp_list ++;
266
		    tmp_list++;
242
		}
267
		}
243
		if (chosen) {
268
		if (chosen) {
244
		    switch (chosen->type) EXHAUSTIVE {
269
		    switch (chosen->type)EXHAUSTIVE {
245
		      case AT_SWITCH:
270
		      case AT_SWITCH:
246
			(*((BoolP) (chosen->closure))) = (c == '-');
271
			(*((BoolP)(chosen->closure))) = (c == '-');
247
			break;
272
			break;
248
		      case AT_NEG_SWITCH:
273
		      case AT_NEG_SWITCH:
249
			(*((BoolP) (chosen->closure))) = (c == '+');
274
			(*((BoolP)(chosen->closure))) = (c == '+');
250
			break;
275
			break;
251
		      case AT_PROC_SWITCH:
276
		      case AT_PROC_SWITCH:
252
			(*(chosen->proc)) (opt, &closure, chosen->closure,
277
			(*(chosen->proc))(opt, &closure, chosen->closure,
253
					   c == '-');
278
					  c == '-');
254
			break;
279
			break;
255
		      case AT_IMMEDIATE:
280
		      case AT_IMMEDIATE:
256
			(*(chosen->proc)) (opt, &closure, chosen->closure,
281
			(*(chosen->proc))(opt, &closure, chosen->closure,
257
					   opt + 1);
282
					  opt + 1);
258
			opt = NIL (CStringP);
283
			opt = NIL(CStringP);
259
			break;
284
			break;
260
		      case AT_EITHER:
285
		      case AT_EITHER:
261
			if (opt [1] != '\0') {
286
			if (opt[1]!= '\0') {
262
			    (*(chosen->proc)) (opt, &closure, chosen->closure,
287
			   (*(chosen->proc))(opt, &closure, chosen->closure,
263
					       opt + 1);
288
					     opt + 1);
264
			} else if (tmp_argc > 1) {
289
			} else if (tmp_argc > 1) {
265
			    tmp_argv ++;
290
			    tmp_argv++;
266
			    tmp_argc --;
291
			    tmp_argc--;
267
			    (*(chosen->proc)) (opt, &closure, chosen->closure,
292
			   (*(chosen->proc))(opt, &closure, chosen->closure,
268
					       tmp_argv [0]);
293
					     tmp_argv[0]);
269
			} else {
294
			} else {
270
			    E_arg_parse_missing_short_arg (option, opt,
295
			    E_arg_parse_missing_short_arg(option, opt,
271
							   &closure);
296
							  &closure);
272
			    UNREACHED;
297
			    UNREACHED;
273
			}
298
			}
274
			opt = NIL (CStringP);
299
			opt = NIL(CStringP);
275
			break;
300
			break;
276
		      case AT_FOLLOWING:
301
		      case AT_FOLLOWING:
277
			if (tmp_argc > 1) {
302
			if (tmp_argc > 1) {
278
			    tmp_argv ++;
303
			    tmp_argv++;
279
			    tmp_argc --;
304
			    tmp_argc--;
280
			    (*(chosen->proc)) (opt, &closure, chosen->closure,
305
			   (*(chosen->proc))(opt, &closure, chosen->closure,
281
					       tmp_argv [0]);
306
					     tmp_argv[0]);
282
			} else {
307
			} else {
283
			    E_arg_parse_missing_short_arg (option, opt,
308
			    E_arg_parse_missing_short_arg(option, opt,
284
							   &closure);
309
							  &closure);
285
			    UNREACHED;
310
			    UNREACHED;
286
			}
311
			}
287
			break;
312
			break;
288
		      case AT_EMPTY:
313
		      case AT_EMPTY:
289
			(*(chosen->proc)) (opt, &closure, chosen->closure);
314
			(*(chosen->proc))(opt, &closure, chosen->closure);
290
			break;
315
			break;
291
		      case AT_FOLLOWING2:
316
		      case AT_FOLLOWING2:
292
			if (tmp_argc > 2) {
317
			if (tmp_argc > 2) {
293
			    tmp_argv += 2;
318
			    tmp_argv += 2;
294
			    tmp_argc -= 2;
319
			    tmp_argc -= 2;
295
			    (*(chosen->proc)) (opt, &closure, chosen->closure,
320
			   (*(chosen->proc))(opt, &closure, chosen->closure,
296
					       tmp_argv [-1], tmp_argv [0]);
321
					     tmp_argv[-1], tmp_argv[0]);
297
			} else {
322
			} else {
298
			    E_arg_parse_missing_short_arg (option, opt,
323
			    E_arg_parse_missing_short_arg(option, opt,
299
							   &closure);
324
							  &closure);
300
			    UNREACHED;
325
			    UNREACHED;
301
			}
326
			}
302
			break;
327
			break;
303
		      case AT_FOLLOWING3:
328
		      case AT_FOLLOWING3:
304
			if (tmp_argc > 3) {
329
			if (tmp_argc > 3) {
305
			    tmp_argv += 3;
330
			    tmp_argv += 3;
306
			    tmp_argc -= 3;
331
			    tmp_argc -= 3;
307
			    (*(chosen->proc)) (opt, &closure, chosen->closure,
332
			   (*(chosen->proc))(opt, &closure, chosen->closure,
308
					       tmp_argv [-2], tmp_argv [-1],
333
					     tmp_argv[-2], tmp_argv[-1],
309
					       tmp_argv [0]);
334
					     tmp_argv[0]);
310
			} else {
335
			} else {
311
			    E_arg_parse_missing_short_arg (option, opt,
336
			    E_arg_parse_missing_short_arg(option, opt,
312
							   &closure);
337
							  &closure);
313
			    UNREACHED;
338
			    UNREACHED;
314
			}
339
			}
315
			break;
340
			break;
316
		    }
341
		    }
317
		} else {
342
		} else {
318
		    E_arg_parse_unknown_short_opt (option, opt, &closure);
343
		    E_arg_parse_unknown_short_opt(option, opt, &closure);
319
		    UNREACHED;
344
		    UNREACHED;
320
		}
345
		}
321
		if (opt) {
346
		if (opt) {
322
		    opt ++;
347
		    opt++;
323
		}
348
		}
324
	    }
349
	    }
325
	} else {
350
	} else {
326
	    return (argc - tmp_argc);
351
	    return(argc - tmp_argc);
327
	}
352
	}
328
	tmp_argv ++;
353
	tmp_argv++;
329
	tmp_argc --;
354
	tmp_argc--;
330
    }
355
    }
331
    return (argc);
356
    return(argc);
332
}
357
}
333
 
358
 
334
void
359
void
335
write_arg_usage PROTO_N ((ostream, closure))
360
write_arg_usage(OStreamP ostream, ArgUsageP closure)
336
		PROTO_T (OStreamP  ostream X
-
 
337
			 ArgUsageP closure)
-
 
338
{
361
{
339
    CStringP usage    = (closure->usage);
362
    CStringP usage    = (closure->usage);
340
    ArgListP arg_list = (closure->arg_list);
363
    ArgListP arg_list = (closure->arg_list);
341
 
364
 
342
    write_cstring (ostream, usage);
365
    write_cstring(ostream, usage);
343
    while ((arg_list->name != NIL (CStringP)) ||
366
    while ((arg_list->name != NIL(CStringP)) ||
344
	   (arg_list->short_name != '\0')) {
367
	   (arg_list->short_name != '\0')) {
345
	CStringP desc = error_string_contents (arg_list->u.message);
368
	CStringP desc = error_string_contents(arg_list->u.message);
346
 
369
 
347
	if (arg_list->name) {
370
	if (arg_list->name) {
348
	    write_newline (ostream);
371
	    write_newline(ostream);
349
	    write_cstring (ostream, "    {--|++}");
372
	    write_cstring(ostream, "    {--|++}");
350
	    write_cstring (ostream, arg_list->name);
373
	    write_cstring(ostream, arg_list->name);
351
	    write_cstring (ostream, desc);
374
	    write_cstring(ostream, desc);
352
	}
375
	}
353
	if (arg_list->short_name != '\0') {
376
	if (arg_list->short_name != '\0') {
354
	    write_newline (ostream);
377
	    write_newline(ostream);
355
	    write_cstring (ostream, "    {-|+}");
378
	    write_cstring(ostream, "    {-|+}");
356
	    write_char (ostream, arg_list->short_name);
379
	    write_char(ostream, arg_list->short_name);
357
	    write_cstring (ostream, desc);
380
	    write_cstring(ostream, desc);
358
	}
381
	}
359
	arg_list ++;
382
	arg_list++;
360
    }
383
    }
361
}
384
}
362

385

363
/*
386
/*
364
 * Local variables(smf):
387
 * Local variables(smf):