Make Serialization input of array / dict more flexible
by supporting space characters within the input.
This commit is contained in:
1 parent
34d0f8ec81
commit
2eaeb26d4c
3 files changed
+7
-4
No files matched your search
@@ -778,7 +778,7 @@
|
|||||||
M_GET_INIT oplist (item); \
|
M_GET_INIT oplist (item); \
|
||||||
do { \
|
do { \
|
||||||
bool b = M_GET_IN_STR oplist (item, file); \
|
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; } \
|
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); \
|
} while (c == M_GET_SEPARATOR oplist); \
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/************************ Compiler Macro ***********************/
|
/************************ Compiler Macro ***********************/
|
||||||
|
|||||||
@@ -547,7 +547,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); \
|
||||||
int c = fgetc(file); \
|
int c = fgetc(file); \
|
||||||
if (M_UNLIKELY (c != '{')) return false; \
|
if (M_UNLIKELY (c != '{')) return false; \
|
||||||
c = fgetc(file); \
|
c = fgetc(file); \
|
||||||
if (M_UNLIKELY (c == '}')) return true; \
|
if (M_UNLIKELY (c == '}')) return true; \
|
||||||
@@ -558,15 +558,17 @@
|
|||||||
M_GET_INIT key_oplist (key); \
|
M_GET_INIT key_oplist (key); \
|
||||||
M_GET_INIT value_oplist (value); \
|
M_GET_INIT value_oplist (value); \
|
||||||
do { \
|
do { \
|
||||||
|
do { c = fgetc(file); } while (isspace(c)); \
|
||||||
|
ungetc(c, file); \
|
||||||
bool b = M_GET_IN_STR key_oplist (key, 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 (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 == false) { 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); \
|
do { c = fgetc(file); } while (isspace(c)); \
|
||||||
} while (c == ','); \
|
} 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); \
|
||||||
|
|||||||
Reference in new issue
Block a user