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

Destructure alt #2

Open
wants to merge 164 commits into
base: master
Choose a base branch
from

Conversation

leonid-s-usov
Copy link

Sorry, you didn't have a corresponding branch so I had to compare with your master

Anyhow, please only look at the final commit, which is a final squash of the relevant changes.
Tests pass

haochenx and others added 30 commits November 12, 2018 16:00
…uild-dependency-in

add automake as build dependency to README.md
'operator' needs to be plural here.
Users are often surprised by the requirement to parenthesize any
non-trivial object key expressions in object constructors.  E.g.,
{"a"+"b":1}.  This commit adds one more kind of key expression besides
literals and idents: variable references.

A common use case for this is jq programs as JSON templates to fill in
with variables computed from inputs or passed in on the command-line.
E.g., {some_key:$value}.  Now users can also use, e.g., {$key:$value}.

This and the restrictions on key and value expressions in object
constructors are now clarified a bit in the documentation.
Adds the release info for 1.6 to NEWS
* Set default error code to -4 in main(), Fixes jqlang#1142
* fix --exit-code with more than one object in input, Fixes jqlang#1139
    - Return code 1 or 4 based on last output, not last input.
"Undefined symbols are not allowed in x86_64-w64-mingw32 shared libraries"

This was also applied in the official MINGW-packages repo:
Alexpux/MINGW-packages@b5566c58a
Follow-up fix to b436156 because BOOL and DWORD
are not built-in to mingw64.
Replace uses of the nonstandard $^ variable by explicitly specifying the
source filenames. This is the only obvious thing preventing the build
from running correctly on non-GNU make.
my_timegm was introduced in 1900c7 to add a mktime fallback used in
4a6241, the subsequently removed in c53823. As a result of this code
shuffling, the jq mktime function (f_mktime) wound up using a fallback
even on systems where timegm is available, with incorrect results in
some time zones with DST, e.g.

% TZ=America/New_York jq -n '"2018-08-31T00:00:00Z"|fromdate|todate'
"2018-08-31T01:00:00Z"

This undoes 1900c7 and moves the workaround it added into the #else of
my_mktime.
If these values do not match exactly, it is because the UTF-8 is invalid
anyway and we counted codepoints differently than oniguruma did.  Perhaps it
would be better to error out here, but at least one similar loop already
uses < vs != and since we're off the rails anyway this might be OK.  It is
certainly better than overruning the buffer.

Resolves jqlang#1804
The distinction between input/0 and _input/0 has been unnecessary since
a9c613..7dc34b, which moved end-of-input handling into C and replaced
the jq definition of input with `def input: _input;`
The parser generates a call to error/0 on break. Having that exported
from C directly removes a language dependency on builtin.jq.

In any case, error/0 seems to be the more fundamental operation, seeing
as the old C impementation of error/1 did nothing useful with its input.
Windows 10 supports color output, but it must be explicitly enabled;
ANSICON provides support for other versions.  Enable color if either of
those are available.  Resolves jqlang#1494.
leonid-s-usov and others added 29 commits January 25, 2020 03:44
This is the first commit that introduces the new instructions and the new execution loop
START; CALL_JQ main_or_coroutine; OUT; BACKTRACK

START is going to throw the handle in the parent context and initiate the read in the child context.
More to come
in case we copy a block of instructions and some of them are branching to the others
within the same block, then the copied instructions would still carry
invalid target references.
To fix it we introduce a copy state so that it's easy to remap the
affected instructions.
when considering to add RET_JQ at the end of a block.
currently two instructions backtrack: BACKTRACK and TAIL_OUT
In case a path gets deleted, we should iterate arrays backwards in
path/1 context.
Now the RET_JQ will only be omitted for the top level program.
It will look uglier being present after BACKTRACKs or TAIL_OUTs,
but it's at least safe
…ned; fix a potential memory leak

For the case of a block_is_single(block) input, the function interface is updated to return an updated block
Additionally, a new inst_dispose method is called on the CALL_JQ instruction to make sure
that the resources which are overwritten are properly released.
typedef enum jq_input_mode_enum {
  // JQ VM reaches a state where it requires the next input
  // when it backtracks to START.
  // At this point the VM can behave differently, and this enum
  // describes the possible actions VM will take.

  // In the RETURN_EMPTY mode jq_next behaves like it always did:
  // it will return a jv_invalid() without any message
  // to show that additional input is needed
  // The caller in this case may choose to restart the VM
  // or set the next value and call jq_next again
  JQ_INPUT_RETURN_EMPTY,

  // In the CALLBACK mode jq_next will issue an input callback
  // in case it will require more input. This will be equivalent
  // to when the jq program reaches the `input` instruction.
  // passing an invalid to the callback will immediately request input again
  // passing an invalid with message will raise this as an error and halt
  JQ_INPUT_CALLBACK,

  // A backward compatible default mode
  JQ_INPUT_DEFAULT = JQ_INPUT_RETURN_EMPTY
} jq_input_mode;
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.