Ticket #379: mc-4.6.2-pre1-line_view.patch

File mc-4.6.2-pre1-line_view.patch, 1.7 KB (added by slavazanko, 10 years ago)
  • src/find.c

    diff -Nur a/src/find.c b/src/find.c
    a b  
    5656static int FIND2_X = 64; 
    5757#define FIND2_X_USE (FIND2_X - 20) 
    5858 
     59/* Separator for file line view in search */ 
     60#define SEPARATOR " -//- " 
     61 
    5962/* A couple of extra messages we need */ 
    6063enum { 
    6164    B_STOP = B_USER + 1, 
     
    559562            if (found == 0){    /* Search in binary line once */ 
    560563                if (find_regex_flag) { 
    561564                if (regexec (r, p, 1, 0, 0) == 0){ 
    562                     g_free (p); 
    563                     p = g_strdup_printf ("%d:%s", line, filename); 
    564                     find_add_match (h, directory, p); 
     565                    char *p2 = g_strdup_printf ("%d:%s%s%s", line, filename, SEPARATOR, p); 
     566                    find_add_match (h, directory, p2); 
     567                    g_free (p2); 
    565568                    found = 1; 
    566569                } 
    567570                } else { 
     
    747750static char * 
    748751make_fullname (const char *dirname, const char *filename) 
    749752{ 
    750  
     753    char *dirty_name, *clean_name, *separator_start; 
     754         
    751755    if (strcmp(dirname, ".") == 0 || strcmp(dirname, "."PATH_SEP_STR) == 0) 
    752         return g_strdup (filename); 
    753     if (strncmp(dirname, "."PATH_SEP_STR, 2) == 0) 
    754         return concat_dir_and_file (dirname + 2, filename); 
    755     return concat_dir_and_file (dirname, filename); 
     756        dirty_name = g_strdup (filename); 
     757    else if (strncmp(dirname, "."PATH_SEP_STR, 2) == 0) 
     758        dirty_name = concat_dir_and_file (dirname + 2, filename); 
     759    else 
     760        dirty_name = concat_dir_and_file (dirname, filename); 
     761 
     762    /* If the separator is in the name remove it */ 
     763    if ((separator_start = strstr (dirty_name, SEPARATOR))) 
     764        clean_name = g_strndup (dirty_name, separator_start - dirty_name); 
     765    else 
     766        return dirty_name; 
     767 
     768    g_free (dirty_name); 
     769 
     770    return (clean_name); 
    756771} 
    757772 
    758773static void