Skip to content

Complete diff-match-patch port (closes #25) #26

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

Open
wants to merge 182 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
182 commits
Select commit Hold shift + click to select a range
9c27090
Add build.zig.zon, update build.zig, .gitignore
mnemnion Jul 2, 2024
4792861
Module name is diffz, not DiffMatchPatch
mnemnion Jul 2, 2024
10bcba0
More paths, .target, .optimize
mnemnion Jul 2, 2024
64bc1bf
Memory-managed halfMatch function
mnemnion Jul 2, 2024
0c7c4e2
Managed memory in diffLinesToChars
mnemnion Jul 2, 2024
9e638e8
Clean up easy leaks + prep for allocating Diffs
mnemnion Jul 2, 2024
a5c993f
Managed memory in diffCharsToLines
mnemnion Jul 2, 2024
a2beb6f
Fix for diffCleanupMerge memory
mnemnion Jul 2, 2024
7c5cccc
One test at a time...
mnemnion Jul 2, 2024
dbc3a84
More tests
mnemnion Jul 2, 2024
0b2f274
Fix two double-frees
mnemnion Jul 2, 2024
18b7531
Free two more clobbered diff texts
mnemnion Jul 2, 2024
1ebee82
Restore all diffCleanMerge tests
mnemnion Jul 2, 2024
350a85e
Restore frees to diffCleanupSemanticLossless
mnemnion Jul 2, 2024
fe21b51
Tests of diffCleanupSemanticLossless pass
mnemnion Jul 2, 2024
5ff7a76
alloc -> allocator
mnemnion Jul 2, 2024
b56449f
Tests pass for diffBisect
mnemnion Jul 2, 2024
2388fff
Catch a few leaks, lather, rinse, repeat
mnemnion Jul 3, 2024
7a47bd7
Defer free until slice is taken
mnemnion Jul 3, 2024
eecdb47
Fait accompli
mnemnion Jul 3, 2024
7032b4b
Polish things up
mnemnion Jul 3, 2024
87b1b32
Remove unused temp diff
mnemnion Jul 3, 2024
2019099
Modifies prefix and suffix diffs to not split UTF-8
mnemnion Jul 3, 2024
006d7a1
Add (failing!) greek test
mnemnion Jul 3, 2024
3cd7a49
Add equalForwards and equalBackwards for Myers 1986
mnemnion Jul 3, 2024
7ebdf12
Add some easy two-byte tests
mnemnion Jul 3, 2024
56104d4
Back out of overlaps if we clip a character
mnemnion Jul 3, 2024
2f2e57e
Less than zero impossible for usize
mnemnion Jul 4, 2024
7b7cd26
Add coverage step for build system
mnemnion Jul 4, 2024
0dbfb97
Add diffIndex, diffBeforeText, diffAfterText
mnemnion Jul 4, 2024
5a7ba7c
Add Levenshtein distance and prettyFormat
mnemnion Jul 4, 2024
477bd5b
Add borrowed encodeUri routine
mnemnion Jul 4, 2024
16a05d2
Code-bumming encodeUri
mnemnion Jul 4, 2024
f647759
Tests for encodeUri
mnemnion Jul 4, 2024
3d0cb77
No extra allocation for hex formatting
mnemnion Jul 4, 2024
7b650f7
Factor uriEncode to use writeUriEncoded
mnemnion Jul 4, 2024
b36c8bf
Break pretty format into writer and string-er
mnemnion Jul 4, 2024
22c4c84
Add Patch struct
mnemnion Jul 4, 2024
ef5dda5
Port main makePatch function
mnemnion Jul 4, 2024
eeaf42f
Adds patchAddContext
mnemnion Jul 4, 2024
5fb7299
Add ownership handling to makePatch
mnemnion Jul 4, 2024
6d477ad
Add clone for patches and patch lists
mnemnion Jul 4, 2024
9060477
Add match section
mnemnion Jul 4, 2024
49339a9
Put fields at top of file/struct
mnemnion Jul 4, 2024
1dea68a
Don't clip codepoints in patch context
mnemnion Jul 4, 2024
a7cc1b2
Mid-function putter out
mnemnion Jul 5, 2024
630bfe6
Rest of patchApply
mnemnion Jul 5, 2024
bf1f95a
Add patch split and patch padding
mnemnion Jul 5, 2024
2d2955d
Add patch writer
mnemnion Jul 5, 2024
b703ac6
Patch parser complete
mnemnion Jul 6, 2024
3afffcc
Add uriDecode
mnemnion Jul 7, 2024
f7906a6
Add other makePatch interfaces
mnemnion Jul 7, 2024
0655ece
Remove conditional free for zero-length text
mnemnion Jul 7, 2024
f044a8b
Use explicit directory names in .gitignore
mnemnion Jul 7, 2024
9bb2819
Update build.zig to remove empty library
mnemnion Jul 7, 2024
cc640a3
Free resources when allocation fails
mnemnion Jul 7, 2024
481a182
Merge remote-tracking branch 'origin/memory-management' into memory-m…
mnemnion Jul 7, 2024
4b63907
errdefer freeing slice appends
mnemnion Jul 7, 2024
83ac54f
Remove spurious line
mnemnion Jul 7, 2024
7cd5391
Merge branch 'memory-management' into more-port
mnemnion Jul 7, 2024
7febe83
Merge changes to memory-manage branch
mnemnion Jul 7, 2024
5c4847e
Partial transfer of functions to dmp
mnemnion Jul 7, 2024
a7ab35c
Patch tests
mnemnion Jul 7, 2024
b35dc24
Convert to ensuring capacity before append/insert
mnemnion Jul 7, 2024
58fbf0f
Restore deleted free
mnemnion Jul 7, 2024
39e0af8
Consistent use of Diff.init()
mnemnion Jul 7, 2024
dcf52f9
Merge branch 'memory-management' into more-port
mnemnion Jul 7, 2024
34d3a7b
use `testing.checkAllAllocationFailures`
Techatrix Jul 7, 2024
92e3c3e
Merge pull request #1 from Techatrix/dev
mnemnion Jul 7, 2024
8cb7f01
errdefer halfmatches
mnemnion Jul 7, 2024
aedb7d6
Fixes two leaks
mnemnion Jul 7, 2024
460f047
More memory order bugs
mnemnion Jul 7, 2024
d5dff30
Last of the skipped tests eliminated
mnemnion Jul 7, 2024
cebcafa
Merge branch 'memory-management' into more-port
mnemnion Jul 7, 2024
ddcbe8f
Errdefer in rebuildtexts
mnemnion Jul 7, 2024
593d38f
Tests for rebuildtexts
mnemnion Jul 8, 2024
39b99aa
Last of the leaks
mnemnion Jul 8, 2024
161c104
Merge branch 'memory-management' into more-port
mnemnion Jul 8, 2024
962b461
I am once again patching
mnemnion Jul 8, 2024
dec0868
diffIndex tests
mnemnion Jul 8, 2024
4bf0e1c
Add DiffMatchPatch to a bunch of things
mnemnion Jul 8, 2024
9e6a7e0
Tests for diffBefore and -AfterText
mnemnion Jul 8, 2024
6ee94e5
Enhancements
mnemnion Jul 8, 2024
d4fc092
Tests for diffLevenshtein
mnemnion Jul 8, 2024
1309b9d
Add comments proving bitap can be changed
mnemnion Jul 8, 2024
20b6ba9
Merge memory-management branch onto more-port
mnemnion Jul 8, 2024
ef0910b
Add test for prettyFormat
mnemnion Jul 8, 2024
57557c3
Move before and after test
mnemnion Jul 8, 2024
cc296a8
Add test for matchAlphabet
mnemnion Jul 8, 2024
155b72c
Preliminary testing for matchBitap
mnemnion Jul 8, 2024
13cd973
Not actually that subtle
mnemnion Jul 8, 2024
236179a
Bitap incorrect somewhere
mnemnion Jul 8, 2024
08fe19b
Screwed up operation order, thanks @divTrunc
mnemnion Jul 8, 2024
4816085
Add remaining matchBitap tests
mnemnion Jul 8, 2024
3931c4a
Add tests for matchMain
mnemnion Jul 8, 2024
8f7b83c
Patch writer test
mnemnion Jul 9, 2024
9975da5
First round-trip patch test passes
mnemnion Jul 9, 2024
f07cd60
Patch from text tests
mnemnion Jul 9, 2024
689f46f
Pass first round of patchAddContext
mnemnion Jul 9, 2024
7a51025
Test coverage for patchAddContext
mnemnion Jul 9, 2024
32fa770
Test for makePatch accepts null case
mnemnion Jul 9, 2024
f2a4adb
Memory leaks inside of diff engine
mnemnion Jul 9, 2024
8a8e49b
Manually port memory-management branch changes
mnemnion Jul 9, 2024
9a460ec
First allocating makePatch test passes
mnemnion Jul 9, 2024
0e1377c
Precalculate maximum space needed for makePatchInternal
mnemnion Jul 9, 2024
6b7a0f8
More makePatch
mnemnion Jul 9, 2024
08fae61
Rename to diffAndMakePatch
mnemnion Jul 9, 2024
6e414d7
Another subscript bug
mnemnion Jul 9, 2024
eac61d9
patchSplitMax compiles (with segfault)
mnemnion Jul 9, 2024
1a47673
Less segfaulting
mnemnion Jul 9, 2024
cbb421a
Obvious segfault is obvious
mnemnion Jul 9, 2024
3ae4f98
Correct answer for first splitMaxPatch test
mnemnion Jul 9, 2024
fa906fa
Remove spurious files
mnemnion Jul 9, 2024
f97e299
This algorithm sucks
mnemnion Jul 10, 2024
be26421
No allocation failures for first splitMax tests
mnemnion Jul 10, 2024
d18e743
Last patchSplitMax test
mnemnion Jul 10, 2024
30d203a
patchAddPadding compiles
mnemnion Jul 10, 2024
d1e1b58
Take slices by pointer
mnemnion Jul 10, 2024
385c846
Padding tests pass
mnemnion Jul 10, 2024
a4d8dfd
Null patch 'application' test passes
mnemnion Jul 10, 2024
0c7ff1d
Use padded text for comparisons
mnemnion Jul 10, 2024
ad5339c
errdefer patch clones
mnemnion Jul 10, 2024
b1e2571
patchApply passes next test
mnemnion Jul 10, 2024
67723ad
Fix some bugs in patchApply
mnemnion Jul 10, 2024
5fe28af
Use the patch, not the destination diff, to apply
mnemnion Jul 10, 2024
7cf64b0
Add postcontext guard to patchSplitMax
mnemnion Jul 10, 2024
dc0e31d
Two more tests pass
mnemnion Jul 10, 2024
07396dd
Last of the serious tests for patchApply
mnemnion Jul 10, 2024
c6c9c04
Last two tests pass.
mnemnion Jul 10, 2024
8e18456
Updates roadmap
mnemnion Jul 10, 2024
23078dd
Add Unicode diff tests
mnemnion Jul 11, 2024
5c92af0
Test succeeds only with breakpoint on
mnemnion Jul 11, 2024
d7abe3d
Add fixup at point of bisection
mnemnion Jul 11, 2024
debe5a6
Remove the safety dance from Myers
mnemnion Jul 11, 2024
1de49ac
Possibly irrelevant tweak
mnemnion Jul 11, 2024
bb91050
Restore previous common suffix routine
mnemnion Jul 11, 2024
ff4e387
Found a failing test
mnemnion Jul 11, 2024
3f48fd8
Check for lead byte in common suffix
mnemnion Jul 11, 2024
27da8d4
All three-byte one-character edits pass
mnemnion Jul 11, 2024
d73e3ed
A common-middle test with one permutation
mnemnion Jul 11, 2024
306f1b5
Add basic four-byte tests
mnemnion Jul 11, 2024
4053973
Doc comment for diffRoundTrip
mnemnion Jul 11, 2024
53167e1
Port streamlined boolInt from other branch
mnemnion Jul 11, 2024
fe5e9a7
Simplify and correct patch adjustment
mnemnion Jul 11, 2024
b4e8913
Simplify split-fix logic for diffBisectSplit
mnemnion Jul 11, 2024
7b18220
Simplify common prefix logic with fixSplitBackward
mnemnion Jul 11, 2024
7e7e5e9
Get rid of was_follow check in commonSuffix
mnemnion Jul 11, 2024
6fc6c89
Replace code in commonSuffix with fixSplitForward
mnemnion Jul 11, 2024
de4ef8d
Use fixSplits in patchAddContext
mnemnion Jul 11, 2024
85bd896
Adds revamp of diffLine mode
mnemnion Jul 12, 2024
ba2840f
Remove unneeded conditional in diffCommonSuffix
mnemnion Jul 12, 2024
583618b
Avoid extra allocation for halfMatch
mnemnion Jul 12, 2024
a785737
Finish adding 2.0 of line mode
mnemnion Jul 12, 2024
c1d9b53
First tests pass.
mnemnion Jul 12, 2024
e043eab
Track codepoint count between calls
mnemnion Jul 12, 2024
780d3e9
Ports basic diffLinesToChars tests
mnemnion Jul 12, 2024
25d87ee
Comment justifying munge assertion
mnemnion Jul 12, 2024
9bab41e
Ports charsToLines
mnemnion Jul 12, 2024
6e721cb
Delete old version, rename new ones
mnemnion Jul 12, 2024
6b237e4
Replace 'magic number' 32 with a constant
mnemnion Jul 12, 2024
09c7e01
Updates roadmap
mnemnion Jul 12, 2024
9191e63
Catch infinite loop bug in decodeUri
mnemnion Jul 12, 2024
39012aa
Line coverage of early stoppage
mnemnion Jul 12, 2024
6787aa6
Remove unused Bitap 2.0 functions
mnemnion Jul 13, 2024
663ae11
Restore necessary const
mnemnion Jul 13, 2024
2d373c7
Move utility functions to own section
mnemnion Jul 13, 2024
ea3e231
Use boolean to eliminate 19 @intCasts
mnemnion Jul 13, 2024
4ca65aa
diffLevenshtein returns f64
mnemnion Jul 13, 2024
1d0c79f
Fix: logic and memory bugs in patchFromHeader
mnemnion Jul 13, 2024
42f36f4
Check memory failure within testBadPatchString
mnemnion Jul 13, 2024
e01668b
Add post-first-patch failing case
mnemnion Jul 13, 2024
ba58e7e
Tracking down line-mode fails
mnemnion Jul 13, 2024
f22ccb4
Port fix for line mode from memory branch
mnemnion Jul 14, 2024
85a84b7
Add configurable line threshold
mnemnion Jul 14, 2024
5d3a83f
Add check-lines limit to DiffMatchPatch struct
mnemnion Jul 14, 2024
1fd9187
Roadmap updates
mnemnion Jul 14, 2024
bf22ea4
Make diffCleanupSemantic public
mnemnion Jul 14, 2024
bb9a1ae
Remove if (false) branches and XXX bool
mnemnion Jul 21, 2024
3a1b7ef
Change most error sets to error{OutOfMemory}
mnemnion Jul 22, 2024
b8d5661
Panic? At the backout!
mnemnion Aug 5, 2024
c87a288
Fix stack overflow in diffBisectSplit
mnemnion Aug 5, 2024
0249d68
Bugfix for the bugfix
mnemnion Aug 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.zig-cache
zig-cache
zig-out
kcov-output
Loading