diff --git a/m-array.h b/m-array.h index 0353e468..939ab571 100644 --- a/m-array.h +++ b/m-array.h @@ -596,12 +596,15 @@ M_C3(array_, name,_clean)(array); \ char c = fgetc(file); \ if (c != '[') return false; \ + c = fgetc(file); \ + if (c == ']') return true; \ + ungetc(c, file); \ type item; \ M_GET_INIT oplist (item); \ do { \ bool b = M_GET_IN_STR oplist (item, file); \ c = fgetc(file); \ - if (!b) { /* How to push back char in stream ? */ break; } \ + if (!b) { break; } \ M_C3(array_, name, _push_back)(array, item); \ } while (c == M_GET_SEPARATOR oplist && !feof(file) && !ferror(file)); \ M_GET_CLEAR oplist (item); \ diff --git a/m-bitset.h b/m-bitset.h index 819f7d6f..6256386c 100644 --- a/m-bitset.h +++ b/m-bitset.h @@ -429,7 +429,7 @@ bitset_in_str(bitset_t set, FILE *file) if (c != '[') return false; c = fgetc(file); do { - if (c != '0' && c != '1') return false; + if (c != '0' && c != '1') break; bool b = (c == '1'); bitset_push_back (set, b); c = fgetc(file); diff --git a/m-dict.h b/m-dict.h index 31ebcb1e..99841c1e 100644 --- a/m-dict.h +++ b/m-dict.h @@ -403,6 +403,9 @@ M_C3(dict_, name, _clean)(dict); \ char c = fgetc(file); \ if (c != '{') return false; \ + c = fgetc(file); \ + if (c == '}') return true; \ + ungetc(c, file); \ key_type key; \ value_type value; \ M_GET_INIT key_oplist (key); \ diff --git a/m-list.h b/m-list.h index 9a956ad0..fc1e7fa2 100644 --- a/m-list.h +++ b/m-list.h @@ -511,6 +511,9 @@ M_C3(list_, name,_clean)(list); \ char c = fgetc(file); \ if (c != '[') return false; \ + c = fgetc(file); \ + if (c == ']') return true; \ + ungetc(c, file); \ type item; \ M_GET_INIT oplist (item); \ do { \ diff --git a/m-rbtree.h b/m-rbtree.h index 9dde9a84..ea33f18e 100644 --- a/m-rbtree.h +++ b/m-rbtree.h @@ -852,6 +852,9 @@ typedef enum { M_C3(rbtree_, name,_clean)(rbtree); \ char c = fgetc(file); \ if (c != '[') return false; \ + c = fgetc(file); \ + if (c == ']') return true; \ + ungetc(c, file); \ type item; \ M_GET_INIT oplist (item); \ do { \ diff --git a/tests/test-marray.c b/tests/test-marray.c index 380dac9f..8d1bfb67 100644 --- a/tests/test-marray.c +++ b/tests/test-marray.c @@ -163,7 +163,7 @@ static void test_mpz(void) f = fopen ("a.dat", "rt"); if (!f) abort(); bool b = array_mpz_in_str (array2, f); - //assert (b == true); // The test fail. How to fix? + assert (b == true); // The test fail. How to fix? assert (array_mpz_equal_p (array1, array2)); fclose(f);