Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtin.c: fix build with -Woverlength-strings #3019

Merged
merged 2 commits into from
Jan 26, 2024

Conversation

emanuele6
Copy link
Member

C99 only allows string literals long at most 4095 characters.
jq_builtins was a lot longer than that.

I rewrote all the optional libm error stubs in C so the value of jq_builtins is not build dependent.

I replaced the command that generates builtin.inc with a POSIX compliant od|sed command that encodes builtin.jq as a comma delimited list of octal numbers (that can be embedded in C using a {} literal).

I also added -Woverlength-strings to AM_CFLAGS to verify that the problem is fixed.

Fixes #1481

src/builtin.c Outdated Show resolved Hide resolved
src/builtin.c Show resolved Hide resolved
Makefile.am Outdated Show resolved Hide resolved
C99 only allows string literals long at most 4095 characters.
jq_builtins was a lot longer than that.

I rewrote all the optional libm error stubs in C so the value of
jq_builtins is not build dependent.

I replaced the command that generates builtin.inc with a POSIX compliant
od|sed command that encodes builtin.jq as a comma delimited list of
octal numbers (that can be embedded in C using a {} literal).

I also added -Woverlength-strings to AM_CFLAGS to verify that the
problem is fixed.

Fixes jqlang#1481
@emanuele6 emanuele6 force-pushed the fixlongstringv2 branch 2 times, most recently from d34fcea to f0ca565 Compare January 26, 2024 10:28
@emanuele6 emanuele6 requested a review from wader January 26, 2024 10:28
src/builtin.c Show resolved Hide resolved
src/libm.h Outdated Show resolved Hide resolved
src/builtin.c Outdated Show resolved Hide resolved
For functions that from one double return an array with two numbers.
@nicowilliams
Copy link
Contributor

LGTM!

@nicowilliams nicowilliams merged commit bd3c828 into jqlang:master Jan 26, 2024
28 checks passed
@emanuele6 emanuele6 deleted the fixlongstringv2 branch January 26, 2024 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

builtin.inc exceeds maximum length for C99
3 participants