0
|
1 /* printsw.c - print switches */
|
|
2
|
|
3 #include "../h/mh.h"
|
|
4
|
|
5
|
|
6 void printsw (substr, swp, prefix)
|
|
7 register char *substr,
|
|
8 *prefix;
|
|
9 register struct swit *swp;
|
|
10 {
|
|
11 int len,
|
|
12 optno;
|
|
13 register int i;
|
|
14 register char *cp,
|
|
15 *cp1,
|
|
16 *sp;
|
|
17 char buf[128];
|
|
18
|
|
19 len = strlen (substr);
|
|
20 for (; swp -> sw; swp++) {
|
|
21 if (!*substr || /* null matches all strings */
|
|
22 (ssequal (substr, swp -> sw) && len >= swp -> minchars)) {
|
|
23 optno = 0;
|
|
24 if (sp = (&swp[1]) -> sw) /* next switch */
|
|
25 if (!*substr && sp[0] == 'n' && sp[1] == 'o' &&
|
|
26 strcmp (&sp[2], swp -> sw) == 0 && (
|
|
27 ((&swp[1]) -> minchars == 0 && swp -> minchars == 0) ||
|
|
28 ((&swp[1]) -> minchars == (swp -> minchars) + 2)))
|
|
29 optno++;
|
|
30 if (swp -> minchars > 0) {
|
|
31 cp = buf;
|
|
32 *cp++ = '(';
|
|
33 if (optno) {
|
|
34 (void) strcpy (cp, "[no]");
|
|
35 cp += strlen (cp);
|
|
36 }
|
|
37 for (cp1 = swp -> sw, i = 0; i < swp -> minchars; i++)
|
|
38 *cp++ = *cp1++;
|
|
39 *cp++ = ')';
|
|
40 while (*cp++ = *cp1++);
|
|
41 printf (" %s%s\n", prefix, buf);
|
|
42 }
|
|
43 else
|
|
44 if (swp -> minchars == 0)
|
|
45 printf (optno ? " %s[no]%s\n" : " %s%s\n",
|
|
46 prefix, swp -> sw);
|
|
47 if (optno)
|
|
48 swp++; /* skip -noswitch */
|
|
49 }
|
|
50 }
|
|
51 }
|