From 2eaeb26d4c3cffa6e024697f03efe0d76f350216 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Mon, 30 Apr 2018 11:02:42 +0200 Subject: [PATCH] Make Serialization input of array / dict more flexible by supporting space characters within the input. --- m-array.h | 2 +- m-core.h | 1 + m-dict.h | 8 +++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/m-array.h b/m-array.h index 5f66659e..90bde100 100644 --- a/m-array.h +++ b/m-array.h @@ -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); \ diff --git a/m-core.h b/m-core.h index c0107ef3..99598b52 100644 --- a/m-core.h +++ b/m-core.h @@ -32,6 +32,7 @@ #include #include #include +#include /***************************************************************/ /************************ Compiler Macro ***********************/ diff --git a/m-dict.h b/m-dict.h index 6ae6c015..a8415fb3 100644 --- a/m-dict.h +++ b/m-dict.h @@ -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); \