csonpath 0.19.0__tar.gz → 0.20.0__tar.gz
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.
- {csonpath-0.19.0 → csonpath-0.20.0}/Makefile +6 -2
- {csonpath-0.19.0/csonpath.egg-info → csonpath-0.20.0}/PKG-INFO +1 -1
- {csonpath-0.19.0 → csonpath-0.20.0/csonpath.egg-info}/PKG-INFO +1 -1
- {csonpath-0.19.0 → csonpath-0.20.0}/csonpath.h +111 -46
- {csonpath-0.19.0 → csonpath-0.20.0}/csonpath_do.h +8 -6
- {csonpath-0.19.0 → csonpath-0.20.0}/csonpath_my_fuzzing.h +1 -1
- {csonpath-0.19.0 → csonpath-0.20.0}/pyproject.toml +2 -2
- {csonpath-0.19.0 → csonpath-0.20.0}/LICENSE +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/MANIFEST.in +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/README.md +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/configure +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/csonpath.egg-info/SOURCES.txt +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/csonpath.egg-info/dependency_links.txt +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/csonpath.egg-info/requires.txt +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/csonpath.egg-info/top_level.txt +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/csonpath_json-c.h +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/csonpath_python.c +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/csonpath_undef.h +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/csonpath_yyjson.h +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/csonpath_yyjson_const.h +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/csonpath_yyjson_mut.h +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/setup.cfg +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/setup.py +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/.git +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/.github/workflows/c-cpp.yml +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/.gitignore +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/LICENSE +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/Makefile +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/README.md +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/clib.json +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/formal_verification.md +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/re.c +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/re.h +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/scripts/exrex.py +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/scripts/regex_test.py +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/scripts/regex_test_neg.py +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/tests/test1.c +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/tests/test2.c +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/tests/test3.c +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/tests/test_compile.c +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/tests/test_print.c +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/tests/test_rand.c +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/tests/test_rand_neg.c +0 -0
- {csonpath-0.19.0 → csonpath-0.20.0}/tiny-regex-c/tests/test_thread.c +0 -0
|
@@ -5,7 +5,7 @@ YYJSON_LDFLAGS=$(shell pkg-config --libs yyjson)
|
|
|
5
5
|
|
|
6
6
|
include config.mk
|
|
7
7
|
|
|
8
|
-
all: test-json-c-get-a test-json-update test-json-filter test-json-subpath test-json-c-array-root test-json-filter-and-missing-key test-json-get-array-big-index test-json-union test-json-audit-bugs test-json-crash-vectors test-json-my-fuzz test-json-regex-overflow
|
|
8
|
+
all: test-json-c-get-a test-json-update test-json-filter test-json-subpath test-json-c-array-root test-json-filter-and-missing-key test-json-get-array-big-index test-json-union test-json-audit-bugs test-json-crash-vectors test-json-my-fuzz test-json-regex-overflow test-json-long-deep-keys
|
|
9
9
|
|
|
10
10
|
YYJSON_TESTS=test-yyjson
|
|
11
11
|
|
|
@@ -55,6 +55,9 @@ test-json-my-fuzz: tests/json-c/my_fuzz.c csonpath_json-c.h csonpath_my_fuzzing.
|
|
|
55
55
|
test-json-regex-overflow: tests/json-c/regex-overflow.c csonpath_json-c.h csonpath.h csonpath_do.h
|
|
56
56
|
$(CC) tests/json-c/regex-overflow.c $(EXTRA_FILES) $(JSON_C_CFLAGS) $(CFLAGS) -Wno-format -I./ -o test-json-regex-overflow $(JSON_C_LDFLAGS) $(LDFLAGS)
|
|
57
57
|
|
|
58
|
+
test-json-long-deep-keys: tests/json-c/long-deep-keys.c csonpath_json-c.h csonpath.h csonpath_do.h
|
|
59
|
+
$(CC) tests/json-c/long-deep-keys.c $(EXTRA_FILES) $(JSON_C_CFLAGS) $(CFLAGS) -Wno-format -I./ -o test-json-long-deep-keys $(JSON_C_LDFLAGS) $(LDFLAGS)
|
|
60
|
+
|
|
58
61
|
test-yyjson: tests/yyjson/test-yyjson.c csonpath_yyjson_const.h csonpath.h csonpath_do.h
|
|
59
62
|
$(CC) tests/yyjson/test-yyjson.c $(EXTRA_FILES) $(YYJSON_CFLAGS) $(CFLAGS) -Wno-format -I./ -o test-yyjson $(YYJSON_LDFLAGS) $(LDFLAGS)
|
|
60
63
|
|
|
@@ -64,7 +67,7 @@ test-yyjson-mixed: tests/yyjson/test-yyjson-mixed.c csonpath_yyjson.h csonpath_y
|
|
|
64
67
|
test-multi-backend-prefix: tests/multi-backend-prefix.c csonpath_json-c.h csonpath_yyjson.h csonpath_yyjson_const.h csonpath_yyjson_mut.h csonpath.h csonpath_do.h
|
|
65
68
|
$(CC) tests/multi-backend-prefix.c $(EXTRA_FILES) $(JSON_C_CFLAGS) $(YYJSON_CFLAGS) $(CFLAGS) -Wno-format -I./ -o test-multi-backend-prefix $(JSON_C_LDFLAGS) $(YYJSON_LDFLAGS) $(LDFLAGS)
|
|
66
69
|
|
|
67
|
-
tests-c: test-json-c-get-a test-json-update test-json-filter test-json-subpath test-json-c-array-root test-json-filter-and-missing-key test-json-get-array-big-index test-json-union test-json-audit-bugs test-json-crash-vectors test-yyjson test-yyjson-mixed test-json-my-fuzz test-multi-backend-prefix test-json-regex-overflow
|
|
70
|
+
tests-c: test-json-c-get-a test-json-update test-json-filter test-json-subpath test-json-c-array-root test-json-filter-and-missing-key test-json-get-array-big-index test-json-union test-json-audit-bugs test-json-crash-vectors test-yyjson test-yyjson-mixed test-json-my-fuzz test-multi-backend-prefix test-json-regex-overflow test-json-long-deep-keys
|
|
68
71
|
./test-json-c-get-a
|
|
69
72
|
./test-json-update
|
|
70
73
|
./test-json-filter
|
|
@@ -80,6 +83,7 @@ tests-c: test-json-c-get-a test-json-update test-json-filter test-json-subpath t
|
|
|
80
83
|
./test-json-my-fuzz
|
|
81
84
|
./test-multi-backend-prefix
|
|
82
85
|
./test-json-regex-overflow
|
|
86
|
+
./test-json-long-deep-keys
|
|
83
87
|
|
|
84
88
|
csonpath: cli/csonpath_cli.c csonpath_json-c.h csonpath.h csonpath_do.h
|
|
85
89
|
$(CC) cli/csonpath_cli.c $(EXTRA_FILES) $(JSON_C_CFLAGS) $(CFLAGS) -I./ -o csonpath $(JSON_C_LDFLAGS) $(LDFLAGS)
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
|
|
23
23
|
#include <stdio.h>
|
|
24
24
|
#include <stdlib.h>
|
|
25
|
+
#include <stdint.h>
|
|
26
|
+
#include <string.h>
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
/* Backends that never allocate in GET_STR leave this empty; backends that do
|
|
@@ -248,6 +250,7 @@ struct csonpath_child_info {
|
|
|
248
250
|
|
|
249
251
|
#define CSONPATH_ERROR_MAX_SIZE 1024
|
|
250
252
|
#define CSONPATH_TMP_BUF_SIZE 256
|
|
253
|
+
#define CSONPATH_MAX_STR_LEN 32767
|
|
251
254
|
|
|
252
255
|
#define CSONPATH_FILTER_PUSH(dst, cnt, c, walk_ptr) do { \
|
|
253
256
|
if ((cnt + 1) >= CSONPATH_TMP_BUF_SIZE) { \
|
|
@@ -257,6 +260,37 @@ struct csonpath_child_info {
|
|
|
257
260
|
(dst)[(cnt)++] = (c); \
|
|
258
261
|
} while (0)
|
|
259
262
|
|
|
263
|
+
|
|
264
|
+
/* Encode a string into dst using a Pascal-style length prefix.
|
|
265
|
+
* max is the maximum number of payload characters (not bytes) the caller
|
|
266
|
+
* allows; the destination buffer is assumed to have room for max + 3 bytes
|
|
267
|
+
* (2-byte length prefix + NUL terminator) from __start. */
|
|
268
|
+
#define CSONPATH_PUSH_STR(dst, dsti, max, next, cond, skipp) \
|
|
269
|
+
do { \
|
|
270
|
+
int __start = (dsti); \
|
|
271
|
+
int __cnt = 0; \
|
|
272
|
+
(dsti)++; \
|
|
273
|
+
while (cond) { \
|
|
274
|
+
if (__cnt >= (max)) { \
|
|
275
|
+
CSONPATH_COMPILE_ERR(tmp, walker - orig, \
|
|
276
|
+
"%s", "string too long"); \
|
|
277
|
+
goto error; \
|
|
278
|
+
} \
|
|
279
|
+
(dst)[(dsti)++] = *(next)++; \
|
|
280
|
+
++__cnt; \
|
|
281
|
+
skipp; \
|
|
282
|
+
} \
|
|
283
|
+
if (__cnt < 128) { \
|
|
284
|
+
(dst)[__start] = (char)__cnt; \
|
|
285
|
+
} else { \
|
|
286
|
+
memmove(&(dst)[__start + 2], &(dst)[__start + 1], __cnt); \
|
|
287
|
+
(dst)[__start] = (char)(0x80 | (__cnt >> 8)); \
|
|
288
|
+
(dst)[__start + 1] = (char)(__cnt & 0xFF); \
|
|
289
|
+
(dsti)++; \
|
|
290
|
+
} \
|
|
291
|
+
(dst)[(dsti)++] = 0; \
|
|
292
|
+
} while (0)
|
|
293
|
+
|
|
260
294
|
/* I'm assuming error message won't be longer than 125 */
|
|
261
295
|
#define CSONPATH_COMPILE_ERR(tmp, idx, args...) do { \
|
|
262
296
|
int ltmp = strlen(tmp), lidx, oidx = idx; \
|
|
@@ -311,12 +345,41 @@ static inline void csonpath_push_char(struct csonpath cjp[static 1], int inst, i
|
|
|
311
345
|
cjp->data[(*inst_idx)++] = inst;
|
|
312
346
|
}
|
|
313
347
|
|
|
314
|
-
|
|
348
|
+
/* Pascal-style length prefix for embedded C strings in the bytecode.
|
|
349
|
+
* - high bit of first byte == 0: length is encoded in that byte (0..127)
|
|
350
|
+
* - high bit of first byte == 1: length is ((byte0 & 0x7F) << 8) | byte1 (0..32767)
|
|
351
|
+
* The actual string bytes follow, terminated by a NUL for backend convenience. */
|
|
352
|
+
static inline int csonpath_str_decode(const char walker[static 1], const char **data)
|
|
353
|
+
{
|
|
354
|
+
unsigned char b0 = walker[0];
|
|
355
|
+
if (b0 & 0x80) {
|
|
356
|
+
unsigned char b1 = walker[1];
|
|
357
|
+
*data = walker + 2;
|
|
358
|
+
return ((b0 & 0x7F) << 8) | b1;
|
|
359
|
+
}
|
|
360
|
+
*data = walker + 1;
|
|
361
|
+
return b0;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
static inline const char *csonpath_str_data(const char walker[static 1])
|
|
365
|
+
{
|
|
366
|
+
const char *data;
|
|
367
|
+
(void)csonpath_str_decode(walker, &data);
|
|
368
|
+
return data;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
static inline const char *csonpath_str_skip(const char walker[static 1])
|
|
372
|
+
{
|
|
373
|
+
const char *data;
|
|
374
|
+
int len = csonpath_str_decode(walker, &data);
|
|
375
|
+
return data + len + 1; /* +1 for trailing NUL */
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
static const char *csonpath_walker_next_inst(const char walker[static 1])
|
|
315
379
|
{
|
|
316
380
|
int l = csonpath_instuction_len[(int)*walker];
|
|
317
|
-
/* skipp 2, 1 for the instruction, and another for \0 */
|
|
318
381
|
if (l < 0)
|
|
319
|
-
return
|
|
382
|
+
return csonpath_str_skip(walker + 1);
|
|
320
383
|
return &walker[l];
|
|
321
384
|
}
|
|
322
385
|
|
|
@@ -595,13 +658,15 @@ root_again:
|
|
|
595
658
|
goto error;
|
|
596
659
|
}
|
|
597
660
|
++walker;
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
661
|
+
next = walker;
|
|
662
|
+
CSONPATH_PUSH_STR(filter_getter, nb_getter_inst,
|
|
663
|
+
CSONPATH_TMP_BUF_SIZE - 3,
|
|
664
|
+
next, *next && *next != getter_end, ;);
|
|
601
665
|
} else {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
666
|
+
next = walker;
|
|
667
|
+
CSONPATH_PUSH_STR(filter_getter, nb_getter_inst,
|
|
668
|
+
CSONPATH_TMP_BUF_SIZE - 3,
|
|
669
|
+
next, csonpath_is_dot_operand(*next), ;);
|
|
605
670
|
}
|
|
606
671
|
if (!*next) {
|
|
607
672
|
CSONPATH_COMPILE_ERR(tmp, next - orig,
|
|
@@ -722,9 +787,9 @@ root_again:
|
|
|
722
787
|
++walker;
|
|
723
788
|
if (regex_idx < 0) {
|
|
724
789
|
csonpath_push_char(cjp, CSONPATH_INST_GET_OBJ, inst_idx);
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
790
|
+
next = walker;
|
|
791
|
+
CSONPATH_PUSH_STR(cjp->data, *inst_idx, CSONPATH_MAX_STR_LEN,
|
|
792
|
+
next, *next && *next != end, ;);
|
|
728
793
|
if (!*next) {
|
|
729
794
|
CSONPATH_COMPILE_ERR(tmp, walker - orig,
|
|
730
795
|
"broken filter");
|
|
@@ -911,21 +976,16 @@ root_again:
|
|
|
911
976
|
inst = CSONPATH_INST_GET_OBJ;
|
|
912
977
|
|
|
913
978
|
++walker;
|
|
914
|
-
next = walker;
|
|
915
979
|
csonpath_push_char(cjp, inst, inst_idx);
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
while (*next == '\\')
|
|
921
|
-
++next;
|
|
922
|
-
}
|
|
980
|
+
next = walker;
|
|
981
|
+
CSONPATH_PUSH_STR(cjp->data, *inst_idx, CSONPATH_MAX_STR_LEN,
|
|
982
|
+
next, *next && *next != end,
|
|
983
|
+
while (*next == '\\') ++next;);
|
|
923
984
|
if (!*next) {
|
|
924
985
|
CSONPATH_COMPILE_ERR(tmp, walker - orig,
|
|
925
986
|
"unclosed string in bracket");
|
|
926
987
|
}
|
|
927
988
|
++next; // skipp end
|
|
928
|
-
csonpath_push_char(cjp, 0, inst_idx);
|
|
929
989
|
if (in_union && *next == ',') {
|
|
930
990
|
walker = next;
|
|
931
991
|
csonpath_push_char(cjp, CSONPATH_INST_UNION_JMP, inst_idx);
|
|
@@ -942,7 +1002,6 @@ root_again:
|
|
|
942
1002
|
}
|
|
943
1003
|
}
|
|
944
1004
|
case '.':
|
|
945
|
-
{
|
|
946
1005
|
inst = CSONPATH_INST_GET_OBJ;
|
|
947
1006
|
|
|
948
1007
|
++walker;
|
|
@@ -952,12 +1011,13 @@ root_again:
|
|
|
952
1011
|
if (*walker == '*') {
|
|
953
1012
|
++walker;
|
|
954
1013
|
/*
|
|
955
|
-
* Encode $..* as FIND_ALL
|
|
1014
|
+
* Encode $..* as FIND_ALL with a 1-byte payload: GET_ALL.
|
|
956
1015
|
* GET_ALL (0x0E) is a non-printable control character, so it can
|
|
957
1016
|
* never appear raw in a valid JSON key; this avoids collision with
|
|
958
1017
|
* real recursive-descent keys like $..name.
|
|
959
1018
|
*/
|
|
960
1019
|
csonpath_push_char(cjp, CSONPATH_INST_FIND_ALL, inst_idx);
|
|
1020
|
+
csonpath_push_char(cjp, 1, inst_idx);
|
|
961
1021
|
csonpath_push_char(cjp, CSONPATH_INST_GET_ALL, inst_idx);
|
|
962
1022
|
csonpath_push_char(cjp, 0, inst_idx);
|
|
963
1023
|
to_check = *walker;
|
|
@@ -974,21 +1034,21 @@ root_again:
|
|
|
974
1034
|
to_check = *walker;
|
|
975
1035
|
goto again;
|
|
976
1036
|
}
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
CSONPATH_COMPILE_ERR(tmp, walker - orig, "empty getter");
|
|
982
|
-
}
|
|
983
|
-
to_check = *next;
|
|
1037
|
+
|
|
1038
|
+
/* Bracket accessor after a dot: $.['x'] or $..['x']. */
|
|
1039
|
+
if (*walker == '[')
|
|
1040
|
+
goto do_array;
|
|
984
1041
|
|
|
985
1042
|
csonpath_push_char(cjp, inst, inst_idx);
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
1043
|
+
next = walker;
|
|
1044
|
+
CSONPATH_PUSH_STR(cjp->data, *inst_idx, CSONPATH_MAX_STR_LEN,
|
|
1045
|
+
next, csonpath_is_dot_operand(*next), ;);
|
|
1046
|
+
if (next == walker)
|
|
1047
|
+
CSONPATH_COMPILE_ERR(tmp, walker - orig, "empty getter");
|
|
1048
|
+
|
|
1049
|
+
to_check = *next;
|
|
1050
|
+
walker = next;
|
|
990
1051
|
goto again;
|
|
991
|
-
}
|
|
992
1052
|
case '|':
|
|
993
1053
|
csonpath_push_char(cjp, CSONPATH_INST_OR, inst_idx);
|
|
994
1054
|
++walker;
|
|
@@ -1190,8 +1250,9 @@ static _Bool CSONPATH_FUNC(csonpath_do_match)(int operand_instruction, CSONPATH_
|
|
|
1190
1250
|
}
|
|
1191
1251
|
case CSONPATH_INST_GET_OBJ:
|
|
1192
1252
|
{
|
|
1193
|
-
|
|
1194
|
-
|
|
1253
|
+
const char *str = csonpath_str_data(*owalker);
|
|
1254
|
+
_Bool ret = CSONPATH_EQUAL_STR(el2, str);
|
|
1255
|
+
*owalker = csonpath_str_skip(*owalker);
|
|
1195
1256
|
return ret;
|
|
1196
1257
|
}
|
|
1197
1258
|
case CSONPATH_INST_GET_ARRAY_SMALL:
|
|
@@ -1224,15 +1285,17 @@ static CSONPATH_JSON CSONPATH_FUNC(csonpath_crawl_filter_el)(const struct csonpa
|
|
|
1224
1285
|
switch (**owalker) {
|
|
1225
1286
|
case CSONPATH_INST_GET_OBJ:
|
|
1226
1287
|
++*owalker;
|
|
1227
|
-
if (el2)
|
|
1228
|
-
|
|
1288
|
+
if (el2) {
|
|
1289
|
+
const char *key = csonpath_str_data(*owalker);
|
|
1290
|
+
el2 = CSONPATH_GET(el2, key);
|
|
1291
|
+
}
|
|
1292
|
+
*owalker = csonpath_str_skip(*owalker);
|
|
1229
1293
|
break;
|
|
1230
1294
|
default:
|
|
1231
1295
|
CSONPATH_FORMAT_EXCEPTION("unsuported %s inst",
|
|
1232
1296
|
csonpath_instuction_str[(int)**owalker]);
|
|
1233
1297
|
return NULL;
|
|
1234
1298
|
}
|
|
1235
|
-
(*owalker) += (strlen(*owalker) + 1);
|
|
1236
1299
|
}
|
|
1237
1300
|
return el2;
|
|
1238
1301
|
}
|
|
@@ -1788,11 +1851,12 @@ static _Bool CSONPATH_FUNC(csonpath_make_match)(const struct csonpath cjp[const
|
|
|
1788
1851
|
if (!CSONPATH_IS_STR(el2))
|
|
1789
1852
|
break;
|
|
1790
1853
|
CSONPATH_CLEANUP_STR const char *s = CSONPATH_GET_STR(el2);
|
|
1854
|
+
const char *operand = csonpath_str_data(*owalker);
|
|
1791
1855
|
if (operation == CSONPATH_INST_FILTER_KEY_SUPERIOR_EQ)
|
|
1792
|
-
match = strcmp(s,
|
|
1856
|
+
match = strcmp(s, operand) >= 0;
|
|
1793
1857
|
else
|
|
1794
|
-
match = strcmp(s,
|
|
1795
|
-
*owalker
|
|
1858
|
+
match = strcmp(s, operand) > 0;
|
|
1859
|
+
*owalker = csonpath_str_skip(*owalker);
|
|
1796
1860
|
} else {
|
|
1797
1861
|
if (!CSONPATH_IS_NUM(el2))
|
|
1798
1862
|
break;
|
|
@@ -1812,11 +1876,12 @@ static _Bool CSONPATH_FUNC(csonpath_make_match)(const struct csonpath cjp[const
|
|
|
1812
1876
|
if (!CSONPATH_IS_STR(el2))
|
|
1813
1877
|
break;
|
|
1814
1878
|
CSONPATH_CLEANUP_STR const char *s = CSONPATH_GET_STR(el2);
|
|
1879
|
+
const char *operand = csonpath_str_data(*owalker);
|
|
1815
1880
|
if (operation == CSONPATH_INST_FILTER_KEY_INFERIOR_EQ)
|
|
1816
|
-
match = strcmp(s,
|
|
1881
|
+
match = strcmp(s, operand) <= 0;
|
|
1817
1882
|
else
|
|
1818
|
-
match = strcmp(s,
|
|
1819
|
-
*owalker
|
|
1883
|
+
match = strcmp(s, operand) < 0;
|
|
1884
|
+
*owalker = csonpath_str_skip(*owalker);
|
|
1820
1885
|
} else {
|
|
1821
1886
|
if (!CSONPATH_IS_NUM(el2))
|
|
1822
1887
|
break;
|
|
@@ -145,14 +145,16 @@ static CSONPATH_DO_RET_TYPE csonpath_do_dotdot(const struct csonpath cjp[const s
|
|
|
145
145
|
(void)ctx;
|
|
146
146
|
|
|
147
147
|
CSONPATH_DO_FIND_ALL_PRE_LOOP;
|
|
148
|
-
const
|
|
148
|
+
const char *find_all_key;
|
|
149
|
+
(void)csonpath_str_decode(walker + 1, &find_all_key);
|
|
150
|
+
const int is_wildcard = (unsigned char)find_all_key[0] == CSONPATH_INST_GET_ALL;
|
|
149
151
|
if (is_obj) {
|
|
150
152
|
const char *key;
|
|
151
153
|
CSONPATH_FOREACH_OBJ(tmp, el, key) {
|
|
152
154
|
key_idx = (intptr_t)key;
|
|
153
155
|
(void)key_idx;
|
|
154
156
|
CSONPATH_DO_FOREACH_PRE_SET;
|
|
155
|
-
if (is_wildcard || !strcmp(key,
|
|
157
|
+
if (is_wildcard || !strcmp(key, find_all_key)) {
|
|
156
158
|
if (!next_inst)
|
|
157
159
|
next_inst = csonpath_walker_next_inst(walker);
|
|
158
160
|
tret = csonpath_do_internal(cjp, origin, el, tmp,
|
|
@@ -449,14 +451,14 @@ static CSONPATH_DO_RET_TYPE csonpath_do_internal(const struct csonpath cjp[const
|
|
|
449
451
|
}
|
|
450
452
|
case CSONPATH_INST_GET_OBJ:
|
|
451
453
|
{
|
|
452
|
-
|
|
454
|
+
const char *this_idx;
|
|
455
|
+
uint16_t this_idx_len = csonpath_str_decode(walker + 1, &this_idx);
|
|
453
456
|
|
|
454
457
|
if (tmp != CSONPATH_NULL)
|
|
455
458
|
ctx = tmp;
|
|
456
459
|
CSONPATH_PRE_GET_OBJ(this_idx);
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
walker += strlen(walker);
|
|
460
|
+
tmp = CSONPATH_GET(tmp, this_idx);
|
|
461
|
+
walker = this_idx + this_idx_len;
|
|
460
462
|
if (tmp == CSONPATH_NULL) {
|
|
461
463
|
CSONPATH_DO_GET_NOTFOUND(this_idx);
|
|
462
464
|
}
|
|
@@ -348,7 +348,7 @@ next_inst:
|
|
|
348
348
|
|
|
349
349
|
switch (*walker) {
|
|
350
350
|
case CSONPATH_INST_GET_OBJ: {
|
|
351
|
-
const char *key = walker + 1;
|
|
351
|
+
const char *key = csonpath_str_data(walker + 1);
|
|
352
352
|
f->saved_child_info.type = CSONPATH_STR;
|
|
353
353
|
f->saved_child_info.key = key;
|
|
354
354
|
new_cur = CSONPATH_GET(f->parent, key);
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "csonpath"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.20.0"
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
|
|
10
10
|
[tool.setuptools]
|
|
@@ -27,7 +27,7 @@ test-command = "pytest {project}/tests/python"
|
|
|
27
27
|
before-build = "choco install mingw -y"
|
|
28
28
|
|
|
29
29
|
[tool.bumpversion]
|
|
30
|
-
current_version = "0.
|
|
30
|
+
current_version = "0.20.0"
|
|
31
31
|
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
|
32
32
|
serialize = ["{major}.{minor}.{patch}"]
|
|
33
33
|
search = "{current_version}"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|