tg_geometry 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@
10
10
  #ifndef JSON_STATIC
11
11
  #include "json.h"
12
12
  #else
13
- enum json_type {
13
+ enum json_type {
14
14
  JSON_NULL,
15
15
  JSON_FALSE,
16
16
  JSON_NUMBER,
@@ -77,7 +77,7 @@ static inline int64_t vesc(const uint8_t *json, int64_t jlen, int64_t i) {
77
77
  i += 1;
78
78
  if (i == jlen) return -(i+1);
79
79
  switch (json[i]) {
80
- case '"': case '\\': case '/': case 'b': case 'f': case 'n':
80
+ case '"': case '\\': case '/': case 'b': case 'f': case 'n':
81
81
  case 'r': case 't': return i+1;
82
82
  case 'u':
83
83
  for (int j = 0; j < 4; j++) {
@@ -142,7 +142,7 @@ static int64_t vstring(const uint8_t *json, int64_t jlen, int64_t i) {
142
142
  } else {
143
143
  break;
144
144
  }
145
- }
145
+ }
146
146
  return -(i+1);
147
147
  }
148
148
 
@@ -154,7 +154,7 @@ static int64_t vnumber(const uint8_t *data, int64_t dlen, int64_t i) {
154
154
  if (i == dlen) return -(i+1);
155
155
  if (data[i] < '0' || data[i] > '9') return -(i+1);
156
156
  }
157
- // int
157
+ // int
158
158
  if (data[i] == '0') {
159
159
  i++;
160
160
  } else {
@@ -300,7 +300,7 @@ static int64_t vany(const uint8_t *data, int64_t dlen, int64_t i, int depth) {
300
300
  case 't': return vtrue(data, dlen, i+1);
301
301
  case 'f': return vfalse(data, dlen, i+1);
302
302
  case 'n': return vnull(data, dlen, i+1);
303
- case '-': case '0': case '1': case '2': case '3': case '4':
303
+ case '-': case '0': case '1': case '2': case '3': case '4':
304
304
  case '5': case '6': case '7': case '8': case '9':
305
305
  return vnumber(data, dlen, i+1);
306
306
  }
@@ -479,7 +479,7 @@ static struct json peek_any(uint8_t *raw, uint8_t *end) {
479
479
  case 'n': return take_literal(raw, end, 4);
480
480
  case 't': return take_literal(raw, end, 4);
481
481
  case 'f': return take_literal(raw, end, 5);
482
- case '-': case '0': case '1': case '2': case '3': case '4': case '5':
482
+ case '-': case '0': case '1': case '2': case '3': case '4': case '5':
483
483
  case '6': case '7': case '8': case '9': return take_number(raw, end);
484
484
  }
485
485
  raw++;
@@ -552,7 +552,7 @@ static int strcmpn(const char *a, size_t alen, const char *b, size_t blen) {
552
552
  return cmp;
553
553
  }
554
554
 
555
- static const uint8_t hextoks[256] = {
555
+ static const uint8_t hextoks[256] = {
556
556
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
557
557
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0,
558
558
  0,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -565,12 +565,12 @@ static uint32_t decode_hex(const uint8_t *str) {
565
565
  }
566
566
 
567
567
  static bool is_surrogate(uint32_t cp) {
568
- return cp > 55296 && cp < 57344;
568
+ return cp >= 55296 && cp < 57344;
569
569
  }
570
570
 
571
571
  static uint32_t decode_codepoint(uint32_t cp1, uint32_t cp2) {
572
- return cp1 > 55296 && cp1 < 56320 && cp2 > 56320 && cp2 < 57344 ?
573
- ((cp1 - 55296) << 10) | ((cp2 - 56320) + 65536) :
572
+ return cp1 >= 55296 && cp1 < 56320 && cp2 >= 56320 && cp2 < 57344 ?
573
+ ((cp1 - 55296) << 10) + (cp2 - 56320) + 65536 :
574
574
  65533;
575
575
  }
576
576
 
@@ -599,7 +599,7 @@ static inline int encode_codepoint(uint8_t dst[], uint32_t cp) {
599
599
  }
600
600
 
601
601
  // for_each_utf8 iterates over each UTF-8 bytes in jstr, unescaping along the
602
- // way. 'f' is a loop expression that will make available the 'ch' char which
602
+ // way. 'f' is a loop expression that will make available the 'ch' char which
603
603
  // is just a single byte in a UTF-8 series.
604
604
  #define for_each_utf8(jstr, len, f) { \
605
605
  size_t nn = (len); \
@@ -647,7 +647,7 @@ static inline int encode_codepoint(uint8_t dst[], uint32_t cp) {
647
647
  } \
648
648
  }
649
649
 
650
- JSON_EXTERN
650
+ JSON_EXTERN
651
651
  int json_raw_comparen(struct json json, const char *str, size_t len) {
652
652
  char *raw = (char*)jraw(json);
653
653
  if (!raw) raw = "";
@@ -674,7 +674,7 @@ JSON_EXTERN size_t json_string_length(struct json json) {
674
674
  return count;
675
675
  }
676
676
 
677
- JSON_EXTERN
677
+ JSON_EXTERN
678
678
  int json_string_comparen(struct json json, const char *str, size_t slen) {
679
679
  if (json_type(json) != JSON_STRING) {
680
680
  return json_raw_comparen(json, str, slen);
@@ -703,7 +703,7 @@ done:
703
703
  return cmp;
704
704
  }
705
705
 
706
- JSON_EXTERN
706
+ JSON_EXTERN
707
707
  int json_string_compare(struct json json, const char *str) {
708
708
  return json_string_comparen(json, str, str?strlen(str):0);
709
709
  }
@@ -893,7 +893,7 @@ JSON_EXTERN bool json_bool(struct json json) {
893
893
  case JSON_TRUE:
894
894
  return true;
895
895
  case JSON_NUMBER:
896
- return json_double(json) != 0.0;
896
+ return json_double(json) != 0.0;
897
897
  case JSON_STRING: {
898
898
  char *trues[] = { "1", "t", "T", "true", "TRUE", "True" };
899
899
  for (size_t i = 0; i < sizeof(trues)/sizeof(char*); i++) {
@@ -906,16 +906,16 @@ JSON_EXTERN bool json_bool(struct json json) {
906
906
  }
907
907
  }
908
908
 
909
- struct jesc_buf {
909
+ struct jesc_buf {
910
910
  uint8_t *esc;
911
911
  size_t esclen;
912
912
  size_t count;
913
913
  };
914
914
 
915
915
  static void jesc_append(struct jesc_buf *buf, uint8_t ch) {
916
- if (buf->esclen > 1) {
916
+ if (buf->esclen > 1) {
917
917
  *(buf->esc++) = ch;
918
- buf->esclen--;
918
+ buf->esclen--;
919
919
  }
920
920
  buf->count++;
921
921
  }
@@ -926,7 +926,7 @@ static void jesc_append2(struct jesc_buf *buf, uint8_t c1, uint8_t c2) {
926
926
 
927
927
  static const uint8_t hexchars[] = "0123456789abcdef";
928
928
 
929
- static void
929
+ static void
930
930
  jesc_append_ux(struct jesc_buf *buf, uint8_t c1, uint8_t c2, uint16_t x) {
931
931
  jesc_append2(buf, c1, c2);
932
932
  jesc_append2(buf, hexchars[x>>12&0xF], hexchars[x>>8&0xF]);
@@ -1008,7 +1008,7 @@ struct json json_getn(const char *json_str, size_t len, const char *path) {
1008
1008
  if (*end && *end != '.') { i = 0; break; }
1009
1009
  json = json_array_get(json, index);
1010
1010
  } else {
1011
- i = 0;
1011
+ i = 0;
1012
1012
  break;
1013
1013
  }
1014
1014
  }
@@ -10,7 +10,7 @@
10
10
  #include <stdint.h>
11
11
  #include <stdbool.h>
12
12
 
13
- enum json_type {
13
+ enum json_type {
14
14
  JSON_NULL,
15
15
  JSON_FALSE,
16
16
  JSON_NUMBER,
@@ -39,7 +39,7 @@ struct json_valid json_validn_ex(const char *json_str, size_t len, int opts);
39
39
  // Invalid json is safe and will not cause program errors, but it may return
40
40
  // unexpected results. If you are consuming JSON from an unpredictable source
41
41
  // then you may want to use the 'json_valid' function first.
42
- //
42
+ //
43
43
  // It's important to note that the resulting 'struct json' is backed by the
44
44
  // same memory as json_str, thus a 'struct json' cannot outlive the original
45
45
  // json_str. Attempting to use any of the json_*(struct json...) functions on
@@ -55,19 +55,19 @@ struct json json_parsen(const char *json_str, size_t len);
55
55
  // object or array, then a non-existent json value is returned.
56
56
  struct json json_first(struct json json);
57
57
 
58
- // json_next returns the json's next child.
58
+ // json_next returns the json's next child.
59
59
  //
60
- // This typically follows a 'json_first' call, and is used to iterate over the
60
+ // This typically follows a 'json_first' call, and is used to iterate over the
61
61
  // children in an object or array. For arrays, each 'json_next' call will
62
62
  // return a the next value. For objects, each 'json_next' call alternates over
63
63
  // value, key, value key, value, etc. If there are no more children, then a
64
64
  // non-existent json value is returned.
65
65
  struct json json_next(struct json json);
66
66
 
67
- // json_exists checks for the existence of json.
67
+ // json_exists checks for the existence of json.
68
68
  bool json_exists(struct json json);
69
69
 
70
- // json_type returns the json's type.
70
+ // json_type returns the json's type.
71
71
  //
72
72
  // Returns one of the following: JSON_NULL, JSON_STRING, JSON_NUMBER,
73
73
  // JSON_TRUE, JSON_FALSE, JSON_OBJECT, JSON_ARRAY.
@@ -75,12 +75,12 @@ bool json_exists(struct json json);
75
75
  enum json_type json_type(struct json json);
76
76
 
77
77
  // json_raw returns the start of the raw json data.
78
- //
78
+ //
79
79
  // This function may return NULL if the input is non-existent. Also there is
80
- // no guarentee that this data will be null-terminated C string. If you want to
80
+ // no guarantee that this data will be null-terminated C string. If you want to
81
81
  // retain this data for longer that the data from the original 'json_parse'
82
82
  // call then you should copy it first, such as:
83
- //
83
+ //
84
84
  // size_t len = json_raw_length(json);
85
85
  // char *raw = malloc(len+1);
86
86
  // memcpy(raw, json_raw(json), len);
@@ -108,12 +108,12 @@ int json_raw_comparen(struct json json, const char *str, size_t len);
108
108
  // other, it continues until the characters differ or until the end of the JSON
109
109
  // or a terminating null-character in the C string is reached.
110
110
  //
111
- // If the JSON type is JSON_STRING, then each character that needs to be
111
+ // If the JSON type is JSON_STRING, then each character that needs to be
112
112
  // unescaped is done so in a streaming manner. ie. without the additional
113
113
  // buffering or memory allocations. Of those characters, the ones that are
114
114
  // non-ascii codepoints are encoded into their UTF-8 representation, of which
115
115
  // those bytes are then compared to the C string.
116
- //
116
+ //
117
117
  // If the JSON type is not a JSON_STRING, then it performs a binary comparison
118
118
  // of the raw JSON to the C string.
119
119
  int json_string_compare(struct json json, const char *str);
@@ -131,9 +131,9 @@ bool json_string_is_escaped(struct json json);
131
131
  //
132
132
  // Returns the number of characters, not including the null-terminator, needed
133
133
  // to store the JSON into the C string buffer.
134
- // If the returned length is greater than nbytes-1, then only a parital copy
134
+ // If the returned length is greater than nbytes-1, then only a partial copy
135
135
  // occurred, for example:
136
- //
136
+ //
137
137
  // char buf[64];
138
138
  // size_t len = json_string_copy(json, str, sizeof(str));
139
139
  // if (len > sizeof(str)-1) {
@@ -167,8 +167,8 @@ struct json json_object_getn(struct json json, const char *key, size_t len);
167
167
  // json_array_get functions.
168
168
  //
169
169
  // json_str = "{\"notes\": {\"special.info\": \"it's nice outside\"}";
170
- // json = json_parse(json_str);
171
- // json = json_object_get(json, "notes");
170
+ // json = json_parse(json_str);
171
+ // json = json_object_get(json, "notes");
172
172
  // json = json_object_get(json, "special.info");
173
173
  //
174
174
  struct json json_get(const char *json_str, const char *path);
@@ -190,14 +190,14 @@ uint64_t json_uint64(struct json json);
190
190
  bool json_bool(struct json json);
191
191
 
192
192
  // json_escape is a utility function for converting a C string into a valid
193
- // json string.
193
+ // json string.
194
194
  //
195
195
  // Returns the number of characters, not including the null-terminator, needed
196
196
  // to store the escaped JSON string in the C string buffer.
197
- // If the returned length is greater than n-1, then only a parital copy
198
- // occurred. In other words the
199
- size_t json_escape(const char *str, char *escaped, size_t n);
200
- size_t json_escapen(const char *str, size_t len, char *escaped, size_t n);
197
+ // If the returned length is greater than n-1, then only a partial copy
198
+ // occurred. In other words the
199
+ size_t json_escape(const char *str, char *escaped, size_t n);
200
+ size_t json_escapen(const char *str, size_t len, char *escaped, size_t n);
201
201
 
202
202
  // json_ensure ensures that the json value has been entirely scanned.
203
203
  // Only useful for when you need to call json_raw_length on large objects and
@@ -1,3 +1,3 @@
1
1
  repo=https://github.com/tidwall/rtree.c.git
2
- ref=v0.5.3
3
- commit=5717a8a1eb373428ebaae8c1c623f186ec46461f
2
+ ref=v0.6.1
3
+ commit=eebc774929f89fd5f4095f7c8835a87f2d2fb73f