Ticket #1844: 1844-UNneeded-goto-in-user_menu.patch

File 1844-UNneeded-goto-in-user_menu.patch, 2.2 KB (added by vit_r, 15 years ago)

only simplifying the code in edit/edit.c user_menu () {}

  • edit/edit.c

    From bd457ec7804b82b7383cb60ba88580f9a51ea261 Mon Sep 17 00:00:00 2001
    From: Vit Rosin <vit_r@list.ru>
    Date: Sat, 28 Nov 2009 12:40:48 +0000
    Subject: [PATCH] UNneeded_goto
    
    ---
     edit/edit.c |   43 ++++++++++++++++++-------------------------
     1 files changed, 18 insertions(+), 25 deletions(-)
    
    diff --git a/edit/edit.c b/edit/edit.c
    index 0b0b1eb..04528b8 100644
    a b edit_execute_macro (WEdit *edit, struct macro macro[], int n) 
    32763276    edit->macro_depth--; 
    32773277} 
    32783278 
    3279 /* User edit menu, like user menu (F2) but only in editor. */ 
     3279/* On file selected (i.e. by arrows) (F4) invokes the editor 
     3280   then (F11) or (S-F1) invokes user menu */ 
    32803281static void 
    32813282user_menu (WEdit * edit) 
    32823283{ 
    32833284    FILE *fd; 
    3284     int nomark; 
    3285     struct stat status; 
     3285    int nomark, rc = 0; 
    32863286    long start_mark, end_mark; 
     3287    struct stat status; 
    32873288    char *block_file = concat_dir_and_file (home_dir, EDIT_BLOCK_FILE); 
    3288     int rc = 0; 
    32893289 
     3290    /* remember marked or not */ 
    32903291    nomark = eval_marks (edit, &start_mark, &end_mark); 
    3291     if (!nomark)                /* remember marked or not */ 
    3292         edit_save_block (edit, block_file, start_mark, end_mark); 
     3292    if (!nomark) 
     3293        edit_save_block (edit, block_file, start_mark, end_mark); 
    32933294 
    32943295    /* run shell scripts from menu */ 
    32953296    user_menu_cmd (edit); 
    32963297 
    3297     if (mc_stat (block_file, &status) != 0 || !status.st_size) { 
    3298         /* no block messages */ 
    3299         goto cleanup; 
    3300     } 
     3298    if (mc_stat (block_file, &status) == 0 || status.st_size) { 
     3299        /* there are block messages */ 
     3300        if (!nomark) /* i.e. we have marked block */ 
     3301            rc = edit_block_delete_cmd (edit); 
    33013302 
    3302     if (!nomark) { 
    3303         /* i.e. we have marked block */ 
    3304         rc = edit_block_delete_cmd (edit); 
    3305     } 
     3303        if (!rc)  
     3304            edit_insert_file (edit, block_file); 
    33063305 
    3307     if (!rc) { 
    3308         edit_insert_file (edit, block_file); 
    3309     } 
     3306        fd = fopen (block_file, "w"); 
     3307        if (fd) /* truncate block file */ 
     3308            fclose (fd); 
    33103309 
    3311     /* truncate block file */ 
    3312     if ((fd = fopen (block_file, "w"))) { 
    3313         fclose (fd); 
     3310        edit_refresh_cmd (edit); 
     3311        edit->force |= REDRAW_COMPLETELY; 
    33143312    } 
    3315  
    3316     edit_refresh_cmd (edit); 
    3317     edit->force |= REDRAW_COMPLETELY; 
    3318  
    3319 cleanup: 
    33203313    g_free (block_file); 
    33213314} 
    33223315