/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/_patiencediff_c.c

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
641
641
 
642
642
    res = PyList_New(nmatches);
643
643
    for (i = 0; i < nmatches; i++) {
644
 
#if PY_VERSION_HEX < 0x02050000
645
 
        item = Py_BuildValue("ii", matches[nmatches - i - 1].a, matches[nmatches - i - 1].b);
646
 
#else
647
644
        item = Py_BuildValue("nn", matches[nmatches - i - 1].a, matches[nmatches - i - 1].b);
648
 
#endif
649
645
        if (item == NULL)
650
646
            goto error;
651
647
        if (PyList_SetItem(res, i, item) != 0)
680
676
    struct hashtable hashtable;
681
677
    struct matching_blocks matches;
682
678
 
683
 
#if PY_VERSION_HEX < 0x02050000
684
 
    if (!PyArg_ParseTuple(args, "OOiiiiOi", &aseq, &bseq, &alo, &blo,
685
 
                          &ahi, &bhi, &answer, &maxrecursion))
686
 
#else
687
679
    if (!PyArg_ParseTuple(args, "OOnnnnOi", &aseq, &bseq, &alo, &blo,
688
680
                          &ahi, &bhi, &answer, &maxrecursion))
689
 
#endif
690
681
        return NULL;
691
682
 
692
683
    hashtable.table = NULL;
722
713
 
723
714
    for (i = 0; i < matches.count; i++) {
724
715
        for (j = 0; j < matches.matches[i].len; j++) {
725
 
#if PY_VERSION_HEX < 0x02050000
726
 
            item = Py_BuildValue("ii", matches.matches[i].a + j,
727
 
                                 matches.matches[i].b + j);
728
 
#else
729
716
            item = Py_BuildValue("nn", matches.matches[i].a + j,
730
717
                                 matches.matches[i].b + j);
731
 
#endif
732
718
            if (item == NULL)
733
719
                goto error;
734
720
            if (PyList_Append(answer, item) != 0)
854
840
    }
855
841
 
856
842
    for (i = 0; i < matches.count; i++) {
857
 
#if PY_VERSION_HEX < 0x02050000
858
 
        item = Py_BuildValue("iii", matches.matches[i].a,
859
 
                             matches.matches[i].b, matches.matches[i].len);
860
 
#else
861
843
        item = Py_BuildValue("nnn", matches.matches[i].a,
862
844
                             matches.matches[i].b, matches.matches[i].len);
863
 
#endif
864
845
        if (item == NULL)
865
846
            goto error;
866
847
        if (PyList_SetItem(answer, i, item) != 0)
867
848
            goto error;
868
849
    }
869
 
#if PY_VERSION_HEX < 0x02050000
870
 
    item = Py_BuildValue("iii", self->asize, self->bsize, 0);
871
 
#else
872
850
    item = Py_BuildValue("nnn", self->asize, self->bsize, 0);
873
 
#endif
874
851
    if (item == NULL)
875
852
        goto error;
876
853
    if (PyList_SetItem(answer, i, item) != 0)
960
937
            tag = OP_INSERT;
961
938
 
962
939
        if (tag != -1) {
963
 
#if PY_VERSION_HEX < 0x02050000
964
 
            item = Py_BuildValue("siiii", opcode_names[tag], i, ai, j, bj);
965
 
#else
966
940
            item = Py_BuildValue("snnnn", opcode_names[tag], i, ai, j, bj);
967
 
#endif
968
941
            if (item == NULL)
969
942
                goto error;
970
943
            if (PyList_Append(answer, item) != 0)
975
948
        j = bj + matches.matches[k].len;
976
949
 
977
950
        if (matches.matches[k].len > 0) {
978
 
#if PY_VERSION_HEX < 0x02050000
979
 
            item = Py_BuildValue("siiii", opcode_names[OP_EQUAL], ai, i, bj, j);
980
 
#else
981
951
            item = Py_BuildValue("snnnn", opcode_names[OP_EQUAL], ai, i, bj, j);
982
 
#endif
983
952
            if (item == NULL)
984
953
                goto error;
985
954
            if (PyList_Append(answer, item) != 0)
1137
1106
        /* end the current group and start a new one whenever
1138
1107
           there is a large range with no changes. */
1139
1108
        if (tag == OP_EQUAL && i2 - i1 > nn) {
1140
 
#if PY_VERSION_HEX < 0x02050000
1141
 
            item = Py_BuildValue("siiii", opcode_names[tag],
1142
 
                                  i1, MIN(i2, i1 + n), j1, MIN(j2, j1 + n));
1143
 
#else
1144
1109
            item = Py_BuildValue("snnnn", opcode_names[tag],
1145
1110
                                  i1, MIN(i2, i1 + n), j1, MIN(j2, j1 + n));
1146
 
#endif
1147
1111
            if (item == NULL)
1148
1112
                goto error;
1149
1113
            if (PyList_Append(group, item) != 0)
1156
1120
            i1 = MAX(i1, i2 - n);
1157
1121
            j1 = MAX(j1, j2 - n);
1158
1122
        }
1159
 
#if PY_VERSION_HEX < 0x02050000
1160
 
        item = Py_BuildValue("siiii", opcode_names[tag], i1, i2, j1 ,j2);
1161
 
#else
1162
1123
        item = Py_BuildValue("snnnn", opcode_names[tag], i1, i2, j1 ,j2);
1163
 
#endif
1164
1124
        if (item == NULL)
1165
1125
            goto error;
1166
1126
        if (PyList_Append(group, item) != 0)