]> source.dussan.org Git - rspamd.git/commitdiff
Sync with libucl.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 15 Nov 2013 14:07:48 +0000 (14:07 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 15 Nov 2013 14:07:48 +0000 (14:07 +0000)
src/ucl/include/ucl.h
src/ucl/src/ucl_emitter.c
src/ucl/src/ucl_internal.h
src/ucl/src/ucl_parser.c
src/ucl/src/ucl_util.c

index 7647ff3b1b2ee23cefa884856a875e3ea4acc484..52429c0a2fd9b6d6414e69fe2409db3827297273 100644 (file)
@@ -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 */
 };
 
 /**
index 2973f1da2a3576f1f58f50bb6880673cc19d387e..c7d14dc8a3d76a1e06d25c437944a6a57e891874 100644 (file)
@@ -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);
index a6d8e096bb861b20d1ef320298d710bfcd63ae37..6fbd4bf8224c98cf9c2b247a65c4838d6e54b705 100644 (file)
@@ -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 *
index 450a4187728762b375085c2423237c096a7f7f02..07fe1a3c55accebdf94525bbcffbdcc37da4da12 100644 (file)
@@ -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;
index 422b2ea753bc046d65a4dc8357820c2b357016a0..b8c779c9abcdf8d3abff771671cebec195cc9725 100644 (file)
@@ -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);
                        }
                }
        }