]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Import nan support from libucl
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 29 Mar 2018 12:47:38 +0000 (13:47 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 29 Mar 2018 12:47:38 +0000 (13:47 +0100)
contrib/libucl/ucl_parser.c

index fedd5065cb27202af05c7a31d00aac3eca4706d0..339b93dffdfe2550bc3e7b38d463aa4720ffb8ae 100644 (file)
@@ -21,6 +21,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <math.h>
 #include "ucl.h"
 #include "ucl_internal.h"
 #include "ucl_chartable.h"
@@ -1832,6 +1833,16 @@ parse_string:
                                obj->len = 0;
                                obj->type = UCL_NULL;
                        }
+                       else if (str_len == 3 && memcmp (c, "nan", 3) == 0) {
+                               obj->len = 0;
+                               obj->type = UCL_FLOAT;
+                               obj->value.dv = NAN;
+                       }
+                       else if (str_len == 3 && memcmp (c, "inf", 3) == 0) {
+                               obj->len = 0;
+                               obj->type = UCL_FLOAT;
+                               obj->value.dv = INFINITY;
+                       }
                        else if (!ucl_maybe_parse_boolean (obj, c, str_len)) {
                                obj->type = UCL_STRING;
                                if ((str_len = ucl_copy_or_store_ptr (parser, c,
@@ -1842,8 +1853,8 @@ parse_string:
                                }
                                obj->len = str_len;
                        }
+
                        parser->state = UCL_STATE_AFTER_VALUE;
-                       p = chunk->pos;
 
                        return true;
                        break;