From c4a1e2ac005d2158fb56d999bf7bbcc1f08deb04 Mon Sep 17 00:00:00 2001 From: Christian Boos Date: Tue, 5 Jun 2012 10:17:31 +0200 Subject: [PATCH] fix windows VC9 build Move variable declarations to the top of the functions. --- src/pygit2/diff.c | 6 +++--- src/pygit2/error.c | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pygit2/diff.c b/src/pygit2/diff.c index 38bb5f4..777ba76 100644 --- a/src/pygit2/diff.c +++ b/src/pygit2/diff.c @@ -55,6 +55,9 @@ static int diff_hunk_cb( { PyObject *hunks; Hunk *hunk; + int len; + char* old_path, *new_path; + hunks = PyDict_GetItemString(cb_data, "hunks"); if (hunks == NULL) { @@ -71,9 +74,6 @@ static int diff_hunk_cb( hunk->new_start = range->new_start; hunk->new_lines = range->new_lines; - int len; - char* old_path, *new_path; - if (delta->old_file.path != NULL) { len = strlen(delta->old_file.path) + 1; old_path = malloc(sizeof(char) * len); diff --git a/src/pygit2/error.c b/src/pygit2/error.c index 246787c..fccf8a8 100644 --- a/src/pygit2/error.c +++ b/src/pygit2/error.c @@ -4,6 +4,7 @@ PyObject *GitError; PyObject * Error_type(int type) { + const git_error* error; // Expected switch (type) { /** Input does not exist in the scope searched. */ @@ -32,7 +33,7 @@ PyObject * Error_type(int type) } // Critical - const git_error* error = giterr_last(); + error = giterr_last(); if(error != NULL) { switch (error->klass) { case GITERR_NOMEMORY: @@ -66,13 +67,14 @@ PyObject* Error_set(int err) PyObject* Error_set_str(int err, const char *str) { + const git_error* error; if (err == GIT_ENOTFOUND) { /* KeyError expects the arg to be the missing key. */ PyErr_SetString(PyExc_KeyError, str); return NULL; } - const git_error* error = giterr_last(); + error = giterr_last(); return PyErr_Format(Error_type(err), "%s: %s", str, error->message); }