Ticket #1950: editor.diff

File editor.diff, 5.6 KB (added by pavlinux, 14 years ago)

FOR LATEST MASTER

  • src/editor/editcmd.c

    diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c
    index f78d9d4..28e0d62 100644
    a b edit_refresh_cmd (WEdit * edit) 
    160160static int 
    161161edit_save_file (WEdit *edit, const char *filename) 
    162162{ 
    163     char *p; 
    164     gchar *tmp; 
    165     long filelen = 0; 
     163    const char *slashpos; 
     164    char *p, *msg; 
     165    char *savedir, *saveprefix; 
    166166    char *savename = 0; 
    167     gchar *real_filename; 
    168     int this_save_mode, fd = -1; 
    169167 
     168    gchar *tmp, *real_filename; 
     169 
     170    int rv, this_save_mode, fd = -1; 
     171    long buf, filelen = 0; 
     172 
     173    struct stat sb; 
     174     
    170175    if (!filename) 
    171176        return 0; 
    172177    if (!*filename) 
    edit_save_file (WEdit *edit, const char *filename) 
    192197            mc_close (fd); 
    193198    } 
    194199 
    195     if (this_save_mode == EDIT_QUICK_SAVE && 
    196         !edit->skip_detach_prompt) { 
    197         int rv; 
    198         struct stat sb; 
    199  
     200    if (this_save_mode == EDIT_QUICK_SAVE && !edit->skip_detach_prompt) { 
    200201        rv = mc_stat (real_filename, &sb); 
    201         if (rv == 0 && sb.st_nlink > 1) { 
     202          if (rv == 0 && sb.st_nlink > 1) { 
    202203            rv = edit_query_dialog3 (_("Warning"), 
    203204                                     _(" File has hard-links. Detach before saving? "), 
    204205                                     _("&Yes"), _("&No"), _("&Cancel")); 
    205             switch (rv) { 
    206             case 0: 
    207                 this_save_mode = EDIT_SAFE_SAVE; 
    208                 /* fallthrough */ 
    209             case 1: 
    210                 edit->skip_detach_prompt = 1; 
    211                 break; 
    212             default: 
    213                 g_free(real_filename); 
    214                 return -1; 
    215             } 
     206                switch (rv) { 
     207                        case 0: 
     208                                this_save_mode = EDIT_SAFE_SAVE; 
     209                                /* fallthrough */ 
     210                        case 1: 
     211                                edit->skip_detach_prompt = 1; 
     212                                break; 
     213                        default: 
     214                                g_free(real_filename); 
     215                                return -1; 
     216                } 
    216217        } 
    217218 
    218219        /* Prevent overwriting changes from other editor sessions. */ 
    219220        if (rv == 0 && edit->stat1.st_mtime != 0 && edit->stat1.st_mtime != sb.st_mtime) { 
    220  
    221221            /* The default action is "Cancel". */ 
    222222            query_set_sel(1); 
    223223 
    edit_save_file (WEdit *edit, const char *filename) 
    234234    } 
    235235 
    236236    if (this_save_mode != EDIT_QUICK_SAVE) { 
    237         char *savedir, *saveprefix; 
    238         const char *slashpos; 
    239237        slashpos = strrchr (real_filename, PATH_SEP); 
    240238        if (slashpos) { 
    241239            savedir = g_strdup (real_filename); 
    edit_save_file (WEdit *edit, const char *filename) 
    299297            goto error_save; 
    300298        } 
    301299        g_free (p); 
    302     } else if (edit->lb == LB_ASIS) { /* do not change line breaks */ 
    303         long buf; 
     300    } else if (edit->lb == LB_ASIS) { /* do not change line breaks */    
    304301        buf = 0; 
    305302        filelen = edit->last_byte; 
    306303        while (buf <= (edit->curs1 >> S_EDIT_BUF_SIZE) - 1) { 
    edit_save_file (WEdit *edit, const char *filename) 
    355352            filelen = edit_write_stream (edit, file); 
    356353            fclose (file); 
    357354        } else { 
    358             char *msg; 
    359  
    360355            msg = g_strdup_printf (_(" Cannot open file for writing: %s "), savename); 
    361356            edit_error_dialog (_("Error"), msg); 
    362357            g_free (msg); 
    edit_delete_macro_cmd (WEdit * edit) 
    787782int edit_load_macro_cmd (WEdit * edit, struct macro macro[], int *n, int k) 
    788783{ 
    789784    FILE *f; 
     785    int u; 
    790786    int s, i = 0, found = 0; 
    791787 
    792788    (void) edit; 
    int edit_load_macro_cmd (WEdit * edit, struct macro macro[], int *n, int k) 
    798794    if ((f = edit_open_macro_file ("r"))) { 
    799795        struct macro dummy; 
    800796        do { 
    801             int u; 
    802797            u = fscanf (f, ("key '%d 0': "), &s); 
    803798            if (!u || u == EOF) 
    804799                break; 
    editcmd_find (WEdit *edit, gsize *len) 
    14571452    if (edit->replace_backwards) { 
    14581453        search_end = end_mark; 
    14591454        while ((int) search_start >= start_mark) { 
    1460             if (search_end > search_start + edit->search->original_len 
     1455            if (search_end > search_start + (off_t)edit->search->original_len 
    14611456                && mc_search_is_fixed_search_str(edit->search)) { 
    14621457                search_end = search_start + edit->search->original_len; 
    14631458            } 
    edit_block_process_cmd (WEdit *edit, const char *shell_cmd, int block) 
    22632258         */ 
    22642259        tmp = g_strconcat (" ", home_dir, PATH_SEP_STR EDIT_DIR, shell_cmd, " ", quoted_name, 
    22652260                         " ", home_dir, PATH_SEP_STR EDIT_BLOCK_FILE " /dev/null", (char *) NULL); 
    2266         system (tmp); 
    2267         g_free(tmp); 
    22682261    } else { 
    22692262        /* 
    22702263         * No block selected, just execute the command for the file. 
    edit_block_process_cmd (WEdit *edit, const char *shell_cmd, int block) 
    22732266         */ 
    22742267        tmp = g_strconcat (" ", home_dir, PATH_SEP_STR EDIT_DIR, shell_cmd, " ", 
    22752268                         quoted_name, (char *) NULL); 
    2276         system (tmp); 
    2277         g_free(tmp); 
    22782269    } 
     2270    system (tmp); 
     2271    g_free(tmp); 
     2272 
     2273 
    22792274    g_free (quoted_name); 
    22802275    close_error_pipe (D_NORMAL, NULL); 
    22812276 
    static gboolean is_break_char(char c) 
    23962391static int edit_find_word_start (WEdit *edit, long *word_start, gsize *word_len) 
    23972392{ 
    23982393    int c, last; 
    2399     gsize i; 
     2394    gssize i; 
    24002395 
    24012396/* return if at begin of file */ 
    24022397    if (edit->curs1 <= 0) 
  • src/editor/editdraw.c

    diff --git a/src/editor/editdraw.c b/src/editor/editdraw.c
    index 7f147de..ece52c1 100644
    a b struct line_s { 
    280280static inline void 
    281281print_to_widget (WEdit *edit, long row, int start_col, int start_col_real, 
    282282                 long end_col, struct line_s line[], char *status) 
    283 { 
    284     struct line_s *p; 
     283{     
     284    unsigned int textchar; 
     285    int i; 
     286    int style; 
     287    int color; 
    285288 
    286289    int x = start_col_real; 
    287290    int x1 = start_col + EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width; 
    288291    int y = row + EDIT_TEXT_VERTICAL_OFFSET; 
    289292    int cols_to_skip = abs (x); 
    290     int i; 
     293 
     294    struct line_s *p; 
    291295 
    292296    tty_setcolor (EDITOR_NORMAL_COLOR); 
    293297 
    print_to_widget (WEdit *edit, long row, int start_col, int start_col_real, 
    321325    p = line; 
    322326    i = 1; 
    323327    while (p->ch) { 
    324         int style; 
    325         unsigned int textchar; 
    326         int color; 
    327  
     328         
    328329        if (cols_to_skip) { 
    329330            p++; 
    330331            cols_to_skip--;