ruby-changes:59017
From: Takashi <ko1@a...>
Date: Sun, 1 Dec 2019 18:36:04 +0900 (JST)
Subject: [ruby-changes:59017] 8a677a6e80 (master): Workaround missing strndup on Windows
https://git.ruby-lang.org/ruby.git/commit/?id=8a677a6e80 From 8a677a6e80b3b7e1f52073b362083a78eb87397f Mon Sep 17 00:00:00 2001 From: Takashi Kokubun <takashikkbn@g...> Date: Sun, 1 Dec 2019 01:35:30 -0800 Subject: Workaround missing strndup on Windows https://ci.appveyor.com/project/ruby/ruby/builds/29230976/job/c910t37313edb97k diff --git a/mjit.c b/mjit.c index 5749f21..f062b4b 100644 --- a/mjit.c +++ b/mjit.c @@ -700,6 +700,16 @@ start_worker(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L700 return true; } +// There's no strndup on Windows +static char* +ruby_strndup(char *str, size_t n) +{ + char *ret = xmalloc(n + 1); + memcpy(ret, str, n); + ret[n] = '\0'; + return ret; +} + // Convert "foo bar" to {"foo", "bar", NULL} array. Caller is responsible for // freeing a returned buffer and its elements. static char ** @@ -716,7 +726,7 @@ split_flags(char *flags) https://github.com/ruby/ruby/blob/trunk/mjit.c#L726 } else { if (next > flags) - buf[i++] = strndup(flags, next - flags); + buf[i++] = ruby_strndup(flags, next - flags); next++; // skip space } } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/