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