comparison mercurial/thirdparty/sha1dc/cext.c @ 44082:c3f741bb2f33

sha1dc: declare all variables at begininng of block This is required to appease ancient C language standards, which msvc 2008 still requires for Python 2.7 on Windows. Differential Revision: https://phab.mercurial-scm.org/D7877
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 14 Jan 2020 17:39:12 -0800
parents bde1cd4c99d9
children 29a110e2776e
comparison
equal deleted inserted replaced
44081:ef36156eac9f 44082:c3f741bb2f33
82 return PyBytes_FromStringAndSize((char *)hash, 20); 82 return PyBytes_FromStringAndSize((char *)hash, 20);
83 } 83 }
84 84
85 static PyObject *pysha1ctx_hexdigest(pysha1ctx *self) 85 static PyObject *pysha1ctx_hexdigest(pysha1ctx *self)
86 { 86 {
87 static const char hexdigit[] = "0123456789abcdef";
87 unsigned char hash[20]; 88 unsigned char hash[20];
89 char hexhash[40];
90 int i;
88 if (!finalize(self->ctx, hash)) { 91 if (!finalize(self->ctx, hash)) {
89 return NULL; 92 return NULL;
90 } 93 }
91 char hexhash[40]; 94 for (i = 0; i < 20; ++i) {
92 static const char hexdigit[] = "0123456789abcdef";
93 for (int i = 0; i < 20; ++i) {
94 hexhash[i * 2] = hexdigit[hash[i] >> 4]; 95 hexhash[i * 2] = hexdigit[hash[i] >> 4];
95 hexhash[i * 2 + 1] = hexdigit[hash[i] & 15]; 96 hexhash[i * 2 + 1] = hexdigit[hash[i] & 15];
96 } 97 }
97 return PyString_FromStringAndSize(hexhash, 40); 98 return PyString_FromStringAndSize(hexhash, 40);
98 } 99 }