From eccf7ab6d440a29f18f90b5b64a9b613ffad71ce Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 20 Oct 2019 13:24:43 +0200 Subject: [PATCH] core: Prepare for M2-Planet: hash.c. * src/hash.c: Rewrite C constructs not supported by M2-Planet. --- src/hash.c | 9 +++++---- src/lib.c | 10 +++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/hash.c b/src/hash.c index e85777d7..7e43de25 100644 --- a/src/hash.c +++ b/src/hash.c @@ -28,7 +28,7 @@ int hash_cstring (char const *s, long size) { int hash = s[0] * 37; - if (s[0] && s[1]) + if (s[0] != 0 && s[1] != 0) hash = hash + s[1] * 43; assert (size); hash = hash % size; @@ -183,7 +183,8 @@ hash_table_printer (SCM table) fdputc (' ', __stdout); SCM buckets = struct_ref_ (table, 4); fdputs ("buckets: ", __stdout); - for (int i = 0; i < LENGTH (buckets); i++) + int i; + for (i = 0; i < LENGTH (buckets); i = i + 1) { SCM e = vector_ref_ (buckets, i); if (e != cell_unspecified) @@ -203,7 +204,7 @@ hash_table_printer (SCM table) } SCM -make_hashq_type () ///((internal)) +make_hashq_type () /*:((internal)) */ { SCM record_type = cell_symbol_record_type; // FIXME SCM fields = cell_nil; @@ -217,7 +218,7 @@ make_hashq_type () ///((internal)) SCM make_hash_table_ (long size) { - if (!size) + if (size == 0) size = 100; SCM hashq_type = make_hashq_type (); diff --git a/src/lib.c b/src/lib.c index 424a1ccc..0d68cbbf 100644 --- a/src/lib.c +++ b/src/lib.c @@ -281,14 +281,14 @@ write_port_ (SCM x, SCM p) } SCM -fdisplay_ (SCM x, int fd, int write_p) ///((internal)) +fdisplay_ (SCM x, int fd, int write_p) /**((internal))*/ { g_depth = 5; return display_helper (x, 0, "", fd, write_p); } SCM -exit_ (SCM x) ///((name . "exit")) +exit_ (SCM x) /**((name . "exit"))*/ { assert (TYPE (x) == TNUMBER); exit (VALUE (x)); @@ -306,7 +306,7 @@ frame_printer (SCM frame) } SCM -make_frame_type () ///((internal)) +make_frame_type () /**((internal))*/ { SCM record_type = cell_symbol_record_type; // FIXME SCM fields = cell_nil; @@ -331,7 +331,7 @@ make_frame (SCM stack, long index) } SCM -make_stack_type () ///((internal)) +make_stack_type () /**((internal))*/ { SCM record_type = cell_symbol_record_type; // FIXME SCM fields = cell_nil; @@ -342,7 +342,7 @@ make_stack_type () ///((internal)) } SCM -make_stack (SCM stack) ///((arity . n)) +make_stack (SCM stack) /**((arity . n))*/ { SCM stack_type = make_stack_type (); long size = (STACK_SIZE - g_stack) / FRAME_SIZE;