version 1.12, 1999/11/07 12:12:55 |
version 1.15, 1999/11/18 21:57:56 |
|
|
/* -*- mode: C; coding: euc-japan -*- */ |
/* -*- mode: C; coding: euc-japan -*- */ |
/* $OpenXM: OpenXM/src/ox_math/ox.c,v 1.11 1999/11/06 21:39:36 ohara Exp $ */ |
/* $OpenXM: OpenXM/src/ox_math/ox.c,v 1.14 1999/11/12 12:55:47 ohara Exp $ */ |
|
|
/* |
/* |
関数の名前付け規約(その2): |
関数の名前付け規約(その2): |
Line 270 static cmo_distributed_polynomial* receive_cmo_distrib |
|
Line 270 static cmo_distributed_polynomial* receive_cmo_distrib |
|
|
|
while (len>0) { |
while (len>0) { |
ob = receive_cmo(fd); |
ob = receive_cmo(fd); |
append_cmo_list(c, ob); |
append_cmo_list((cmo_list *)c, ob); |
len--; |
len--; |
} |
} |
return c; |
return c; |
Line 513 int print_cmo(cmo* c) |
|
Line 513 int print_cmo(cmo* c) |
|
{ |
{ |
int tag = c->tag; |
int tag = c->tag; |
|
|
#ifdef DEBUG |
|
symbol* symp = lookup_by_tag(tag); |
symbol* symp = lookup_by_tag(tag); |
if (symp != NULL) { |
if (symp != NULL) { |
fprintf(stderr, "local::tag = %s: ", symp->key); |
fprintf(stderr, "(%s", symp->key); |
}else { |
}else { |
fprintf(stderr, "local::tag = %d: ", tag); |
fprintf(stderr, "(%d", tag); |
} |
} |
#endif |
|
|
|
switch(tag) { |
switch(tag) { |
case CMO_LIST: |
case CMO_LIST: |
Line 530 int print_cmo(cmo* c) |
|
Line 528 int print_cmo(cmo* c) |
|
print_cmo_int32((cmo_int32 *)c); |
print_cmo_int32((cmo_int32 *)c); |
break; |
break; |
case CMO_MATHCAP: |
case CMO_MATHCAP: |
|
case CMO_INDETERMINATE: |
|
case CMO_RING_BY_NAME: |
|
case CMO_ERROR2: |
print_cmo_mathcap((cmo_mathcap *)c); |
print_cmo_mathcap((cmo_mathcap *)c); |
break; |
break; |
case CMO_STRING: |
case CMO_STRING: |
print_cmo_string((cmo_string *)c); |
print_cmo_string((cmo_string *)c); |
break; |
break; |
case CMO_NULL: |
case CMO_NULL: |
fprintf(stderr, "\n"); |
case CMO_ZERO: |
|
case CMO_DMS_GENERIC: |
|
fprintf(stderr, ")"); |
break; |
break; |
default: |
default: |
fprintf(stderr, "print_cmo() does not know how to print.\n"); |
fprintf(stderr, "print_cmo() does not know how to print.\n"); |
Line 545 int print_cmo(cmo* c) |
|
Line 548 int print_cmo(cmo* c) |
|
|
|
int print_cmo_int32(cmo_int32* c) |
int print_cmo_int32(cmo_int32* c) |
{ |
{ |
fprintf(stderr, "cmo_int32 = (%d)\n", c->i); |
fprintf(stderr, ", %d)", c->i); |
} |
} |
|
|
int print_cmo_list(cmo_list* li) |
int print_cmo_list(cmo_list* li) |
{ |
{ |
cell* cp = li->head; |
cell* cp = li->head; |
fprintf(stderr, "length = (%d)\nlist:\n", li->length); |
while(cp->next != NULL) { |
while(cp != NULL) { |
fprintf(stderr, ", "); |
print_cmo(cp->cmo); |
print_cmo(cp->cmo); |
cp=cp->next; |
cp=cp->next; |
} |
} |
fprintf(stderr, "end of list\n"); |
fprintf(stderr, ")"); |
} |
} |
|
|
int print_cmo_mathcap(cmo_mathcap* c) |
int print_cmo_mathcap(cmo_mathcap* c) |
{ |
{ |
fprintf(stderr, "\n"); |
fprintf(stderr, ", "); |
print_cmo(c->ob); |
print_cmo(c->ob); |
|
fprintf(stderr, ")"); |
} |
} |
|
|
int print_cmo_string(cmo_string* c) |
int print_cmo_string(cmo_string* c) |
{ |
{ |
fprintf(stderr, "cmo_string = (%s)\n", c->s); |
fprintf(stderr, ", \"%s\")", c->s); |
} |
} |
|
|
void ox_close(ox_file_t sv) |
void ox_close(ox_file_t sv) |
Line 1233 static cmo_list *make_list_of_tag(int type) |
|
Line 1237 static cmo_list *make_list_of_tag(int type) |
|
|
|
cmo* make_mathcap_object(int version, char *id_string) |
cmo* make_mathcap_object(int version, char *id_string) |
{ |
{ |
char sysname[] = "ox_math"; |
char *sysname = "ox_math"; |
cmo_list *li = new_cmo_list(); |
cmo_list *li = new_cmo_list(); |
cmo_list *li_ver = make_list_of_id(version, id_string, sysname); |
cmo_list *li_1st = make_list_of_id(version, id_string, sysname); |
|
cmo_list *li_2nd = make_list_of_tag(IS_SM); |
|
cmo_list *li_3rd = new_cmo_list(); |
cmo_list *li_cmo = make_list_of_tag(IS_CMO); |
cmo_list *li_cmo = make_list_of_tag(IS_CMO); |
cmo_list *li_sm = make_list_of_tag(IS_SM); |
|
|
|
append_cmo_list(li, (cmo *)li_ver); |
cmo_list *li_ox = new_cmo_list(); |
append_cmo_list(li, (cmo *)li_cmo); |
append_cmo_list(li_ox, (cmo *)new_cmo_int32(OX_DATA)); |
append_cmo_list(li, (cmo *)li_sm); |
append_cmo_list(li_3rd, (cmo *)li_ox); |
|
append_cmo_list(li_3rd, (cmo *)li_cmo); |
|
|
|
append_cmo_list(li, (cmo *)li_1st); |
|
append_cmo_list(li, (cmo *)li_2nd); |
|
append_cmo_list(li, (cmo *)li_3rd); |
|
|
return (cmo *)new_cmo_mathcap((cmo *)li); |
return (cmo *)new_cmo_mathcap((cmo *)li); |
} |
} |
|
|
Line 1313 char *convert_zz_to_string(cmo_zz *c) |
|
Line 1323 char *convert_zz_to_string(cmo_zz *c) |
|
return mpz_get_str(NULL, 10, c->mpz); |
return mpz_get_str(NULL, 10, c->mpz); |
} |
} |
|
|
|
char *convert_null_to_string() |
|
{ |
|
static char* null_string = ""; |
|
return null_string; |
|
} |
|
|
|
char *convert_int_to_string(int integer) |
|
{ |
|
char buff[1024]; |
|
char *s; |
|
|
|
sprintf(buff, "%d", integer); |
|
s = malloc(strlen(buff)+1); |
|
strcpy(s, buff); |
|
|
|
return s; |
|
} |
|
|
|
char *convert_cmo_list_to_string(cmo_list *m) |
|
{ |
|
char *s; |
|
int i; |
|
int size = 0; |
|
int len = length_cmo_list(m); |
|
char **sp = malloc(len*sizeof(cmo *)); |
|
|
|
cell *cp = m->head; |
|
for(i = 0; i < len; i++) { |
|
sp[i] = convert_cmo_to_string(cp->cmo); |
|
size += strlen(sp[i]) + 3; |
|
cp = cp->next; |
|
} |
|
s = malloc(size+2); |
|
strcpy(s, "[ "); |
|
for(i = 0; i < len - 1; i++) { |
|
strcat(s, sp[i]); |
|
strcat(s, " , "); |
|
} |
|
strcat(s, sp[len-1]); |
|
strcat(s, " ]"); |
|
free(sp); |
|
return s; |
|
} |
|
|
char *convert_cmo_to_string(cmo *m) |
char *convert_cmo_to_string(cmo *m) |
{ |
{ |
symbol *symp; |
symbol *symp; |
Line 1325 char *convert_cmo_to_string(cmo *m) |
|
Line 1379 char *convert_cmo_to_string(cmo *m) |
|
return ((cmo_string *)m)->s; |
return ((cmo_string *)m)->s; |
case CMO_NULL: |
case CMO_NULL: |
return convert_null_to_string(); |
return convert_null_to_string(); |
|
case CMO_LIST: |
|
return convert_cmo_list_to_string((cmo_list *)m); |
default: |
default: |
#ifdef DEBUG |
#ifdef DEBUG |
symp = lookup_by_tag(m->tag); |
symp = lookup_by_tag(m->tag); |
Line 1333 char *convert_cmo_to_string(cmo *m) |
|
Line 1389 char *convert_cmo_to_string(cmo *m) |
|
/* まだ実装していません. */ |
/* まだ実装していません. */ |
return NULL; |
return NULL; |
} |
} |
} |
|
|
|
char *convert_null_to_string() |
|
{ |
|
static char* null_string = ""; |
|
return null_string; |
|
} |
|
|
|
char *convert_int_to_string(int integer) |
|
{ |
|
char buff[1024]; |
|
char *s; |
|
|
|
sprintf(buff, "%d", integer); |
|
s = malloc(strlen(buff)+1); |
|
strcpy(s, buff); |
|
|
|
return s; |
|
} |
} |