s/struct pic_string/pic_str/g
This commit is contained in:
parent
ca4276afc7
commit
131440b1d0
|
@ -164,8 +164,9 @@ bool pic_interned_p(pic_state *, pic_sym);
|
||||||
|
|
||||||
char *pic_strdup(pic_state *, const char *);
|
char *pic_strdup(pic_state *, const char *);
|
||||||
char *pic_strndup(pic_state *, const char *, size_t);
|
char *pic_strndup(pic_state *, const char *, size_t);
|
||||||
struct pic_string *pic_str_new(pic_state *, const char *, size_t); /* the 2nd arg may be NULL for empty string */
|
pic_str *pic_str_new(pic_state *, const char * /* nullable */, size_t);
|
||||||
struct pic_string *pic_str_new_cstr(pic_state *, const char *);
|
pic_str *pic_str_new_cstr(pic_state *, const char *);
|
||||||
|
|
||||||
pic_value pic_format(pic_state *, const char *, ...);
|
pic_value pic_format(pic_state *, const char *, ...);
|
||||||
pic_value pic_vformat(pic_state *, const char *, va_list);
|
pic_value pic_vformat(pic_state *, const char *, va_list);
|
||||||
pic_value pic_vfformat(pic_state *, XFILE *, const char *, va_list);
|
pic_value pic_vfformat(pic_state *, XFILE *, const char *, va_list);
|
||||||
|
|
23
src/string.c
23
src/string.c
|
@ -8,10 +8,10 @@
|
||||||
#include "picrin/pair.h"
|
#include "picrin/pair.h"
|
||||||
#include "picrin/port.h"
|
#include "picrin/port.h"
|
||||||
|
|
||||||
struct pic_string *
|
pic_str *
|
||||||
pic_str_new(pic_state *pic, const char *cstr, size_t len)
|
pic_str_new(pic_state *pic, const char *cstr, size_t len)
|
||||||
{
|
{
|
||||||
struct pic_string *str;
|
pic_str *str;
|
||||||
char *copy;
|
char *copy;
|
||||||
|
|
||||||
if (cstr) {
|
if (cstr) {
|
||||||
|
@ -20,12 +20,18 @@ pic_str_new(pic_state *pic, const char *cstr, size_t len)
|
||||||
copy = (char *)pic_alloc(pic, len);
|
copy = (char *)pic_alloc(pic, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
str = (struct pic_string *)pic_obj_alloc(pic, sizeof(struct pic_string), PIC_TT_STRING);
|
str = (pic_str *)pic_obj_alloc(pic, sizeof(pic_str), PIC_TT_STRING);
|
||||||
str->len = len;
|
str->len = len;
|
||||||
str->str = copy;
|
str->str = copy;
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pic_str *
|
||||||
|
pic_str_new_cstr(pic_state *pic, const char *cstr)
|
||||||
|
{
|
||||||
|
return pic_str_new(pic, cstr, strlen(cstr));
|
||||||
|
}
|
||||||
|
|
||||||
pic_value
|
pic_value
|
||||||
pic_vfformat(pic_state *pic, XFILE *file, const char *fmt, va_list ap)
|
pic_vfformat(pic_state *pic, XFILE *file, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
|
@ -119,15 +125,6 @@ pic_format(pic_state *pic, const char *fmt, ...)
|
||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pic_string *
|
|
||||||
pic_str_new_cstr(pic_state *pic, const char *cstr)
|
|
||||||
{
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
len = strlen(cstr);
|
|
||||||
return pic_str_new(pic, cstr, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
pic_str_string_p(pic_state *pic)
|
pic_str_string_p(pic_state *pic)
|
||||||
{
|
{
|
||||||
|
@ -230,7 +227,7 @@ pic_str_string_copy(pic_state *pic)
|
||||||
size_t len, start, end, i;
|
size_t len, start, end, i;
|
||||||
char *str;
|
char *str;
|
||||||
int n;
|
int n;
|
||||||
struct pic_string *copy;
|
pic_str *copy;
|
||||||
|
|
||||||
n = pic_get_args(pic, "s|ii", &str, &len, &start, &end);
|
n = pic_get_args(pic, "s|ii", &str, &len, &start, &end);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue