31 /* tolerate CRLF in last line */ |
31 /* tolerate CRLF in last line */ |
32 sz -= 1; |
32 sz -= 1; |
33 hline = PyString_FromStringAndSize(l, sz-1); |
33 hline = PyString_FromStringAndSize(l, sz-1); |
34 |
34 |
35 if (c == ' ' || c == '+') { |
35 if (c == ' ' || c == '+') { |
36 PyObject *rline = PyString_FromStringAndSize(l+1, sz-2); |
36 PyObject *rline = PyString_FromStringAndSize(l + 1, sz - 2); |
37 PyList_SetItem(b, blen-1, rline); |
37 PyList_SetItem(b, blen-1, rline); |
38 } |
38 } |
39 if (c == ' ' || c == '-') { |
39 if (c == ' ' || c == '-') { |
40 Py_INCREF(hline); |
40 Py_INCREF(hline); |
41 PyList_SetItem(a, alen-1, hline); |
41 PyList_SetItem(a, alen-1, hline); |
72 char *s, c; |
72 char *s, c; |
73 PyObject *l; |
73 PyObject *l; |
74 if (!PyArg_ParseTuple(args, "OOiiOO", &fp, &hunk, &lena, &lenb, &a, &b)) |
74 if (!PyArg_ParseTuple(args, "OOiiOO", &fp, &hunk, &lena, &lenb, &a, &b)) |
75 return NULL; |
75 return NULL; |
76 |
76 |
77 while(1) { |
77 while (1) { |
78 todoa = lena - PyList_Size(a); |
78 todoa = lena - PyList_Size(a); |
79 todob = lenb - PyList_Size(b); |
79 todob = lenb - PyList_Size(b); |
80 num = todoa > todob ? todoa : todob; |
80 num = todoa > todob ? todoa : todob; |
81 if (num == 0) |
81 if (num == 0) |
82 break; |
82 break; |
83 for (i = 0 ; i < num ; i++) { |
83 for (i = 0; i < num; i++) { |
84 x = PyFile_GetLine(fp, 0); |
84 x = PyFile_GetLine(fp, 0); |
85 s = PyString_AS_STRING(x); |
85 s = PyString_AS_STRING(x); |
86 c = *s; |
86 c = *s; |
87 if (strcmp(s, "\\ No newline at end of file\n") == 0) { |
87 if (strcmp(s, "\\ No newline at end of file\n") == 0) { |
88 _fix_newline(hunk, a, b); |
88 _fix_newline(hunk, a, b); |
133 alen = PyList_Size(a); |
133 alen = PyList_Size(a); |
134 blen = PyList_Size(b); |
134 blen = PyList_Size(b); |
135 if (alen > blen - bstart) { |
135 if (alen > blen - bstart) { |
136 return Py_BuildValue("l", -1); |
136 return Py_BuildValue("l", -1); |
137 } |
137 } |
138 for (i = 0 ; i < alen ; i++) { |
138 for (i = 0; i < alen; i++) { |
139 sa = PyString_AS_STRING(PyList_GET_ITEM(a, i)); |
139 sa = PyString_AS_STRING(PyList_GET_ITEM(a, i)); |
140 sb = PyString_AS_STRING(PyList_GET_ITEM(b, i + bstart)); |
140 sb = PyString_AS_STRING(PyList_GET_ITEM(b, i + bstart)); |
141 if (strcmp(sa+1, sb) != 0) |
141 if (strcmp(sa + 1, sb) != 0) |
142 return Py_BuildValue("l", -1); |
142 return Py_BuildValue("l", -1); |
143 } |
143 } |
144 return Py_BuildValue("l", 0); |
144 return Py_BuildValue("l", 0); |
145 } |
145 } |
146 |
146 |