add length argument to pic_str()

This commit is contained in:
Yuichi Nishiwaki
2017-03-28 23:31:15 +09:00
parent b58a81ca39
commit 53ec7384ca
11 changed files with 40 additions and 27 deletions
+2
View File
@@ -13,6 +13,8 @@ static pic_value pic_compile(pic_state *, pic_value);
#define EQ(sym, lit) (strcmp(pic_sym(pic, sym), lit) == 0)
#define S(lit) (pic_intern_lit(pic, lit))
#define pic_sym(pic,sym) pic_str(pic, pic_sym_name(pic, (sym)), NULL)
static void
define_macro(pic_state *pic, pic_value uid, pic_value mac)
{
+3 -3
View File
@@ -84,10 +84,10 @@ pic_add_identifier(pic_state *pic, pic_value id, pic_value env)
return uid;
}
name = pic_str(pic, pic_id_name(pic, id));
name = pic_str(pic, pic_id_name(pic, id), NULL);
if (pic_env_ptr(pic, env)->up == NULL && pic_sym_p(pic, id)) { /* toplevel & public */
lib = pic_str(pic, pic_obj_value(pic_env_ptr(pic, env)->lib));
lib = pic_str(pic, pic_obj_value(pic_env_ptr(pic, env)->lib), NULL);
str = pic_strf_value(pic, "%s/%s", lib, name);
} else {
str = pic_strf_value(pic, ".%s.%d", name, pic->ucnt++);
@@ -168,7 +168,7 @@ pic_make_library(pic_state *pic, const char *lib)
env = make_library_env(pic, name);
exports = pic_make_dict(pic);
it = kh_put(ltable, h, pic_str(pic, name), &ret);
it = kh_put(ltable, h, pic_str(pic, name, NULL), &ret);
if (ret == 0) { /* if exists */
pic_error(pic, "library name already in use", 1, pic_cstr_value(pic, lib));
}
+5 -4
View File
@@ -270,10 +270,10 @@ static void
write_str(pic_state *pic, pic_value str, pic_value port, struct writer_control *p)
{
int i;
const char *cstr = pic_str(pic, str);
const char *cstr = pic_str(pic, str, NULL);
if (p->mode == DISPLAY_MODE) {
pic_fprintf(pic, port, "%s", pic_str(pic, str));
pic_fprintf(pic, port, "%s", pic_str(pic, str, NULL));
return;
}
pic_fprintf(pic, port, "\"");
@@ -324,7 +324,8 @@ write_pair_help(pic_state *pic, pic_value pair, pic_value port, struct writer_co
}
}
#define EQ(sym, lit) (strcmp(pic_sym(pic, sym), lit) == 0)
#define EQ(sym, lit) (strcmp(pic_str(pic, pic_sym_name(pic, sym), NULL), lit) == 0)
#define pic_sym(pic,sym) pic_str(pic, pic_sym_name(pic, (sym)), NULL)
static void
write_pair(pic_state *pic, pic_value pair, pic_value port, struct writer_control *p)
@@ -439,7 +440,7 @@ write_core(pic_state *pic, pic_value obj, pic_value port, struct writer_control
pic_fprintf(pic, port, "#f");
break;
case PIC_TYPE_ID:
pic_fprintf(pic, port, "#<identifier %s>", pic_str(pic, pic_id_name(pic, obj)));
pic_fprintf(pic, port, "#<identifier %s>", pic_str(pic, pic_id_name(pic, obj), NULL));
break;
case PIC_TYPE_EOF:
pic_fprintf(pic, port, "#.(eof-object)");