]> source.dussan.org Git - rspamd.git/commitdiff
Merge from libucl.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 19 Oct 2015 17:53:39 +0000 (18:53 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 19 Oct 2015 17:53:39 +0000 (18:53 +0100)
contrib/libucl/ucl.h
contrib/libucl/ucl_chartable.h
contrib/libucl/ucl_internal.h
contrib/libucl/ucl_parser.c
contrib/libucl/ucl_util.c

index bd209295bcb16e0182168e0158af520a07e399f2..82a1fd1880f390ccb3c4a26b9643d355ba8bb617 100644 (file)
@@ -740,7 +740,7 @@ UCL_EXTERN int ucl_object_compare (const ucl_object_t *o1,
  * @param cmp
  */
 UCL_EXTERN void ucl_object_array_sort (ucl_object_t *ar,
-               int (*cmp)(const ucl_object_t *o1, const ucl_object_t *o2));
+               int (*cmp)(const ucl_object_t **o1, const ucl_object_t **o2));
 
 /**
  * Get the priority for specific UCL object
index 5248e117c63ddb3246837662cc077f9176f56535..db9f02900c0201f46de386425173d189c3450e56 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "ucl_internal.h"
 
-static const unsigned int ucl_chartable[255] = {
+static const unsigned int ucl_chartable[256] = {
 UCL_CHARACTER_VALUE_END, UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED,
 UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED,
 UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED,
@@ -255,6 +255,7 @@ UCL_CHARACTER_KEY_START|UCL_CHARACTER_KEY|UCL_CHARACTER_VALUE_STR,
 UCL_CHARACTER_KEY_START|UCL_CHARACTER_KEY|UCL_CHARACTER_VALUE_STR,
 UCL_CHARACTER_KEY_START|UCL_CHARACTER_KEY|UCL_CHARACTER_VALUE_STR,
 UCL_CHARACTER_KEY_START|UCL_CHARACTER_KEY|UCL_CHARACTER_VALUE_STR,
+UCL_CHARACTER_KEY_START|UCL_CHARACTER_KEY|UCL_CHARACTER_VALUE_STR,
 UCL_CHARACTER_KEY_START|UCL_CHARACTER_KEY|UCL_CHARACTER_VALUE_STR
 };
 
index da7df1270b677aa4bb88256941249c7d89567cf0..31d6b1361383b405cd812360d4ff97e4aaa8731f 100644 (file)
@@ -309,7 +309,6 @@ __attribute__ (( format( printf, 2, 3) ));
 
 static inline void
 ucl_create_err (UT_string **err, const char *fmt, ...)
-
 {
        if (*err == NULL) {
                utstring_new (*err);
index ae8b3c2591698847d0b0d3b9e7985892bb58f9dd..9bd41391ba36eb7e61ffc4c32bf49c534586f0e1 100644 (file)
@@ -2102,20 +2102,36 @@ ucl_state_machine (struct ucl_parser *parser)
                                        *p != '(') {
                                ucl_chunk_skipc (chunk, p);
                        }
-                       else if (p - c > 0) {
-                               /* We got macro name */
-                               macro_len = (size_t)(p - c);
-                               HASH_FIND (hh, parser->macroes, c, macro_len, macro);
-                               if (macro == NULL) {
-                                       ucl_create_err (&parser->err, "error on line %d at column %d: "
-                                                       "unknown macro: '%.*s', character: '%c'",
-                                                               chunk->line, chunk->column, (int)(p - c), c, *chunk->pos);
+                       else {
+                               if (p - c > 0) {
+                                       /* We got macro name */
+                                       macro_len = (size_t) (p - c);
+                                       HASH_FIND (hh, parser->macroes, c, macro_len, macro);
+                                       if (macro == NULL) {
+                                               ucl_create_err (&parser->err,
+                                                               "error on line %d at column %d: "
+                                                                               "unknown macro: '%.*s', character: '%c'",
+                                                               chunk->line,
+                                                               chunk->column,
+                                                               (int) (p - c),
+                                                               c,
+                                                               *chunk->pos);
+                                               parser->state = UCL_STATE_ERROR;
+                                               return false;
+                                       }
+                                       /* Now we need to skip all spaces */
+                                       SKIP_SPACES_COMMENTS(parser, chunk, p);
+                                       parser->state = UCL_STATE_MACRO;
+                               }
+                               else {
+                                       /* We have invalid macro name */
+                                       ucl_create_err (&parser->err,
+                                                       "error on line %d at column %d: invalid macro name",
+                                                       chunk->line,
+                                                       chunk->column);
                                        parser->state = UCL_STATE_ERROR;
                                        return false;
                                }
-                               /* Now we need to skip all spaces */
-                               SKIP_SPACES_COMMENTS(parser, chunk, p);
-                               parser->state = UCL_STATE_MACRO;
                        }
                        break;
                case UCL_STATE_MACRO:
index 9ea151e37c4bc46c9b79d79f1cad2b235231e7c7..730a5c4afd57d18c6ad26a9148d9278cf4cc2099 100644 (file)
@@ -3219,7 +3219,7 @@ ucl_object_compare (const ucl_object_t *o1, const ucl_object_t *o2)
 
 void
 ucl_object_array_sort (ucl_object_t *ar,
-               int (*cmp)(const ucl_object_t *o1, const ucl_object_t *o2))
+               int (*cmp)(const ucl_object_t **o1, const ucl_object_t **o2))
 {
        UCL_ARRAY_GET (vec, ar);