[BACK]Return to pexpr.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2018 / io

Annotation of OpenXM_contrib2/asir2018/io/pexpr.c, Revision 1.4

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.
1.4     ! kondoh     47:  * $OpenXM: OpenXM_contrib2/asir2018/io/pexpr.c,v 1.3 2019/10/17 03:03:12 kondoh Exp $
1.1       noro       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:
1.4     ! kondoh    126: #if defined(INTERVAL)
        !           127: #define PRINTBF4ITV printbf4itv
        !           128: #endif
        !           129:
1.1       noro      130: #include "pexpr_body.c"
                    131:
                    132: /* spetial functions for file output */
                    133:
                    134: void output_init() {
                    135:   OUT = stdout;
                    136:   sprintf(DFORMAT,"%%0%dd",DLENGTH);
                    137: }
                    138:
                    139: int mmono(p)
                    140: P p;
                    141: {
                    142:   if ( NUM(p) )
                    143: #if defined(INTERVAL)
                    144:     if ( NID(p) != N_IP && NID(p) != N_IntervalDouble && NID(p) != N_IntervalQuad && NID(p) != N_IntervalBigFloat
                    145:       && compnum(CO,(Num)p,0) < 0 )
                    146: #else
                    147:     if ( compnum(CO,(Num)p,0) < 0 )
                    148: #endif
                    149:       return ( 1 );
                    150:     else
                    151:       return ( 0 );
                    152:   else if ( NEXT(DC(p)) )
                    153:     return ( 0 );
                    154:   else
                    155:     return (mmono(COEF(DC(p))));
                    156: }
                    157:
                    158: void printbf(BF a)
                    159: {
                    160:   int dprec;
                    161:   char fbuf[BUFSIZ];
                    162:   char *s;
                    163:   dprec = (a->body->_mpfr_prec)*0.30103;
                    164:   if ( !dprec ) dprec = 1;
1.4     ! kondoh    165:   sprintf(fbuf,"%%.%dR%c",dprec,(double_output==1)?'f':(double_output==2)?'e':'g');
        !           166:   mpfr_asprintf(&s,fbuf,a->body);
        !           167:   TAIL PUTS(s);
        !           168:   mpfr_free_str(s);
        !           169: }
        !           170:
1.3       kondoh    171: #if defined(INTERVAL)
1.4     ! kondoh    172: void printbf4itv(BF a)
        !           173: {
        !           174:   int dprec;
        !           175:   char fbuf[BUFSIZ];
        !           176:   char *s;
        !           177:   dprec = (a->body->_mpfr_prec)*0.30103;
        !           178:   if ( !dprec ) dprec = 1;
        !           179:   dprec += 1;
1.1       noro      180:   sprintf(fbuf,"%%.%dR%c",dprec,(double_output==1)?'f':(double_output==2)?'e':'g');
                    181:   mpfr_asprintf(&s,fbuf,a->body);
                    182:   TAIL PUTS(s);
                    183:   mpfr_free_str(s);
                    184: }
1.4     ! kondoh    185: #endif
1.1       noro      186:
                    187: void printz(Z n)
                    188: {
1.2       noro      189:   if ( hex_output == 1 ) {
                    190:     TAIL PUTS("0x");
                    191:     mpz_out_str(OUT,16,BDY(n));
                    192:   } else
                    193:     mpz_out_str(OUT,10,BDY(n));
1.1       noro      194: }
                    195:
                    196: void printmpz(mpz_t z)
                    197: {
1.2       noro      198:   if ( hex_output == 1 ) {
                    199:     TAIL PUTS("0x");
                    200:     mpz_out_str(OUT,16,z);
                    201:   } else
                    202:     mpz_out_str(OUT,10,z);
1.1       noro      203: }
                    204:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>