version 1.18, 2004/03/04 06:29:47 |
version 1.21, 2004/03/04 13:12:27 |
|
|
* 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.17 2004/03/04 05:16:42 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/strobj.c,v 1.20 2004/03/04 12:28:14 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
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); |
static struct TeXSymbol *user_texsymbol; |
static struct TeXSymbol *user_texsymbol; |
|
static char *(*conv_rule)(char *); |
|
|
static struct { |
static struct { |
char *name; |
char *name; |
|
|
{0,0,0}, |
{0,0,0}, |
}; |
}; |
|
|
|
#define PARTIAL "\\partial" |
|
char *conv_rule_d(char *name) |
|
{ |
|
int l,i,j,alpha,start; |
|
char *b,*r; |
|
l = strlen(name); |
|
|
|
if ( name[0] == 'd' ) { |
|
/* 3 : _{} */ |
|
b = (char *)ALLOCA((2*l+1+strlen(PARTIAL)+3)*sizeof(char)); |
|
sprintf(b,"%s_{",PARTIAL); |
|
i = 1; |
|
j = strlen(b); |
|
} else { |
|
b = (char *)ALLOCA((2*l+1)*sizeof(char)); |
|
i = j = 0; |
|
} |
|
for ( ; i < l && name[i] == '_'; i++); |
|
for ( ; i < l; ) { |
|
if ( !isalpha(name[i]) ) |
|
break; |
|
else |
|
b[j++] = name[i++]; |
|
} |
|
if ( i == l ) |
|
if ( name[0] == 'd' ) |
|
goto END; |
|
else |
|
return name; |
|
/* we found a digit or '_' */ |
|
b[j++] = '_'; b[j++] = '{'; |
|
if ( name[i] == '_' ) i++; |
|
for ( start = 1; i < l; ) { |
|
if ( name[i] == '_' ) { |
|
i++; |
|
start = 1; |
|
b[j++] = ','; |
|
} else if ( start ) { |
|
alpha = isalpha(name[i])?1:0; |
|
b[j++] = name[i++]; |
|
start = 0; |
|
} else if ( alpha ) { |
|
if ( isalpha(name[i]) ) |
|
b[j++] = name[i++]; |
|
else { |
|
alpha = 0; |
|
start = 1; |
|
b[j++] = ','; |
|
} |
|
} else { |
|
if ( isdigit(name[i]) ) |
|
b[j++] = name[i++]; |
|
else { |
|
alpha = 1; |
|
start = 1; |
|
b[j++] = ','; |
|
} |
|
} |
|
} |
|
b[j++] = '}'; |
|
END: |
|
if ( name[0] == 'd' ) b[j++] = '}'; |
|
b[j++] = 0; |
|
r = (char *)MALLOC_ATOMIC((j+1)*sizeof(char)); |
|
strcpy(r,b); |
|
return r; |
|
} |
|
|
int register_symbol_table(Obj arg) |
int register_symbol_table(Obj arg) |
{ |
{ |
NODE n,t; |
NODE n,t; |
Line 162 int register_symbol_table(Obj arg) |
|
Line 231 int register_symbol_table(Obj arg) |
|
|
|
int register_conv_rule(Obj arg) |
int register_conv_rule(Obj arg) |
{ |
{ |
|
if ( INT(arg) ) { |
|
switch ( QTOS((Q)arg) ) { |
|
case 0: |
|
conv_rule = 0; |
|
return 1; |
|
break; |
|
case 1: |
|
conv_rule = conv_rule_d; |
|
return 1; |
|
break; |
|
default: |
|
return 0; |
|
break; |
|
} |
|
} else return 0; |
} |
} |
|
|
void Pquotetotex_setenv(NODE arg,Obj *rp) |
void Pquotetotex_setenv(NODE arg,Obj *rp) |
Line 551 char *symbol_name(char *name) |
|
Line 635 char *symbol_name(char *name) |
|
for ( i = 0; texsymbol[i].text; i++ ) |
for ( i = 0; texsymbol[i].text; i++ ) |
if ( !strcmp(texsymbol[i].text,name) ) |
if ( !strcmp(texsymbol[i].text,name) ) |
return texsymbol[i].symbol; |
return texsymbol[i].symbol; |
return name; |
if ( conv_rule ) |
|
return (*conv_rule)(name); |
|
else |
|
return name; |
} |
} |
|
|
void fnodetotex_tb(FNODE f,TB tb) |
void fnodetotex_tb(FNODE f,TB tb) |