version 1.14, 1999/11/12 12:55:47 |
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.13 1999/11/11 09:08:52 ohara Exp $ */ |
/* $OpenXM: OpenXM/src/ox_math/ox.c,v 1.14 1999/11/12 12:55:47 ohara Exp $ */ |
|
|
/* |
/* |
関数の名前付け規約(その2): |
関数の名前付け規約(その2): |
Line 1323 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 1335 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 1343 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; |
|
} |
} |