Make Serialization input of array / dict more flexible

by supporting space characters within the input.
This commit is contained in:
Patrick Pelissier committed 2018-04-30 11:02:42 +02:00
1 parent 34d0f8ec81
commit 2eaeb26d4c
3 files changed
+7 -4

No files matched your search

+1 -1
View File
@@ -778,7 +778,7 @@
M_GET_INIT oplist (item); \
do { \
bool b = M_GET_IN_STR oplist (item, file); \
c = fgetc(file); \
do { c = fgetc(file); } while (isspace(c)); \
if (b == false || c == EOF) { break; } \
M_C(name, _push_back)(array, item); \
} while (c == M_GET_SEPARATOR oplist); \
+1
View File
@@ -32,6 +32,7 @@
#include <limits.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
/***************************************************************/
/************************ Compiler Macro ***********************/
+5 -3
View File
@@ -547,7 +547,7 @@
assert (file != NULL); \
DICTI_CONTRACT(name, dict); \
M_C(name, _clean)(dict); \
int c = fgetc(file); \
int c = fgetc(file); \
if (M_UNLIKELY (c != '{')) return false; \
c = fgetc(file); \
if (M_UNLIKELY (c == '}')) return true; \
@@ -558,15 +558,17 @@
M_GET_INIT key_oplist (key); \
M_GET_INIT value_oplist (value); \
do { \
do { c = fgetc(file); } while (isspace(c)); \
ungetc(c, file); \
bool b = M_GET_IN_STR key_oplist (key, file); \
c = fgetc(file); \
do { c = fgetc(file); } while (isspace(c)); \
if (b == false || c == EOF) { break; } \
if (c != ':') { c = 0; break; } \
b = M_GET_IN_STR value_oplist (value, file); \
if (b == false) { c = 0; break; } \
M_C(name, _set_at)(dict, key \
M_IF(isSet)( , M_DEFERRED_COMMA value)); \
c = fgetc(file); \
do { c = fgetc(file); } while (isspace(c)); \
} while (c == ','); \
M_GET_CLEAR key_oplist (key); \
M_GET_CLEAR value_oplist (value); \