rfmtexec.c

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 597 行 · 第 1/2 页

C
597
字号
/****************************************************************************
*
*                            Open Watcom Project
*
*    Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
*  ========================================================================
*
*    This file contains Original Code and/or Modifications of Original
*    Code as defined in and that are subject to the Sybase Open Watcom
*    Public License version 1.0 (the 'License'). You may not use this file
*    except in compliance with the License. BY USING THIS FILE YOU AGREE TO
*    ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
*    provided with the Original Code and Modifications, and is also
*    available at www.sybase.com/developer/opensource.
*
*    The Original Code and all software distributed under the License are
*    distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
*    EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
*    ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
*    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
*    NON-INFRINGEMENT. Please see the License for the specific language
*    governing rights and limitations under the License.
*
*  ========================================================================
*
* Description:  Runtime formatted I/O processing routines
*
****************************************************************************/


#include "ftnstd.h"
#include "rundat.h"
#include "errcod.h"
#include "fmtdef.h"
#include "format.h"
#include "iotype.h"

extern  void            SendStr(char PGM *,uint);
extern  void            IOErr(int,...);
extern  void            RTErr(int,...);
extern  void            R_NewRec(void);
extern  void            R_FIStr(void);
extern  void            R_FOStr(void);
extern  void            R_FILog(void);
extern  void            R_FOLog(void);
extern  void            R_FIInt(void);
extern  void            R_FOInt(void);
extern  void            R_FIHex(void);
extern  void            R_FOHex(void);
extern  void            R_ChkType(PTYPE,PTYPE);
extern  void            R_ChkFType(void);
extern  void            R_ChkIType(void);
extern  void            R_ChkRecLen(void);
extern  void            R_FOF(void);
extern  void            R_FOE(int,char);
extern  void            R_FOG(void);
extern  void            R_FIFloat(void);
extern  void            ArrayIOType(void);


static  void   R_FEH( uint dummy1 , char dummy2 ) {
//======================

    ftnfile     *fcb;
    uint        len;
    char PGM    *str;

    fcb = IOCB->fileinfo;
    if( IOCB->flags & IOF_OUTPT ) {
        len = IOCB->fmtptr->fmtstring.fld1;
        if( fcb->col + len > fcb->bufflen ) {
            IOErr( IO_BUFF_LEN );
        }
        str = IOCB->fmtptr->fmtstring.str;
        SendStr( str, len );
    } else {
        RTErr( FM_NOT_INP );
    }
    R_ChkRecLen();
    IOCB->fmtptr = (fmt_desc PGM *)((char PGM *)IOCB->fmtptr + sizeof( fmt4 ) +
                           len * sizeof( char ));
}


static  void    R_FESlash( uint rep_spec, char dummy2 ) {
//==========================================

    for(;;) {
        R_NewRec();
        if( --rep_spec == 0 ) break;
    }
    IOCB->fmtptr = (fmt_desc PGM *)((fmt PGM *)IOCB->fmtptr + 1);
}


static  void    R_FEX( uint dummy1 , char dummy2 ) {
//=======================

    ftnfile     *fcb;

    fcb = IOCB->fileinfo;
    fcb->col += IOCB->fmtptr->fmt4.fld1;
    IOCB->fmtptr = (fmt_desc PGM *)((fmt4 PGM *)IOCB->fmtptr + 1);
}


static  void    R_FEI( uint rep, char dummy2 ) {
//=================================

    for(;;) {
        if( IOCB->typ == PT_NOTYPE ) {
            IOCB->flags |= IOF_FMTDONE;
        }
        if( IOCB->typ == PT_NOTYPE ) break;
        FmtPrepOp();
        R_ChkIType();
        if( IOCB->flags & IOF_OUTPT ) {
            R_FOInt();
            R_ChkRecLen();
        } else {
            R_FIInt();
        }
        FmtIOType();
        if( --rep == 0 ) break;
    }
    IOCB->flags |= IOF_FMTREP;
    IOCB->fmtptr = (fmt_desc PGM *)((fmt2 PGM *)IOCB->fmtptr + 1);
}


static  void    R_FEColon( uint dummy1 , char dummy2 ) {
//===========================

    if( IOCB->typ == PT_NOTYPE ) {
        IOCB->flags |= IOF_FMTDONE;
    }
    IOCB->fmtptr = (fmt_desc PGM *)((fmt PGM *)IOCB->fmtptr + 1);
}


