1 /*- 2 * %sccs.include.proprietary.c% 3 */ 4 5 #ifndef lint 6 static char sccsid[] = "@(#)refer4.c 4.2 (Berkeley) 04/18/91"; 7 #endif /* not lint */ 8 9 #include "refer..c" 10 #define punctuat(c) (c=='.' || c=='?' || c=='!' || c==',' || c==';' || c==':') 11 12 static gate = 0; 13 static char buff[BUFSIZ]; 14 15 output(s) 16 char *s; 17 { 18 if (gate) 19 fputs(buff,ftemp); 20 else 21 gate = 1; 22 strcpy(buff, s); 23 if (strlen(buff) > BUFSIZ) 24 err("one buff too big (%d)!", BUFSIZ); 25 } 26 27 append(s) 28 char *s; 29 { 30 char *p; 31 int lch; 32 33 trimnl(buff); 34 for (p = buff; *p; p++) 35 ; 36 lch = *--p; 37 if (postpunct && punctuat(lch)) 38 *p = NULL; 39 else /* pre-punctuation */ 40 switch (lch) { 41 case '.': 42 case '?': 43 case '!': 44 case ',': 45 case ';': 46 case ':': 47 *p++ = lch; 48 *p = NULL; 49 } 50 strcat(buff, s); 51 if (postpunct) 52 switch(lch) { 53 case '.': 54 case '?': 55 case '!': 56 case ',': 57 case ';': 58 case ':': 59 for(p = buff; *p; p++) 60 ; 61 if (*--p == '\n') 62 *p = NULL; 63 *p++ = lch; 64 *p++ = '\n'; 65 *p = NULL; 66 } 67 if (strlen(buff) > BUFSIZ) 68 err("output buff too long (%d)", BUFSIZ); 69 } 70 71 flout() 72 { 73 if (gate) 74 fputs(buff,ftemp); 75 gate = 0; 76 } 77 78 char * 79 trimnl(ln) 80 char *ln; 81 { 82 register char *p = ln; 83 84 while (*p) 85 p++; 86 p--; 87 if (*p == '\n') 88 *p = 0; 89 return(ln); 90 } 91