]> diplodocus.org Git - nmh/blob - docs/historical/mh-jun-1982/subs/printsw.c
Create new mh-format function %(ordinal)
[nmh] / docs / historical / mh-jun-1982 / subs / printsw.c
1 #ifdef COMMENT
2 Proprietary Rand Corporation, 1981.
3 Further distribution of this software
4 subject to the terms of the Rand
5 license agreement.
6 #endif
7
8 #include "../mh.h"
9
10 printsw(substr, swp, prefix)
11 char *substr, *prefix;
12 struct swit *swp;
13 {
14 char buf[128];
15 register char *cp, *cp1;
16 register int i;
17 int len;
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 if(swp->minchars > 0) {
24 cp = buf;
25 *cp++ = '(';
26 for(cp1 = swp->sw, i = 0; i < swp->minchars; i++)
27 *cp++ = *cp1++;
28 *cp++ = ')';
29 while(*cp++ = *cp1++);
30 printf(" %s%s\n", prefix, buf);
31 } else if(swp->minchars == 0)
32 printf(" %s%s\n", prefix, swp->sw);
33 }