[BACK]Return to asir_sm.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / parse

Diff for /OpenXM_contrib2/asir2000/parse/asir_sm.c between version 1.1.1.1 and 1.9

version 1.1.1.1, 1999/12/03 07:39:11 version 1.9, 2018/03/29 01:32:54
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/asir99/parse/asir_sm.c,v 1.1.1.1 1999/11/10 08:12:34 noro Exp $ */  /*
    * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
    * All rights reserved.
    *
    * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
    * non-exclusive and royalty-free license to use, copy, modify and
    * redistribute, solely for non-commercial and non-profit purposes, the
    * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
    * conditions of this Agreement. For the avoidance of doubt, you acquire
    * only a limited right to use the SOFTWARE hereunder, and FLL or any
    * third party developer retains all rights, including but not limited to
    * copyrights, in and to the SOFTWARE.
    *
    * (1) FLL does not grant you a license in any way for commercial
    * purposes. You may use the SOFTWARE only for non-commercial and
    * non-profit purposes only, such as academic, research and internal
    * business use.
    * (2) The SOFTWARE is protected by the Copyright Law of Japan and
    * international copyright treaties. If you make copies of the SOFTWARE,
    * with or without modification, as permitted hereunder, you shall affix
    * to all such copies of the SOFTWARE the above copyright notice.
    * (3) An explicit reference to this SOFTWARE and its copyright owner
    * shall be made on your publication or presentation in any form of the
    * results obtained by use of the SOFTWARE.
    * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
    * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
    * for such modification or the source code of the modified part of the
    * SOFTWARE.
    *
    * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
    * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
    * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
    * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
    * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
    * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
    * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
    * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
    * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
    * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
    * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
    * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
    * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
    * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
    * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
    * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
    * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
    *
    * $OpenXM: OpenXM_contrib2/asir2000/parse/asir_sm.c,v 1.8 2012/12/17 07:20:45 noro Exp $
   */
 #include "ca.h"  #include "ca.h"
 #include "parse.h"  #include "parse.h"
 #if defined(THINK_C)  #if defined(THINK_C)
 #include <console.h>  #include <console.h>
 #endif  #endif
   
 #if PARI  #if defined(PARI)
 #include "genpari.h"  #include "genpari.h"
   #  if !(PARI_VERSION_CODE > 131588)
 extern jmp_buf environnement;  extern jmp_buf environnement;
   #  endif
 #endif  #endif
   
 extern jmp_buf env;  extern jmp_buf env;
 extern int *StackBottom;  
 extern int ox_do_copy, ox_do_count, ox_count_length;  extern int ox_do_copy, ox_do_count, ox_count_length;
 extern char *ox_copy_bptr;  extern char *ox_copy_bptr;
   
