Remove use of feof and ferror as it is not needed as the return of fgetc

is sufficent.
This commit is contained in:
Patrick Pelissier committed 2017-08-19 21:05:55 +02:00
1 parent 7ddb7e63b7
commit 44cdfa0c77
8 files changed
+21 -21

No files matched your search

+3 -3
View File
@@ -681,7 +681,7 @@
ARRAYI_CONTRACT(array); \ ARRAYI_CONTRACT(array); \
assert (file != NULL); \ assert (file != NULL); \
M_C(name,_clean)(array); \ M_C(name,_clean)(array); \
char c = fgetc(file); \ int c = fgetc(file); \
if (c != '[') return false; \ if (c != '[') return false; \
c = fgetc(file); \ c = fgetc(file); \
if (c == ']') return true; \ if (c == ']') return true; \
@@ -691,9 +691,9 @@
do { \ do { \
bool b = M_GET_IN_STR oplist (item, file); \ bool b = M_GET_IN_STR oplist (item, file); \
c = fgetc(file); \ c = fgetc(file); \
if (!b) { break; } \ if (b == false || c == EOF) { break; } \
M_C(name, _push_back)(array, item); \ M_C(name, _push_back)(array, item); \
} while (c == M_GET_SEPARATOR oplist && !feof(file) && !ferror(file)); \ } while (c == M_GET_SEPARATOR oplist); \
M_GET_CLEAR oplist (item); \ M_GET_CLEAR oplist (item); \
ARRAYI_CONTRACT(array); \ ARRAYI_CONTRACT(array); \
return c == ']'; \ return c == ']'; \
+2 -2
View File
@@ -510,7 +510,7 @@ bitset_in_str(bitset_t set, FILE *file)
BITSETI_CONTRACT (set); BITSETI_CONTRACT (set);
assert(file != NULL); assert(file != NULL);
bitset_clean(set); bitset_clean(set);
char c = fgetc(file); int c = fgetc(file);
if (c != '[') return false; if (c != '[') return false;
c = fgetc(file); c = fgetc(file);
do { do {
@@ -518,7 +518,7 @@ bitset_in_str(bitset_t set, FILE *file)
const bool b = (c == '1'); const bool b = (c == '1');
bitset_push_back (set, b); bitset_push_back (set, b);
c = fgetc(file); c = fgetc(file);
} while (c != ']' && !feof(file) && !ferror(file)); } while (c != ']' && c != EOF);
BITSETI_CONTRACT (set); BITSETI_CONTRACT (set);
return c == ']'; return c == ']';
} }
+4 -4
View File
@@ -503,7 +503,7 @@
assert (file != NULL); \ assert (file != NULL); \
DICTI_CONTRACT(name, dict); \ DICTI_CONTRACT(name, dict); \
M_C(name, _clean)(dict); \ M_C(name, _clean)(dict); \
char c = fgetc(file); \ int c = fgetc(file); \
if (c != '{') return false; \ if (c != '{') return false; \
c = fgetc(file); \ c = fgetc(file); \
if (c == '}') return true; \ if (c == '}') return true; \
@@ -515,14 +515,14 @@
do { \ do { \
bool b = M_GET_IN_STR key_oplist (key, file); \ bool b = M_GET_IN_STR key_oplist (key, file); \
c = fgetc(file); \ c = fgetc(file); \
if (!b) { break; } \ if (b == false || c == EOF) { break; } \
if (c != ':') { c = 0; break; } \ if (c != ':') { c = 0; break; } \
b = M_GET_IN_STR value_oplist (value, file); \ b = M_GET_IN_STR value_oplist (value, file); \
if (!b) { c = 0; break; } \ if (b == false) { c = 0; break; } \
M_C(name, _set_at)(dict, key \ M_C(name, _set_at)(dict, key \
M_IF(isSet)( , M_DEFERRED_COMMA value)); \ M_IF(isSet)( , M_DEFERRED_COMMA value)); \
c = fgetc(file); \ c = fgetc(file); \
} while (c == ',' && !feof(file) && !ferror(file)); \ } while (c == ','); \
M_GET_CLEAR key_oplist (key); \ M_GET_CLEAR key_oplist (key); \
M_GET_CLEAR value_oplist (value); \ M_GET_CLEAR value_oplist (value); \
return c == '}'; \ return c == '}'; \
+3 -3
View File
@@ -525,7 +525,7 @@
{ \ { \
assert (file != NULL && list != NULL); \ assert (file != NULL && list != NULL); \
M_C(name,_clean)(list); \ M_C(name,_clean)(list); \
char c = fgetc(file); \ int c = fgetc(file); \
if (c != '[') return false; \ if (c != '[') return false; \
c = fgetc(file); \ c = fgetc(file); \
if (c == ']') return true; \ if (c == ']') return true; \
@@ -535,9 +535,9 @@
do { \ do { \
bool b = M_GET_IN_STR oplist (item, file); \ bool b = M_GET_IN_STR oplist (item, file); \
c = fgetc(file); \ c = fgetc(file); \
if (!b) { break; } \ if (b == false || c == EOF) { break; } \
M_C(name, _push_back)(list, item); \ M_C(name, _push_back)(list, item); \
} while (c == M_GET_SEPARATOR oplist && !feof(file) && !ferror(file)); \ } while (c == M_GET_SEPARATOR oplist); \
M_GET_CLEAR oplist (item); \ M_GET_CLEAR oplist (item); \
M_C(name, _reverse)(list); \ M_C(name, _reverse)(list); \
return c == ']'; \ return c == ']'; \
+3 -3
View File
@@ -947,7 +947,7 @@ typedef enum {
RBTREEI_CONTRACT(rbtree); \ RBTREEI_CONTRACT(rbtree); \
assert (file != NULL); \ assert (file != NULL); \
M_C(name,_clean)(rbtree); \ M_C(name,_clean)(rbtree); \
char c = fgetc(file); \ int c = fgetc(file); \
if (c != '[') return false; \ if (c != '[') return false; \
c = fgetc(file); \ c = fgetc(file); \
if (c == ']') return true; \ if (c == ']') return true; \
@@ -957,9 +957,9 @@ typedef enum {
do { \ do { \
bool b = M_GET_IN_STR oplist (item, file); \ bool b = M_GET_IN_STR oplist (item, file); \
c = fgetc(file); \ c = fgetc(file); \
if (!b) break; \ if (b == false || c == EOF) break; \
M_C(name, _push)(rbtree, item); \ M_C(name, _push)(rbtree, item); \
} while (c == M_GET_SEPARATOR oplist && !feof(file) && !ferror(file)); \ } while (c == M_GET_SEPARATOR oplist); \
M_GET_CLEAR oplist (item); \ M_GET_CLEAR oplist (item); \
return c == ']'; \ return c == ']'; \
} \ } \
+2 -2
View File
@@ -794,11 +794,11 @@ string_in_str(string_t v, FILE *f)
{ {
STRING_CONTRACT(v); STRING_CONTRACT(v);
M_ASSUME (f != NULL); M_ASSUME (f != NULL);
char c = fgetc(f); int c = fgetc(f);
if (c != '"') return false; if (c != '"') return false;
string_clean(v); string_clean(v);
c = fgetc(f); c = fgetc(f);
while (c != '"' && !feof(f) && !ferror(f)) { while (c != '"' && c != EOF) {
if (c == '\\') { if (c == '\\') {
c = getc(f); c = getc(f);
if (c != '"') string_push_back (v, '\\'); if (c != '"') string_push_back (v, '\\');
+2 -2
View File
@@ -230,7 +230,7 @@
static inline bool M_C(name, _in_str)(M_C(name,_t) el, FILE *f) { \ static inline bool M_C(name, _in_str)(M_C(name,_t) el, FILE *f) { \
bool comma = false; \ bool comma = false; \
assert (f != NULL && el != NULL); \ assert (f != NULL && el != NULL); \
char c = fgetc(f); \ int c = fgetc(f); \
if (c != '(') return false; \ if (c != '(') return false; \
M_MAP(TUPLE_DEFINE_IN_STR_FUNC , __VA_ARGS__) \ M_MAP(TUPLE_DEFINE_IN_STR_FUNC , __VA_ARGS__) \
c = fgetc(f); \ c = fgetc(f); \
@@ -239,7 +239,7 @@
#define TUPLE_DEFINE_IN_STR_FUNC(a) \ #define TUPLE_DEFINE_IN_STR_FUNC(a) \
if (comma) { \ if (comma) { \
c = fgetc (f); \ c = fgetc (f); \
if (c != ',' || feof(f) || ferror(f)) return false; \ if (c != ',' || c == EOF) return false; \
} \ } \
comma = true; \ comma = true; \
if (TUPLE_GET_IN_STR a (el -> TUPLE_GET_FIELD a, f) == false) \ if (TUPLE_GET_IN_STR a (el -> TUPLE_GET_FIELD a, f) == false) \
+2 -2
View File
@@ -364,9 +364,9 @@
char variantTypeBuf[400]; \ char variantTypeBuf[400]; \
if (fgetc(f) != '@') return false; \ if (fgetc(f) != '@') return false; \
/* First read the name of the type */ \ /* First read the name of the type */ \
char c = fgetc(f); \ int c = fgetc(f); \
unsigned int i = 0; \ unsigned int i = 0; \
while (c != '@' && !feof(f) && !ferror(f) && i < sizeof(variantTypeBuf) - 1) { \ while (c != '@' && c != EOF && i < sizeof(variantTypeBuf) - 1) { \
variantTypeBuf[i++] = c; \ variantTypeBuf[i++] = c; \
c = fgetc(f); \ c = fgetc(f); \
} \ } \