aboutsummaryrefslogtreecommitdiffstats
path: root/src/ucl
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-11-15 14:07:48 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-11-15 14:07:48 +0000
commitc2433f1728704e794e729ac1e3518596218d368e (patch)
tree9a3b0397ce869c6dcc681ffc3e442c3d28c23f90 /src/ucl
parent917f52af5c8180096d541f8c9d6c1b11ce96aaae (diff)
downloadrspamd-c2433f1728704e794e729ac1e3518596218d368e.tar.gz
rspamd-c2433f1728704e794e729ac1e3518596218d368e.zip
Sync with libucl.
Diffstat (limited to 'src/ucl')
-rw-r--r--src/ucl/include/ucl.h3
-rw-r--r--src/ucl/src/ucl_emitter.c2
-rw-r--r--src/ucl/src/ucl_internal.h2
-rw-r--r--src/ucl/src/ucl_parser.c12
-rw-r--r--src/ucl/src/ucl_util.c6
5 files changed, 14 insertions, 11 deletions
diff --git a/src/ucl/include/ucl.h b/src/ucl/include/ucl.h
index 7647ff3b1..52429c0a2 100644
--- a/src/ucl/include/ucl.h
+++ b/src/ucl/include/ucl.h
@@ -136,8 +136,9 @@ enum ucl_string_flags {
UCL_STRING_PARSE_DOUBLE = 0x10, /**< UCL_STRING_PARSE_DOUBLE parse passed string and detect integer or float number */
UCL_STRING_PARSE_NUMBER = UCL_STRING_PARSE_INT|UCL_STRING_PARSE_DOUBLE , /**<
UCL_STRING_PARSE_NUMBER parse passed string and detect number */
- UCL_STRING_PARSE = UCL_STRING_PARSE_BOOLEAN|UCL_STRING_PARSE_NUMBER /**<
+ UCL_STRING_PARSE = UCL_STRING_PARSE_BOOLEAN|UCL_STRING_PARSE_NUMBER, /**<
UCL_STRING_PARSE parse passed string (and detect booleans and numbers) */
+ UCL_STRING_PARSE_BYTES = 0x20 /**< Treat numbers as bytes */
};
/**
diff --git a/src/ucl/src/ucl_emitter.c b/src/ucl/src/ucl_emitter.c
index 2973f1da2..c7d14dc8a 100644
--- a/src/ucl/src/ucl_emitter.c
+++ b/src/ucl/src/ucl_emitter.c
@@ -537,7 +537,7 @@ ucl_elt_array_write_yaml (ucl_object_t *obj, UT_string *buf, unsigned int tabs,
ucl_add_tabs (buf, tabs, false);
}
- utstring_append_len (buf, ": [\n", 4);
+ utstring_append_len (buf, "[\n", 2);
while (cur) {
ucl_elt_write_yaml (cur, buf, tabs + 1, true, false, false);
utstring_append_len (buf, ",\n", 2);
diff --git a/src/ucl/src/ucl_internal.h b/src/ucl/src/ucl_internal.h
index a6d8e096b..6fbd4bf82 100644
--- a/src/ucl/src/ucl_internal.h
+++ b/src/ucl/src/ucl_internal.h
@@ -250,7 +250,7 @@ ucl_maybe_parse_boolean (ucl_object_t *obj, const unsigned char *start, size_t l
* @return 0 if string is numeric and error code (EINVAL or ERANGE) in case of conversion error
*/
int ucl_maybe_parse_number (ucl_object_t *obj,
- const char *start, const char *end, const char **pos, bool allow_double);
+ const char *start, const char *end, const char **pos, bool allow_double, bool number_bytes);
static inline ucl_object_t *
diff --git a/src/ucl/src/ucl_parser.c b/src/ucl/src/ucl_parser.c
index 450a41877..07fe1a3c5 100644
--- a/src/ucl/src/ucl_parser.c
+++ b/src/ucl/src/ucl_parser.c
@@ -270,7 +270,7 @@ ucl_copy_or_store_ptr (struct ucl_parser *parser,
int
ucl_maybe_parse_number (ucl_object_t *obj,
- const char *start, const char *end, const char **pos, bool allow_double)
+ const char *start, const char *end, const char **pos, bool allow_double, bool number_bytes)
{
const char *p = start, *c = start;
char *endptr;
@@ -387,8 +387,8 @@ ucl_maybe_parse_number (ucl_object_t *obj,
p += 2;
goto set_obj;
}
- else if (p[1] == 'b' || p[1] == 'B') {
- /* Megabytes */
+ else if (number_bytes || (p[1] == 'b' || p[1] == 'B')) {
+ /* Bytes */
if (need_double) {
need_double = false;
lv = dv;
@@ -402,7 +402,7 @@ ucl_maybe_parse_number (ucl_object_t *obj,
dv *= ucl_lex_num_multiplier (*p, false);
}
else {
- lv *= ucl_lex_num_multiplier (*p, false);
+ lv *= ucl_lex_num_multiplier (*p, number_bytes);
}
p ++;
goto set_obj;
@@ -428,7 +428,7 @@ ucl_maybe_parse_number (ucl_object_t *obj,
dv *= ucl_lex_num_multiplier (*p, false);
}
else {
- lv *= ucl_lex_num_multiplier (*p, false);
+ lv *= ucl_lex_num_multiplier (*p, number_bytes);
}
p ++;
goto set_obj;
@@ -502,7 +502,7 @@ ucl_lex_number (struct ucl_parser *parser,
const unsigned char *pos;
int ret;
- ret = ucl_maybe_parse_number (obj, chunk->pos, chunk->end, (const char **)&pos, true);
+ ret = ucl_maybe_parse_number (obj, chunk->pos, chunk->end, (const char **)&pos, true, false);
if (ret == 0) {
chunk->remain -= pos - chunk->pos;
diff --git a/src/ucl/src/ucl_util.c b/src/ucl/src/ucl_util.c
index 422b2ea75..b8c779c9a 100644
--- a/src/ucl/src/ucl_util.c
+++ b/src/ucl/src/ucl_util.c
@@ -845,12 +845,14 @@ ucl_object_fromstring_common (const char *str, size_t len, enum ucl_string_flags
if (flags & UCL_STRING_PARSE_BOOLEAN) {
if (!ucl_maybe_parse_boolean (obj, dst, obj->len) && (flags & UCL_STRING_PARSE_NUMBER)) {
ucl_maybe_parse_number (obj, dst, dst + obj->len, &pos,
- flags & UCL_STRING_PARSE_DOUBLE);
+ flags & UCL_STRING_PARSE_DOUBLE,
+ flags & UCL_STRING_PARSE_BYTES);
}
}
else {
ucl_maybe_parse_number (obj, dst, dst + obj->len, &pos,
- flags & UCL_STRING_PARSE_DOUBLE);
+ flags & UCL_STRING_PARSE_DOUBLE,
+ flags & UCL_STRING_PARSE_BYTES);
}
}
}