Line 23  int Asir_DebugStackPtr;
Line 71  int Asir_DebugStackPtr;
   
 Asir_Start()  Asir_Start()
 {  {
         int tmp;    int tmp;
         FILE *ifp;    FILE *ifp;
         char ifname[BUFSIZ];    char ifname[BUFSIZ];
         extern int GC_dont_gc;    extern int GC_dont_gc;
         extern int read_exec_file;    extern int read_exec_file;
         extern int do_asirrc;    extern int do_asirrc;
         char *getenv();    char *getenv();
         static ox_asir_initialized = 0;    static ox_asir_initialized = 0;
   
         asir_save_handler();    asir_save_handler();
         if ( ox_asir_initialized )    if ( ox_asir_initialized )
                 return;      return;
         ox_asir_initialized = 1;    GC_init();
         ox_do_copy = 1;    ox_asir_initialized = 1;
     ox_do_copy = 1;
 #if defined(THINK_C)  #if defined(THINK_C)
         param_init();    param_init();
 #endif  #endif
         StackBottom = &tmp + 1; /* XXX */    rtime_init();
         rtime_init();    env_init();
         env_init();    endian_init();
         endian_init();  
 #if !defined(TOWNS) && !defined(THINK_C)  #if !defined(TOWNS) && !defined(THINK_C)
 /*      check_key(); */  /*  check_key(); */
 #endif  #endif
 #if defined(TOWNS) && !defined(GO32) && !defined(__WIN32__)  #if defined(TOWNS) && !defined(GO32) && !defined(__WIN32__)
         disable_ctrl_c();    disable_ctrl_c();
 #endif  #endif
         GC_init();  /*  process_args(argc,argv); */
 /*      process_args(argc,argv); */  
 #if 0  #if 0
         copyright();    copyright();
 #endif  #endif
         output_init();    output_init();
         arf_init();    arf_init();
         nglob_init();    nglob_init();
         glob_init();    glob_init();
         sig_init();    sig_init();
         tty_init();    tty_init();
         debug_init();    debug_init();
         pf_init();    pf_init();
         sysf_init();    sysf_init();
         parif_init();    parif_init();
 #if defined(UINIT)  #if defined(UINIT)
         reg_sysf();    reg_sysf();
 #endif  #endif
 #if defined(THINK_C) || defined(TOWNS)  #if defined(THINK_C) || defined(TOWNS)
         sprintf(ifname,"asirrc");    sprintf(ifname,"asirrc");
 #else  #else
         sprintf(ifname,"%s/.asirrc",getenv("HOME"));    sprintf(ifname,"%s/.asirrc",getenv("HOME"));
 #endif  #endif
         asir_set_handler();    asir_set_handler();
         if ( do_asirrc && (ifp = fopen(ifname,"r")) ) {    if ( do_asirrc && (ifp = fopen(ifname,"r")) ) {
                 input_init(ifp,ifname);      input_init(ifp,ifname);
                 if ( !setjmp(env) ) {      if ( !setjmp(env) ) {
                         read_exec_file = 1;        read_exec_file = 1;
                         read_eval_loop();        read_eval_loop();
                 }      }
                 fclose(ifp);      fclose(ifp);
         }    }
         asir_reset_handler();    asir_reset_handler();
         input_init(0,"string");    input_init(0,"string");
         Asir_OperandStackPtr = Asir_DebugStackPtr = -1;    Asir_OperandStackPtr = Asir_DebugStackPtr = -1;
 }  }
   
 char *Asir_PopBinary();  char *Asir_PopBinary();
