FYI: Reply from HP-UX
[git/dscho.git] / flex-2.5.33 / scanopt.c
blobcc7f63198122e0fb42c5267319c468e750fdfb19
1 /* flex - tool to generate fast lexical analyzers */
3 /* Copyright (c) 1990 The Regents of the University of California. */
4 /* All rights reserved. */
6 /* This code is derived from software contributed to Berkeley by */
7 /* Vern Paxson. */
9 /* The United States Government has rights in this work pursuant */
10 /* to contract no. DE-AC03-76SF00098 between the United States */
11 /* Department of Energy and the University of California. */
13 /* This file is part of flex. */
15 /* Redistribution and use in source and binary forms, with or without */
16 /* modification, are permitted provided that the following conditions */
17 /* are met: */
19 /* 1. Redistributions of source code must retain the above copyright */
20 /* notice, this list of conditions and the following disclaimer. */
21 /* 2. Redistributions in binary form must reproduce the above copyright */
22 /* notice, this list of conditions and the following disclaimer in the */
23 /* documentation and/or other materials provided with the distribution. */
25 /* Neither the name of the University nor the names of its contributors */
26 /* may be used to endorse or promote products derived from this software */
27 /* without specific prior written permission. */
29 /* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
30 /* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
31 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
32 /* PURPOSE. */
34 #include "flexdef.h"
35 #include "scanopt.h"
38 /* Internal structures */
40 #ifdef HAVE_STRCASECMP
41 #define STRCASECMP(a,b) strcasecmp(a,b)
42 #else
43 static int STRCASECMP PROTO ((const char *, const char *));
45 static int STRCASECMP (a, b)
46 const char *a;
47 const char *b;
49 while (tolower (*a++) == tolower (*b++)) ;
50 return b - a;
52 #endif
54 #define ARG_NONE 0x01
55 #define ARG_REQ 0x02
56 #define ARG_OPT 0x04
57 #define IS_LONG 0x08
59 struct _aux {
60 int flags; /* The above hex flags. */
61 int namelen; /* Length of the actual option word, e.g., "--file[=foo]" is 4 */
62 int printlen; /* Length of entire string, e.g., "--file[=foo]" is 12 */
66 struct _scanopt_t {
67 const optspec_t *options; /* List of options. */
68 struct _aux *aux; /* Auxiliary data about options. */
69 int optc; /* Number of options. */
70 int argc; /* Number of args. */
71 char **argv; /* Array of strings. */
72 int index; /* Used as: argv[index][subscript]. */
73 int subscript;
74 char no_err_msg; /* If true, do not print errors. */
75 char has_long;
76 char has_short;
79 /* Accessor functions. These WOULD be one-liners, but portability calls. */
80 static const char *NAME PROTO ((struct _scanopt_t *, int));
81 static int PRINTLEN PROTO ((struct _scanopt_t *, int));
82 static int RVAL PROTO ((struct _scanopt_t *, int));
83 static int FLAGS PROTO ((struct _scanopt_t *, int));
84 static const char *DESC PROTO ((struct _scanopt_t *, int));
85 static int scanopt_err PROTO ((struct _scanopt_t *, int, int, int));
86 static int matchlongopt PROTO ((char *, char **, int *, char **, int *));
87 static int find_opt
88 PROTO ((struct _scanopt_t *, int, char *, int, int *, int *opt_offset));
90 static const char *NAME (s, i)
91 struct _scanopt_t *s;
92 int i;
94 return s->options[i].opt_fmt +
95 ((s->aux[i].flags & IS_LONG) ? 2 : 1);
98 static int PRINTLEN (s, i)
99 struct _scanopt_t *s;
100 int i;
102 return s->aux[i].printlen;
105 static int RVAL (s, i)
106 struct _scanopt_t *s;
107 int i;
109 return s->options[i].r_val;
112 static int FLAGS (s, i)
113 struct _scanopt_t *s;
114 int i;
116 return s->aux[i].flags;
119 static const char *DESC (s, i)
120 struct _scanopt_t *s;
121 int i;
123 return s->options[i].desc ? s->options[i].desc : "";
126 #ifndef NO_SCANOPT_USAGE
127 static int get_cols PROTO ((void));
129 static int get_cols ()
131 char *env;
132 int cols = 80; /* default */
134 #ifdef HAVE_NCURSES_H
135 initscr ();
136 endwin ();
137 if (COLS > 0)
138 return COLS;
139 #endif
141 if ((env = getenv ("COLUMNS")) != NULL)
142 cols = atoi (env);
144 return cols;
146 #endif
148 /* Macro to check for NULL before assigning a value. */
149 #define SAFE_ASSIGN(ptr,val) \
150 do{ \
151 if((ptr)!=NULL) \
152 *(ptr) = val; \
153 }while(0)
155 /* Macro to assure we reset subscript whenever we adjust s->index.*/
156 #define INC_INDEX(s,n) \
157 do{ \
158 (s)->index += (n); \
159 (s)->subscript= 0; \
160 }while(0)
162 scanopt_t *scanopt_init (options, argc, argv, flags)
163 const optspec_t *options;
164 int argc;
165 char **argv;
166 int flags;
168 int i;
169 struct _scanopt_t *s;
170 s = (struct _scanopt_t *) malloc (sizeof (struct _scanopt_t));
172 s->options = options;
173 s->optc = 0;
174 s->argc = argc;
175 s->argv = (char **) argv;
176 s->index = 1;
177 s->subscript = 0;
178 s->no_err_msg = (flags & SCANOPT_NO_ERR_MSG);
179 s->has_long = 0;
180 s->has_short = 0;
182 /* Determine option count. (Find entry with all zeros). */
183 s->optc = 0;
184 while (options[s->optc].opt_fmt
185 || options[s->optc].r_val || options[s->optc].desc)
186 s->optc++;
188 /* Build auxiliary data */
189 s->aux = (struct _aux *) malloc (s->optc * sizeof (struct _aux));
191 for (i = 0; i < s->optc; i++) {
192 const char *p, *pname;
193 const struct optspec_t *opt;
194 struct _aux *aux;
196 opt = s->options + i;
197 aux = s->aux + i;
199 aux->flags = ARG_NONE;
201 if (opt->opt_fmt[0] == '-' && opt->opt_fmt[1] == '-') {
202 aux->flags |= IS_LONG;
203 pname = opt->opt_fmt + 2;
204 s->has_long = 1;
206 else {
207 pname = opt->opt_fmt + 1;
208 s->has_short = 1;
210 aux->printlen = strlen (opt->opt_fmt);
212 aux->namelen = 0;
213 for (p = pname + 1; *p; p++) {
214 /* detect required arg */
215 if (*p == '=' || isspace (*p)
216 || !(aux->flags & IS_LONG)) {
217 if (aux->namelen == 0)
218 aux->namelen = p - pname;
219 aux->flags |= ARG_REQ;
220 aux->flags &= ~ARG_NONE;
222 /* detect optional arg. This overrides required arg. */
223 if (*p == '[') {
224 if (aux->namelen == 0)
225 aux->namelen = p - pname;
226 aux->flags &= ~(ARG_REQ | ARG_NONE);
227 aux->flags |= ARG_OPT;
228 break;
231 if (aux->namelen == 0)
232 aux->namelen = p - pname;
234 return (scanopt_t *) s;
237 #ifndef NO_SCANOPT_USAGE
238 /* these structs are for scanopt_usage(). */
239 struct usg_elem {
240 int idx;
241 struct usg_elem *next;
242 struct usg_elem *alias;
244 typedef struct usg_elem usg_elem;
247 /* Prints a usage message based on contents of optlist.
248 * Parameters:
249 * scanner - The scanner, already initialized with scanopt_init().
250 * fp - The file stream to write to.
251 * usage - Text to be prepended to option list.
252 * Return: Always returns 0 (zero).
253 * The output looks something like this:
255 [indent][option, alias1, alias2...][indent][description line1
256 description line2...]
258 int scanopt_usage (scanner, fp, usage)
259 scanopt_t *scanner;
260 FILE *fp;
261 const char *usage;
263 struct _scanopt_t *s;
264 int i, columns, indent = 2;
265 usg_elem *byr_val = NULL; /* option indices sorted by r_val */
266 usg_elem *store; /* array of preallocated elements. */
267 int store_idx = 0;
268 usg_elem *ue;
269 int maxlen[2];
270 int desccol = 0;
271 int print_run = 0;
273 maxlen[0] = 0;
274 maxlen[1] = 0;
276 s = (struct _scanopt_t *) scanner;
278 if (usage) {
279 fprintf (fp, "%s\n", usage);
281 else {
282 /* Find the basename of argv[0] */
283 const char *p;
285 p = s->argv[0] + strlen (s->argv[0]);
286 while (p != s->argv[0] && *p != '/')
287 --p;
288 if (*p == '/')
289 p++;
291 fprintf (fp, _("Usage: %s [OPTIONS]...\n"), p);
293 fprintf (fp, "\n");
295 /* Sort by r_val and string. Yes, this is O(n*n), but n is small. */
296 store = (usg_elem *) malloc (s->optc * sizeof (usg_elem));
297 for (i = 0; i < s->optc; i++) {
299 /* grab the next preallocate node. */
300 ue = store + store_idx++;
301 ue->idx = i;
302 ue->next = ue->alias = NULL;
304 /* insert into list. */
305 if (!byr_val)
306 byr_val = ue;
307 else {
308 int found_alias = 0;
309 usg_elem **ue_curr, **ptr_if_no_alias = NULL;
311 ue_curr = &byr_val;
312 while (*ue_curr) {
313 if (RVAL (s, (*ue_curr)->idx) ==
314 RVAL (s, ue->idx)) {
315 /* push onto the alias list. */
316 ue_curr = &((*ue_curr)->alias);
317 found_alias = 1;
318 break;
320 if (!ptr_if_no_alias
322 STRCASECMP (NAME (s, (*ue_curr)->idx),
323 NAME (s, ue->idx)) > 0) {
324 ptr_if_no_alias = ue_curr;
326 ue_curr = &((*ue_curr)->next);
328 if (!found_alias && ptr_if_no_alias)
329 ue_curr = ptr_if_no_alias;
330 ue->next = *ue_curr;
331 *ue_curr = ue;
335 #if 0
336 if (1) {
337 printf ("ORIGINAL:\n");
338 for (i = 0; i < s->optc; i++)
339 printf ("%2d: %s\n", i, NAME (s, i));
340 printf ("SORTED:\n");
341 ue = byr_val;
342 while (ue) {
343 usg_elem *ue2;
345 printf ("%2d: %s\n", ue->idx, NAME (s, ue->idx));
346 for (ue2 = ue->alias; ue2; ue2 = ue2->next)
347 printf (" +---> %2d: %s\n", ue2->idx,
348 NAME (s, ue2->idx));
349 ue = ue->next;
352 #endif
354 /* Now build each row of output. */
356 /* first pass calculate how much room we need. */
357 for (ue = byr_val; ue; ue = ue->next) {
358 usg_elem *ap;
359 int len = 0;
360 int nshort = 0, nlong = 0;
363 #define CALC_LEN(i) do {\
364 if(FLAGS(s,i) & IS_LONG) \
365 len += (nlong++||nshort) ? 2+PRINTLEN(s,i) : PRINTLEN(s,i);\
366 else\
367 len += (nshort++||nlong)? 2+PRINTLEN(s,i) : PRINTLEN(s,i);\
368 }while(0)
370 if (!(FLAGS (s, ue->idx) & IS_LONG))
371 CALC_LEN (ue->idx);
373 /* do short aliases first. */
374 for (ap = ue->alias; ap; ap = ap->next) {
375 if (FLAGS (s, ap->idx) & IS_LONG)
376 continue;
377 CALC_LEN (ap->idx);
380 if (FLAGS (s, ue->idx) & IS_LONG)
381 CALC_LEN (ue->idx);
383 /* repeat the above loop, this time for long aliases. */
384 for (ap = ue->alias; ap; ap = ap->next) {
385 if (!(FLAGS (s, ap->idx) & IS_LONG))
386 continue;
387 CALC_LEN (ap->idx);
390 if (len > maxlen[0])
391 maxlen[0] = len;
393 /* It's much easier to calculate length for description column! */
394 len = strlen (DESC (s, ue->idx));
395 if (len > maxlen[1])
396 maxlen[1] = len;
399 /* Determine how much room we have, and how much we will allocate to each col.
400 * Do not address pathological cases. Output will just be ugly. */
401 columns = get_cols () - 1;
402 if (maxlen[0] + maxlen[1] + indent * 2 > columns) {
403 /* col 0 gets whatever it wants. we'll wrap the desc col. */
404 maxlen[1] = columns - (maxlen[0] + indent * 2);
405 if (maxlen[1] < 14) /* 14 is arbitrary lower limit on desc width. */
406 maxlen[1] = INT_MAX;
408 desccol = maxlen[0] + indent * 2;
410 #define PRINT_SPACES(fp,n)\
411 do{\
412 int _n;\
413 _n=(n);\
414 while(_n-- > 0)\
415 fputc(' ',(fp));\
416 }while(0)
419 /* Second pass (same as above loop), this time we print. */
420 /* Sloppy hack: We iterate twice. The first time we print short and long options.
421 The second time we print those lines that have ONLY long options. */
422 while (print_run++ < 2) {
423 for (ue = byr_val; ue; ue = ue->next) {
424 usg_elem *ap;
425 int nwords = 0, nchars = 0, has_short = 0;
427 /* TODO: get has_short schtick to work */
428 has_short = !(FLAGS (s, ue->idx) & IS_LONG);
429 for (ap = ue->alias; ap; ap = ap->next) {
430 if (!(FLAGS (s, ap->idx) & IS_LONG)) {
431 has_short = 1;
432 break;
435 if ((print_run == 1 && !has_short) ||
436 (print_run == 2 && has_short))
437 continue;
439 PRINT_SPACES (fp, indent);
440 nchars += indent;
442 /* Print, adding a ", " between aliases. */
443 #define PRINT_IT(i) do{\
444 if(nwords++)\
445 nchars+=fprintf(fp,", ");\
446 nchars+=fprintf(fp,"%s",s->options[i].opt_fmt);\
447 }while(0)
449 if (!(FLAGS (s, ue->idx) & IS_LONG))
450 PRINT_IT (ue->idx);
452 /* print short aliases first. */
453 for (ap = ue->alias; ap; ap = ap->next) {
454 if (!(FLAGS (s, ap->idx) & IS_LONG))
455 PRINT_IT (ap->idx);
459 if (FLAGS (s, ue->idx) & IS_LONG)
460 PRINT_IT (ue->idx);
462 /* repeat the above loop, this time for long aliases. */
463 for (ap = ue->alias; ap; ap = ap->next) {
464 if (FLAGS (s, ap->idx) & IS_LONG)
465 PRINT_IT (ap->idx);
468 /* pad to desccol */
469 PRINT_SPACES (fp, desccol - nchars);
471 /* Print description, wrapped to maxlen[1] columns. */
472 if (1) {
473 const char *pstart;
475 pstart = DESC (s, ue->idx);
476 while (1) {
477 int n = 0;
478 const char *lastws = NULL, *p;
480 p = pstart;
482 while (*p && n < maxlen[1]
483 && *p != '\n') {
484 if (isspace (*p)
485 || *p == '-') lastws =
487 n++;
488 p++;
491 if (!*p) { /* hit end of desc. done. */
492 fprintf (fp, "%s\n",
493 pstart);
494 break;
496 else if (*p == '\n') { /* print everything up to here then wrap. */
497 fprintf (fp, "%.*s\n", n,
498 pstart);
499 PRINT_SPACES (fp, desccol);
500 pstart = p + 1;
501 continue;
503 else { /* we hit the edge of the screen. wrap at space if possible. */
504 if (lastws) {
505 fprintf (fp,
506 "%.*s\n",
507 lastws -
508 pstart,
509 pstart);
510 pstart =
511 lastws + 1;
513 else {
514 fprintf (fp,
515 "%.*s\n",
517 pstart);
518 pstart = p + 1;
520 PRINT_SPACES (fp, desccol);
521 continue;
526 } /* end while */
527 free (store);
528 return 0;
530 #endif /* no scanopt_usage */
533 static int scanopt_err (s, opt_offset, is_short, err)
534 struct _scanopt_t *s;
535 int opt_offset;
536 int is_short;
537 int err;
539 const char *optname = "";
540 char optchar[2];
541 const optspec_t *opt = NULL;
543 if (opt_offset >= 0)
544 opt = s->options + opt_offset;
546 if (!s->no_err_msg) {
548 if (s->index > 0 && s->index < s->argc) {
549 if (is_short) {
550 optchar[0] =
551 s->argv[s->index][s->subscript];
552 optchar[1] = '\0';
553 optname = optchar;
555 else {
556 optname = s->argv[s->index];
560 fprintf (stderr, "%s: ", s->argv[0]);
561 switch (err) {
562 case SCANOPT_ERR_ARG_NOT_ALLOWED:
563 fprintf (stderr,
565 ("option `%s' doesn't allow an argument\n"),
566 optname);
567 break;
568 case SCANOPT_ERR_ARG_NOT_FOUND:
569 fprintf (stderr,
570 _("option `%s' requires an argument\n"),
571 optname);
572 break;
573 case SCANOPT_ERR_OPT_AMBIGUOUS:
574 fprintf (stderr, _("option `%s' is ambiguous\n"),
575 optname);
576 break;
577 case SCANOPT_ERR_OPT_UNRECOGNIZED:
578 fprintf (stderr, _("Unrecognized option `%s'\n"),
579 optname);
580 break;
581 default:
582 fprintf (stderr, _("Unknown error=(%d)\n"), err);
583 break;
586 return err;
590 /* Internal. Match str against the regex ^--([^=]+)(=(.*))?
591 * return 1 if *looks* like a long option.
592 * 'str' is the only input argument, the rest of the arguments are output only.
593 * optname will point to str + 2
596 static int matchlongopt (str, optname, optlen, arg, arglen)
597 char *str;
598 char **optname;
599 int *optlen;
600 char **arg;
601 int *arglen;
603 char *p;
605 *optname = *arg = (char *) 0;
606 *optlen = *arglen = 0;
608 /* Match regex /--./ */
609 p = str;
610 if (p[0] != '-' || p[1] != '-' || !p[2])
611 return 0;
613 p += 2;
614 *optname = (char *) p;
616 /* find the end of optname */
617 while (*p && *p != '=')
618 ++p;
620 *optlen = p - *optname;
622 if (!*p)
623 /* an option with no '=...' part. */
624 return 1;
627 /* We saw an '=' char. The rest of p is the arg. */
628 p++;
629 *arg = p;
630 while (*p)
631 ++p;
632 *arglen = p - *arg;
634 return 1;
638 /* Internal. Look up long or short option by name.
639 * Long options must match a non-ambiguous prefix, or exact match.
640 * Short options must be exact.
641 * Return boolean true if found and no error.
642 * Error stored in err_code or zero if no error. */
643 static int find_opt (s, lookup_long, optstart, len, err_code, opt_offset)
644 struct _scanopt_t *s;
645 int lookup_long;
646 char *optstart;
647 int len;
648 int *err_code;
649 int *opt_offset;
651 int nmatch = 0, lastr_val = 0, i;
653 *err_code = 0;
654 *opt_offset = -1;
656 if (!optstart)
657 return 0;
659 for (i = 0; i < s->optc; i++) {
660 char *optname;
662 optname =
663 (char *) (s->options[i].opt_fmt +
664 (lookup_long ? 2 : 1));
666 if (lookup_long && (s->aux[i].flags & IS_LONG)) {
667 if (len > s->aux[i].namelen)
668 continue;
670 if (strncmp (optname, optstart, len) == 0) {
671 nmatch++;
672 *opt_offset = i;
674 /* exact match overrides all. */
675 if (len == s->aux[i].namelen) {
676 nmatch = 1;
677 break;
680 /* ambiguity is ok between aliases. */
681 if (lastr_val
682 && lastr_val ==
683 s->options[i].r_val) nmatch--;
684 lastr_val = s->options[i].r_val;
687 else if (!lookup_long && !(s->aux[i].flags & IS_LONG)) {
688 if (optname[0] == optstart[0]) {
689 nmatch++;
690 *opt_offset = i;
695 if (nmatch == 0) {
696 *err_code = SCANOPT_ERR_OPT_UNRECOGNIZED;
697 *opt_offset = -1;
699 else if (nmatch > 1) {
700 *err_code = SCANOPT_ERR_OPT_AMBIGUOUS;
701 *opt_offset = -1;
704 return *err_code ? 0 : 1;
708 int scanopt (svoid, arg, optindex)
709 scanopt_t *svoid;
710 char **arg;
711 int *optindex;
713 char *optname = NULL, *optarg = NULL, *pstart;
714 int namelen = 0, arglen = 0;
715 int errcode = 0, has_next;
716 const optspec_t *optp;
717 struct _scanopt_t *s;
718 struct _aux *auxp;
719 int is_short;
720 int opt_offset = -1;
722 s = (struct _scanopt_t *) svoid;
724 /* Normalize return-parameters. */
725 SAFE_ASSIGN (arg, NULL);
726 SAFE_ASSIGN (optindex, s->index);
728 if (s->index >= s->argc)
729 return 0;
731 /* pstart always points to the start of our current scan. */
732 pstart = s->argv[s->index] + s->subscript;
733 if (!pstart)
734 return 0;
736 if (s->subscript == 0) {
738 /* test for exact match of "--" */
739 if (pstart[0] == '-' && pstart[1] == '-' && !pstart[2]) {
740 SAFE_ASSIGN (optindex, s->index + 1);
741 INC_INDEX (s, 1);
742 return 0;
745 /* Match an opt. */
746 if (matchlongopt
747 (pstart, &optname, &namelen, &optarg, &arglen)) {
749 /* it LOOKS like an opt, but is it one?! */
750 if (!find_opt
751 (s, 1, optname, namelen, &errcode,
752 &opt_offset)) {
753 scanopt_err (s, opt_offset, 0, errcode);
754 return errcode;
756 /* We handle this below. */
757 is_short = 0;
759 /* Check for short opt. */
761 else if (pstart[0] == '-' && pstart[1]) {
762 /* Pass through to below. */
763 is_short = 1;
764 s->subscript++;
765 pstart++;
768 else {
769 /* It's not an option. We're done. */
770 return 0;
774 /* We have to re-check the subscript status because it
775 * may have changed above. */
777 if (s->subscript != 0) {
779 /* we are somewhere in a run of short opts,
780 * e.g., at the 'z' in `tar -xzf` */
782 optname = pstart;
783 namelen = 1;
784 is_short = 1;
786 if (!find_opt
787 (s, 0, pstart, namelen, &errcode, &opt_offset)) {
788 return scanopt_err (s, opt_offset, 1, errcode);
791 optarg = pstart + 1;
792 arglen = 0;
793 while (optarg[arglen])
794 arglen++;
796 if (arglen == 0)
797 optarg = NULL;
800 /* At this point, we have a long or short option matched at opt_offset into
801 * the s->options array (and corresponding aux array).
802 * A trailing argument is in {optarg,arglen}, if any.
805 /* Look ahead in argv[] to see if there is something
806 * that we can use as an argument (if needed). */
807 has_next = s->index + 1 < s->argc
808 && strcmp ("--", s->argv[s->index + 1]) != 0;
810 optp = s->options + opt_offset;
811 auxp = s->aux + opt_offset;
813 /* case: no args allowed */
814 if (auxp->flags & ARG_NONE) {
815 if (optarg) {
816 scanopt_err (s, opt_offset, is_short, errcode =
817 SCANOPT_ERR_ARG_NOT_ALLOWED);
818 INC_INDEX (s, 1);
819 return errcode;
821 INC_INDEX (s, 1);
822 return optp->r_val;
825 /* case: required */
826 if (auxp->flags & ARG_REQ) {
827 if (!optarg && !has_next)
828 return scanopt_err (s, opt_offset, is_short,
829 SCANOPT_ERR_ARG_NOT_FOUND);
831 if (!optarg) {
832 /* Let the next argv element become the argument. */
833 SAFE_ASSIGN (arg, s->argv[s->index + 1]);
834 INC_INDEX (s, 2);
836 else {
837 SAFE_ASSIGN (arg, (char *) optarg);
838 INC_INDEX (s, 1);
840 return optp->r_val;
843 /* case: optional */
844 if (auxp->flags & ARG_OPT) {
845 SAFE_ASSIGN (arg, optarg);
846 INC_INDEX (s, 1);
847 return optp->r_val;
851 /* Should not reach here. */
852 return 0;
856 int scanopt_destroy (svoid)
857 scanopt_t *svoid;
859 struct _scanopt_t *s;
861 s = (struct _scanopt_t *) svoid;
862 if (s) {
863 if (s->aux)
864 free (s->aux);
865 free (s);
867 return 0;
871 /* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */