Annotation of 43BSD/usr.bin/f77/src/f77pass1/setfmt.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1980 Regents of the University of California.
        !             3:  * All rights reserved.  The Berkeley software License Agreement
        !             4:  * specifies the terms and conditions for redistribution.
        !             5:  */
        !             6: 
        !             7: #ifndef lint
        !             8: static char sccsid[] = "@(#)setfmt.c   5.1 (Berkeley) 6/7/85";
        !             9: #endif not lint
        !            10: 
        !            11: #include "defs.h"
        !            12: #include "format.h"
        !            13: 
        !            14: #define GLITCH '\2'
        !            15: 
        !            16: extern char *fmtptr, *s_init;
        !            17: extern int fmt_strings;
        !            18: 
        !            19: setfmt(lp)
        !            20: struct Labelblock *lp;
        !            21: {
        !            22: int fmt_len, frmt_str_lab;
        !            23: char *s, *lexline();
        !            24: 
        !            25: s = lexline(&fmt_len);
        !            26: preven(ALILONG);
        !            27: prlabel(asmfile, lp->labelno);
        !            28: if( pars_f(s) != 0) {
        !            29:        err_fmt(fmt_len);
        !            30: } else {
        !            31:        fprintf( asmfile, ".word %d\n", FMT_COMP ); /* precompiled format */
        !            32:        fprintf( asmfile, ".word %d\n", pc );
        !            33:        frmt_str_lab = newlabel();      /* to mark loc of format string */
        !            34:        prcona( asmfile, frmt_str_lab );
        !            35:        putshrts( syl, sizeof(struct syl)/SZSHORT*pc );
        !            36: }
        !            37: if( fmt_strings ) pruse( asmfile, USEINIT) ;
        !            38: prlabel(asmfile, frmt_str_lab );
        !            39: putstr(asmfile, s, fmt_len);
        !            40: if( fmt_strings ) pruse( asmfile, USECONST) ;
        !            41: flline();
        !            42: }
        !            43: 
        !            44: LOCAL
        !            45: putshrts( words, count )
        !            46: short *words;
        !            47: {
        !            48:     while ( count-- > 0 )
        !            49:        fprintf( asmfile, ".word %d\n", *words++ );
        !            50: }
        !            51: 
        !            52: static char *fmt_seg_ptr;
        !            53: 
        !            54: LOCAL
        !            55: err_fmt(fmt_len)
        !            56: {
        !            57:        int i;
        !            58:        char *ep, *end_ptr = s_init+fmt_len;
        !            59:        char fmt_seg[50];
        !            60: 
        !            61:        fmt_seg_ptr = fmt_seg;
        !            62:        i = fmtptr - s_init;
        !            63:        ep = fmtptr - (i<25?i:25);
        !            64:        i = i + 5;
        !            65:        while(i && *ep && ep<end_ptr)
        !            66:        {
        !            67:                if(ep==fmtptr) save_char('|',fmt_seg);
        !            68:                save_char(*ep);
        !            69:                ep++; i--;
        !            70:        }
        !            71:        *fmt_seg_ptr++ = '\0';
        !            72:        errstr("Error in format:  %s", fmt_seg);
        !            73: }
        !            74: 
        !            75: LOCAL
        !            76: save_char(c)
        !            77: int    c;
        !            78: {
        !            79:        c &= 0177;
        !            80:        if( c == GLITCH ) {
        !            81:                c = '"';
        !            82:        } else if (c < ' ' || c == 0177) {
        !            83:                *fmt_seg_ptr++ ='^';
        !            84:                c ^= 0100;
        !            85:        } 
        !            86:        *fmt_seg_ptr++ = c;
        !            87: }

unix.superglobalmegacorp.com

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