Documentation fixes.
[mdsms.git] / manfmt.c
1 #include "config.h"
2 #ifndef lint
3 static char rcsid[] ATTR_UNUSED = "$Id$";
4 #endif
5
6 /*
7  * $Log$
8  * Revision 1.1.1.1  1999/05/26 13:06:26  short
9  * First alpha release.
10  *
11  */
12
13 #include <stdio.h>
14 #include <string.h>
15 #include <stdlib.h>
16 #include <limits.h>
17
18 static char buf[LINE_MAX];
19
20 int main(void)
21 {
22 char *s,*s2,*d;
23 char f;
24
25         while (fgets(buf,sizeof(buf),stdin)) {
26                 if (*buf=='#') continue;
27                 for (s=buf;*s==' ';s++);
28                 if (*s=='\n' || !*s) continue;
29                 f=0;
30                 for (d=s=buf;*s;s++) {
31                         if (*s=='\t') {
32                                 if ((f=!f)) {
33 /*fprintf(stderr,"DURING TURN-ON:%s",s);*/
34                                         if (s[1]=='"') s++;
35                                         }
36                                 else {
37 /*fprintf(stderr,"DURING TURN-OFF:%s",s);*/
38                                         while (d>buf && (d[-1]=='"' || d[-1]==' ')) d--;
39                                         }
40                                 continue;
41                                 }
42                         s2=s;
43                         if (*s=='~' ) *s='"';
44                         else if (f && s[0]=='"' && s[1]==' ') {
45                                 while (*++s==' ');
46                                 if (*s=='"') continue;
47                                 s=s2;
48                                 }
49                         *d++=*s;
50                         }
51                 *d='\0';
52                 fputs(buf,stdout);
53                 }
54         return(EXIT_SUCCESS);
55 }