diff --git a/apple/iOS/menu.m b/apple/iOS/menu.m index 16a966ed4c..45863e2b36 100644 --- a/apple/iOS/menu.m +++ b/apple/iOS/menu.m @@ -416,16 +416,23 @@ static void RunActionSheet(const char* title, const struct string_list* items, U list = [[RADirectoryList alloc] initWithPath:path extensions:self.setting->values action: ^(RADirectoryList* list, RADirectoryItem* item) { - if (!list.allowBlank && !item) + const char *newval = NULL; + if (item) { + if (list.forDirectory && !item.isDirectory) return; - - if (list.forDirectory && !item.isDirectory) + + newval = [item.path UTF8String]; + } else { + if (!list.allowBlank) return; + + newval = ""; + } + + setting_data_set_with_string_representation(weakSelf.setting, newval); + [[list navigationController] popViewControllerAnimated:YES]; - setting_data_set_with_string_representation(weakSelf.setting, item ? [item.path UTF8String] : ""); - [[list navigationController] popViewControllerAnimated:YES]; - - [weakSelf.parentTable reloadData]; + [weakSelf.parentTable reloadData]; }]; list.allowBlank = (self.setting->flags & SD_FLAG_ALLOW_EMPTY); diff --git a/driver.c b/driver.c index dfb657abfe..b519e87793 100644 --- a/driver.c +++ b/driver.c @@ -194,34 +194,29 @@ static const input_driver_t *input_drivers[] = { * the drivers. */ -const char* config_get_input_driver_options(void) -{ - char *input_options; - int i; - int input_option_k = 0; - int input_options_len = 0; - unsigned offset = 0; +const char* config_get_input_driver_options(void) { + char *input_options = NULL; + int input_option_k = 0; + int input_options_len = 0; + + union string_list_elem_attr attr; + attr.i = 0; + struct string_list *input_options_l = string_list_new(); - while (input_drivers[input_option_k]) - { - const char *opt = input_drivers[input_option_k]->ident; - input_options_len += strlen(opt) + 1; - input_option_k++; - } + for (input_option_k = 0; input_drivers[input_option_k]; input_option_k++) { + const char *opt = input_drivers[input_option_k]->ident; + input_options_len += strlen(opt) + 1; + string_list_append(input_options_l, opt, attr); + } - input_options = (char*)calloc(input_options_len, sizeof(char)); + input_options = (char*)calloc(input_options_len, sizeof(char)); - for (i = 0; i < input_option_k; i++) - { - const char *opt = input_drivers[i]->ident; - strlcpy(input_options + offset, opt, input_options_len - offset); - offset += strlen(opt); - input_options[offset] = '|'; - offset += 1; - } - input_options[input_options_len - 1] = '\0'; + string_list_join_concat(input_options, input_options_len, input_options_l, "|"); + + string_list_free(input_options_l); + input_options_l = NULL; - return input_options; + return input_options; } static const input_osk_driver_t *osk_drivers[] = {