refactor pic_gensym

This commit is contained in:
Yuichi Nishiwaki 2014-02-13 13:53:56 +09:00
parent 38bb76808b
commit e5a84e3f4c
1 changed files with 4 additions and 3 deletions

View File

@ -30,12 +30,13 @@ pic_intern_cstr(pic_state *pic, const char *str)
pic_sym
pic_gensym(pic_state *pic, pic_sym base)
{
int s = ++pic->uniq_sym_cnt;
int id;
char *str;
pic_sym uniq;
str = (char *)pic_alloc(pic, strlen(pic_symbol_name(pic, base)) + (int)log10(s) + 3);
sprintf(str, "%s@%d", pic_symbol_name(pic, base), s);
id = ++pic->uniq_sym_cnt;
str = (char *)pic_alloc(pic, strlen(pic_symbol_name(pic, base)) + (int)log10(id) + 3);
sprintf(str, "%s@%d", pic_symbol_name(pic, base), id);
/* don't put the symbol to pic->syms to keep it uninterned */
uniq = pic->sym_cnt++;