Line 97  extern int ox_do_copy;
Line 144  extern int ox_do_copy;
 int Asir_ExecuteString(s)  int Asir_ExecuteString(s)
 char *s;  char *s;
 {  {
         SNODE snode;    SNODE snode;
         pointer val;    pointer val;
 #if PARI  #if defined(PARI)
         static long tloc,listloc;    static long tloc,listloc;
         extern long avloc;    extern long avloc;
   
         Asir_Start();    Asir_Start();
         asir_set_handler();    asir_set_handler();
         avloc = avma; tloc = tglobal; listloc = marklist();    avloc = avma; tloc = tglobal; listloc = marklist();
         if ( setjmp(environnement) ) {  #  if !(PARI_VERSION_CODE > 131588)
                 avma = avloc; tglobal = tloc; recover(listloc);    if ( setjmp(environnement) ) {
                 resetenv("");      avma = avloc; tglobal = tloc; recover(listloc);
         }      resetenv("");
     }
   #  endif
 #endif  #endif
         if ( setjmp(env) ) {    if ( setjmp(env) ) {
                 asir_reset_handler();      asir_reset_handler();
                 return -1;      return -1;
         }    }
         parse_strp = s;    parse_strp = s;
         if ( mainparse(&snode) ) {    if ( mainparse(&snode) ) {
                 asir_reset_handler();      asir_reset_handler();
                 return -1;      return -1;
         }    }
         val = evalstat(snode);    val = evalstat(snode);
         if ( NEXT(asir_infile) ) {    if ( NEXT(asir_infile) ) {
                 while ( NEXT(asir_infile) ) {      while ( NEXT(asir_infile) ) {
                         if ( mainparse(&snode) ) {        if ( mainparse(&snode) ) {
                                 asir_push_obj(val);          asir_push_obj(val);
                                 asir_reset_handler();          asir_reset_handler();
                                 return -1;          return -1;
                         }        }
                         nextbp = 0;        nextbp = 0;
                         val = evalstat(snode);        val = evalstat(snode);
                 }      }
         }    }
         asir_push_obj(val);    asir_push_obj(val);
         asir_reset_handler();    asir_reset_handler();
         return 0;    return 0;
 }  }
   
 char *Asir_PopString()  char *Asir_PopString()
 {  {
         Obj val;    Obj val;
         char *buf,*obuf;    char *buf,*obuf;
         int l;    int l;
   
         Asir_Start();    Asir_Start();
         val = asir_pop_obj();    val = asir_pop_obj();
         if ( !val )    if ( !val )
                 return 0;      return 0;
         else {    else {
                 l = estimate_length(CO,val);      l = estimate_length(CO,val);
                 buf = (char *)ALLOCA(l+1);      buf = (char *)ALLOCA(l+1);
                 soutput_init(buf);      soutput_init(buf);
                 sprintexpr(CO,val);      sprintexpr(CO,val);
                 l = strlen(buf);      l = strlen(buf);
                 obuf = (char *)GC_malloc(l+1);      obuf = (char *)MALLOC(l+1);
                 strcpy(obuf,buf);      strcpy(obuf,buf);
                 return obuf;      return obuf;
         }    }
 }  }
   
 int Asir_Set(name)  int Asir_Set(name)
 char *name;  char *name;
 {  {
         int l,n;    int l,n;
         char *dummy = "=0;";    char *dummy = "=0;";
         SNODE snode;    SNODE snode;
   
         Asir_Start();    Asir_Start();
         l = strlen(name);    l = strlen(name);
         n = l+strlen(dummy)+1;    n = l+strlen(dummy)+1;
         parse_strp = (char *)ALLOCA(n);    parse_strp = (char *)ALLOCA(n);
         sprintf(parse_strp,"%s%s",name,dummy);    sprintf(parse_strp,"%s%s",name,dummy);
         if ( mainparse(&snode) )    if ( mainparse(&snode) )
                 return -1;      return -1;
         FA1((FNODE)FA0(snode)) = (pointer)mkfnode(1,I_FORMULA,asir_pop_obj());    FA1((FNODE)FA0(snode)) = (pointer)mkfnode(1,I_FORMULA,asir_pop_obj());
         evalstat(snode);    evalstat(snode);
         return 0;    return 0;
 }  }
   
 int Asir_PushBinary(size,data)  int Asir_PushBinary(size,data)
 int size;  int size;
 char *data;  char *data;
 {  {
         Obj val;    Obj val;
   
         Asir_Start();    Asir_Start();
         ox_copy_bptr = data;    ox_copy_bptr = data;
         loadvl(0);    loadvl(0);
         loadobj(0,&val);    loadobj(0,&val);
         asir_push_obj(val);    asir_push_obj(val);
         ox_copy_bptr = 0;    ox_copy_bptr = 0;
 }  }
   
 char *Asir_PopBinary(size)  char *Asir_PopBinary(size)
 int *size;  int *size;
 {  {
         Obj val;    Obj val;
         char *buf;    char *buf;
         VL vl,t;    VL vl,t;
   
         Asir_Start();    Asir_Start();
         val = asir_pop_obj();    val = asir_pop_obj();
         get_vars(val,&vl);    get_vars(val,&vl);
         for ( t = vl; t; t = NEXT(t) )    for ( t = vl; t; t = NEXT(t) )
                 if ( t->v->attr == (pointer)V_UC || t->v->attr == (pointer)V_PF )      if ( t->v->attr == (pointer)V_UC || t->v->attr == (pointer)V_PF )
                         error("bsave : not implemented");        error("bsave : not implemented");
         ox_count_length = 0; ox_do_count = 1;    ox_count_length = 0; ox_do_count = 1;
         savevl(0,vl);    savevl(0,vl);
         saveobj(0,val);    saveobj(0,val);
         *size = ox_count_length;    *size = ox_count_length;
         ox_count_length = 0; ox_do_count = 0;    ox_count_length = 0; ox_do_count = 0;
         ox_copy_bptr = buf = (char *)GC_malloc(*size);    ox_copy_bptr = buf = (char *)MALLOC(*size);
         savevl(0,vl);    savevl(0,vl);
         saveobj(0,val);    saveobj(0,val);
         ox_copy_bptr = 0;    ox_copy_bptr = 0;
         return buf;    return buf;
 }  }
   
 asir_push_obj(obj)  asir_push_obj(obj)
 Obj obj;  Obj obj;
 {  {
         Asir_OperandStack[++Asir_OperandStackPtr] = obj;    Asir_OperandStack[++Asir_OperandStackPtr] = obj;
 }  }
   
 Obj asir_pop_obj() {  Obj asir_pop_obj() {
         if ( Asir_OperandStackPtr < 0 )    if ( Asir_OperandStackPtr < 0 )
                 return 0;      return 0;
         else    else
                 return Asir_OperandStack[Asir_OperandStackPtr--];      return Asir_OperandStack[Asir_OperandStackPtr--];
 }  }

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.9

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