Ticket #2344: 0001-Ticket-XXXX-Fix-line-jump-when-started-as-editor-4-7-0-stable.patch

File 0001-Ticket-XXXX-Fix-line-jump-when-started-as-editor-4-7-0-stable.patch, 1.4 KB (added by zaytsev, 9 years ago)

Patch for the stable branch

  • src/main.c

    From c1957249250c934ae0cf62cd1e445ccd2bdb9581 Mon Sep 17 00:00:00 2001
    From: Yury V. Zaytsev <yury@shurup.com>
    Date: Wed, 8 Sep 2010 21:43:11 +0200
    Subject: [PATCH] Ticket #XXXX: Fix line jump when started as editor
    
    Two common line jump protocols supported by mc are:
    
        * mcedit +lineno file
        * mcedit file:lineno
    
    Unfortunately, in the implementation of the first protocol, if line
    number equals to zero, which is often used to position the cursor at the
    beginning of the file, it is completely ignored and file "+0" is opened
    instead.
    
    This patch fixes aforementioned issue.
    
    Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
    ---
     src/main.c |    8 ++++++++
     1 files changed, 8 insertions(+), 0 deletions(-)
    
    diff --git a/src/main.c b/src/main.c
    index 2be2a7f..2ff2bce 100644
    a b mc_main__setup_by_args (int argc, char *argv[]) 
    20502050            try_plus_filename: 
    20512051                if (*tmp == '+' && g_ascii_isdigit ((gchar) tmp[1])) { 
    20522052                    int start_line = atoi (tmp); 
     2053 
     2054                    /* 
     2055                     * If start_line is zero, position the cursor at the 
     2056                     * beginning of the file as other editors (vi, nano) 
     2057                     */ 
     2058                    if (start_line == 0) 
     2059                        start_line++; 
     2060 
    20532061                    if (start_line > 0) { 
    20542062                        char *file = (argc > 1) ? argv[2] : NULL; 
    20552063                        if (file) {