Ticket #1495: mc-4.7.0-pre1.whole_words.patch

File mc-4.7.0-pre1.whole_words.patch, 11.1 KB (added by dborca, 13 years ago)
  • edit/edit-widget.h

    diff -Naur mc-4.7.0-pre1~/edit/edit-widget.h mc-4.7.0-pre1/edit/edit-widget.h
    old new  
    6262    int replace_mode; 
    6363    int replace_backwards; 
    6464    int replace_case; 
     65    int whole_words; 
    6566    int all_codepages; 
    6667 
    6768    long search_start;          /* First character to start searching from */ 
  • edit/editcmd.c

    diff -Naur mc-4.7.0-pre1~/edit/editcmd.c mc-4.7.0-pre1/edit/editcmd.c
    old new  
    14071407        edit->search->search_type = edit->search_type; 
    14081408        edit->search->is_all_charsets = edit->all_codepages; 
    14091409        edit->search->is_case_sentitive = edit->replace_case; 
     1410        edit->search->whole_words = edit->whole_words; 
    14101411        edit->search->search_fn = edit_search_cmd_callback; 
    14111412    } 
    14121413 
     
    16041605        edit->search->search_type = edit->search_type; 
    16051606        edit->search->is_all_charsets = edit->all_codepages; 
    16061607        edit->search->is_case_sentitive = edit->replace_case; 
     1608        edit->search->whole_words = edit->whole_words; 
    16071609        edit->search->search_fn = edit_search_cmd_callback; 
    16081610    } 
    16091611 
  • edit/editcmd_dialogs.c

    diff -Naur mc-4.7.0-pre1~/edit/editcmd_dialogs.c mc-4.7.0-pre1/edit/editcmd_dialogs.c
    old new  
    4949/*** file scope macro definitions **************************************/ 
    5050 
    5151#define SEARCH_DLG_WIDTH 58 
    52 #define SEARCH_DLG_MIN_HEIGHT 11 
     52#define SEARCH_DLG_MIN_HEIGHT 12 
    5353#define SEARCH_DLG_HEIGHT_SUPPLY 3 
    5454 
    5555#define REPLACE_DLG_WIDTH 58 
     
    8484{ 
    8585    int treplace_backwards = edit->replace_backwards; 
    8686    int treplace_case = edit->replace_case; 
     87    int twhole_words = edit->whole_words; 
    8788    int tall_codepages = edit->all_codepages; 
    8889    mc_search_type_t ttype_of_search = edit->search_type; 
    8990    int dialog_result; 
     
    101102         0, 0, NULL, NULL, NULL}, 
    102103 
    103104#ifdef HAVE_CHARSET 
    104         {quick_checkbox, 33, REPLACE_DLG_WIDTH, 9, REPLACE_DLG_HEIGHT, N_("All charsets"), 0, 0, 
     105        {quick_checkbox, 33, REPLACE_DLG_WIDTH, 10, REPLACE_DLG_HEIGHT, N_("All charsets"), 0, 0, 
    105106         &tall_codepages, 0, NULL, NULL, NULL}, 
    106107#endif 
    107108 
    108         {quick_checkbox, 33, REPLACE_DLG_WIDTH, 8, REPLACE_DLG_HEIGHT, N_("&Backwards"), 0, 0, 
     109        {quick_checkbox, 33, REPLACE_DLG_WIDTH, 9, REPLACE_DLG_HEIGHT, N_("&Backwards"), 0, 0, 
    109110         &treplace_backwards, 0, NULL, NULL, NULL}, 
    110111 
     112        {quick_checkbox, 33, REPLACE_DLG_WIDTH, 8, REPLACE_DLG_HEIGHT, N_("&Whole words"), 0, 0, 
     113         &twhole_words, 0, NULL, NULL, NULL}, 
     114 
    111115        {quick_checkbox, 33, REPLACE_DLG_WIDTH, 7, REPLACE_DLG_HEIGHT, N_("case &Sensitive"), 0, 0, 
    112116         &treplace_case, 0, NULL, NULL, NULL}, 
    113117 
     
    153157        edit->all_codepages = tall_codepages; 
    154158        edit->replace_backwards = treplace_backwards; 
    155159        edit->replace_case = treplace_case; 
     160        edit->whole_words = twhole_words; 
    156161        return; 
    157162    } else { 
    158163        *replace_text = NULL; 
     
    167172editcmd_dialog_search_show (WEdit * edit, char **search_text) 
    168173{ 
    169174    int tsearch_case = edit->replace_case; 
     175    int twhole_words = edit->whole_words; 
    170176    int tsearch_backwards = edit->replace_backwards; 
    171177    int tall_codepages = edit->all_codepages; 
    172178    mc_search_type_t ttype_of_search = edit->search_type; 
     
    175181 
    176182 
    177183    QuickWidget quick_widgets[] = { 
    178         {quick_button, 6, 10, 9, SEARCH_DLG_HEIGHT, N_("&Cancel"), 0, B_CANCEL, 0, 
     184        {quick_button, 6, 10, 10, SEARCH_DLG_HEIGHT, N_("&Cancel"), 0, B_CANCEL, 0, 
    179185         0, NULL, NULL, NULL}, 
    180         {quick_button, 2, 10, 9, SEARCH_DLG_HEIGHT, N_("&OK"), 0, B_ENTER, 0, 
     186        {quick_button, 2, 10, 10, SEARCH_DLG_HEIGHT, N_("&OK"), 0, B_ENTER, 0, 
    181187         0, NULL, NULL, NULL}, 
    182188 
    183189#ifdef HAVE_CHARSET 
    184         {quick_checkbox, 33, SEARCH_DLG_WIDTH, 7, SEARCH_DLG_HEIGHT, N_("All charsets"), 0, 0, 
     190        {quick_checkbox, 33, SEARCH_DLG_WIDTH, 8, SEARCH_DLG_HEIGHT, N_("All charsets"), 0, 0, 
    185191         &tall_codepages, 0, NULL, NULL, NULL}, 
    186192#endif 
    187193 
    188         {quick_checkbox, 33, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT, N_("&Backwards"), 0, 0, 
     194        {quick_checkbox, 33, SEARCH_DLG_WIDTH, 7, SEARCH_DLG_HEIGHT, N_("&Backwards"), 0, 0, 
    189195         &tsearch_backwards, 0, NULL, NULL, NULL}, 
     196        {quick_checkbox, 33, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT, N_("&Whole words"), 0, 0, 
     197         &twhole_words, 0, NULL, NULL, NULL}, 
    190198        {quick_checkbox, 33, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, N_("case &Sensitive"), 0, 0, 
    191199         &tsearch_case, 0, NULL, NULL, NULL}, 
    192200 
     
    213221        edit->replace_backwards = tsearch_backwards; 
    214222        edit->all_codepages = tall_codepages; 
    215223        edit->replace_case = tsearch_case; 
     224        edit->whole_words = twhole_words; 
    216225    } else { 
    217226        *search_text = NULL; 
    218227    } 
  • mc-4.7.0-pre1

    diff -Naur mc-4.7.0-pre1~/src/find.c mc-4.7.0-pre1/src/find.c
    old new  
    8989static WCheck *file_case_sens;          /* "case sensitive" checkbox */ 
    9090static WCheck *find_regex_cbox;         /* [x] find regular expression */ 
    9191static WCheck *content_case_sens;       /* "case sensitive" checkbox */ 
     92static WCheck *content_whole_words_cbox;/* "whole words" checkbox */ 
    9293 
    9394static int running = 0;                 /* nice flag */ 
    9495static char *find_pattern = NULL;       /* Pattern to search */ 
     
    148149static gboolean content_regexp_flag = FALSE; 
    149150static gboolean content_all_charsets_flag = FALSE; 
    150151static gboolean content_case_sensitive = TRUE; 
     152static gboolean content_whole_words = FALSE; 
    151153 
    152154static int find_recursively = 1; 
    153155 
     
    261263 
    262264    static const char *file_case_label = N_("Cas&e sensitive"); 
    263265    static const char *content_case_label = N_("Case sens&itive"); 
     266    static const char *content_whole_words_label = N_("&Whole words"); 
    264267    static const char *file_recurs_label = N_("&Find recursively"); 
    265268    static const char *file_skip_hidden_label = N_("S&kip hidden"); 
    266269    static const char *file_all_charsets_label = N_("&All charsets"); 
     
    327330                button_new (FIND_Y - 3, FIND_X/4 - b0/2, B_ENTER, DEFPUSH_BUTTON, buts[0], 0)); 
    328331 
    329332#ifdef HAVE_CHARSET 
    330     content_all_charsets_cbox = check_new (9, FIND_X / 2 + 1, 
     333    content_all_charsets_cbox = check_new (11, FIND_X / 2 + 1, 
    331334                content_all_charsets_flag, content_all_charsets_label); 
    332335    add_widget (find_dlg, content_all_charsets_cbox); 
    333336#endif 
    334337 
    335     find_regex_cbox = check_new (8, FIND_X / 2 + 1, content_regexp_flag, content_regexp_label); 
     338    find_regex_cbox = check_new (9, FIND_X / 2 + 1, content_regexp_flag, content_regexp_label); 
    336339    add_widget (find_dlg, find_regex_cbox); 
    337340 
     341    content_whole_words_cbox = check_new (8, FIND_X / 2 + 1, content_whole_words, content_whole_words_label); 
     342    add_widget (find_dlg, content_whole_words_cbox); 
     343 
    338344    content_case_sens = check_new (7, FIND_X / 2 + 1, content_case_sensitive, content_case_label); 
    339345    add_widget (find_dlg, content_case_sens); 
    340346 
     
    385391        content_all_charsets_flag = content_all_charsets_cbox->state & C_BOOL; 
    386392#endif 
    387393        content_case_sensitive = content_case_sens->state & C_BOOL; 
     394        content_whole_words = content_whole_words_cbox->state & C_BOOL; 
    388395        content_regexp_flag = find_regex_cbox->state & C_BOOL; 
    389396        file_pattern_flag = file_pattern_cbox->state & C_BOOL; 
    390397        file_case_sensitive = file_case_sens->state & C_BOOL; 
     
    418425        content_all_charsets_flag = content_all_charsets_cbox->state & C_BOOL; 
    419426#endif 
    420427        content_case_sensitive = content_case_sens->state & C_BOOL; 
     428        content_whole_words = content_whole_words_cbox->state & C_BOOL; 
    421429        content_regexp_flag = find_regex_cbox->state & C_BOOL; 
    422430        find_recursively = recursively_cbox->state & C_BOOL; 
    423431        file_pattern_flag = file_pattern_cbox->state & C_BOOL; 
     
    741749    { 
    742750        search_content_handle->search_type = (content_regexp_flag) ? MC_SEARCH_T_REGEX : MC_SEARCH_T_NORMAL; 
    743751        search_content_handle->is_case_sentitive = content_case_sensitive; 
     752        search_content_handle->whole_words = content_whole_words; 
    744753        search_content_handle->is_all_charsets = content_all_charsets_flag; 
    745754    } 
    746755    search_file_handle = mc_search_new(find_pattern, -1); 
  • mc-4.7.0-pre1

    diff -Naur mc-4.7.0-pre1~/src/view.c mc-4.7.0-pre1/src/view.c
    old new  
    261261    mc_search_type_t search_type; 
    262262    gboolean search_all_codepages; 
    263263    gboolean search_case; 
     264    gboolean whole_words; 
    264265    gboolean search_backwards; 
    265266 
    266267    int search_numNeedSkipChar; 
     
    31463147    if (view->search_backwards) { 
    31473148        search_end = view_get_filesize (view); 
    31483149        while ((int) search_start >= 0) { 
    3149             if (search_end - search_start > view->search->original_len && mc_search_is_fixed_search_str(view->search)) 
     3150            if (search_end > search_start + view->search->original_len && mc_search_is_fixed_search_str(view->search)) 
    31503151                search_end = search_start + view->search->original_len; 
    31513152 
    31523153            view_read_start (view, &view->search_onechar_info, search_start); 
     
    32683269    int ttype_of_search = (int) view->search_type; 
    32693270    int tall_codepages = (int) view->search_all_codepages; 
    32703271    int tsearch_case = (int) view->search_case; 
     3272    int twhole_words = (int) view->whole_words; 
    32713273    int tsearch_backwards = (int) view->search_backwards; 
    32723274 
    32733275    gchar **list_of_types = mc_search_get_types_strings_array(); 
     
    32823284         0, 0, NULL, NULL, NULL}, 
    32833285 
    32843286#ifdef HAVE_CHARSET 
    3285         {quick_checkbox, SEARCH_DLG_WIDTH/2 + 3, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT, N_("All charsets"), 0, 0, 
     3287        {quick_checkbox, SEARCH_DLG_WIDTH/2 + 3, SEARCH_DLG_WIDTH, 7, SEARCH_DLG_HEIGHT, N_("All charsets"), 0, 0, 
    32863288         &tall_codepages, 0, NULL, NULL, NULL}, 
    32873289#endif 
    32883290 
    3289         {quick_checkbox, SEARCH_DLG_WIDTH/2 + 3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, 
     3291        {quick_checkbox, SEARCH_DLG_WIDTH/2 + 3, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT, 
    32903292         N_("&Backwards"), 0, 0, &tsearch_backwards, 0, NULL, NULL, NULL}, 
    32913293 
     3294        {quick_checkbox, SEARCH_DLG_WIDTH/2 + 3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, N_("&Whole words"), 0, 0, 
     3295         &twhole_words, 0, NULL, NULL, NULL}, 
     3296 
    32923297        {quick_checkbox, SEARCH_DLG_WIDTH/2 + 3, SEARCH_DLG_WIDTH, 4, SEARCH_DLG_HEIGHT, N_("case &Sensitive"), 0, 0, 
    32933298         &tsearch_case, 0, NULL, NULL, NULL}, 
    32943299 
     
    33213326 
    33223327    view->search_all_codepages = (gboolean) tall_codepages; 
    33233328    view->search_case = (gboolean) tsearch_case; 
     3329    view->whole_words = (gboolean) twhole_words; 
    33243330 
    33253331    if (exp == NULL || exp[0] == '\0') 
    33263332        goto cleanup; 
     
    33493355    view->search->search_type = view->search_type; 
    33503356    view->search->is_all_charsets = view->search_all_codepages; 
    33513357    view->search->is_case_sentitive = view->search_case; 
     3358    view->search->whole_words = view->whole_words; 
    33523359    view->search->search_fn = view_search_cmd_callback; 
    33533360    view->search->update_fn = view_search_update_cmd_callback; 
    33543361