Navigation Menu

Skip to content

Commit

Permalink
mrb: revert locale to UTF-8 conversion
Browse files Browse the repository at this point in the history
It didn't solve anything...
  • Loading branch information
kou committed Jun 18, 2018
1 parent 4dd4b58 commit 57cf8ad
Showing 1 changed file with 1 addition and 40 deletions.
41 changes: 1 addition & 40 deletions lib/mrb.c
Expand Up @@ -68,43 +68,6 @@ grn_mrb_is_order_by_estimated_size_enabled(void)

#ifdef GRN_WITH_MRUBY
# ifdef WIN32
static char *
grn_mrb_string_locale_to_utf8(grn_ctx *ctx, const char *locale_string)
{
size_t locale_string_bytes;
wchar_t *wide_string;
int n_wide_chars;
char *utf8_string;
int utf8_string_bytes;

locale_string_bytes = strlen(locale_string);
n_wide_chars = MultiByteToWideChar(CP_ACP, 0,
locale_string, locale_string_bytes,
NULL, 0);
wide_string = GRN_MALLOCN(wchar_t, n_wide_chars);
if (!wide_string) {
return NULL;
}
n_wide_chars = MultiByteToWideChar(CP_ACP, 0,
locale_string, locale_string_bytes,
wide_string, n_wide_chars);
utf8_string_bytes = WideCharToMultiByte(CP_UTF8, 0,
wide_string, n_wide_chars,
NULL, 0,
NULL,NULL);
utf8_string = GRN_MALLOCN(char, utf8_string_bytes + 1);
if (!utf8_string) {
GRN_FREE(wide_string);
return NULL;
}
utf8_string_bytes = WideCharToMultiByte(CP_UTF8, 0,
wide_string, n_wide_chars,
utf8_string, utf8_string_bytes,
NULL, NULL);
utf8_string[utf8_string_bytes] = '\0';
return utf8_string;
}

static char *windows_ruby_scripts_dir = NULL;
static char windows_ruby_scripts_dir_buffer[PATH_MAX];
static const char *
Expand All @@ -113,11 +76,9 @@ grn_mrb_get_default_system_ruby_scripts_dir(grn_ctx *ctx)
if (!windows_ruby_scripts_dir) {
const char *base_dir;
const char *relative_path = GRN_RELATIVE_RUBY_SCRIPTS_DIR;
const char *utf8_base_dir;

base_dir = grn_windows_base_dir();
utf8_base_dir = grn_mrb_string_locale_to_utf8(ctx, base_dir);
grn_strcpy(windows_ruby_scripts_dir_buffer, PATH_MAX, utf8_base_dir);
grn_strcpy(windows_ruby_scripts_dir_buffer, PATH_MAX, base_dir);
grn_strcat(windows_ruby_scripts_dir_buffer, PATH_MAX, "/");
grn_strcat(windows_ruby_scripts_dir_buffer, PATH_MAX, relative_path);
windows_ruby_scripts_dir = windows_ruby_scripts_dir_buffer;
Expand Down

0 comments on commit 57cf8ad

Please sign in to comment.