D7877: sha1dc: declare all variables at begininng of block

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Wed Jan 15 01:54:49 UTC 2020


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is required to appease ancient C language standards, which
  msvc 2008 still requires for Python 2.7 on Windows.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D7877

AFFECTED FILES
  mercurial/thirdparty/sha1dc/cext.c

CHANGE DETAILS

diff --git a/mercurial/thirdparty/sha1dc/cext.c b/mercurial/thirdparty/sha1dc/cext.c
--- a/mercurial/thirdparty/sha1dc/cext.c
+++ b/mercurial/thirdparty/sha1dc/cext.c
@@ -84,13 +84,14 @@
 
 static PyObject *pysha1ctx_hexdigest(pysha1ctx *self)
 {
+	static const char hexdigit[] = "0123456789abcdef";
 	unsigned char hash[20];
+	char hexhash[40];
+	int i;
 	if (!finalize(self->ctx, hash)) {
 		return NULL;
 	}
-	char hexhash[40];
-	static const char hexdigit[] = "0123456789abcdef";
-	for (int i = 0; i < 20; ++i) {
+	for (i = 0; i < 20; ++i) {
 		hexhash[i * 2] = hexdigit[hash[i] >> 4];
 		hexhash[i * 2 + 1] = hexdigit[hash[i] & 15];
 	}



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list