File: [local] / OpenXM_contrib2 / asir2000 / builtin / ctrl.c (download)
Revision 1.3, Mon Feb 7 03:14:38 2000 UTC (24 years, 5 months ago) by noro
Branch: MAIN
Changes since 1.2: +3 -2
lines
Added a switch "fortran_output" in ctrl().
If it is equal to 1, polynomials are displayed in fortran style
(x^2 -> x**2 etc.).
Numbers and keywords of arbitrary length can be accepted by the parser.
|
/* $OpenXM: OpenXM_contrib2/asir2000/builtin/ctrl.c,v 1.3 2000/02/07 03:14:38 noro Exp $ */
#include "ca.h"
#include "parse.h"
void Pctrl();
struct ftab ctrl_tab[] = {
{"ctrl",Pctrl,-2},
{0,0,0},
};
extern int prtime,nez,echoback,bigfloat;
extern int GC_free_space_numerator,GC_free_space_divisor,debug_up,no_prompt;
extern int GC_max_heap_size,Verbose,hideargs,hex_output,do_server_in_X11;
extern int do_message;
extern int ox_batch,ox_check;
extern int f4_nocheck;
extern int fortran_output;
static struct {
char *key;
int *val;
} ctrls[] = {
{"cputime",&prtime},
{"nez",&nez},
{"echo",&echoback},
{"bigfloat",&bigfloat},
{"verbose",&Verbose},
{"hideargs",&hideargs},
{"hex",&hex_output},
{"debug_window",&do_server_in_X11},
{"message",&do_message},
{"debug_up",&debug_up},
{"no_prompt",&no_prompt},
{"ox_batch",&ox_batch},
{"ox_check",&ox_check},
{"f4_nocheck",&f4_nocheck},
{"fortran_output",&fortran_output},
{0,0},
};
void Pctrl(arg,rp)
NODE arg;
Q *rp;
{
int t,i;
N num,den;
Q c;
char *key;
char buf[BUFSIZ];
if ( !arg ) {
*rp = 0;
return;
}
key = BDY((STRING)ARG0(arg));
if ( !strcmp(key,"adj") ) {
/* special treatment is necessary for "adj" */
if ( argc(arg) == 1 ) {
UTON(GC_free_space_divisor,num);
UTON(GC_free_space_numerator,den);
} else {
c = (Q)ARG1(arg);
if ( !c )
error("ctrl : adj : invalid argument");
num = NM(c);
den = !DN(c)?ONEN:DN(c);
GC_free_space_divisor = BD(num)[0];
GC_free_space_numerator = BD(den)[0];
}
NDTOQ(num,den,1,*rp);
return;
}
for ( i = 0; ctrls[i].key; i++ )
if ( !strcmp(key,ctrls[i].key) )
break;
if ( ctrls[i].key ) {
if ( argc(arg) == 1 )
t = *ctrls[i].val;
else
*ctrls[i].val = t = QTOS((Q)ARG1(arg));
STOQ(t,*rp);
} else {
sprintf(buf,"ctrl : %s : no such key",key);
error(buf);
}
}