summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-oe/recipes-devtools/jq/jq/0001-builtin.c-fix-build-with-Woverlength-strings.patch215
-rw-r--r--meta-oe/recipes-devtools/jq/jq/0002-libm.h-builtin.c-add-and-use-LIBM_DA-and-LIBM_DA_NO-.patch164
-rw-r--r--meta-oe/recipes-devtools/jq/jq/0003-builtin.c-typecheck-builtin-cfunctions-in-function_l.patch249
-rw-r--r--meta-oe/recipes-devtools/jq/jq_1.7.1.bb3
4 files changed, 0 insertions, 631 deletions
diff --git a/meta-oe/recipes-devtools/jq/jq/0001-builtin.c-fix-build-with-Woverlength-strings.patch b/meta-oe/recipes-devtools/jq/jq/0001-builtin.c-fix-build-with-Woverlength-strings.patch
deleted file mode 100644
index cd7cdba00c..0000000000
--- a/meta-oe/recipes-devtools/jq/jq/0001-builtin.c-fix-build-with-Woverlength-strings.patch
+++ /dev/null
@@ -1,215 +0,0 @@
1From 8707f8764dfc470d1974eb1d613f5a4bec3610ac Mon Sep 17 00:00:00 2001
2From: Emanuele Torre <torreemanuele6@gmail.com>
3Date: Fri, 26 Jan 2024 04:42:11 +0100
4Subject: [PATCH] builtin.c: fix build with -Woverlength-strings
5
6C99 only allows string literals long at most 4095 characters.
7jq_builtins was a lot longer than that.
8
9I rewrote all the optional libm error stubs in C so the value of
10jq_builtins is not build dependent.
11
12I replaced the command that generates builtin.inc with a POSIX compliant
13od|sed command that encodes builtin.jq as a comma delimited list of
14octal numbers (that can be embedded in C using a {} literal).
15
16I also added -Woverlength-strings to AM_CFLAGS to verify that the
17problem is fixed.
18
19Fixes #1481
20Upstream-Status: Backport [605836b builtin.c: fix build with -Woverlength-strings]
21Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
22---
23
24 Makefile.am | 10 ++++--
25 src/builtin.c | 86 ++++++++++++++++++++++++---------------------------
26 2 files changed, 48 insertions(+), 48 deletions(-)
27
28diff --git a/Makefile.am b/Makefile.am
29index 76e35df..f1f9f2e 100644
30--- a/Makefile.am
31+++ b/Makefile.am
32@@ -19,7 +19,8 @@ LIBJQ_SRC = src/builtin.c src/bytecode.c src/compile.c src/execute.c \
33
34 ### C build options
35
36-AM_CFLAGS = -Wextra -Wall -Wno-unused-parameter -Wno-unused-function
37+AM_CFLAGS = -Wextra -Wall -Wno-unused-parameter -Wno-unused-function \
38+ -Woverlength-strings
39
40 if WIN32
41 AM_CFLAGS += -municode
42@@ -119,7 +120,12 @@ src/main.c: src/version.h src/config_opts.inc
43
44 src/builtin.inc: $(srcdir)/src/builtin.jq
45 mkdir -p src
46- $(AM_V_GEN) sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n"/' $(srcdir)/src/builtin.jq > $@
47+ $(AM_V_GEN) od -v -A n -t o1 -- $< | \
48+ sed -e 's/$$/ /' \
49+ -e 's/\([0123456789]\) /\1, /g' \
50+ -e 's/ $$//' \
51+ -e 's/ 0/ 0/g' \
52+ -e 's/ \([123456789]\)/ 0\1/g' > $@
53 src/builtin.o: src/builtin.inc
54
55 CLEANFILES = src/version.h .remake-version-h src/builtin.inc src/config_opts.inc
56diff --git a/src/builtin.c b/src/builtin.c
57index 902490d..a3ce7e4 100644
58--- a/src/builtin.c
59+++ b/src/builtin.c
60@@ -155,7 +155,11 @@ static jv f_ ## name(jq_state *jq, jv input) { \
61 jv_free(input); \
62 return ret; \
63 }
64-#define LIBM_DD_NO(name)
65+#define LIBM_DD_NO(name) \
66+static jv f_ ## name(jq_state *jq, jv input) { \
67+ jv error = jv_string("Error: " #name "/0 not found at build time"); \
68+ return ret_error(input, error); \
69+}
70
71 #define LIBM_DDD(name) \
72 static jv f_ ## name(jq_state *jq, jv input, jv a, jv b) { \
73@@ -173,7 +177,12 @@ static jv f_ ## name(jq_state *jq, jv input, jv a, jv b) { \
74 jv_free(b); \
75 return ret; \
76 }
77-#define LIBM_DDD_NO(name)
78+#define LIBM_DDD_NO(name) \
79+static jv f_ ## name(jq_state *jq, jv input, jv a, jv b) { \
80+ jv_free(b); \
81+ jv error = jv_string("Error: " #name "/2 not found at build time"); \
82+ return ret_error2(input, a, error); \
83+}
84
85 #define LIBM_DDDD(name) \
86 static jv f_ ## name(jq_state *jq, jv input, jv a, jv b, jv c) { \
87@@ -199,7 +208,14 @@ static jv f_ ## name(jq_state *jq, jv input, jv a, jv b, jv c) { \
88 jv_free(c); \
89 return ret; \
90 }
91-#define LIBM_DDDD_NO(name)
92+#define LIBM_DDDD_NO(name) \
93+static jv f_ ## name(jq_state *jq, jv input, jv a, jv b, jv c) { \
94+ jv_free(c) \
95+ jv_free(b); \
96+ jv error = jv_string("Error: " #name "/3 not found at build time"); \
97+ return ret_error2(input, a, error); \
98+}
99+
100 #include "libm.h"
101 #undef LIBM_DDDD_NO
102 #undef LIBM_DDD_NO
103@@ -226,6 +242,11 @@ static jv f_frexp(jq_state *jq, jv input) {
104 jv_free(input);
105 return ret;
106 }
107+#else
108+static jv f_frexp(jq_state *jq, jv input) {
109+ jv error = jv_string("Error: frexp/0 not found at build time");
110+ return ret_error(input, error);
111+}
112 #endif
113 #ifdef HAVE_MODF
114 static jv f_modf(jq_state *jq, jv input) {
115@@ -237,6 +258,11 @@ static jv f_modf(jq_state *jq, jv input) {
116 jv_free(input);
117 return jv_array_append(ret, jv_number(i));
118 }
119+#else
120+static jv f_modf(jq_state *jq, jv input) {
121+ jv error = jv_string("Error: modf/0 not found at build time");
122+ return ret_error(input, error);
123+}
124 #endif
125 #ifdef HAVE_LGAMMA_R
126 static jv f_lgamma_r(jq_state *jq, jv input) {
127@@ -248,6 +274,11 @@ static jv f_lgamma_r(jq_state *jq, jv input) {
128 jv_free(input);
129 return jv_array_append(ret, jv_number(sign));
130 }
131+#else
132+static jv f_lgamma_r(jq_state *jq, jv input) {
133+ jv error = jv_string("Error: lgamma_r/0 not found at build time");
134+ return ret_error(input, error);
135+}
136 #endif
137
138 static jv f_negate(jq_state *jq, jv input) {
139@@ -1703,27 +1734,21 @@ static jv f_current_line(jq_state *jq, jv a) {
140
141 #define LIBM_DD(name) \
142 {f_ ## name, #name, 1},
143-#define LIBM_DD_NO(name)
144+#define LIBM_DD_NO(name) LIBM_DD(name)
145
146 #define LIBM_DDD(name) \
147 {f_ ## name, #name, 3},
148-#define LIBM_DDD_NO(name)
149+#define LIBM_DDD_NO(name) LIBM_DDD(name)
150
151 #define LIBM_DDDD(name) \
152 {f_ ## name, #name, 4},
153-#define LIBM_DDDD_NO(name)
154+#define LIBM_DDDD_NO(name) LIBM_DDDD(name)
155
156 static const struct cfunction function_list[] = {
157 #include "libm.h"
158-#ifdef HAVE_FREXP
159 {f_frexp,"frexp", 1},
160-#endif
161-#ifdef HAVE_MODF
162 {f_modf,"modf", 1},
163-#endif
164-#ifdef HAVE_LGAMMA_R
165 {f_lgamma_r,"lgamma_r", 1},
166-#endif
167 {f_negate, "_negate", 1},
168 #define BINOP(name) {f_ ## name, "_" #name, 3},
169 BINOPS
170@@ -1838,42 +1863,11 @@ static block bind_bytecoded_builtins(block b) {
171 return BLOCK(builtins, b);
172 }
173
174-static const char jq_builtins[] =
175+static const char jq_builtins[] = {
176 /* Include jq-coded builtins */
177 #include "src/builtin.inc"
178-
179-/* Include unsupported math functions next */
180-#define LIBM_DD(name)
181-#define LIBM_DDD(name)
182-#define LIBM_DDDD(name)
183-#define LIBM_DD_NO(name) "def " #name ": \"Error: " #name "/0 not found at build time\"|error;"
184-#define LIBM_DDD_NO(name) "def " #name "(a;b): \"Error: " #name "/2 not found at build time\"|error;"
185-#define LIBM_DDDD_NO(name) "def " #name "(a;b;c): \"Error: " #name "/3 not found at build time\"|error;"
186-#include "libm.h"
187-#ifndef HAVE_FREXP
188- "def frexp: \"Error: frexp/0 not found at build time\"|error;"
189-#endif
190-#ifndef HAVE_MODF
191- "def modf: \"Error: modf/0 not found at build time\"|error;"
192-#endif
193-#ifndef HAVE_LGAMMA_R
194- "def lgamma_r: \"Error: lgamma_r/0 not found at build time\"|error;"
195-#endif
196-;
197-
198-#undef LIBM_DDDD_NO
199-#undef LIBM_DDD_NO
200-#undef LIBM_DD_NO
201-#undef LIBM_DDDD
202-#undef LIBM_DDD
203-#undef LIBM_DD
204-
205-#ifdef __APPLE__
206-#undef HAVE_GAMMA
207-#undef HAVE_EXP10
208-#undef HAVE_DREM
209-#undef HAVE_SIGNIFICAND
210-#endif
211+ '\0',
212+};
213
214 static block gen_builtin_list(block builtins) {
215 jv list = jv_array_append(block_list_funcs(builtins, 1), jv_string("builtins/0"));
diff --git a/meta-oe/recipes-devtools/jq/jq/0002-libm.h-builtin.c-add-and-use-LIBM_DA-and-LIBM_DA_NO-.patch b/meta-oe/recipes-devtools/jq/jq/0002-libm.h-builtin.c-add-and-use-LIBM_DA-and-LIBM_DA_NO-.patch
deleted file mode 100644
index 68b8cb4f6e..0000000000
--- a/meta-oe/recipes-devtools/jq/jq/0002-libm.h-builtin.c-add-and-use-LIBM_DA-and-LIBM_DA_NO-.patch
+++ /dev/null
@@ -1,164 +0,0 @@
1From c65e6fa48e6da30727c87ccdd88d8fb6a7a70f20 Mon Sep 17 00:00:00 2001
2From: Emanuele Torre <torreemanuele6@gmail.com>
3Date: Fri, 26 Jan 2024 11:26:57 +0100
4Subject: [PATCH] libm.h+builtin.c: add and use LIBM_DA and LIBM_DA_NO macros
5
6For functions that from one double return an array with two numbers.
7Upstream-Status: Backport [bd3c828 libm.h+builtin.c: add and use LIBM_DA and LIBM_DA_NO macros]
8Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
9---
10 src/builtin.c | 78 ++++++++++++++++-----------------------------------
11 src/libm.h | 15 ++++++++++
12 2 files changed, 39 insertions(+), 54 deletions(-)
13
14diff --git a/src/builtin.c b/src/builtin.c
15index a3ce7e4..9b71bca 100644
16--- a/src/builtin.c
17+++ b/src/builtin.c
18@@ -216,13 +216,32 @@ static jv f_ ## name(jq_state *jq, jv input, jv a, jv b, jv c) { \
19 return ret_error2(input, a, error); \
20 }
21
22+#define LIBM_DA(name, type) \
23+static jv f_ ## name(jq_state *jq, jv input) { \
24+ if (jv_get_kind(input) != JV_KIND_NUMBER) { \
25+ return type_error(input, "number required"); \
26+ } \
27+ type value; \
28+ double d = name(jv_number_value(input), &value); \
29+ jv ret = JV_ARRAY(jv_number(d), jv_number(value)); \
30+ jv_free(input); \
31+ return ret; \
32+}
33+#define LIBM_DA_NO(name, type) \
34+static jv f_ ## name(jq_state *jq, jv input) { \
35+ jv error = jv_string("Error: " #name "/0 not found at build time"); \
36+ return ret_error(input, error); \
37+}
38+
39 #include "libm.h"
40 #undef LIBM_DDDD_NO
41 #undef LIBM_DDD_NO
42 #undef LIBM_DD_NO
43+#undef LIBM_DA_NO
44 #undef LIBM_DDDD
45 #undef LIBM_DDD
46 #undef LIBM_DD
47+#undef LIBM_DA
48
49 #ifdef __APPLE__
50 #undef gamma
51@@ -231,56 +250,6 @@ static jv f_ ## name(jq_state *jq, jv input, jv a, jv b, jv c) { \
52 #undef exp10
53 #endif
54
55-#ifdef HAVE_FREXP
56-static jv f_frexp(jq_state *jq, jv input) {
57- if (jv_get_kind(input) != JV_KIND_NUMBER) {
58- return type_error(input, "number required");
59- }
60- int exp;
61- double d = frexp(jv_number_value(input), &exp);
62- jv ret = JV_ARRAY(jv_number(d), jv_number(exp));
63- jv_free(input);
64- return ret;
65-}
66-#else
67-static jv f_frexp(jq_state *jq, jv input) {
68- jv error = jv_string("Error: frexp/0 not found at build time");
69- return ret_error(input, error);
70-}
71-#endif
72-#ifdef HAVE_MODF
73-static jv f_modf(jq_state *jq, jv input) {
74- if (jv_get_kind(input) != JV_KIND_NUMBER) {
75- return type_error(input, "number required");
76- }
77- double i;
78- jv ret = JV_ARRAY(jv_number(modf(jv_number_value(input), &i)));
79- jv_free(input);
80- return jv_array_append(ret, jv_number(i));
81-}
82-#else
83-static jv f_modf(jq_state *jq, jv input) {
84- jv error = jv_string("Error: modf/0 not found at build time");
85- return ret_error(input, error);
86-}
87-#endif
88-#ifdef HAVE_LGAMMA_R
89-static jv f_lgamma_r(jq_state *jq, jv input) {
90- if (jv_get_kind(input) != JV_KIND_NUMBER) {
91- return type_error(input, "number required");
92- }
93- int sign;
94- jv ret = JV_ARRAY(jv_number(lgamma_r(jv_number_value(input), &sign)));
95- jv_free(input);
96- return jv_array_append(ret, jv_number(sign));
97-}
98-#else
99-static jv f_lgamma_r(jq_state *jq, jv input) {
100- jv error = jv_string("Error: lgamma_r/0 not found at build time");
101- return ret_error(input, error);
102-}
103-#endif
104-
105 static jv f_negate(jq_state *jq, jv input) {
106 if (jv_get_kind(input) != JV_KIND_NUMBER) {
107 return type_error(input, "cannot be negated");
108@@ -1733,8 +1702,10 @@ static jv f_current_line(jq_state *jq, jv a) {
109 }
110
111 #define LIBM_DD(name) \
112- {f_ ## name, #name, 1},
113+ {f_ ## name, #name, 1},
114 #define LIBM_DD_NO(name) LIBM_DD(name)
115+#define LIBM_DA(name, type) LIBM_DD(name)
116+#define LIBM_DA_NO(name, type) LIBM_DD(name)
117
118 #define LIBM_DDD(name) \
119 {f_ ## name, #name, 3},
120@@ -1746,9 +1717,6 @@ static jv f_current_line(jq_state *jq, jv a) {
121
122 static const struct cfunction function_list[] = {
123 #include "libm.h"
124- {f_frexp,"frexp", 1},
125- {f_modf,"modf", 1},
126- {f_lgamma_r,"lgamma_r", 1},
127 {f_negate, "_negate", 1},
128 #define BINOP(name) {f_ ## name, "_" #name, 3},
129 BINOPS
130@@ -1813,9 +1781,11 @@ BINOPS
131 #undef LIBM_DDDD_NO
132 #undef LIBM_DDD_NO
133 #undef LIBM_DD_NO
134+#undef LIBM_DA_NO
135 #undef LIBM_DDDD
136 #undef LIBM_DDD
137 #undef LIBM_DD
138+#undef LIBM_DA
139
140 struct bytecoded_builtin { const char* name; block code; };
141 static block bind_bytecoded_builtins(block b) {
142diff --git a/src/libm.h b/src/libm.h
143index 8efc1c5..7332bd8 100644
144--- a/src/libm.h
145+++ b/src/libm.h
146@@ -289,3 +289,18 @@ LIBM_DDD(ldexp)
147 #else
148 LIBM_DDD_NO(ldexp)
149 #endif
150+#ifdef HAVE_MODF
151+LIBM_DA(modf, double)
152+#else
153+LIBM_DA_NO(modf, double)
154+#endif
155+#ifdef HAVE_FREXP
156+LIBM_DA(frexp, int)
157+#else
158+LIBM_DA_NO(frexp, int)
159+#endif
160+#ifdef HAVE_LGAMMA_R
161+LIBM_DA(lgamma_r, int)
162+#else
163+LIBM_DA_NO(lgamma_r, int)
164+#endif
diff --git a/meta-oe/recipes-devtools/jq/jq/0003-builtin.c-typecheck-builtin-cfunctions-in-function_l.patch b/meta-oe/recipes-devtools/jq/jq/0003-builtin.c-typecheck-builtin-cfunctions-in-function_l.patch
deleted file mode 100644
index f8b6c5baf6..0000000000
--- a/meta-oe/recipes-devtools/jq/jq/0003-builtin.c-typecheck-builtin-cfunctions-in-function_l.patch
+++ /dev/null
@@ -1,249 +0,0 @@
1From 98839759a92e3ad41870bfc7415f0ecf320b5097 Mon Sep 17 00:00:00 2001
2From: Emanuele Torre <torreemanuele6@gmail.com>
3Date: Mon, 25 Nov 2024 07:47:14 +0100
4Subject: [PATCH] builtin.c: typecheck builtin cfunctions in function_list
5
6In C23 (default C standard used by GCC 15), jv (*fptr)(); has become
7equivalent to jv (*fptr)(void); so we can no longer assign builtin
8implemenations directly to the fptr member of cfunctions without
9generating a compile error.
10
11Since there does not seem to be any straight-forward way to tell
12autoconf to force the compiler to use C99 short of explicitly adding
13-std=c99 to CFLAGS, it is probably a cleaner solution to just make the
14code C23 compatible.
15
16A possible solution could have been to just redeclare cfunction.fptr
17as void*, but then the functions' return type would not have been type
18checked (e.g. if you tried to add a {printf, "printf", 2}, where printf
19is a function that does not return jv, the compiler wouldn't have
20complained.)
21We were already not typechecking the arguments of the functions, so e.g.
22 {binop_plus, "_plus", 3}, /* instead of {f_plus, "_plus, 3}, */
23 {f_setpath, "setpath", 4}, /* instead of {f_setpath, "setpath", 3}, */
24compile without errors despite not having the correct prototype.
25
26So I thought of instead improving the situation by redefining
27cfunction.fptr as a union of function pointers with the prototypes that
28the jq bytecode interpreter can call, and use a macro to add the builtin
29functions to function_list using to the arity argument to assign the
30implementation function to the appropriate union member.
31
32Now the code won't compile if the wrong arity, or an arity not supported
33by the bytecode interpreter (>5 = 1input+4arguments), or a prototype not
34jallable by the bytecode interpreter (e.g. binop_plus that doesn't
35expect a jq_state* argument).
36
37Also, the code now compiles with gcc -std=c23.
38
39Fixes #3206
40Upstream-Status: Backport [0b82b38 builtin.c: typecheck builtin cfunctions in function_list]
41Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
42---
43 src/builtin.c | 126 +++++++++++++++++++++++++------------------------
44 src/bytecode.h | 11 +++--
45 src/execute.c | 11 ++---
46 3 files changed, 78 insertions(+), 70 deletions(-)
47
48diff --git a/src/builtin.c b/src/builtin.c
49index 9b71bca..6ba6511 100644
50--- a/src/builtin.c
51+++ b/src/builtin.c
52@@ -1701,82 +1701,83 @@ static jv f_current_line(jq_state *jq, jv a) {
53 return jq_util_input_get_current_line(jq);
54 }
55
56+#define CFUNC(func, name, arity) \
57+ {.fptr = { .a ## arity = func }, name, arity}
58+
59 #define LIBM_DD(name) \
60- {f_ ## name, #name, 1},
61+ CFUNC(f_ ## name, #name, 1),
62 #define LIBM_DD_NO(name) LIBM_DD(name)
63 #define LIBM_DA(name, type) LIBM_DD(name)
64 #define LIBM_DA_NO(name, type) LIBM_DD(name)
65
66 #define LIBM_DDD(name) \
67- {f_ ## name, #name, 3},
68+ CFUNC(f_ ## name, #name, 3),
69 #define LIBM_DDD_NO(name) LIBM_DDD(name)
70
71 #define LIBM_DDDD(name) \
72- {f_ ## name, #name, 4},
73+ CFUNC(f_ ## name, #name, 4),
74 #define LIBM_DDDD_NO(name) LIBM_DDDD(name)
75
76 static const struct cfunction function_list[] = {
77 #include "libm.h"
78- {f_negate, "_negate", 1},
79-#define BINOP(name) {f_ ## name, "_" #name, 3},
80+ CFUNC(f_negate, "_negate", 1),
81+#define BINOP(name) CFUNC(f_ ## name, "_" #name, 3),
82 BINOPS
83 #undef BINOP
84- {f_dump, "tojson", 1},
85- {f_json_parse, "fromjson", 1},
86- {f_tonumber, "tonumber", 1},
87- {f_tostring, "tostring", 1},
88- {f_keys, "keys", 1},
89- {f_keys_unsorted, "keys_unsorted", 1},
90- {f_startswith, "startswith", 2},
91- {f_endswith, "endswith", 2},
92- {f_ltrimstr, "ltrimstr", 2},
93- {f_rtrimstr, "rtrimstr", 2},
94- {f_string_split, "split", 2},
95- {f_string_explode, "explode", 1},
96- {f_string_implode, "implode", 1},
97- {f_string_indexes, "_strindices", 2},
98- {f_setpath, "setpath", 3}, // FIXME typechecking
99- {f_getpath, "getpath", 2},
100- {f_delpaths, "delpaths", 2},
101- {f_has, "has", 2},
102- {f_contains, "contains", 2},
103- {f_length, "length", 1},
104- {f_utf8bytelength, "utf8bytelength", 1},
105- {f_type, "type", 1},
106- {f_isinfinite, "isinfinite", 1},
107- {f_isnan, "isnan", 1},
108- {f_isnormal, "isnormal", 1},
109- {f_infinite, "infinite", 1},
110- {f_nan, "nan", 1},
111- {f_sort, "sort", 1},
112- {f_sort_by_impl, "_sort_by_impl", 2},
113- {f_group_by_impl, "_group_by_impl", 2},
114- {f_min, "min", 1},
115- {f_max, "max", 1},
116- {f_min_by_impl, "_min_by_impl", 2},
117- {f_max_by_impl, "_max_by_impl", 2},
118- {f_error, "error", 1},
119- {f_format, "format", 2},
120- {f_env, "env", 1},
121- {f_halt, "halt", 1},
122- {f_halt_error, "halt_error", 2},
123- {f_get_search_list, "get_search_list", 1},
124- {f_get_prog_origin, "get_prog_origin", 1},
125- {f_get_jq_origin, "get_jq_origin", 1},
126- {f_match, "_match_impl", 4},
127- {f_modulemeta, "modulemeta", 1},
128- {f_input, "input", 1},
129- {f_debug, "debug", 1},
130- {f_stderr, "stderr", 1},
131- {f_strptime, "strptime", 2},
132- {f_strftime, "strftime", 2},
133- {f_strflocaltime, "strflocaltime", 2},
134- {f_mktime, "mktime", 1},
135- {f_gmtime, "gmtime", 1},
136- {f_localtime, "localtime", 1},
137- {f_now, "now", 1},
138- {f_current_filename, "input_filename", 1},
139- {f_current_line, "input_line_number", 1},
140+ CFUNC(f_dump, "tojson", 1),
141+ CFUNC(f_json_parse, "fromjson", 1),
142+ CFUNC(f_tonumber, "tonumber", 1),
143+ CFUNC(f_tostring, "tostring", 1),
144+ CFUNC(f_keys, "keys", 1),
145+ CFUNC(f_keys_unsorted, "keys_unsorted", 1),
146+ CFUNC(f_startswith, "startswith", 2),
147+ CFUNC(f_endswith, "endswith", 2),
148+ CFUNC(f_string_split, "split", 2),
149+ CFUNC(f_string_explode, "explode", 1),
150+ CFUNC(f_string_implode, "implode", 1),
151+ CFUNC(f_string_indexes, "_strindices", 2),
152+ CFUNC(f_setpath, "setpath", 3),
153+ CFUNC(f_getpath, "getpath", 2),
154+ CFUNC(f_delpaths, "delpaths", 2),
155+ CFUNC(f_has, "has", 2),
156+ CFUNC(f_contains, "contains", 2),
157+ CFUNC(f_length, "length", 1),
158+ CFUNC(f_utf8bytelength, "utf8bytelength", 1),
159+ CFUNC(f_type, "type", 1),
160+ CFUNC(f_isinfinite, "isinfinite", 1),
161+ CFUNC(f_isnan, "isnan", 1),
162+ CFUNC(f_isnormal, "isnormal", 1),
163+ CFUNC(f_infinite, "infinite", 1),
164+ CFUNC(f_nan, "nan", 1),
165+ CFUNC(f_sort, "sort", 1),
166+ CFUNC(f_sort_by_impl, "_sort_by_impl", 2),
167+ CFUNC(f_group_by_impl, "_group_by_impl", 2),
168+ CFUNC(f_min, "min", 1),
169+ CFUNC(f_max, "max", 1),
170+ CFUNC(f_min_by_impl, "_min_by_impl", 2),
171+ CFUNC(f_max_by_impl, "_max_by_impl", 2),
172+ CFUNC(f_error, "error", 1),
173+ CFUNC(f_format, "format", 2),
174+ CFUNC(f_env, "env", 1),
175+ CFUNC(f_halt, "halt", 1),
176+ CFUNC(f_halt_error, "halt_error", 2),
177+ CFUNC(f_get_search_list, "get_search_list", 1),
178+ CFUNC(f_get_prog_origin, "get_prog_origin", 1),
179+ CFUNC(f_get_jq_origin, "get_jq_origin", 1),
180+ CFUNC(f_match, "_match_impl", 4),
181+ CFUNC(f_modulemeta, "modulemeta", 1),
182+ CFUNC(f_input, "input", 1),
183+ CFUNC(f_debug, "debug", 1),
184+ CFUNC(f_stderr, "stderr", 1),
185+ CFUNC(f_strptime, "strptime", 2),
186+ CFUNC(f_strftime, "strftime", 2),
187+ CFUNC(f_strflocaltime, "strflocaltime", 2),
188+ CFUNC(f_mktime, "mktime", 1),
189+ CFUNC(f_gmtime, "gmtime", 1),
190+ CFUNC(f_localtime, "localtime", 1),
191+ CFUNC(f_now, "now", 1),
192+ CFUNC(f_current_filename, "input_filename", 1),
193+ CFUNC(f_current_line, "input_line_number", 1),
194 };
195 #undef LIBM_DDDD_NO
196 #undef LIBM_DDD_NO
197diff --git a/src/bytecode.h b/src/bytecode.h
198index 1501985..a4055f5 100644
199--- a/src/bytecode.h
200+++ b/src/bytecode.h
201@@ -2,7 +2,7 @@
202 #define BYTECODE_H
203 #include <stdint.h>
204
205-#include "jv.h"
206+#include "jq.h"
207
208 typedef enum {
209 #define OP(name, imm, in, out) name,
210@@ -44,9 +44,14 @@ struct opcode_description {
211 const struct opcode_description* opcode_describe(opcode op);
212
213
214-#define MAX_CFUNCTION_ARGS 10
215+#define MAX_CFUNCTION_ARGS 4
216 struct cfunction {
217- jv (*fptr)();
218+ union {
219+ jv (*a1)(jq_state *, jv);
220+ jv (*a2)(jq_state *, jv, jv);
221+ jv (*a3)(jq_state *, jv, jv, jv);
222+ jv (*a4)(jq_state *, jv, jv, jv, jv);
223+ } fptr;
224 const char* name;
225 int nargs;
226 };
227diff --git a/src/execute.c b/src/execute.c
228index 9ef8368..62404db 100644
229--- a/src/execute.c
230+++ b/src/execute.c
231@@ -913,14 +913,13 @@ jv jq_next(jq_state *jq) {
232 }
233 struct cfunction* function = &frame_current(jq)->bc->globals->cfunctions[*pc++];
234 switch (function->nargs) {
235- case 1: top = ((jv (*)(jq_state *, jv))function->fptr)(jq, in[0]); break;
236- case 2: top = ((jv (*)(jq_state *, jv, jv))function->fptr)(jq, in[0], in[1]); break;
237- case 3: top = ((jv (*)(jq_state *, jv, jv, jv))function->fptr)(jq, in[0], in[1], in[2]); break;
238- case 4: top = ((jv (*)(jq_state *, jv, jv, jv, jv))function->fptr)(jq, in[0], in[1], in[2], in[3]); break;
239- case 5: top = ((jv (*)(jq_state *, jv, jv, jv, jv, jv))function->fptr)(jq, in[0], in[1], in[2], in[3], in[4]); break;
240+ case 1: top = function->fptr.a1(jq, in[0]); break;
241+ case 2: top = function->fptr.a2(jq, in[0], in[1]); break;
242+ case 3: top = function->fptr.a3(jq, in[0], in[1], in[2]); break;
243+ case 4: top = function->fptr.a4(jq, in[0], in[1], in[2], in[3]); break;
244 // FIXME: a) up to 7 arguments (input + 6), b) should assert
245 // because the compiler should not generate this error.
246 default: return jv_invalid_with_msg(jv_string("Function takes too many arguments"));
247 }
248
249 if (jv_is_valid(top)) {
diff --git a/meta-oe/recipes-devtools/jq/jq_1.7.1.bb b/meta-oe/recipes-devtools/jq/jq_1.7.1.bb
index 3f57adb910..6b12335513 100644
--- a/meta-oe/recipes-devtools/jq/jq_1.7.1.bb
+++ b/meta-oe/recipes-devtools/jq/jq_1.7.1.bb
@@ -10,9 +10,6 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=488f4e0b04c0456337fb70d1ac1758ba"
10 10
11GITHUB_BASE_URI = "https://github.com/jqlang/${BPN}/releases/" 11GITHUB_BASE_URI = "https://github.com/jqlang/${BPN}/releases/"
12SRC_URI = "${GITHUB_BASE_URI}/download/${BPN}-${PV}/${BPN}-${PV}.tar.gz \ 12SRC_URI = "${GITHUB_BASE_URI}/download/${BPN}-${PV}/${BPN}-${PV}.tar.gz \
13 file://0001-builtin.c-fix-build-with-Woverlength-strings.patch \
14 file://0002-libm.h-builtin.c-add-and-use-LIBM_DA-and-LIBM_DA_NO-.patch \
15 file://0003-builtin.c-typecheck-builtin-cfunctions-in-function_l.patch \
16 file://run-ptest \ 13 file://run-ptest \
17 " 14 "
18SRC_URI[sha256sum] = "478c9ca129fd2e3443fe27314b455e211e0d8c60bc8ff7df703873deeee580c2" 15SRC_URI[sha256sum] = "478c9ca129fd2e3443fe27314b455e211e0d8c60bc8ff7df703873deeee580c2"