From f72cac196a361e14b7a9d766dfa6cd85132c7478 Mon Sep 17 00:00:00 2001 From: Hans Kolek Date: Wed, 18 Aug 2010 00:48:23 +0200 Subject: [PATCH] Provide strnlen() on mingw32 which doesn't have it. --- NEWS | 2 ++ dulwich/_objects.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/NEWS b/NEWS index daedefd..5dc4369 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ * ThinPackData.from_file now works with resolve_ext_ref callback. (Dave Borowitz) + * Provide strnlen() on mingw32 which doesn't have it. (Hans Kolek) + FEATURES * Use slots for core objects to save up on memory. (Jelmer Vernooij) diff --git a/dulwich/_objects.c b/dulwich/_objects.c index c16e5cc..f29b127 100644 --- a/dulwich/_objects.c +++ b/dulwich/_objects.c @@ -25,6 +25,14 @@ typedef int Py_ssize_t; #endif +#ifdef __MINGW32_VERSION +size_t strnlen(char *text, size_t maxlen) +{ + const char *last = memchr(text, '\0', maxlen); + return last ? (size_t) (last - text) : maxlen; +} +#endif + #define bytehex(x) (((x)<0xa)?('0'+(x)):('a'-0xa+(x))) static PyObject *sha_to_pyhex(const unsigned char *sha) -- 2.34.1