curran / curran/google-diff-match-patch

The bool vector return of patch_apply generally does not correspond to anything the caller knows about.

Offen
#63 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
auto-migrated Priority-Medium Type-Defect
Vorherrschende Sprache
Python
Sterne
17
Forks
2
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

```
Before I start, thanks for a creating a great library. It's very useful and is
much appreciated.

Using the C++ version I came across what seems like either very odd or just
plain broken behaviour with diff_match_patch::patch_apply. It returns a vector
of bools to indicate individual patch success but the size of this vector can
be larger then the size of the patch list that is input to the function.

It appears that the list of input patches can be broken up into a larger list
by patch_splitMax. Despite patch_apply passing the patch list as a reference it
takes a deep copy of it and therefore does not alter it. This means that the
vector of bools is with reference to the internal, in general larger, patch
list and is therefore of little use to the caller. In fact it's potentially
dangerous if one tries to index into the input patch list to, for example,
print out the patches that failed (as I did).

Either the patch list really should be altered on return or the bool vector
should correspond to the original input list (and the patch list passed by
reference-to-const).

Whether this is an issue with the other implementations or is confined to the
C++/Qt version I don't know.

```

Original issue reported on code.google.com by `fotherin...@gmail.com` on 19 Jan 2012 at 9:28

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne bei der C++/Qt-Implementierung von diff_match_patch::patch_apply und untersuche, wie patch_splitMax die interne Patch-Liste verändert und wie der zurückgegebene bool-Vektor erstellt wird. Vergleiche dieses Verhalten mit der ursprünglichen Patch-Liste des Aufrufers und bestimme, welcher vorgeschlagene Rückgabewertvertrag konsistent implementiert werden kann; abgeschlossen ist die Aufgabe, wenn das Ergebnis für Aufrufer eindeutig ist und durch relevante Tests abgedeckt wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.