Annotation of OpenXM_contrib2/asir2000/builtin/strobj.c, Revision 1.1
1.1 ! noro 1: /* $OpenXM: OpenXM/src/asir99/builtin/strobj.c,v 1.1.1.1 1999/11/10 08:12:26 noro Exp $ */
! 2: #include "ca.h"
! 3: #include "parse.h"
! 4: #include "ctype.h"
! 5: #if PARI
! 6: #include "genpari.h"
! 7: extern jmp_buf environnement;
! 8: #endif
! 9: extern char *parse_strp;
! 10:
! 11: void Prtostr(), Pstrtov(), Peval_str();
! 12:
! 13: struct ftab str_tab[] = {
! 14: {"rtostr",Prtostr,1},
! 15: {"strtov",Pstrtov,1},
! 16: {"eval_str",Peval_str,1},
! 17: {0,0,0},
! 18: };
! 19:
! 20: void Peval_str(arg,rp)
! 21: NODE arg;
! 22: Obj *rp;
! 23: {
! 24: FNODE fnode;
! 25: char *cmd;
! 26: #if PARI
! 27: recover(0);
! 28: if ( setjmp(environnement) ) {
! 29: avma = top; recover(1);
! 30: resetenv("");
! 31: }
! 32: #endif
! 33: cmd = BDY((STRING)ARG0(arg));
! 34: exprparse(0,cmd,&fnode);
! 35: *rp = eval(fnode);
! 36: }
! 37:
! 38: void Prtostr(arg,rp)
! 39: NODE arg;
! 40: STRING *rp;
! 41: {
! 42: char *b;
! 43: int len;
! 44:
! 45: len = countobj(ARG0(arg));
! 46: b = (char *)MALLOC(len+1);
! 47: soutput_init(b);
! 48: sprintexpr(CO,ARG0(arg));
! 49: MKSTR(*rp,b);
! 50: }
! 51:
! 52: void Pstrtov(arg,rp)
! 53: NODE arg;
! 54: P *rp;
! 55: {
! 56: char *p,*t;
! 57:
! 58: p = BDY((STRING)ARG0(arg));
! 59: #if 0
! 60: if ( !islower(*p) )
! 61: *rp = 0;
! 62: else {
! 63: for ( t = p+1; t && (isalnum(*t) || *t == '_'); t++ );
! 64: if ( *t )
! 65: *rp = 0;
! 66: else
! 67: makevar(p,rp);
! 68: }
! 69: #else
! 70: makevar(p,rp);
! 71: #endif
! 72: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>