version 1.23, 2004/03/05 01:15:48 |
version 1.26, 2004/03/05 01:47:19 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/strobj.c,v 1.22 2004/03/04 13:19:11 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/strobj.c,v 1.25 2004/03/05 01:34:24 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 74 void Pclear_tb(); |
|
Line 74 void Pclear_tb(); |
|
void Pstring_to_tb(); |
void Pstring_to_tb(); |
void Pquotetotex_tb(); |
void Pquotetotex_tb(); |
void Pquotetotex(); |
void Pquotetotex(); |
void Pquotetotex_setenv(); |
void Pquotetotex_env(); |
void fnodetotex_tb(FNODE f,TB tb); |
void fnodetotex_tb(FNODE f,TB tb); |
char *symbol_name(char *name); |
char *symbol_name(char *name); |
void tb_to_string(TB tb,STRING *rp); |
void tb_to_string(TB tb,STRING *rp); |
Line 96 struct ftab str_tab[] = { |
|
Line 96 struct ftab str_tab[] = { |
|
{"string_to_tb",Pstring_to_tb,1}, |
{"string_to_tb",Pstring_to_tb,1}, |
{"quotetotex_tb",Pquotetotex_tb,2}, |
{"quotetotex_tb",Pquotetotex_tb,2}, |
{"quotetotex",Pquotetotex,1}, |
{"quotetotex",Pquotetotex,1}, |
{"quotetotex_setenv",Pquotetotex_setenv,-99999999}, |
{"quotetotex_env",Pquotetotex_env,-99999999}, |
{0,0,0}, |
{0,0,0}, |
}; |
}; |
|
|
Line 113 void write_tb(char *s,TB tb) |
|
Line 113 void write_tb(char *s,TB tb) |
|
int register_symbol_table(Obj arg); |
int register_symbol_table(Obj arg); |
int register_conv_rule(Obj arg); |
int register_conv_rule(Obj arg); |
int register_dp_vars(Obj arg); |
int register_dp_vars(Obj arg); |
|
int register_dp_vars_prefix(Obj arg); |
static struct TeXSymbol *user_texsymbol; |
static struct TeXSymbol *user_texsymbol; |
static char *(*conv_rule)(char *); |
static char *(*conv_rule)(char *); |
static char **dp_vars; |
static char **dp_vars; |
int dp_vars_len; |
static int dp_vars_len; |
|
static char *dp_vars_prefix; |
|
static FUNC convfunc; |
|
|
static struct { |
static struct { |
char *name; |
char *name; |
|
|
{"symbol_table",0,register_symbol_table}, |
{"symbol_table",0,register_symbol_table}, |
{"conv_rule",0,register_conv_rule}, |
{"conv_rule",0,register_conv_rule}, |
{"dp_vars",0,register_dp_vars}, |
{"dp_vars",0,register_dp_vars}, |
|
{"dp_vars_prefix",0,register_dp_vars_prefix}, |
{0,0,0}, |
{0,0,0}, |
}; |
}; |
|
|
Line 162 char *conv_rule_d(char *name) |
|
Line 166 char *conv_rule_d(char *name) |
|
b[j++] = '_'; b[j++] = '{'; |
b[j++] = '_'; b[j++] = '{'; |
if ( name[i] == '_' ) i++; |
if ( name[i] == '_' ) i++; |
for ( start = 1; i < l; ) { |
for ( start = 1; i < l; ) { |
if ( name[i] == '_' ) { |
if ( name[i] == '{' || name[i] == '}' || name[i] == ' ' ) |
|
b[j++] = name[i++]; |
|
else if ( name[i] == '_' ) { |
i++; |
i++; |
start = 1; |
start = 1; |
b[j++] = ','; |
b[j++] = ','; |
|
|
return r; |
return r; |
} |
} |
|
|
|
char *call_convfunc(char *name) |
|
{ |
|
STRING str,r; |
|
NODE arg; |
|
|
|
MKSTR(str,name); |
|
arg = mknode(1,str); |
|
r = (STRING)bevalf(convfunc,arg); |
|
if ( !r || OID(r) != O_STR ) |
|
error("call_convfunc : invalid result"); |
|
return BDY(r); |
|
} |
|
|
int register_symbol_table(Obj arg) |
int register_symbol_table(Obj arg) |
{ |
{ |
NODE n,t; |
NODE n,t; |
Line 243 int register_symbol_table(Obj arg) |
|
Line 262 int register_symbol_table(Obj arg) |
|
return 1; |
return 1; |
} |
} |
|
|
|
|
int register_conv_rule(Obj arg) |
int register_conv_rule(Obj arg) |
{ |
{ |
if ( INT(arg) ) { |
if ( INT(arg) ) { |
Line 259 int register_conv_rule(Obj arg) |
|
Line 279 int register_conv_rule(Obj arg) |
|
return 0; |
return 0; |
break; |
break; |
} |
} |
|
} else if ( OID(arg) == O_P && |
|
(int)(VR((P)arg))->attr == V_SR ) { |
|
convfunc = (FUNC)(VR((P)arg)->priv); |
|
/* f must be a function which takes single argument */ |
|
conv_rule = call_convfunc; |
|
return 1; |
} else return 0; |
} else return 0; |
} |
} |
|
|
Line 272 int register_dp_vars(Obj arg) |
|
Line 298 int register_dp_vars(Obj arg) |
|
if ( !arg ) { |
if ( !arg ) { |
dp_vars = 0; |
dp_vars = 0; |
dp_vars_len = 0; |
dp_vars_len = 0; |
|
return 1; |
} else if ( OID(arg) != O_LIST ) |
} else if ( OID(arg) != O_LIST ) |
return 0; |
return 0; |
else { |
else { |
Line 294 int register_dp_vars(Obj arg) |
|
Line 321 int register_dp_vars(Obj arg) |
|
} |
} |
} |
} |
|
|
void Pquotetotex_setenv(NODE arg,Obj *rp) |
int register_dp_vars_prefix(Obj arg) |
{ |
{ |
|
if ( !arg ) { |
|
dp_vars_prefix = 0; |
|
return 1; |
|
} else if ( OID(arg) == O_STR ) { |
|
dp_vars_prefix = BDY((STRING)arg); |
|
return 1; |
|
} else if ( OID(arg) == O_P ) { |
|
dp_vars_prefix = NAME(VR((P)arg)); |
|
return 1; |
|
} else return 0; |
|
} |
|
|
|
void Pquotetotex_env(NODE arg,Obj *rp) |
|
{ |
int ac,i; |
int ac,i; |
char *name; |
char *name; |
NODE n,n0; |
NODE n,n0; |
Line 313 void Pquotetotex_setenv(NODE arg,Obj *rp) |
|
Line 354 void Pquotetotex_setenv(NODE arg,Obj *rp) |
|
MKLIST(l,n0); |
MKLIST(l,n0); |
*rp = (Obj)l; |
*rp = (Obj)l; |
} else if ( ac == 1 || ac == 2 ) { |
} else if ( ac == 1 || ac == 2 ) { |
asir_assert(ARG0(arg),O_STR,"quotetotex_setenv"); |
asir_assert(ARG0(arg),O_STR,"quotetotex_env"); |
name = BDY((STRING)ARG0(arg)); |
name = BDY((STRING)ARG0(arg)); |
for ( i = 0; qtot_env[i].name; i++ ) |
for ( i = 0; qtot_env[i].name; i++ ) |
if ( !strcmp(qtot_env[i].name,name) ) { |
if ( !strcmp(qtot_env[i].name,name) ) { |
Line 321 void Pquotetotex_setenv(NODE arg,Obj *rp) |
|
Line 362 void Pquotetotex_setenv(NODE arg,Obj *rp) |
|
if ( (qtot_env[i].reg)((Obj)ARG1(arg)) ) |
if ( (qtot_env[i].reg)((Obj)ARG1(arg)) ) |
qtot_env[i].value = (Obj)ARG1(arg); |
qtot_env[i].value = (Obj)ARG1(arg); |
else |
else |
error("quotetotex_setenv : invalid argument"); |
error("quotetotex_env : invalid argument"); |
} |
} |
*rp = qtot_env[i].value; |
*rp = qtot_env[i].value; |
return; |
return; |
Line 913 void fnodetotex_tb(FNODE f,TB tb) |
|
Line 954 void fnodetotex_tb(FNODE f,TB tb) |
|
allzero = 0; |
allzero = 0; |
if ( dp_vars && i < dp_vars_len ) |
if ( dp_vars && i < dp_vars_len ) |
strcpy(vname,dp_vars[i]); |
strcpy(vname,dp_vars[i]); |
|
else if ( dp_vars_prefix ) |
|
sprintf(vname,"%s_{%d}",dp_vars_prefix,i); |
else |
else |
sprintf(vname,"x_{%d}",i); |
sprintf(vname,"x_{%d}",i); |
vname_conv = symbol_name(vname); |
vname_conv = symbol_name(vname); |