1*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 3*7c478bd9Sstevel@tonic-gate 4*7c478bd9Sstevel@tonic-gate 5*7c478bd9Sstevel@tonic-gate /* 6*7c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California. 7*7c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 8*7c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 9*7c478bd9Sstevel@tonic-gate */ 10*7c478bd9Sstevel@tonic-gate 11*7c478bd9Sstevel@tonic-gate /* 12*7c478bd9Sstevel@tonic-gate * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. 13*7c478bd9Sstevel@tonic-gate * All Rights Reserved. 14*7c478bd9Sstevel@tonic-gate */ 15*7c478bd9Sstevel@tonic-gate 16*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 17*7c478bd9Sstevel@tonic-gate 18*7c478bd9Sstevel@tonic-gate #include "refer..c" 19*7c478bd9Sstevel@tonic-gate #include <locale.h> 20*7c478bd9Sstevel@tonic-gate 21*7c478bd9Sstevel@tonic-gate #define punctuat(c) (c=='.' || c=='?' || c=='!' || c==',' || c==';' || c==':') 22*7c478bd9Sstevel@tonic-gate 23*7c478bd9Sstevel@tonic-gate static gate = 0; 24*7c478bd9Sstevel@tonic-gate static char buff[BUFSIZ]; 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate output(s) 27*7c478bd9Sstevel@tonic-gate char *s; 28*7c478bd9Sstevel@tonic-gate { 29*7c478bd9Sstevel@tonic-gate if (gate) 30*7c478bd9Sstevel@tonic-gate fputs(buff,ftemp); 31*7c478bd9Sstevel@tonic-gate else 32*7c478bd9Sstevel@tonic-gate gate = 1; 33*7c478bd9Sstevel@tonic-gate strcpy(buff, s); 34*7c478bd9Sstevel@tonic-gate if (strlen(buff) > BUFSIZ) 35*7c478bd9Sstevel@tonic-gate err(gettext("one buff too big (%d)!"), BUFSIZ); 36*7c478bd9Sstevel@tonic-gate } 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate append(s) 39*7c478bd9Sstevel@tonic-gate char *s; 40*7c478bd9Sstevel@tonic-gate { 41*7c478bd9Sstevel@tonic-gate char *p; 42*7c478bd9Sstevel@tonic-gate int lch; 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate trimnl(buff); 45*7c478bd9Sstevel@tonic-gate for (p = buff; *p; p++) 46*7c478bd9Sstevel@tonic-gate ; 47*7c478bd9Sstevel@tonic-gate lch = *--p; 48*7c478bd9Sstevel@tonic-gate if (postpunct && punctuat(lch)) 49*7c478bd9Sstevel@tonic-gate *p = NULL; 50*7c478bd9Sstevel@tonic-gate else /* pre-punctuation */ 51*7c478bd9Sstevel@tonic-gate switch (lch) { 52*7c478bd9Sstevel@tonic-gate case '.': 53*7c478bd9Sstevel@tonic-gate case '?': 54*7c478bd9Sstevel@tonic-gate case '!': 55*7c478bd9Sstevel@tonic-gate case ',': 56*7c478bd9Sstevel@tonic-gate case ';': 57*7c478bd9Sstevel@tonic-gate case ':': 58*7c478bd9Sstevel@tonic-gate *p++ = lch; 59*7c478bd9Sstevel@tonic-gate *p = NULL; 60*7c478bd9Sstevel@tonic-gate } 61*7c478bd9Sstevel@tonic-gate strcat(buff, s); 62*7c478bd9Sstevel@tonic-gate if (postpunct) 63*7c478bd9Sstevel@tonic-gate switch(lch) { 64*7c478bd9Sstevel@tonic-gate case '.': 65*7c478bd9Sstevel@tonic-gate case '?': 66*7c478bd9Sstevel@tonic-gate case '!': 67*7c478bd9Sstevel@tonic-gate case ',': 68*7c478bd9Sstevel@tonic-gate case ';': 69*7c478bd9Sstevel@tonic-gate case ':': 70*7c478bd9Sstevel@tonic-gate for(p = buff; *p; p++) 71*7c478bd9Sstevel@tonic-gate ; 72*7c478bd9Sstevel@tonic-gate if (*--p == '\n') 73*7c478bd9Sstevel@tonic-gate *p = NULL; 74*7c478bd9Sstevel@tonic-gate *p++ = lch; 75*7c478bd9Sstevel@tonic-gate *p++ = '\n'; 76*7c478bd9Sstevel@tonic-gate *p = NULL; 77*7c478bd9Sstevel@tonic-gate } 78*7c478bd9Sstevel@tonic-gate if (strlen(buff) > BUFSIZ) 79*7c478bd9Sstevel@tonic-gate err(gettext("output buff too long (%d)"), BUFSIZ); 80*7c478bd9Sstevel@tonic-gate } 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate flout() 83*7c478bd9Sstevel@tonic-gate { 84*7c478bd9Sstevel@tonic-gate if (gate) 85*7c478bd9Sstevel@tonic-gate fputs(buff,ftemp); 86*7c478bd9Sstevel@tonic-gate gate = 0; 87*7c478bd9Sstevel@tonic-gate } 88*7c478bd9Sstevel@tonic-gate 89*7c478bd9Sstevel@tonic-gate char * 90*7c478bd9Sstevel@tonic-gate trimnl(ln) 91*7c478bd9Sstevel@tonic-gate char *ln; 92*7c478bd9Sstevel@tonic-gate { 93*7c478bd9Sstevel@tonic-gate register char *p = ln; 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate while (*p) 96*7c478bd9Sstevel@tonic-gate p++; 97*7c478bd9Sstevel@tonic-gate p--; 98*7c478bd9Sstevel@tonic-gate if (*p == '\n') 99*7c478bd9Sstevel@tonic-gate *p = 0; 100*7c478bd9Sstevel@tonic-gate return(ln); 101*7c478bd9Sstevel@tonic-gate } 102