Annotation of 43BSD/usr.bin/refer/refer4.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.