rugged 1.5.0.1 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rugged/extconf.rb +2 -2
- data/ext/rugged/rugged_allocator.c +0 -54
- data/ext/rugged/rugged_blame.c +2 -0
- data/ext/rugged/rugged_blob.c +3 -0
- data/ext/rugged/rugged_commit.c +1 -0
- data/ext/rugged/rugged_config.c +2 -0
- data/ext/rugged/rugged_diff.c +1 -0
- data/ext/rugged/rugged_index.c +2 -0
- data/ext/rugged/rugged_patch.c +1 -0
- data/ext/rugged/rugged_rebase.c +1 -0
- data/ext/rugged/rugged_reference.c +1 -0
- data/ext/rugged/rugged_remote.c +1 -0
- data/ext/rugged/rugged_repo.c +5 -2
- data/ext/rugged/rugged_revwalk.c +5 -1
- data/ext/rugged/rugged_submodule.c +1 -0
- data/ext/rugged/rugged_tag.c +1 -0
- data/ext/rugged/rugged_tree.c +4 -0
- data/lib/rugged/index.rb +1 -1
- data/lib/rugged/tree.rb +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +7 -8
- data/vendor/libgit2/COPYING +30 -0
- data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -0
- data/vendor/libgit2/cmake/ExperimentalFeatures.cmake +23 -0
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +3 -3
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +21 -2
- data/vendor/libgit2/cmake/SelectHashes.cmake +4 -0
- data/vendor/libgit2/cmake/SelectXdiff.cmake +9 -0
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/pcre/LICENCE +5 -5
- data/vendor/libgit2/deps/pcre/pcre.h +2 -2
- data/vendor/libgit2/deps/pcre/pcre_compile.c +6 -3
- data/vendor/libgit2/deps/pcre/pcre_exec.c +2 -2
- data/vendor/libgit2/deps/xdiff/CMakeLists.txt +28 -0
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/git-xdiff.h +4 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.c +19 -18
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.h +2 -4
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.c +3 -3
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xhistogram.c +7 -18
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmacros.h +18 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmerge.c +24 -22
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xpatience.c +21 -30
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.c +13 -30
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.c +18 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.h +2 -1
- data/vendor/libgit2/include/git2/common.h +38 -6
- data/vendor/libgit2/include/git2/deprecated.h +6 -0
- data/vendor/libgit2/include/git2/diff.h +42 -4
- data/vendor/libgit2/include/git2/errors.h +4 -2
- data/vendor/libgit2/include/git2/experimental.h +20 -0
- data/vendor/libgit2/include/git2/index.h +9 -0
- data/vendor/libgit2/include/git2/indexer.h +29 -0
- data/vendor/libgit2/include/git2/object.h +28 -2
- data/vendor/libgit2/include/git2/odb.h +58 -7
- data/vendor/libgit2/include/git2/odb_backend.h +106 -18
- data/vendor/libgit2/include/git2/oid.h +116 -16
- data/vendor/libgit2/include/git2/remote.h +18 -0
- data/vendor/libgit2/include/git2/repository.h +32 -3
- data/vendor/libgit2/include/git2/stash.h +60 -6
- data/vendor/libgit2/include/git2/strarray.h +0 -13
- data/vendor/libgit2/include/git2/sys/alloc.h +0 -34
- data/vendor/libgit2/include/git2/sys/commit_graph.h +12 -2
- data/vendor/libgit2/include/git2/sys/midx.h +5 -1
- data/vendor/libgit2/include/git2/sys/odb_backend.h +1 -1
- data/vendor/libgit2/include/git2/sys/stream.h +16 -2
- data/vendor/libgit2/include/git2/sys/transport.h +32 -2
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +3 -1
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +34 -17
- data/vendor/libgit2/src/cli/CMakeLists.txt +5 -2
- data/vendor/libgit2/src/cli/cmd_clone.c +22 -6
- data/vendor/libgit2/src/cli/cmd_hash_object.c +27 -8
- data/vendor/libgit2/src/cli/opt.c +1 -1
- data/vendor/libgit2/src/cli/progress.c +9 -8
- data/vendor/libgit2/src/cli/progress.h +4 -4
- data/vendor/libgit2/src/libgit2/CMakeLists.txt +25 -34
- data/vendor/libgit2/src/libgit2/annotated_commit.c +2 -2
- data/vendor/libgit2/src/libgit2/annotated_commit.h +1 -1
- data/vendor/libgit2/src/libgit2/apply.c +4 -3
- data/vendor/libgit2/src/libgit2/attr_file.c +1 -1
- data/vendor/libgit2/src/libgit2/attrcache.c +1 -1
- data/vendor/libgit2/src/libgit2/blame.c +23 -14
- data/vendor/libgit2/src/libgit2/blame_git.c +0 -1
- data/vendor/libgit2/src/libgit2/blob.c +4 -2
- data/vendor/libgit2/src/libgit2/blob.h +2 -2
- data/vendor/libgit2/src/libgit2/branch.c +2 -2
- data/vendor/libgit2/src/libgit2/cherrypick.c +3 -3
- data/vendor/libgit2/src/libgit2/clone.c +34 -3
- data/vendor/libgit2/src/libgit2/commit.c +78 -21
- data/vendor/libgit2/src/libgit2/commit.h +25 -7
- data/vendor/libgit2/src/libgit2/commit_graph.c +129 -47
- data/vendor/libgit2/src/libgit2/commit_graph.h +23 -4
- data/vendor/libgit2/src/libgit2/commit_list.c +16 -5
- data/vendor/libgit2/src/libgit2/commit_list.h +1 -0
- data/vendor/libgit2/src/libgit2/config.c +6 -3
- data/vendor/libgit2/src/libgit2/config_file.c +16 -10
- data/vendor/libgit2/src/libgit2/describe.c +11 -8
- data/vendor/libgit2/src/libgit2/diff.c +19 -6
- data/vendor/libgit2/src/libgit2/diff.h +6 -6
- data/vendor/libgit2/src/libgit2/diff_file.c +16 -7
- data/vendor/libgit2/src/libgit2/diff_generate.c +37 -11
- data/vendor/libgit2/src/libgit2/diff_parse.c +20 -4
- data/vendor/libgit2/src/libgit2/diff_print.c +26 -7
- data/vendor/libgit2/src/libgit2/diff_tform.c +4 -0
- data/vendor/libgit2/src/libgit2/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/libgit2/email.c +4 -3
- data/vendor/libgit2/src/libgit2/errors.c +73 -18
- data/vendor/libgit2/src/libgit2/experimental.h.in +13 -0
- data/vendor/libgit2/src/libgit2/fetch.c +38 -13
- data/vendor/libgit2/src/libgit2/fetch.h +0 -2
- data/vendor/libgit2/src/libgit2/fetchhead.c +11 -9
- data/vendor/libgit2/src/libgit2/grafts.c +272 -0
- data/vendor/libgit2/src/libgit2/grafts.h +36 -0
- data/vendor/libgit2/src/libgit2/ident.c +3 -3
- data/vendor/libgit2/src/libgit2/index.c +327 -123
- data/vendor/libgit2/src/libgit2/index.h +14 -1
- data/vendor/libgit2/src/libgit2/indexer.c +116 -46
- data/vendor/libgit2/src/libgit2/iterator.c +21 -4
- data/vendor/libgit2/src/libgit2/iterator.h +3 -0
- data/vendor/libgit2/src/libgit2/libgit2.c +58 -0
- data/vendor/libgit2/src/libgit2/merge.c +14 -9
- data/vendor/libgit2/src/libgit2/merge_file.c +0 -2
- data/vendor/libgit2/src/libgit2/midx.c +68 -38
- data/vendor/libgit2/src/libgit2/midx.h +13 -3
- data/vendor/libgit2/src/libgit2/mwindow.c +5 -2
- data/vendor/libgit2/src/libgit2/mwindow.h +4 -1
- data/vendor/libgit2/src/libgit2/notes.c +9 -8
- data/vendor/libgit2/src/libgit2/object.c +118 -29
- data/vendor/libgit2/src/libgit2/object.h +17 -2
- data/vendor/libgit2/src/libgit2/odb.c +224 -55
- data/vendor/libgit2/src/libgit2/odb.h +43 -4
- data/vendor/libgit2/src/libgit2/odb_loose.c +128 -70
- data/vendor/libgit2/src/libgit2/odb_pack.c +111 -46
- data/vendor/libgit2/src/libgit2/oid.c +141 -77
- data/vendor/libgit2/src/libgit2/oid.h +183 -9
- data/vendor/libgit2/src/libgit2/oidarray.c +49 -3
- data/vendor/libgit2/src/libgit2/oidarray.h +5 -1
- data/vendor/libgit2/src/libgit2/pack-objects.c +31 -13
- data/vendor/libgit2/src/libgit2/pack-objects.h +5 -2
- data/vendor/libgit2/src/libgit2/pack.c +93 -70
- data/vendor/libgit2/src/libgit2/pack.h +29 -15
- data/vendor/libgit2/src/libgit2/parse.c +8 -4
- data/vendor/libgit2/src/libgit2/parse.h +1 -1
- data/vendor/libgit2/src/libgit2/patch.h +7 -1
- data/vendor/libgit2/src/libgit2/patch_generate.c +24 -5
- data/vendor/libgit2/src/libgit2/patch_parse.c +16 -8
- data/vendor/libgit2/src/libgit2/push.c +13 -3
- data/vendor/libgit2/src/libgit2/reader.c +1 -1
- data/vendor/libgit2/src/libgit2/rebase.c +72 -83
- data/vendor/libgit2/src/libgit2/refdb_fs.c +92 -52
- data/vendor/libgit2/src/libgit2/reflog.c +7 -5
- data/vendor/libgit2/src/libgit2/reflog.h +1 -2
- data/vendor/libgit2/src/libgit2/refs.c +9 -0
- data/vendor/libgit2/src/libgit2/remote.c +47 -37
- data/vendor/libgit2/src/libgit2/remote.h +41 -0
- data/vendor/libgit2/src/libgit2/repository.c +784 -329
- data/vendor/libgit2/src/libgit2/repository.h +26 -2
- data/vendor/libgit2/src/libgit2/reset.c +2 -2
- data/vendor/libgit2/src/libgit2/revert.c +8 -11
- data/vendor/libgit2/src/libgit2/revparse.c +23 -7
- data/vendor/libgit2/src/libgit2/revwalk.c +31 -5
- data/vendor/libgit2/src/libgit2/stash.c +209 -33
- data/vendor/libgit2/src/libgit2/strarray.c +1 -0
- data/vendor/libgit2/src/libgit2/strarray.h +25 -0
- data/vendor/libgit2/src/libgit2/streams/mbedtls.c +0 -1
- data/vendor/libgit2/src/libgit2/streams/openssl.c +9 -17
- data/vendor/libgit2/src/libgit2/streams/openssl_dynamic.c +7 -3
- data/vendor/libgit2/src/libgit2/streams/schannel.c +715 -0
- data/vendor/libgit2/src/libgit2/streams/schannel.h +28 -0
- data/vendor/libgit2/src/libgit2/streams/socket.c +240 -51
- data/vendor/libgit2/src/libgit2/streams/socket.h +3 -1
- data/vendor/libgit2/src/libgit2/streams/stransport.c +40 -12
- data/vendor/libgit2/src/libgit2/streams/tls.c +5 -0
- data/vendor/libgit2/src/libgit2/submodule.c +6 -2
- data/vendor/libgit2/src/libgit2/submodule.h +3 -3
- data/vendor/libgit2/src/libgit2/sysdir.c +294 -7
- data/vendor/libgit2/src/libgit2/sysdir.h +41 -9
- data/vendor/libgit2/src/libgit2/tag.c +29 -10
- data/vendor/libgit2/src/libgit2/tag.h +2 -2
- data/vendor/libgit2/src/libgit2/threadstate.c +15 -2
- data/vendor/libgit2/src/libgit2/threadstate.h +1 -3
- data/vendor/libgit2/src/libgit2/transports/auth.h +1 -2
- data/vendor/libgit2/src/libgit2/transports/{auth_negotiate.c → auth_gssapi.c} +32 -32
- data/vendor/libgit2/src/libgit2/transports/auth_negotiate.h +1 -1
- data/vendor/libgit2/src/libgit2/transports/auth_ntlm.h +1 -1
- data/vendor/libgit2/src/libgit2/transports/{auth_ntlm.c → auth_ntlmclient.c} +12 -12
- data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
- data/vendor/libgit2/src/libgit2/transports/git.c +7 -8
- data/vendor/libgit2/src/libgit2/transports/http.c +15 -9
- data/vendor/libgit2/src/libgit2/transports/httpclient.c +14 -0
- data/vendor/libgit2/src/libgit2/transports/httpclient.h +10 -0
- data/vendor/libgit2/src/libgit2/transports/local.c +27 -4
- data/vendor/libgit2/src/libgit2/transports/smart.c +68 -27
- data/vendor/libgit2/src/libgit2/transports/smart.h +33 -9
- data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +281 -49
- data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +192 -55
- data/vendor/libgit2/src/libgit2/transports/ssh.c +334 -102
- data/vendor/libgit2/src/libgit2/transports/winhttp.c +22 -18
- data/vendor/libgit2/src/libgit2/tree-cache.c +26 -16
- data/vendor/libgit2/src/libgit2/tree-cache.h +5 -3
- data/vendor/libgit2/src/libgit2/tree.c +23 -17
- data/vendor/libgit2/src/libgit2/tree.h +2 -2
- data/vendor/libgit2/src/libgit2/worktree.c +30 -10
- data/vendor/libgit2/src/util/CMakeLists.txt +6 -1
- data/vendor/libgit2/src/util/alloc.c +65 -6
- data/vendor/libgit2/src/util/alloc.h +34 -9
- data/vendor/libgit2/src/util/allocators/failalloc.c +0 -60
- data/vendor/libgit2/src/util/allocators/failalloc.h +0 -6
- data/vendor/libgit2/src/util/allocators/stdalloc.c +2 -105
- data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +0 -68
- data/vendor/libgit2/src/util/array.h +6 -1
- data/vendor/libgit2/src/util/cc-compat.h +2 -0
- data/vendor/libgit2/src/util/filebuf.c +6 -1
- data/vendor/libgit2/src/util/filebuf.h +19 -6
- data/vendor/libgit2/src/util/fs_path.c +2 -2
- data/vendor/libgit2/src/util/futils.c +8 -8
- data/vendor/libgit2/src/{features.h.in → util/git2_features.h.in} +9 -3
- data/vendor/libgit2/src/util/git2_util.h +2 -2
- data/vendor/libgit2/src/util/hash/openssl.c +4 -3
- data/vendor/libgit2/src/util/hash/rfc6234/sha.h +0 -112
- data/vendor/libgit2/src/util/hash.h +13 -0
- data/vendor/libgit2/src/util/net.c +492 -87
- data/vendor/libgit2/src/util/net.h +32 -0
- data/vendor/libgit2/src/util/posix.c +54 -0
- data/vendor/libgit2/src/util/posix.h +24 -0
- data/vendor/libgit2/src/util/rand.c +10 -4
- data/vendor/libgit2/src/util/regexp.c +3 -3
- data/vendor/libgit2/src/util/staticstr.h +66 -0
- data/vendor/libgit2/src/util/thread.h +20 -19
- data/vendor/libgit2/src/util/util.c +15 -10
- data/vendor/libgit2/src/util/util.h +25 -16
- data/vendor/libgit2/src/util/win32/error.c +1 -1
- data/vendor/libgit2/src/util/win32/path_w32.c +8 -8
- data/vendor/libgit2/src/util/win32/posix_w32.c +1 -1
- data/vendor/libgit2/src/util/win32/utf-conv.c +73 -75
- data/vendor/libgit2/src/util/win32/utf-conv.h +81 -14
- data/vendor/libgit2/src/util/win32/w32_util.c +1 -1
- metadata +34 -26
- data/vendor/libgit2/cmake/SelectWinHTTP.cmake +0 -17
- data/vendor/libgit2/src/libgit2/netops.c +0 -124
- data/vendor/libgit2/src/libgit2/netops.h +0 -68
- data/vendor/libgit2/src/util/win32/findfile.c +0 -286
- data/vendor/libgit2/src/util/win32/findfile.h +0 -22
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiff.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xinclude.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xtypes.h +0 -0
@@ -6,7 +6,7 @@
|
|
6
6
|
and semantics are as close as possible to those of the Perl 5 language.
|
7
7
|
|
8
8
|
Written by Philip Hazel
|
9
|
-
Copyright (c) 1997-
|
9
|
+
Copyright (c) 1997-2021 University of Cambridge
|
10
10
|
|
11
11
|
-----------------------------------------------------------------------------
|
12
12
|
Redistribution and use in source and binary forms, with or without
|
@@ -9104,6 +9104,8 @@ pcre_uchar cworkspace[COMPILE_WORK_SIZE];
|
|
9104
9104
|
similar way to cworkspace, it can be expanded using malloc() if necessary. */
|
9105
9105
|
|
9106
9106
|
named_group named_groups[NAMED_GROUP_LIST_SIZE];
|
9107
|
+
cd->named_groups = named_groups;
|
9108
|
+
cd->named_group_list_size = NAMED_GROUP_LIST_SIZE;
|
9107
9109
|
|
9108
9110
|
/* Set this early so that early errors get offset 0. */
|
9109
9111
|
|
@@ -9377,8 +9379,6 @@ cd->hwm = cworkspace;
|
|
9377
9379
|
cd->iscondassert = FALSE;
|
9378
9380
|
cd->start_workspace = cworkspace;
|
9379
9381
|
cd->workspace_size = COMPILE_WORK_SIZE;
|
9380
|
-
cd->named_groups = named_groups;
|
9381
|
-
cd->named_group_list_size = NAMED_GROUP_LIST_SIZE;
|
9382
9382
|
cd->start_pattern = (const pcre_uchar *)pattern;
|
9383
9383
|
cd->end_pattern = (const pcre_uchar *)(pattern + STRLEN_UC((const pcre_uchar *)pattern));
|
9384
9384
|
cd->req_varyopt = 0;
|
@@ -9489,6 +9489,7 @@ if (cd->names_found > 0)
|
|
9489
9489
|
add_name(cd, ng->name, ng->length, ng->number);
|
9490
9490
|
if (cd->named_group_list_size > NAMED_GROUP_LIST_SIZE)
|
9491
9491
|
(PUBL(free))((void *)cd->named_groups);
|
9492
|
+
cd->named_group_list_size = 0; /* So we don't free it twice */
|
9492
9493
|
}
|
9493
9494
|
|
9494
9495
|
/* Set up a starting, non-extracting bracket, then compile the expression. On
|
@@ -9639,6 +9640,8 @@ if (errorcode != 0)
|
|
9639
9640
|
{
|
9640
9641
|
(PUBL(free))(re);
|
9641
9642
|
PCRE_EARLY_ERROR_RETURN:
|
9643
|
+
if (cd->named_group_list_size > NAMED_GROUP_LIST_SIZE)
|
9644
|
+
(PUBL(free))((void *)cd->named_groups);
|
9642
9645
|
*erroroffset = (int)(ptr - (const pcre_uchar *)pattern);
|
9643
9646
|
PCRE_EARLY_ERROR_RETURN2:
|
9644
9647
|
*errorptr = find_error_text(errorcode);
|
@@ -6,7 +6,7 @@
|
|
6
6
|
and semantics are as close as possible to those of the Perl 5 language.
|
7
7
|
|
8
8
|
Written by Philip Hazel
|
9
|
-
Copyright (c) 1997-
|
9
|
+
Copyright (c) 1997-2021 University of Cambridge
|
10
10
|
|
11
11
|
-----------------------------------------------------------------------------
|
12
12
|
Redistribution and use in source and binary forms, with or without
|
@@ -758,7 +758,7 @@ for (;;)
|
|
758
758
|
md->mark = NULL; /* In case previously set by assertion */
|
759
759
|
RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top, md,
|
760
760
|
eptrb, RM55);
|
761
|
-
if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&
|
761
|
+
if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT || rrc == MATCH_KETRPOS) &&
|
762
762
|
md->mark == NULL) md->mark = ecode + 2;
|
763
763
|
|
764
764
|
/* A return of MATCH_SKIP_ARG means that matching failed at SKIP with an
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
file(GLOB SRC_XDIFF "*.c" "*.h")
|
3
|
+
list(SORT SRC_XDIFF)
|
4
|
+
|
5
|
+
add_library(xdiff OBJECT ${SRC_XDIFF})
|
6
|
+
target_include_directories(xdiff SYSTEM PRIVATE
|
7
|
+
"${PROJECT_SOURCE_DIR}/include"
|
8
|
+
"${PROJECT_SOURCE_DIR}/src/util"
|
9
|
+
"${PROJECT_BINARY_DIR}/src/util"
|
10
|
+
${LIBGIT2_SYSTEM_INCLUDES}
|
11
|
+
${LIBGIT2_DEPENDENCY_INCLUDES})
|
12
|
+
|
13
|
+
# the xdiff dependency is not (yet) warning-free, disable warnings
|
14
|
+
# as errors for the xdiff sources until we've sorted them out
|
15
|
+
if(MSVC)
|
16
|
+
set_source_files_properties(xdiffi.c PROPERTIES COMPILE_FLAGS -WX-)
|
17
|
+
set_source_files_properties(xemit.c PROPERTIES COMPILE_FLAGS -WX-)
|
18
|
+
set_source_files_properties(xhistogram.c PROPERTIES COMPILE_FLAGS -WX-)
|
19
|
+
set_source_files_properties(xmerge.c PROPERTIES COMPILE_FLAGS -WX-)
|
20
|
+
set_source_files_properties(xutils.c PROPERTIES COMPILE_FLAGS -WX-)
|
21
|
+
set_source_files_properties(xpatience.c PROPERTIES COMPILE_FLAGS -WX-)
|
22
|
+
else()
|
23
|
+
set_source_files_properties(xdiffi.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-parameter")
|
24
|
+
set_source_files_properties(xemit.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-parameter")
|
25
|
+
set_source_files_properties(xhistogram.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
|
26
|
+
set_source_files_properties(xutils.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
|
27
|
+
set_source_files_properties(xpatience.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
|
28
|
+
endif()
|
@@ -27,11 +27,14 @@
|
|
27
27
|
# endif
|
28
28
|
#endif
|
29
29
|
|
30
|
+
#define XDL_UNUSED GIT_UNUSED_ARG
|
31
|
+
|
30
32
|
#define xdl_malloc(x) git__malloc(x)
|
33
|
+
#define xdl_calloc(n, sz) git__calloc(n, sz)
|
31
34
|
#define xdl_free(ptr) git__free(ptr)
|
32
35
|
#define xdl_realloc(ptr, x) git__realloc(ptr, x)
|
33
36
|
|
34
|
-
#define XDL_BUG(msg) GIT_ASSERT(msg)
|
37
|
+
#define XDL_BUG(msg) GIT_ASSERT(!msg)
|
35
38
|
|
36
39
|
#define xdl_regex_t git_regexp
|
37
40
|
#define xdl_regmatch_t git_regmatch
|
@@ -315,16 +315,19 @@ int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
|
315
315
|
long *kvd, *kvdf, *kvdb;
|
316
316
|
xdalgoenv_t xenv;
|
317
317
|
diffdata_t dd1, dd2;
|
318
|
+
int res;
|
318
319
|
|
319
|
-
if (
|
320
|
-
return
|
321
|
-
|
322
|
-
if (XDF_DIFF_ALG(xpp->flags) == XDF_HISTOGRAM_DIFF)
|
323
|
-
return xdl_do_histogram_diff(mf1, mf2, xpp, xe);
|
320
|
+
if (xdl_prepare_env(mf1, mf2, xpp, xe) < 0)
|
321
|
+
return -1;
|
324
322
|
|
325
|
-
if (
|
323
|
+
if (XDF_DIFF_ALG(xpp->flags) == XDF_PATIENCE_DIFF) {
|
324
|
+
res = xdl_do_patience_diff(xpp, xe);
|
325
|
+
goto out;
|
326
|
+
}
|
326
327
|
|
327
|
-
|
328
|
+
if (XDF_DIFF_ALG(xpp->flags) == XDF_HISTOGRAM_DIFF) {
|
329
|
+
res = xdl_do_histogram_diff(xpp, xe);
|
330
|
+
goto out;
|
328
331
|
}
|
329
332
|
|
330
333
|
/*
|
@@ -334,7 +337,7 @@ int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
|
334
337
|
* One is to store the forward path and one to store the backward path.
|
335
338
|
*/
|
336
339
|
ndiags = xe->xdf1.nreff + xe->xdf2.nreff + 3;
|
337
|
-
if (!(kvd
|
340
|
+
if (!XDL_ALLOC_ARRAY(kvd, 2 * ndiags + 2)) {
|
338
341
|
|
339
342
|
xdl_free_env(xe);
|
340
343
|
return -1;
|
@@ -359,17 +362,15 @@ int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
|
359
362
|
dd2.rchg = xe->xdf2.rchg;
|
360
363
|
dd2.rindex = xe->xdf2.rindex;
|
361
364
|
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
xdl_free(kvd);
|
366
|
-
xdl_free_env(xe);
|
367
|
-
return -1;
|
368
|
-
}
|
369
|
-
|
365
|
+
res = xdl_recs_cmp(&dd1, 0, dd1.nrec, &dd2, 0, dd2.nrec,
|
366
|
+
kvdf, kvdb, (xpp->flags & XDF_NEED_MINIMAL) != 0,
|
367
|
+
&xenv);
|
370
368
|
xdl_free(kvd);
|
369
|
+
out:
|
370
|
+
if (res < 0)
|
371
|
+
xdl_free_env(xe);
|
371
372
|
|
372
|
-
return
|
373
|
+
return res;
|
373
374
|
}
|
374
375
|
|
375
376
|
|
@@ -972,7 +973,7 @@ void xdl_free_script(xdchange_t *xscr) {
|
|
972
973
|
}
|
973
974
|
}
|
974
975
|
|
975
|
-
static int xdl_call_hunk_func(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
|
976
|
+
static int xdl_call_hunk_func(xdfenv_t *xe XDL_UNUSED, xdchange_t *xscr, xdemitcb_t *ecb,
|
976
977
|
xdemitconf_t const *xecfg)
|
977
978
|
{
|
978
979
|
xdchange_t *xch, *xche;
|
@@ -56,9 +56,7 @@ int xdl_build_script(xdfenv_t *xe, xdchange_t **xscr);
|
|
56
56
|
void xdl_free_script(xdchange_t *xscr);
|
57
57
|
int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
|
58
58
|
xdemitconf_t const *xecfg);
|
59
|
-
int xdl_do_patience_diff(
|
60
|
-
|
61
|
-
int xdl_do_histogram_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
62
|
-
xdfenv_t *env);
|
59
|
+
int xdl_do_patience_diff(xpparam_t const *xpp, xdfenv_t *env);
|
60
|
+
int xdl_do_histogram_diff(xpparam_t const *xpp, xdfenv_t *env);
|
63
61
|
|
64
62
|
#endif /* #if !defined(XDIFFI_H) */
|
@@ -65,7 +65,7 @@ xdchange_t *xdl_get_hunk(xdchange_t **xscr, xdemitconf_t const *xecfg)
|
|
65
65
|
*xscr = xch;
|
66
66
|
}
|
67
67
|
|
68
|
-
if (
|
68
|
+
if (!*xscr)
|
69
69
|
return NULL;
|
70
70
|
|
71
71
|
lxch = *xscr;
|
@@ -95,7 +95,7 @@ xdchange_t *xdl_get_hunk(xdchange_t **xscr, xdemitconf_t const *xecfg)
|
|
95
95
|
}
|
96
96
|
|
97
97
|
|
98
|
-
static long def_ff(const char *rec, long len, char *buf, long sz
|
98
|
+
static long def_ff(const char *rec, long len, char *buf, long sz)
|
99
99
|
{
|
100
100
|
if (len > 0 &&
|
101
101
|
(isalpha((unsigned char)*rec) || /* identifier? */
|
@@ -117,7 +117,7 @@ static long match_func_rec(xdfile_t *xdf, xdemitconf_t const *xecfg, long ri,
|
|
117
117
|
const char *rec;
|
118
118
|
long len = xdl_get_rec(xdf, ri, &rec);
|
119
119
|
if (!xecfg->find_func)
|
120
|
-
return def_ff(rec, len, buf, sz
|
120
|
+
return def_ff(rec, len, buf, sz);
|
121
121
|
return xecfg->find_func(rec, len, buf, sz, xecfg->find_func_priv);
|
122
122
|
}
|
123
123
|
|
@@ -251,7 +251,7 @@ static int find_lcs(xpparam_t const *xpp, xdfenv_t *env,
|
|
251
251
|
int line1, int count1, int line2, int count2)
|
252
252
|
{
|
253
253
|
int b_ptr;
|
254
|
-
int
|
254
|
+
int ret = -1;
|
255
255
|
struct histindex index;
|
256
256
|
|
257
257
|
memset(&index, 0, sizeof(index));
|
@@ -265,23 +265,16 @@ static int find_lcs(xpparam_t const *xpp, xdfenv_t *env,
|
|
265
265
|
index.rcha.head = NULL;
|
266
266
|
|
267
267
|
index.table_bits = xdl_hashbits(count1);
|
268
|
-
|
269
|
-
|
270
|
-
if (!(index.records = (struct record **) xdl_malloc(sz)))
|
268
|
+
index.records_size = 1 << index.table_bits;
|
269
|
+
if (!XDL_CALLOC_ARRAY(index.records, index.records_size))
|
271
270
|
goto cleanup;
|
272
|
-
memset(index.records, 0, sz);
|
273
271
|
|
274
|
-
|
275
|
-
|
276
|
-
if (!(index.line_map = (struct record **) xdl_malloc(sz)))
|
272
|
+
index.line_map_size = count1;
|
273
|
+
if (!XDL_CALLOC_ARRAY(index.line_map, index.line_map_size))
|
277
274
|
goto cleanup;
|
278
|
-
memset(index.line_map, 0, sz);
|
279
275
|
|
280
|
-
|
281
|
-
sz *= sizeof(unsigned int);
|
282
|
-
if (!(index.next_ptrs = (unsigned int *) xdl_malloc(sz)))
|
276
|
+
if (!XDL_CALLOC_ARRAY(index.next_ptrs, index.line_map_size))
|
283
277
|
goto cleanup;
|
284
|
-
memset(index.next_ptrs, 0, sz);
|
285
278
|
|
286
279
|
/* lines / 4 + 1 comes from xprepare.c:xdl_prepare_ctx() */
|
287
280
|
if (xdl_cha_init(&index.rcha, sizeof(struct record), count1 / 4 + 1) < 0)
|
@@ -369,12 +362,8 @@ out:
|
|
369
362
|
return result;
|
370
363
|
}
|
371
364
|
|
372
|
-
int xdl_do_histogram_diff(
|
373
|
-
xpparam_t const *xpp, xdfenv_t *env)
|
365
|
+
int xdl_do_histogram_diff(xpparam_t const *xpp, xdfenv_t *env)
|
374
366
|
{
|
375
|
-
if (xdl_prepare_env(file1, file2, xpp, env) < 0)
|
376
|
-
return -1;
|
377
|
-
|
378
367
|
return histogram_diff(xpp, env,
|
379
368
|
env->xdf1.dstart + 1, env->xdf1.dend - env->xdf1.dstart + 1,
|
380
369
|
env->xdf2.dstart + 1, env->xdf2.dend - env->xdf2.dstart + 1);
|
@@ -34,7 +34,6 @@
|
|
34
34
|
#define XDL_ADDBITS(v,b) ((v) + ((v) >> (b)))
|
35
35
|
#define XDL_MASKBITS(b) ((1UL << (b)) - 1)
|
36
36
|
#define XDL_HASHLONG(v,b) (XDL_ADDBITS((unsigned long)(v), b) & XDL_MASKBITS(b))
|
37
|
-
#define XDL_PTRFREE(p) do { if (p) { xdl_free(p); (p) = NULL; } } while (0)
|
38
37
|
#define XDL_LE32_PUT(p, v) \
|
39
38
|
do { \
|
40
39
|
unsigned char *__p = (unsigned char *) (p); \
|
@@ -50,5 +49,23 @@ do { \
|
|
50
49
|
((unsigned long) __p[2]) << 16 | ((unsigned long) __p[3]) << 24; \
|
51
50
|
} while (0)
|
52
51
|
|
52
|
+
/* Allocate an array of nr elements, returns NULL on failure */
|
53
|
+
#define XDL_ALLOC_ARRAY(p, nr) \
|
54
|
+
((p) = SIZE_MAX / sizeof(*(p)) >= (size_t)(nr) \
|
55
|
+
? xdl_malloc((nr) * sizeof(*(p))) \
|
56
|
+
: NULL)
|
57
|
+
|
58
|
+
/* Allocate an array of nr zeroed out elements, returns NULL on failure */
|
59
|
+
#define XDL_CALLOC_ARRAY(p, nr) ((p) = xdl_calloc(nr, sizeof(*(p))))
|
60
|
+
|
61
|
+
/*
|
62
|
+
* Ensure array p can accommodate at least nr elements, growing the
|
63
|
+
* array and updating alloc (which is the number of allocated
|
64
|
+
* elements) as necessary. Frees p and returns -1 on failure, returns
|
65
|
+
* 0 on success
|
66
|
+
*/
|
67
|
+
#define XDL_ALLOC_GROW(p, nr, alloc) \
|
68
|
+
(-!((nr) <= (alloc) || \
|
69
|
+
((p) = xdl_alloc_grow_helper((p), (nr), &(alloc), sizeof(*(p))))))
|
53
70
|
|
54
71
|
#endif /* #if !defined(XMACROS_H) */
|
@@ -88,7 +88,7 @@ static int xdl_cleanup_merge(xdmerge_t *c)
|
|
88
88
|
if (c->mode == 0)
|
89
89
|
count++;
|
90
90
|
next_c = c->next;
|
91
|
-
|
91
|
+
free(c);
|
92
92
|
}
|
93
93
|
return count;
|
94
94
|
}
|
@@ -456,7 +456,7 @@ static void xdl_merge_two_conflicts(xdmerge_t *m)
|
|
456
456
|
m->chg1 = next_m->i1 + next_m->chg1 - m->i1;
|
457
457
|
m->chg2 = next_m->i2 + next_m->chg2 - m->i2;
|
458
458
|
m->next = next_m->next;
|
459
|
-
|
459
|
+
free(next_m);
|
460
460
|
}
|
461
461
|
|
462
462
|
/*
|
@@ -684,42 +684,42 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1,
|
|
684
684
|
int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2,
|
685
685
|
xmparam_t const *xmp, mmbuffer_t *result)
|
686
686
|
{
|
687
|
-
xdchange_t *xscr1, *xscr2;
|
687
|
+
xdchange_t *xscr1 = NULL, *xscr2 = NULL;
|
688
688
|
xdfenv_t xe1, xe2;
|
689
|
-
int status;
|
689
|
+
int status = -1;
|
690
690
|
xpparam_t const *xpp = &xmp->xpp;
|
691
691
|
|
692
692
|
result->ptr = NULL;
|
693
693
|
result->size = 0;
|
694
694
|
|
695
|
-
if (xdl_do_diff(orig, mf1, xpp, &xe1) < 0)
|
695
|
+
if (xdl_do_diff(orig, mf1, xpp, &xe1) < 0)
|
696
696
|
return -1;
|
697
|
-
|
698
|
-
if (xdl_do_diff(orig, mf2, xpp, &xe2) < 0)
|
699
|
-
|
700
|
-
|
701
|
-
}
|
697
|
+
|
698
|
+
if (xdl_do_diff(orig, mf2, xpp, &xe2) < 0)
|
699
|
+
goto free_xe1; /* avoid double free of xe2 */
|
700
|
+
|
702
701
|
if (xdl_change_compact(&xe1.xdf1, &xe1.xdf2, xpp->flags) < 0 ||
|
703
702
|
xdl_change_compact(&xe1.xdf2, &xe1.xdf1, xpp->flags) < 0 ||
|
704
|
-
xdl_build_script(&xe1, &xscr1) < 0)
|
705
|
-
|
706
|
-
|
707
|
-
}
|
703
|
+
xdl_build_script(&xe1, &xscr1) < 0)
|
704
|
+
goto out;
|
705
|
+
|
708
706
|
if (xdl_change_compact(&xe2.xdf1, &xe2.xdf2, xpp->flags) < 0 ||
|
709
707
|
xdl_change_compact(&xe2.xdf2, &xe2.xdf1, xpp->flags) < 0 ||
|
710
|
-
xdl_build_script(&xe2, &xscr2) < 0)
|
711
|
-
|
712
|
-
|
713
|
-
xdl_free_env(&xe2);
|
714
|
-
return -1;
|
715
|
-
}
|
716
|
-
status = 0;
|
708
|
+
xdl_build_script(&xe2, &xscr2) < 0)
|
709
|
+
goto out;
|
710
|
+
|
717
711
|
if (!xscr1) {
|
718
712
|
result->ptr = xdl_malloc(mf2->size);
|
713
|
+
if (!result->ptr)
|
714
|
+
goto out;
|
715
|
+
status = 0;
|
719
716
|
memcpy(result->ptr, mf2->ptr, mf2->size);
|
720
717
|
result->size = mf2->size;
|
721
718
|
} else if (!xscr2) {
|
722
719
|
result->ptr = xdl_malloc(mf1->size);
|
720
|
+
if (!result->ptr)
|
721
|
+
goto out;
|
722
|
+
status = 0;
|
723
723
|
memcpy(result->ptr, mf1->ptr, mf1->size);
|
724
724
|
result->size = mf1->size;
|
725
725
|
} else {
|
@@ -727,11 +727,13 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2,
|
|
727
727
|
&xe2, xscr2,
|
728
728
|
xmp, result);
|
729
729
|
}
|
730
|
+
out:
|
730
731
|
xdl_free_script(xscr1);
|
731
732
|
xdl_free_script(xscr2);
|
732
733
|
|
733
|
-
xdl_free_env(&xe1);
|
734
734
|
xdl_free_env(&xe2);
|
735
|
+
free_xe1:
|
736
|
+
xdl_free_env(&xe1);
|
735
737
|
|
736
738
|
return status;
|
737
739
|
}
|
@@ -69,7 +69,6 @@ struct hashmap {
|
|
69
69
|
} *entries, *first, *last;
|
70
70
|
/* were common records found? */
|
71
71
|
unsigned long has_matches;
|
72
|
-
mmfile_t *file1, *file2;
|
73
72
|
xdfenv_t *env;
|
74
73
|
xpparam_t const *xpp;
|
75
74
|
};
|
@@ -139,23 +138,17 @@ static void insert_record(xpparam_t const *xpp, int line, struct hashmap *map,
|
|
139
138
|
*
|
140
139
|
* It is assumed that env has been prepared using xdl_prepare().
|
141
140
|
*/
|
142
|
-
static int fill_hashmap(
|
143
|
-
xpparam_t const *xpp, xdfenv_t *env,
|
141
|
+
static int fill_hashmap(xpparam_t const *xpp, xdfenv_t *env,
|
144
142
|
struct hashmap *result,
|
145
143
|
int line1, int count1, int line2, int count2)
|
146
144
|
{
|
147
|
-
result->file1 = file1;
|
148
|
-
result->file2 = file2;
|
149
145
|
result->xpp = xpp;
|
150
146
|
result->env = env;
|
151
147
|
|
152
148
|
/* We know exactly how large we want the hash map */
|
153
149
|
result->alloc = count1 * 2;
|
154
|
-
result->entries
|
155
|
-
xdl_malloc(result->alloc * sizeof(struct entry));
|
156
|
-
if (!result->entries)
|
150
|
+
if (!XDL_CALLOC_ARRAY(result->entries, result->alloc))
|
157
151
|
return -1;
|
158
|
-
memset(result->entries, 0, result->alloc * sizeof(struct entry));
|
159
152
|
|
160
153
|
/* First, fill with entries from the first file */
|
161
154
|
while (count1--)
|
@@ -198,9 +191,9 @@ static int binary_search(struct entry **sequence, int longest,
|
|
198
191
|
* item per sequence length: the sequence with the smallest last
|
199
192
|
* element (in terms of line2).
|
200
193
|
*/
|
201
|
-
static
|
194
|
+
static int find_longest_common_sequence(struct hashmap *map, struct entry **res)
|
202
195
|
{
|
203
|
-
struct entry **sequence
|
196
|
+
struct entry **sequence;
|
204
197
|
int longest = 0, i;
|
205
198
|
struct entry *entry;
|
206
199
|
|
@@ -211,6 +204,9 @@ static struct entry *find_longest_common_sequence(struct hashmap *map)
|
|
211
204
|
*/
|
212
205
|
int anchor_i = -1;
|
213
206
|
|
207
|
+
if (!XDL_ALLOC_ARRAY(sequence, map->nr))
|
208
|
+
return -1;
|
209
|
+
|
214
210
|
for (entry = map->first; entry; entry = entry->next) {
|
215
211
|
if (!entry->line2 || entry->line2 == NON_UNIQUE)
|
216
212
|
continue;
|
@@ -230,8 +226,9 @@ static struct entry *find_longest_common_sequence(struct hashmap *map)
|
|
230
226
|
|
231
227
|
/* No common unique lines were found */
|
232
228
|
if (!longest) {
|
229
|
+
*res = NULL;
|
233
230
|
xdl_free(sequence);
|
234
|
-
return
|
231
|
+
return 0;
|
235
232
|
}
|
236
233
|
|
237
234
|
/* Iterate starting at the last element, adjusting the "next" members */
|
@@ -241,8 +238,9 @@ static struct entry *find_longest_common_sequence(struct hashmap *map)
|
|
241
238
|
entry->previous->next = entry;
|
242
239
|
entry = entry->previous;
|
243
240
|
}
|
241
|
+
*res = entry;
|
244
242
|
xdl_free(sequence);
|
245
|
-
return
|
243
|
+
return 0;
|
246
244
|
}
|
247
245
|
|
248
246
|
static int match(struct hashmap *map, int line1, int line2)
|
@@ -252,8 +250,7 @@ static int match(struct hashmap *map, int line1, int line2)
|
|
252
250
|
return record1->ha == record2->ha;
|
253
251
|
}
|
254
252
|
|
255
|
-
static int patience_diff(
|
256
|
-
xpparam_t const *xpp, xdfenv_t *env,
|
253
|
+
static int patience_diff(xpparam_t const *xpp, xdfenv_t *env,
|
257
254
|
int line1, int count1, int line2, int count2);
|
258
255
|
|
259
256
|
static int walk_common_sequence(struct hashmap *map, struct entry *first,
|
@@ -284,8 +281,7 @@ static int walk_common_sequence(struct hashmap *map, struct entry *first,
|
|
284
281
|
|
285
282
|
/* Recurse */
|
286
283
|
if (next1 > line1 || next2 > line2) {
|
287
|
-
if (patience_diff(map->
|
288
|
-
map->xpp, map->env,
|
284
|
+
if (patience_diff(map->xpp, map->env,
|
289
285
|
line1, next1 - line1,
|
290
286
|
line2, next2 - line2))
|
291
287
|
return -1;
|
@@ -324,8 +320,7 @@ static int fall_back_to_classic_diff(struct hashmap *map,
|
|
324
320
|
*
|
325
321
|
* This function assumes that env was prepared with xdl_prepare_env().
|
326
322
|
*/
|
327
|
-
static int patience_diff(
|
328
|
-
xpparam_t const *xpp, xdfenv_t *env,
|
323
|
+
static int patience_diff(xpparam_t const *xpp, xdfenv_t *env,
|
329
324
|
int line1, int count1, int line2, int count2)
|
330
325
|
{
|
331
326
|
struct hashmap map;
|
@@ -344,7 +339,7 @@ static int patience_diff(mmfile_t *file1, mmfile_t *file2,
|
|
344
339
|
}
|
345
340
|
|
346
341
|
memset(&map, 0, sizeof(map));
|
347
|
-
if (fill_hashmap(
|
342
|
+
if (fill_hashmap(xpp, env, &map,
|
348
343
|
line1, count1, line2, count2))
|
349
344
|
return -1;
|
350
345
|
|
@@ -358,25 +353,21 @@ static int patience_diff(mmfile_t *file1, mmfile_t *file2,
|
|
358
353
|
return 0;
|
359
354
|
}
|
360
355
|
|
361
|
-
|
356
|
+
result = find_longest_common_sequence(&map, &first);
|
357
|
+
if (result)
|
358
|
+
goto out;
|
362
359
|
if (first)
|
363
360
|
result = walk_common_sequence(&map, first,
|
364
361
|
line1, count1, line2, count2);
|
365
362
|
else
|
366
363
|
result = fall_back_to_classic_diff(&map,
|
367
364
|
line1, count1, line2, count2);
|
368
|
-
|
365
|
+
out:
|
369
366
|
xdl_free(map.entries);
|
370
367
|
return result;
|
371
368
|
}
|
372
369
|
|
373
|
-
int xdl_do_patience_diff(
|
374
|
-
xpparam_t const *xpp, xdfenv_t *env)
|
370
|
+
int xdl_do_patience_diff(xpparam_t const *xpp, xdfenv_t *env)
|
375
371
|
{
|
376
|
-
|
377
|
-
return -1;
|
378
|
-
|
379
|
-
/* environment is cleaned up in xdl_diff() */
|
380
|
-
return patience_diff(file1, file2, xpp, env,
|
381
|
-
1, env->xdf1.nrec, 1, env->xdf2.nrec);
|
372
|
+
return patience_diff(xpp, env, 1, env->xdf1.nrec, 1, env->xdf2.nrec);
|
382
373
|
}
|
@@ -78,15 +78,14 @@ static int xdl_init_classifier(xdlclassifier_t *cf, long size, long flags) {
|
|
78
78
|
|
79
79
|
return -1;
|
80
80
|
}
|
81
|
-
if (!(cf->rchash
|
81
|
+
if (!XDL_CALLOC_ARRAY(cf->rchash, cf->hsize)) {
|
82
82
|
|
83
83
|
xdl_cha_free(&cf->ncha);
|
84
84
|
return -1;
|
85
85
|
}
|
86
|
-
memset(cf->rchash, 0, cf->hsize * sizeof(xdlclass_t *));
|
87
86
|
|
88
87
|
cf->alloc = size;
|
89
|
-
if (!(cf->rcrecs
|
88
|
+
if (!XDL_ALLOC_ARRAY(cf->rcrecs, cf->alloc)) {
|
90
89
|
|
91
90
|
xdl_free(cf->rchash);
|
92
91
|
xdl_cha_free(&cf->ncha);
|
@@ -112,7 +111,6 @@ static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t
|
|
112
111
|
long hi;
|
113
112
|
char const *line;
|
114
113
|
xdlclass_t *rcrec;
|
115
|
-
xdlclass_t **rcrecs;
|
116
114
|
|
117
115
|
line = rec->ptr;
|
118
116
|
hi = (long) XDL_HASHLONG(rec->ha, cf->hbits);
|
@@ -128,14 +126,8 @@ static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t
|
|
128
126
|
return -1;
|
129
127
|
}
|
130
128
|
rcrec->idx = cf->count++;
|
131
|
-
if (cf->count
|
132
|
-
cf->alloc *= 2;
|
133
|
-
if (!(rcrecs = (xdlclass_t **) xdl_realloc(cf->rcrecs, cf->alloc * sizeof(xdlclass_t *)))) {
|
134
|
-
|
129
|
+
if (XDL_ALLOC_GROW(cf->rcrecs, cf->count, cf->alloc))
|
135
130
|
return -1;
|
136
|
-
}
|
137
|
-
cf->rcrecs = rcrecs;
|
138
|
-
}
|
139
131
|
cf->rcrecs[rcrec->idx] = rcrec;
|
140
132
|
rcrec->line = line;
|
141
133
|
rcrec->size = rec->size;
|
@@ -164,7 +156,7 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
|
|
164
156
|
unsigned long hav;
|
165
157
|
char const *blk, *cur, *top, *prev;
|
166
158
|
xrecord_t *crec;
|
167
|
-
xrecord_t **recs
|
159
|
+
xrecord_t **recs;
|
168
160
|
xrecord_t **rhash;
|
169
161
|
unsigned long *ha;
|
170
162
|
char *rchg;
|
@@ -178,26 +170,21 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
|
|
178
170
|
|
179
171
|
if (xdl_cha_init(&xdf->rcha, sizeof(xrecord_t), narec / 4 + 1) < 0)
|
180
172
|
goto abort;
|
181
|
-
if (!(recs
|
173
|
+
if (!XDL_ALLOC_ARRAY(recs, narec))
|
182
174
|
goto abort;
|
183
175
|
|
184
176
|
hbits = xdl_hashbits((unsigned int) narec);
|
185
177
|
hsize = 1 << hbits;
|
186
|
-
if (!(rhash
|
178
|
+
if (!XDL_CALLOC_ARRAY(rhash, hsize))
|
187
179
|
goto abort;
|
188
|
-
memset(rhash, 0, hsize * sizeof(xrecord_t *));
|
189
180
|
|
190
181
|
nrec = 0;
|
191
|
-
if ((cur = blk = xdl_mmfile_first(mf, &bsize))
|
182
|
+
if ((cur = blk = xdl_mmfile_first(mf, &bsize))) {
|
192
183
|
for (top = blk + bsize; cur < top; ) {
|
193
184
|
prev = cur;
|
194
185
|
hav = xdl_hash_record(&cur, top, xpp->flags);
|
195
|
-
if (nrec
|
196
|
-
|
197
|
-
if (!(rrecs = (xrecord_t **) xdl_realloc(recs, narec * sizeof(xrecord_t *))))
|
198
|
-
goto abort;
|
199
|
-
recs = rrecs;
|
200
|
-
}
|
186
|
+
if (XDL_ALLOC_GROW(recs, nrec + 1, narec))
|
187
|
+
goto abort;
|
201
188
|
if (!(crec = xdl_cha_alloc(&xdf->rcha)))
|
202
189
|
goto abort;
|
203
190
|
crec->ptr = prev;
|
@@ -209,15 +196,14 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
|
|
209
196
|
}
|
210
197
|
}
|
211
198
|
|
212
|
-
if (!(rchg
|
199
|
+
if (!XDL_CALLOC_ARRAY(rchg, nrec + 2))
|
213
200
|
goto abort;
|
214
|
-
memset(rchg, 0, (nrec + 2) * sizeof(char));
|
215
201
|
|
216
202
|
if ((XDF_DIFF_ALG(xpp->flags) != XDF_PATIENCE_DIFF) &&
|
217
203
|
(XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF)) {
|
218
|
-
if (!(rindex
|
204
|
+
if (!XDL_ALLOC_ARRAY(rindex, nrec + 1))
|
219
205
|
goto abort;
|
220
|
-
if (!(ha
|
206
|
+
if (!XDL_ALLOC_ARRAY(ha, nrec + 1))
|
221
207
|
goto abort;
|
222
208
|
}
|
223
209
|
|
@@ -383,11 +369,8 @@ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xd
|
|
383
369
|
xdlclass_t *rcrec;
|
384
370
|
char *dis, *dis1, *dis2;
|
385
371
|
|
386
|
-
if (!(dis
|
387
|
-
|
372
|
+
if (!XDL_CALLOC_ARRAY(dis, xdf1->nrec + xdf2->nrec + 2))
|
388
373
|
return -1;
|
389
|
-
}
|
390
|
-
memset(dis, 0, xdf1->nrec + xdf2->nrec + 2);
|
391
374
|
dis1 = dis;
|
392
375
|
dis2 = dis1 + xdf1->nrec + 1;
|
393
376
|
|