Annotation of OpenXM_contrib2/asir2018/io/pexpr.c, Revision 1.1
1.1 ! noro 1: /*
! 2: * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
! 3: * All rights reserved.
! 4: *
! 5: * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
! 6: * non-exclusive and royalty-free license to use, copy, modify and
! 7: * redistribute, solely for non-commercial and non-profit purposes, the
! 8: * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
! 9: * conditions of this Agreement. For the avoidance of doubt, you acquire
! 10: * only a limited right to use the SOFTWARE hereunder, and FLL or any
! 11: * third party developer retains all rights, including but not limited to
! 12: * copyrights, in and to the SOFTWARE.
! 13: *
! 14: * (1) FLL does not grant you a license in any way for commercial
! 15: * purposes. You may use the SOFTWARE only for non-commercial and
! 16: * non-profit purposes only, such as academic, research and internal
! 17: * business use.
! 18: * (2) The SOFTWARE is protected by the Copyright Law of Japan and
! 19: * international copyright treaties. If you make copies of the SOFTWARE,
! 20: * with or without modification, as permitted hereunder, you shall affix
! 21: * to all such copies of the SOFTWARE the above copyright notice.
! 22: * (3) An explicit reference to this SOFTWARE and its copyright owner
! 23: * shall be made on your publication or presentation in any form of the
! 24: * results obtained by use of the SOFTWARE.
! 25: * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
! 26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
! 27: * for such modification or the source code of the modified part of the
! 28: * SOFTWARE.
! 29: *
! 30: * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
! 31: * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
! 32: * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
! 33: * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
! 34: * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
! 35: * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
! 36: * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
! 37: * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
! 38: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
! 39: * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
! 40: * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
! 41: * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
! 42: * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
! 43: * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
! 44: * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
! 45: * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
! 46: * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
! 47: * $OpenXM$
! 48: */
! 49: #include "ca.h"
! 50: #include "al.h"
! 51: #include "parse.h"
! 52: #include "comp.h"
! 53: #include "base.h"
! 54:
! 55: #ifndef FPRINT
! 56: #define FPRINT
! 57: #endif
! 58:
! 59: extern int outputstyle;
! 60:
! 61: FILE *asir_out;
! 62: #define OUT asir_out
! 63: char DFORMAT[BUFSIZ];
! 64: int hex_output;
! 65: int fortran_output;
! 66: int double_output;
! 67: int real_digit;
! 68: int real_binary;
! 69: int print_quote;
! 70: int hideargs;
! 71: extern FUNC user_print_function;
! 72: #if 0
! 73: int printmode = PRINTF_E;
! 74: #else
! 75: int printmode = PRINTF_G;
! 76: #endif
! 77:
! 78: #define DATA_BEGIN 2
! 79: #define DATA_END 5
! 80:
! 81: #define TAIL
! 82: #define PUTS(s) fputs(s,OUT)
! 83: #define PRINTF fprintf
! 84: #define PRINTZ printz
! 85: #define PRINTMPZ printmpz
! 86: #define PRINTBF printbf
! 87: #define PRINTCPLX printcplx
! 88: #define PRINTLM printlm
! 89: #define PRINTUP2 printup2
! 90: #define PRINTV printv
! 91: #define PRINTEXPR printexpr
! 92: #define PRINTNUM printnum
! 93: #define PRINTP asir_printp
! 94: #define PRINTR printr
! 95: #define PRINTLIST printlist
! 96: #define PRINTVECT printvect
! 97: #define PRINTMAT printmat
! 98: #define PRINTSTR printstr
! 99: #define PRINTCOMP printcomp
! 100: #define PRINTDP printdp
! 101: #define PRINTDPM printdpm
! 102: #define PRINTUI printui
! 103: #define PRINTGF2MAT printgf2mat
! 104: #define PRINTGFMMAT printgfmmat
! 105: #define PRINTBYTEARRAY printbytearray
! 106: #define PRINTQUOTE printquote
! 107: #define PRINTQUOTEARG printquotearg
! 108: #define PRINTNBP printnbp
! 109: #define PRINTERR printerr
! 110: #define PRINTLF printlf
! 111: #define PRINTLOP printlop
! 112: #define PRINTFOP printfop
! 113: #define PRINTEOP printeop
! 114: #define PRINTQOP printqop
! 115: #define PRINTUP printup
! 116: #define PRINTUM printum
! 117: #define PRINTSF printsf
! 118: #define PRINTSYMBOL printsymbol
! 119: #define PRINTRANGE printrange
! 120: #define PRINTTB printtb
! 121: #define PRINTDPV printdpv
! 122: #define PRINTFNODE printfnode
! 123: #define PRINTFNODENODE printfnodenode
! 124: #define PRINTFARGS printfargs
! 125:
! 126: #include "pexpr_body.c"
! 127:
! 128: /* spetial functions for file output */
! 129:
! 130: void output_init() {
! 131: OUT = stdout;
! 132: sprintf(DFORMAT,"%%0%dd",DLENGTH);
! 133: }
! 134:
! 135: int mmono(p)
! 136: P p;
! 137: {
! 138: if ( NUM(p) )
! 139: #if defined(INTERVAL)
! 140: if ( NID(p) != N_IP && NID(p) != N_IntervalDouble && NID(p) != N_IntervalQuad && NID(p) != N_IntervalBigFloat
! 141: && compnum(CO,(Num)p,0) < 0 )
! 142: #else
! 143: if ( compnum(CO,(Num)p,0) < 0 )
! 144: #endif
! 145: return ( 1 );
! 146: else
! 147: return ( 0 );
! 148: else if ( NEXT(DC(p)) )
! 149: return ( 0 );
! 150: else
! 151: return (mmono(COEF(DC(p))));
! 152: }
! 153:
! 154: void printbf(BF a)
! 155: {
! 156: int dprec;
! 157: char fbuf[BUFSIZ];
! 158: char *s;
! 159: dprec = (a->body->_mpfr_prec)*0.30103;
! 160: if ( !dprec ) dprec = 1;
! 161: sprintf(fbuf,"%%.%dR%c",dprec,(double_output==1)?'f':(double_output==2)?'e':'g');
! 162: mpfr_asprintf(&s,fbuf,a->body);
! 163: TAIL PUTS(s);
! 164: mpfr_free_str(s);
! 165: }
! 166:
! 167: void printz(Z n)
! 168: {
! 169: mpz_out_str(OUT,10,BDY(n));
! 170: }
! 171:
! 172: void printmpz(mpz_t z)
! 173: {
! 174: mpz_out_str(OUT,10,z);
! 175: }
! 176:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>