linker.c (jq-1.5) | : | linker.c (jq-1.6) | ||
---|---|---|---|---|
skipping to change at line 12 | skipping to change at line 12 | |||
#include <errno.h> | #include <errno.h> | |||
#include <limits.h> | #include <limits.h> | |||
#include <string.h> | #include <string.h> | |||
#include <stdio.h> | #include <stdio.h> | |||
#include <stdlib.h> | #include <stdlib.h> | |||
#include <stdint.h> | #include <stdint.h> | |||
#include <sys/stat.h> | #include <sys/stat.h> | |||
#include <libgen.h> | #include <libgen.h> | |||
#ifdef WIN32 | #ifdef WIN32 | |||
#include <windows.h> | ||||
#include <shlwapi.h> | #include <shlwapi.h> | |||
#endif | #endif | |||
#include "jq_parser.h" | #include "jq_parser.h" | |||
#include "locfile.h" | #include "locfile.h" | |||
#include "jv.h" | #include "jv.h" | |||
#include "jq.h" | #include "jq.h" | |||
#include "parser.h" | #include "parser.h" | |||
#include "util.h" | #include "util.h" | |||
#include "compile.h" | #include "compile.h" | |||
#include "jv_alloc.h" | ||||
struct lib_loading_state { | struct lib_loading_state { | |||
char **names; | char **names; | |||
block *defs; | block *defs; | |||
uint64_t ct; | uint64_t ct; | |||
}; | }; | |||
static int load_library(jq_state *jq, jv lib_path, int is_data, int raw, | static int load_library(jq_state *jq, jv lib_path, int is_data, int raw, | |||
const char *as, block *out_block, | const char *as, block *out_block, | |||
struct lib_loading_state *lib_state); | struct lib_loading_state *lib_state); | |||
skipping to change at line 281 | skipping to change at line 281 | |||
jv_free(resolved); | jv_free(resolved); | |||
// Bind the library to the program | // Bind the library to the program | |||
bk = block_bind_library(lib_state->defs[state_idx], bk, OP_IS_CALL_PSEUDO, as_str); | bk = block_bind_library(lib_state->defs[state_idx], bk, OP_IS_CALL_PSEUDO, as_str); | |||
} else { // Not found. Add it to the table before binding. | } else { // Not found. Add it to the table before binding. | |||
block dep_def_block = gen_noop(); | block dep_def_block = gen_noop(); | |||
nerrors += load_library(jq, resolved, is_data, raw, as_str, &dep_def_block , lib_state); | nerrors += load_library(jq, resolved, is_data, raw, as_str, &dep_def_block , lib_state); | |||
// resolved has been freed | // resolved has been freed | |||
if (nerrors == 0) { | if (nerrors == 0) { | |||
// Bind the library to the program | // Bind the library to the program | |||
bk = block_bind_library(dep_def_block, bk, OP_IS_CALL_PSEUDO, as_str); | bk = block_bind_library(dep_def_block, bk, OP_IS_CALL_PSEUDO, as_str); | |||
if (is_data) | ||||
bk = block_bind_library(dep_def_block, bk, OP_IS_CALL_PSEUDO, NULL); | ||||
} | } | |||
} | } | |||
jv_free(as); | jv_free(as); | |||
} | } | |||
jv_free(lib_origin); | jv_free(lib_origin); | |||
jv_free(jq_origin); | jv_free(jq_origin); | |||
jv_free(deps); | jv_free(deps); | |||
return nerrors; | return nerrors; | |||
} | } | |||
skipping to change at line 327 | skipping to change at line 329 | |||
nerrors += jq_parse_library(src, &program); | nerrors += jq_parse_library(src, &program); | |||
if (nerrors == 0) { | if (nerrors == 0) { | |||
char *lib_origin = strdup(jv_string_value(lib_path)); | char *lib_origin = strdup(jv_string_value(lib_path)); | |||
nerrors += process_dependencies(jq, jq_get_jq_origin(jq), | nerrors += process_dependencies(jq, jq_get_jq_origin(jq), | |||
jv_string(dirname(lib_origin)), | jv_string(dirname(lib_origin)), | |||
&program, lib_state); | &program, lib_state); | |||
free(lib_origin); | free(lib_origin); | |||
} | } | |||
} | } | |||
state_idx = lib_state->ct++; | state_idx = lib_state->ct++; | |||
lib_state->names = realloc(lib_state->names, lib_state->ct * sizeof(const char | lib_state->names = jv_mem_realloc(lib_state->names, lib_state->ct * sizeof(con | |||
*)); | st char *)); | |||
lib_state->defs = realloc(lib_state->defs, lib_state->ct * sizeof(block)); | lib_state->defs = jv_mem_realloc(lib_state->defs, lib_state->ct * sizeof(block | |||
)); | ||||
lib_state->names[state_idx] = strdup(jv_string_value(lib_path)); | lib_state->names[state_idx] = strdup(jv_string_value(lib_path)); | |||
lib_state->defs[state_idx] = program; | lib_state->defs[state_idx] = program; | |||
*out_block = program; | *out_block = program; | |||
if (src) | if (src) | |||
locfile_free(src); | locfile_free(src); | |||
out: | out: | |||
jv_free(lib_path); | jv_free(lib_path); | |||
jv_free(data); | jv_free(data); | |||
return nerrors; | return nerrors; | |||
} | } | |||
End of changes. 4 change blocks. | ||||
4 lines changed or deleted | 7 lines changed or added |