]> andersk Git - libyaml.git/blobdiff - src/yaml_private.h
Compilation fix for Solaris
[libyaml.git] / src / yaml_private.h
index 6320cafdbeefe185e054bac334559c844ee63ef3..05123285d441a4624a48827e55d85e1fd8af1cc4 100644 (file)
@@ -1,4 +1,3 @@
-
 #if HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -7,6 +6,29 @@
 
 #include <assert.h>
 #include <limits.h>
+#include <stddef.h>
+
+#ifndef _MSC_VER
+#if defined(__sun) || defined(__sun__)
+#include <sys/inttypes.h>
+#define PTRDIFF_MAX INT_MAX
+#else
+#include <stdint.h>
+#ifndef PTRDIFF_MAX /* gcc on HP-UX */
+#ifdef _LP64
+#define PTRDIFF_MAX 0x7FFFFFFFFFFFFFFFLL
+#else
+#define PTRDIFF_MAX 0x7FFFFFFFL
+#endif
+#endif
+#endif
+#else
+#ifdef _WIN64
+#define PTRDIFF_MAX _I64_MAX
+#else
+#define PTRDIFF_MAX INT_MAX
+#endif
+#endif
 
 /*
  * Memory management.
@@ -113,6 +135,11 @@ yaml_string_join(
 
 #define STRING(string,length)   { (string), (string)+(length), (string) }
 
+#define STRING_ASSIGN(value,string,length)                                      \
+    ((value).start = (string),                                                  \
+     (value).end = (string)+(length),                                           \
+     (value).pointer = (string))
+
 #define STRING_INIT(context,string,size)                                        \
     (((string).start = yaml_malloc(size)) ?                                     \
         ((string).pointer = (string).start,                                     \
@@ -127,9 +154,12 @@ yaml_string_join(
      (string).start = (string).pointer = (string).end = 0)
 
 #define STRING_EXTEND(context,string)                                           \
-    (((string).pointer+5 < (string).end)                                        \
+    ((((string).pointer+5 < (string).end)                                       \
         || yaml_string_extend(&(string).start,                                  \
-            &(string).pointer, &(string).end))
+            &(string).pointer, &(string).end)) ?                                \
+         1 :                                                                    \
+        ((context)->error = YAML_MEMORY_ERROR,                                  \
+         0))
 
 #define CLEAR(context,string)                                                   \
     ((string).pointer = (string).start,                                         \
@@ -223,9 +253,9 @@ yaml_string_join(
         (string).pointer[offset] <= (yaml_char_t) 'f') ?                        \
        ((string).pointer[offset] - (yaml_char_t) 'a' + 10) :                    \
        ((string).pointer[offset] - (yaml_char_t) '0'))
+
 #define AS_HEX(string)  AS_HEX_AT((string),0)
+
 /*
  * Check if the character is ASCII.
  */
@@ -416,6 +446,12 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end);
 #define STACK_EMPTY(context,stack)                                              \
     ((stack).start == (stack).top)
 
+#define STACK_LIMIT(context,stack,size)                                         \
+    ((stack).top - (stack).start < (size) ?                                     \
+        1 :                                                                     \
+        ((context)->error = YAML_MEMORY_ERROR,                                  \
+         0))
+
 #define PUSH(context,stack,value)                                               \
     (((stack).top != (stack).end                                                \
       || yaml_stack_extend((void **)&(stack).start,                             \
@@ -632,4 +668,3 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end);
      (node).data.mapping.pairs.end = (node_pairs_end),                          \
      (node).data.mapping.pairs.top = (node_pairs_start),                        \
      (node).data.mapping.style = (node_style))
-
This page took 0.039054 seconds and 4 git commands to generate.