# HG changeset patch # User Patrick Mezard # Date 2009-12-28 17:29:35 # Node ID 9c59cdafcc247f227bd5f82db231ff53db101987 # Parent aec9360517340b0d1018b213018475411c0456ad diffhelpers: fix variable declaration for MSVC (not C99) diff --git a/mercurial/diffhelpers.c b/mercurial/diffhelpers.c --- a/mercurial/diffhelpers.c +++ b/mercurial/diffhelpers.c @@ -21,15 +21,17 @@ static void _fix_newline(PyObject *hunk, int hunksz = PyList_Size(hunk); PyObject *s = PyList_GET_ITEM(hunk, hunksz-1); char *l = PyString_AS_STRING(s); - int sz = PyString_GET_SIZE(s); - if (sz > 1 && l[sz-2] == '\r') - /* tolerate CRLF in last line */ - sz -= 1; int alen = PyList_Size(a); int blen = PyList_Size(b); char c = l[0]; + PyObject *hline; + int sz = PyString_GET_SIZE(s); - PyObject *hline = PyString_FromStringAndSize(l, sz-1); + if (sz > 1 && l[sz-2] == '\r') + /* tolerate CRLF in last line */ + sz -= 1; + hline = PyString_FromStringAndSize(l, sz-1); + if (c == ' ' || c == '+') { PyObject *rline = PyString_FromStringAndSize(l+1, sz-2); PyList_SetItem(b, blen-1, rline);