8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / refer / refer4.c
blobe8cd5f22ab33b8802e645635ee3f1de6230143dc
1 /*
2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
9 /*
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
17 #include "refer..c"
18 #include <locale.h>
20 #define punctuat(c) (c == '.' || c == '?' || c == '!' || \
21 c == ',' || c == ';' || c == ':')
23 static int gate = 0;
24 static char buff[BUFSIZ];
26 extern void err();
28 char *trimnl(char *);
30 void
31 output(char *s)
33 if (gate)
34 fputs(buff, ftemp);
35 else
36 gate = 1;
37 strcpy(buff, s);
38 if (strlen(buff) > BUFSIZ)
39 err(gettext("one buff too big (%d)!"), BUFSIZ);
42 void
43 append(char *s)
45 char *p;
46 int lch;
48 trimnl(buff);
49 for (p = buff; *p; p++)
51 lch = *--p;
52 if (postpunct && punctuat(lch))
53 *p = NULL;
54 else /* pre-punctuation */
55 switch (lch) {
56 case '.':
57 case '?':
58 case '!':
59 case ',':
60 case ';':
61 case ':':
62 *p++ = lch;
63 *p = NULL;
65 strcat(buff, s);
66 if (postpunct)
67 switch (lch) {
68 case '.':
69 case '?':
70 case '!':
71 case ',':
72 case ';':
73 case ':':
74 for (p = buff; *p; p++)
76 if (*--p == '\n')
77 *p = NULL;
78 *p++ = lch;
79 *p++ = '\n';
80 *p = NULL;
82 if (strlen(buff) > BUFSIZ)
83 err(gettext("output buff too long (%d)"), BUFSIZ);
86 void
87 flout(void)
89 if (gate)
90 fputs(buff, ftemp);
91 gate = 0;
94 char *
95 trimnl(char *ln)
97 char *p = ln;
99 while (*p)
100 p++;
101 p--;
102 if (*p == '\n')
103 *p = 0;
104 return (ln);