Fix #3 (Empty containers & IN_STR operator).

This commit is contained in:
Patrick Pelissier committed 2017-03-10 01:29:49 +01:00
1 parent 6464acff57
commit e21b45d9ac
6 files changed
+15 -3

No files matched your search

+4 -1
View File
@@ -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); \
+1 -1
View File
@@ -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);
+3
View File
@@ -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); \
+3
View File
@@ -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 { \
+3
View File
@@ -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 { \
+1 -1
View File
@@ -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);