From 59290204295ff5e73028b6ec7bbf1343b78ec986 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 16 Jan 2014 21:32:22 +0900 Subject: [PATCH] reordering functions --- src/write.c | 65 ++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/src/write.c b/src/write.c index 7ea9b5fa..e54bba13 100644 --- a/src/write.c +++ b/src/write.c @@ -4,8 +4,38 @@ #include "picrin/blob.h" #include "picrin/macro.h" -static void write_pair(pic_state *pic, struct pic_pair *pair); -static void write_str(pic_state *pic, struct pic_string *str); +static void write(pic_state *, pic_value); + +static void +write_pair(pic_state *pic, struct pic_pair *pair) +{ + write(pic, pair->car); + + if (pic_nil_p(pair->cdr)) { + return; + } + if (pic_pair_p(pair->cdr)) { + printf(" "); + write_pair(pic, pic_pair_ptr(pair->cdr)); + return; + } + printf(" . "); + write(pic, pair->cdr); +} + +static void +write_str(pic_state *pic, struct pic_string *str) +{ + int i; + const char *cstr = str->str; + + for (i = 0; i < str->len; ++i) { + if (cstr[i] == '"' || cstr[i] == '\\') { + putchar('\\'); + } + putchar(cstr[i]); + } +} static void write(pic_state *pic, pic_value obj) @@ -115,37 +145,6 @@ write(pic_state *pic, pic_value obj) } } -static void -write_pair(pic_state *pic, struct pic_pair *pair) -{ - write(pic, pair->car); - - if (pic_nil_p(pair->cdr)) { - return; - } - if (pic_pair_p(pair->cdr)) { - printf(" "); - write_pair(pic, pic_pair_ptr(pair->cdr)); - return; - } - printf(" . "); - write(pic, pair->cdr); -} - -static void -write_str(pic_state *pic, struct pic_string *str) -{ - int i; - const char *cstr = str->str; - - for (i = 0; i < str->len; ++i) { - if (cstr[i] == '"' || cstr[i] == '\\') { - putchar('\\'); - } - putchar(cstr[i]); - } -} - void pic_debug(pic_state *pic, pic_value obj) {