From cfc32a1b152f8bd000b99b8683862e9d77fce546 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Fri, 19 Feb 2016 00:14:50 +0900 Subject: [PATCH] remove string.h --- contrib/20.r7rs/src/mutable-string.c | 1 + contrib/40.srfi/src/106.c | 12 +++--------- contrib/40.srfi/srfi/106.scm | 2 +- extlib/benz/include/picrin.h | 1 - extlib/benz/include/picrin/object.h | 13 +++++++++++++ extlib/benz/include/picrin/string.h | 10 ---------- extlib/benz/string.c | 1 + 7 files changed, 19 insertions(+), 21 deletions(-) diff --git a/contrib/20.r7rs/src/mutable-string.c b/contrib/20.r7rs/src/mutable-string.c index b00842df..0f3bcfe6 100644 --- a/contrib/20.r7rs/src/mutable-string.c +++ b/contrib/20.r7rs/src/mutable-string.c @@ -1,4 +1,5 @@ #include "picrin.h" +#include "picrin/object.h" void pic_str_set(pic_state *pic, struct pic_string *str, int i, char c) diff --git a/contrib/40.srfi/src/106.c b/contrib/40.srfi/src/106.c index 2ccb0c21..ef31ec43 100644 --- a/contrib/40.srfi/src/106.c +++ b/contrib/40.srfi/src/106.c @@ -69,22 +69,16 @@ pic_socket_socket_p(pic_state *pic) static pic_value pic_socket_make_socket(pic_state *pic) { - pic_value n, s; const char *node, *service; int family, socktype, flags, protocol; int result; struct addrinfo hints, *ai, *it; struct pic_socket_t *sock; - pic_get_args(pic, "ooiiii", &n, &s, &family, &socktype, &flags, &protocol); + pic_get_args(pic, "zziiii", &node, &service, &family, &socktype, &flags, &protocol); - node = service = NULL; - if (pic_str_p(pic, n)) { - node = pic_str(pic, pic_str_ptr(n)); - } - if (pic_str_p(pic, s)) { - service = pic_str(pic, pic_str_ptr(s)); - } + if (strlen(node) == 0) node = NULL; + if (strlen(service) == 0) service = NULL; sock = pic_malloc(pic, sizeof(struct pic_socket_t)); sock->fd = -1; diff --git a/contrib/40.srfi/srfi/106.scm b/contrib/40.srfi/srfi/106.scm index e224b603..a9ac0408 100644 --- a/contrib/40.srfi/srfi/106.scm +++ b/contrib/40.srfi/srfi/106.scm @@ -34,7 +34,7 @@ (type *sock-stream*) (flags *ai-passive*) (protocol *ipproto-ip*)) - (make-socket #f service family type flags protocol))) + (make-socket "" service family type flags protocol))) (define %address-family `((inet . ,*af-inet*) (inet6 . ,*af-inet6*) diff --git a/extlib/benz/include/picrin.h b/extlib/benz/include/picrin.h index 606af64f..9566cd7b 100644 --- a/extlib/benz/include/picrin.h +++ b/extlib/benz/include/picrin.h @@ -268,7 +268,6 @@ int pic_str_hash(pic_state *, struct pic_string *); #include "picrin/port.h" #include "picrin/proc.h" #include "picrin/record.h" -#include "picrin/string.h" #include "picrin/symbol.h" void *pic_default_allocf(void *, void *, size_t); diff --git a/extlib/benz/include/picrin/object.h b/extlib/benz/include/picrin/object.h index b362f95c..ac7615e5 100644 --- a/extlib/benz/include/picrin/object.h +++ b/extlib/benz/include/picrin/object.h @@ -10,6 +10,19 @@ extern "C" { #endif +/* string */ + +struct pic_string { + PIC_OBJECT_HEADER + struct pic_rope *rope; +}; + +void pic_rope_incref(pic_state *, struct pic_rope *); +void pic_rope_decref(pic_state *, struct pic_rope *); + +#define pic_str_ptr(o) ((struct pic_string *)pic_obj_ptr(o)) + + /* vector */ struct pic_vector { diff --git a/extlib/benz/include/picrin/string.h b/extlib/benz/include/picrin/string.h index 7d4eeab0..ac5d2ce8 100644 --- a/extlib/benz/include/picrin/string.h +++ b/extlib/benz/include/picrin/string.h @@ -9,16 +9,6 @@ extern "C" { #endif -struct pic_string { - PIC_OBJECT_HEADER - struct pic_rope *rope; -}; - -void pic_rope_incref(pic_state *, struct pic_rope *); -void pic_rope_decref(pic_state *, struct pic_rope *); - -#define pic_str_ptr(o) ((struct pic_string *)pic_obj_ptr(o)) - #if defined(__cplusplus) } #endif diff --git a/extlib/benz/string.c b/extlib/benz/string.c index 90103455..8027a36e 100644 --- a/extlib/benz/string.c +++ b/extlib/benz/string.c @@ -3,6 +3,7 @@ */ #include "picrin.h" +#include "picrin/object.h" struct pic_chunk { char *str;