From f8ff180b94c8e05fec2b1a3bbd6ddc76d685ad64 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 8 Jul 2017 13:00:47 +0200 Subject: [PATCH] Prepare for conditionnal use of m-string by m-bitset. --- m-bitset.h | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/m-bitset.h b/m-bitset.h index cb3be3b9..081d8191 100644 --- a/m-bitset.h +++ b/m-bitset.h @@ -32,7 +32,7 @@ #include #include "m-core.h" -#include "m-string.h" // Only for bitset_get_str function +#include "m-string.h" // Only for bitset_get_str function. // Define a limb of a bitset typedef unsigned int bitset_limb; @@ -505,23 +505,6 @@ bitset_set_str(bitset_t set, const char str[]) return c == ']'; } -// NOTE: Define this function only if m-string has been included -#ifdef __M_STRING_H -static inline void -bitset_get_str(string_t str, const bitset_t set, bool append) -{ - BITSETI_CONTRACT (set); - assert(str != NULL); - (append ? string_cat_str : string_set_str) (str, "["); - for(size_t i = 0; i < set->size; i++) { - const bool b = bitset_get (set, i); - const char c = b ? '1' : '0'; - string_push_back (str, c); - } - string_push_back (str, ']'); -} -#endif - static inline void bitset_and(bitset_t dest, const bitset_t src) { @@ -644,3 +627,25 @@ bitset_hash(const bitset_t dest) // TODO: set_at2, insert_v, remove_v #endif + +// NOTE: Define this function only if m-string has been included +#ifndef __M_BITSET_STRING_H +#ifdef __M_STRING_H +#define __M_BITSET_STRING_H + +static inline void +bitset_get_str(string_t str, const bitset_t set, bool append) +{ + BITSETI_CONTRACT (set); + assert(str != NULL); + (append ? string_cat_str : string_set_str) (str, "["); + for(size_t i = 0; i < set->size; i++) { + const bool b = bitset_get (set, i); + const char c = b ? '1' : '0'; + string_push_back (str, c); + } + string_push_back (str, ']'); +} + +#endif +#endif