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

Load ~/.jq as a library #1830

Merged
merged 6 commits into from
Feb 21, 2019
Merged

Load ~/.jq as a library #1830

merged 6 commits into from
Feb 21, 2019

Conversation

muhmuhten
Copy link
Contributor

There are no performance improvements in this patchset, unfortunately.

It's just an attempt at cleaning up builtins_bind to make a better springboard for working out the details of #1826 without having ~/.jq guts in the same function, when it can better be loaded as a library that just happens to have the same name and location.

There is a small incompatibility in the resolution order of shadowed names, but that's already buggy IMO (#1828) so I don't think it matters.

(muhmuhten@0702990 is a slightly more truthful history of this changeset.)

@nicowilliams
Copy link
Contributor

Tests fail, FYI.

@muhmuhten
Copy link
Contributor Author

Well okay, looks like I introduced a(?) memory leak, but it's a works-on-my-machine so this space might get a bit noisy with pushes as I try to suss that out with the CI.

"Module path must be a string" is not a useful error message when the
reason the module path isn't a string is because the string it was got
replaced with an invalid with an error message for some other reason.

Also fixes a few memory leaks on early exits.
Only the second and subsequent path components were being checked, which
I guess is theoretically security-relevant.

There's no apparent point to reconstructing the path after splitting it
by adding /s back in, either.
The case isn't actually possible afaict.
A library marked is imported if found, but silently skipped if missing.
This is the desired semantic for the auto-include at ~/.jq
Remove the special code which loads ~/.jq in builtin.c, and instead glue
an optional include which points to the same file onto the main program
in linker.c.

Fixes a minor bug where errors in ~/.jq would be labelled <builtin>.
@muhmuhten
Copy link
Contributor Author

Tests are passing now, or at least the ones that normally pass anyway.

I squashed bugfixes into their corresponding commits; sorry for the extra noise, though.

@nicowilliams
Copy link
Contributor

Yeah, I've been meaning to figure out what's up with the tests that fail all the time...

@nicowilliams nicowilliams merged commit b2b0bd3 into jqlang:master Feb 21, 2019
@nicowilliams
Copy link
Contributor

Thanks!!!

@muhmuhten muhmuhten deleted the init_as_lib branch February 21, 2019 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants