diff a/lib/mcconfig.h b/lib/mcconfig.h
a
|
b
|
const char *mc_config_get_cache_path (void); |
99 | 99 | const char *mc_config_get_home_dir (void); |
100 | 100 | const char *mc_config_get_path (void); |
101 | 101 | char *mc_config_get_full_path (const char *config_name); |
| 102 | char *mc_file_get_full_path (const char *file_name); |
102 | 103 | vfs_path_t *mc_config_get_full_vpath (const char *config_name); |
103 | 104 | |
104 | 105 | gboolean mc_config_migrate_from_old_place (GError ** mcerror, char **msg); |
diff --git a/lib/mcconfig/paths.c b/lib/mcconfig/paths.c
index 916bff9..4aa1e89 100644
a
|
b
|
mc_config_get_full_path (const char *config_name) |
528 | 528 | |
529 | 529 | /* --------------------------------------------------------------------------------------------- */ |
530 | 530 | /** |
| 531 | * Get full path to existing file by short name. |
| 532 | * |
| 533 | * @param file_name file short name |
| 534 | * @return full path to file (NULL if not found) |
| 535 | */ |
| 536 | |
| 537 | char * |
| 538 | mc_file_get_full_path (const char *file_name) |
| 539 | { |
| 540 | size_t rule_index; |
| 541 | char* full_path; |
| 542 | |
| 543 | if (file_name == NULL) |
| 544 | return NULL; |
| 545 | |
| 546 | if (!xdg_vars_initialized) |
| 547 | mc_config_init_config_paths (NULL); |
| 548 | |
| 549 | for (rule_index = 0; mc_config_files_reference[rule_index].old_filename != NULL; rule_index++) |
| 550 | { |
| 551 | full_path = g_build_filename (*mc_config_files_reference[rule_index].new_basedir, |
| 552 | file_name, NULL); |
| 553 | if (exist_file(full_path)) |
| 554 | return full_path; |
| 555 | g_free(full_path); |
| 556 | } |
| 557 | return NULL; |
| 558 | } |
| 559 | |
| 560 | /* --------------------------------------------------------------------------------------------- */ |
| 561 | /** |
531 | 562 | * Get full path to config file by short name. |
532 | 563 | * |
533 | 564 | * @param config_name short name |
diff --git a/src/filemanager/usermenu.c b/src/filemanager/usermenu.c
index bafb1a7..afde214 100644
a
|
b
|
|
420 | 420 | /* --------------------------------------------------------------------------------------------- */ |
421 | 421 | /** FIXME: recode this routine on version 3.0, it could be cleaner */ |
422 | 422 | |
423 | | static void |
| 423 | static char* |
424 | 424 | execute_menu_command (const WEdit * edit_widget, const char *commands, gboolean show_prompt) |
425 | 425 | { |
426 | 426 | FILE *cmd_file; |
… |
… |
|
432 | 432 | int col; |
433 | 433 | vfs_path_t *file_name_vpath; |
434 | 434 | gboolean run_view = FALSE; |
| 435 | const char* text_start; |
| 436 | char* new_menu; |
435 | 437 | |
436 | 438 | /* Skip menu entry title line */ |
437 | 439 | commands = strchr (commands, '\n'); |
438 | 440 | if (commands == NULL) |
439 | | return; |
| 441 | return(NULL); |
| 442 | |
| 443 | /* chain menu? */ |
| 444 | text_start = commands+1; |
| 445 | while (*text_start == ' ' || *text_start == '\t') ++text_start; |
| 446 | if (*text_start == '>') |
| 447 | { |
| 448 | char* line_end; |
| 449 | |
| 450 | ++text_start; |
| 451 | while (*text_start == ' ' || *text_start == '\t') ++text_start; |
| 452 | line_end = strchr (text_start, '\n'); |
| 453 | if (!line_end) return(NULL); |
| 454 | new_menu = g_strndup(text_start, line_end - text_start); |
| 455 | return(new_menu); |
| 456 | } |
440 | 457 | |
441 | 458 | cmd_file_fd = mc_mkstemps (&file_name_vpath, "mcusr", SCRIPT_SUFFIX); |
442 | 459 | |
… |
… |
|
445 | 462 | message (D_ERROR, MSG_ERROR, _("Cannot create temporary command file\n%s"), |
446 | 463 | unix_error_string (errno)); |
447 | 464 | vfs_path_free (file_name_vpath); |
448 | | return; |
| 465 | return(NULL); |
449 | 466 | } |
450 | 467 | cmd_file = fdopen (cmd_file_fd, "w"); |
451 | 468 | fputs ("#! /bin/sh\n", cmd_file); |
… |
… |
|
481 | 498 | fclose (cmd_file); |
482 | 499 | mc_unlink (file_name_vpath); |
483 | 500 | vfs_path_free (file_name_vpath); |
484 | | return; |
| 501 | return(NULL); |
485 | 502 | } |
486 | 503 | if (do_quote) |
487 | 504 | { |
… |
… |
|
568 | 585 | } |
569 | 586 | mc_unlink (file_name_vpath); |
570 | 587 | vfs_path_free (file_name_vpath); |
| 588 | return(NULL); |
571 | 589 | } |
572 | 590 | |
573 | 591 | /* --------------------------------------------------------------------------------------------- */ |
… |
… |
|
934 | 952 | menu = g_strdup (menu_file); |
935 | 953 | else |
936 | 954 | menu = g_strdup (edit_widget != NULL ? EDIT_LOCAL_MENU : MC_LOCAL_MENU); |
| 955 | |
| 956 | do /* process menu file */ |
| 957 | { |
| 958 | res = FALSE; |
937 | 959 | if (!exist_file (menu) || !menu_file_own (menu)) |
938 | 960 | { |
939 | 961 | if (menu_file != NULL) |
… |
… |
|
982 | 1004 | MC_PTR_FREE (menu); |
983 | 1005 | return FALSE; |
984 | 1006 | } |
| 1007 | g_free (menu); |
| 1008 | menu = NULL; |
985 | 1009 | |
986 | 1010 | max_cols = 0; |
987 | 1011 | selected = 0; |
… |
… |
|
1110 | 1134 | } |
1111 | 1135 | if (selected >= 0) |
1112 | 1136 | { |
1113 | | execute_menu_command (edit_widget, entries[selected], interactive); |
| 1137 | menu = execute_menu_command (edit_widget, entries[selected], interactive); |
1114 | 1138 | res = TRUE; |
1115 | 1139 | } |
1116 | 1140 | |
… |
… |
|
1118 | 1142 | } |
1119 | 1143 | |
1120 | 1144 | easy_patterns = old_patterns; |
1121 | | MC_PTR_FREE (menu); |
1122 | 1145 | g_free (entries); |
1123 | 1146 | g_free (data); |
| 1147 | if (menu) /* possible chain menu */ |
| 1148 | { |
| 1149 | char* temp = mc_file_get_full_path (menu); |
| 1150 | g_free (menu); |
| 1151 | menu = temp; |
| 1152 | if (!exist_file (menu)) |
| 1153 | { |
| 1154 | g_free(menu); |
| 1155 | menu = NULL; |
| 1156 | } |
| 1157 | } |
| 1158 | } |
| 1159 | while (menu); |
| 1160 | do_refresh (); |
1124 | 1161 | return res; |
1125 | 1162 | } |
1126 | 1163 | |