mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-bin-mirb: fix Windows/MSVC compilation warnings
- Define strdup as _strdup on MSVC to avoid deprecation warning - Add strndup implementation for Windows (not available in MSVC) Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,23 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Windows compatibility */
|
||||
#ifdef _MSC_VER
|
||||
#define strdup _strdup
|
||||
static char*
|
||||
strndup(const char *s, size_t n)
|
||||
{
|
||||
size_t len = strlen(s);
|
||||
if (len > n) len = n;
|
||||
char *p = (char*)malloc(len + 1);
|
||||
if (p) {
|
||||
memcpy(p, s, len);
|
||||
p[len] = '\0';
|
||||
}
|
||||
return p;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MRB_USE_READLINE
|
||||
#ifndef MRB_USE_LINENOISE
|
||||
#include MRB_READLINE_HEADER
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Windows compatibility */
|
||||
#ifdef _MSC_VER
|
||||
#define strdup _strdup
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Initialize history
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user