From e5a84e3f4c52432a64db52f54870dca9f652b570 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 13 Feb 2014 13:53:56 +0900 Subject: [PATCH] refactor pic_gensym --- src/symbol.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/symbol.c b/src/symbol.c index 4e931ea3..07c67b42 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -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++;