static  void    R_FEA( uint rep , char dummy2) {
//=================================

    for(;;) {
        if( IOCB->typ == PT_NOTYPE ) {
            IOCB->flags |= IOF_FMTDONE;
        }
        if( IOCB->typ == PT_NOTYPE ) break;
        if( IOCB->flags & IOF_OUTPT ) {
            R_FOStr();
            R_ChkRecLen();
        } else {
            R_FIStr();
        }
        FmtIOType();
        if( --rep == 0 ) break;
    }
    IOCB->flags |= IOF_FMTREP;
    IOCB->fmtptr = (fmt_desc PGM *)((fmt4 PGM *)IOCB->fmtptr + 1);
}


static  void    R_FET( uint dummy1 , char dummy2 ) {
//=======================

    ftnfile     *fcb;

    fcb = IOCB->fileinfo;
    fcb->col = IOCB->fmtptr->fmt4.fld1 - sizeof( char );
    IOCB->fmtptr = (fmt_desc PGM *)((fmt4 PGM *)IOCB->fmtptr + 1);
}


static  void    R_FETL( uint dummy1 , char dummy2 ) {
//========================

    ftnfile     *fcb;
    uint        offset;

    fcb = IOCB->fileinfo;
    offset = IOCB->fmtptr->fmt4.fld1;
    if( fcb->col < offset ) {
        fcb->col = 0;
    } else {
        fcb->col -= offset;
    }
    IOCB->fmtptr = (fmt_desc PGM *)((fmt4 PGM *)IOCB->fmtptr + 1);
}


static  void    R_FETR( uint dummy1 , char dummy2 ) {
//========================

    ftnfile     *fcb;

    fcb = IOCB->fileinfo;
    fcb->col += IOCB->fmtptr->fmt4.fld1;
    IOCB->fmtptr = (fmt_desc PGM *)((fmt4 PGM *)IOCB->fmtptr + 1);
}


static  void    R_FES( uint dummy1 , char dummy2 ) {
//=======================

    IOCB->flags &= ~IOF_PLUS;
    IOCB->fmtptr = (fmt_desc PGM *)((fmt PGM *)IOCB->fmtptr + 1);
}


static  void    R_FESP( uint dummy1 , char dummy2 ) {
//========================

    IOCB->flags |= IOF_PLUS;
    IOCB->fmtptr = (fmt_desc PGM *)((fmt PGM *)IOCB->fmtptr + 1);
}


static  void    R_FESS( uint dummy1 , char dummy2 ) {
//========================

    IOCB->flags &= ~IOF_PLUS;
    IOCB->fmtptr = (fmt_desc PGM *)((fmt PGM *)IOCB->fmtptr + 1);
}


static  void    R_FEBN( uint dummy1 , char dummy2 ) {
//========================

    IOCB->fileinfo->blanks = BLANK_NULL;
    IOCB->fmtptr = (fmt_desc PGM *)((fmt PGM *)IOCB->fmtptr + 1);
}


static  void    R_FEBZ( uint dummy1 , char dummy2 ) {
//========================

    IOCB->fileinfo->blanks = BLANK_ZERO;
    IOCB->fmtptr = (fmt_desc PGM *)((fmt PGM *)IOCB->fmtptr + 1);
}


static  void    R_FEL( uint rep, char dummy2 ) {
//=================================

    for(;;) {
        if( IOCB->typ == PT_NOTYPE ) {
            IOCB->flags |= IOF_FMTDONE;
        }
        if( IOCB->typ == PT_NOTYPE ) break;
        FmtPrepOp();
        R_ChkType( PT_LOG_1, PT_LOG_4 );
        if( IOCB->flags & IOF_OUTPT ) {
            R_FOLog();
            R_ChkRecLen();
        } else {
            R_FILog();
        }
        FmtIOType();
        if( --rep == 0 ) break;
    }
    IOCB->flags |= IOF_FMTREP;
    IOCB->fmtptr = (fmt_desc PGM *)((fmt1 PGM *)IOCB->fmtptr + 1);
}


static  void    R_FEF( uint rep, char dummy2 ) {
//=================================

    for(;;) {
        if( IOCB->typ == PT_NOTYPE ) {
            IOCB->flags |= IOF_FMTDONE;
        }
        if( IOCB->typ == PT_NOTYPE ) break;
        FmtPrepOp();
        R_ChkFType();
        if( IOCB->flags & IOF_OUTPT ) {
            R_FOF();
            R_ChkRecLen();
        } else {
            R_FIFloat();
        }
        FmtIOType();
        if( --rep == 0 ) break;
    }
    IOCB->flags |= IOF_FMTREP;
    IOCB->fmtptr = (fmt_desc PGM *)((fmt2 PGM *)IOCB->fmtptr + 1);
}


static  void    R_FED( uint rep, char dummy2 ) {
//=================================

    for(;;) {
        if( IOCB->typ == PT_NOTYPE ) {
            IOCB->flags |= IOF_FMTDONE;
        }
        if( IOCB->typ == PT_NOTYPE ) break;
        FmtPrepOp();

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?