mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
add recursive search file TAGS
This commit is contained in:
parent
20c769b063
commit
351f42ac24
@ -46,6 +46,7 @@
|
||||
#include "editcmddef.h"
|
||||
#include "edit-widget.h"
|
||||
#include "etags.h"
|
||||
#include "../src/panel.h"
|
||||
|
||||
#include "../src/color.h" /* dialog_colors */
|
||||
#include "../src/tty.h" /* LINES */
|
||||
@ -3095,7 +3096,7 @@ edit_select_definition_dialog (WEdit * edit, int max_len, int word_len,
|
||||
edit_history_moveto[edit_stack_iterator].filename = g_strdup(edit->filename);
|
||||
edit_history_moveto[edit_stack_iterator].line = edit->start_line + edit->curs_row + 1;
|
||||
edit_stack_iterator++;
|
||||
mc_log("%s:%i iterator=%i\n", curr_def->filename, curr_def->line, edit_stack_iterator);
|
||||
// mc_log("%s:%i iterator=%i\n", curr_def->filename, curr_def->line, edit_stack_iterator);
|
||||
g_free( edit_history_moveto[edit_stack_iterator].filename );
|
||||
edit_history_moveto[edit_stack_iterator].filename = g_strdup(curr_def->filename);
|
||||
edit_history_moveto[edit_stack_iterator].line = curr_def->line;
|
||||
@ -3120,8 +3121,14 @@ edit_get_match_keyword_cmd (WEdit *edit)
|
||||
{
|
||||
int word_len = 0, num_def = 0, max_len;
|
||||
long word_start = 0;
|
||||
int len = 0;
|
||||
unsigned char *bufpos;
|
||||
char *match_expr;
|
||||
char *path = NULL;
|
||||
char *ptr = NULL;
|
||||
char *tagfile = NULL;
|
||||
FILE *f;
|
||||
|
||||
struct def_hash_type def_hash[MAX_DEFINITIONS];
|
||||
|
||||
for ( int i = 0; i < MAX_DEFINITIONS; i++) {
|
||||
@ -3138,9 +3145,29 @@ edit_get_match_keyword_cmd (WEdit *edit)
|
||||
[word_start & M_EDIT_BUF_SIZE];
|
||||
match_expr = g_strdup_printf ("%.*s", word_len, bufpos);
|
||||
|
||||
mc_log("%s \n", match_expr);
|
||||
path = g_strdup_printf ("%s/", current_panel->cwd);
|
||||
mc_log("%s\n", path);
|
||||
len = strlen(path);
|
||||
ptr = path + len;
|
||||
|
||||
set_def_hash("TAGS", match_expr, (struct def_hash_type *) &def_hash, &num_def);
|
||||
while ( ptr != path ) {
|
||||
if ( *ptr == '/' ) {
|
||||
path[len] = '\0';
|
||||
g_free (tagfile);
|
||||
tagfile = g_strdup_printf ("%s/TAGS", path);
|
||||
mc_log("%s\n",tagfile);
|
||||
f = fopen (tagfile, "r");
|
||||
if ( f ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
ptr--;
|
||||
len--;
|
||||
}
|
||||
|
||||
set_def_hash(tagfile, path, match_expr, (struct def_hash_type *) &def_hash, &num_def);
|
||||
g_free (path);
|
||||
g_free (tagfile);
|
||||
max_len = 50;
|
||||
word_len = 0;
|
||||
if ( num_def > 0 ) {
|
||||
|
15
edit/etags.c
15
edit/etags.c
@ -25,7 +25,7 @@ long get_pos_from(char *str)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_def_hash(char *tagfile, char *match_func, struct def_hash_type *def_hash, int *num)
|
||||
int set_def_hash(char *tagfile, char *start_path, char *match_func, struct def_hash_type *def_hash, int *num)
|
||||
{
|
||||
FILE *f;
|
||||
static char buf[4048];
|
||||
@ -35,12 +35,13 @@ int set_def_hash(char *tagfile, char *match_func, struct def_hash_type *def_hash
|
||||
int i;
|
||||
if (!f)
|
||||
return 1;
|
||||
|
||||
len = strlen( match_func );
|
||||
int pos;
|
||||
|
||||
char *fullpath = NULL;
|
||||
char *filename = NULL;
|
||||
long line;
|
||||
enum {start, in_filename, in_define} state=start;
|
||||
enum {start, in_filename, in_define} state = start;
|
||||
|
||||
while (fgets (buf, sizeof (buf), f)) {
|
||||
|
||||
@ -52,9 +53,7 @@ int set_def_hash(char *tagfile, char *match_func, struct def_hash_type *def_hash
|
||||
break;
|
||||
case in_filename:
|
||||
pos = strcspn(buf, ",");
|
||||
if ( filename ) {
|
||||
g_free(filename);
|
||||
}
|
||||
g_free(filename);
|
||||
filename = malloc(pos + 2);
|
||||
g_strlcpy ( filename, (char *)buf, pos + 1 );
|
||||
state = in_define;
|
||||
@ -73,7 +72,9 @@ int set_def_hash(char *tagfile, char *match_func, struct def_hash_type *def_hash
|
||||
state = start;
|
||||
if ( *num < MAX_DEFINITIONS ) {
|
||||
def_hash[*num].filename_len = strlen(filename);
|
||||
def_hash[*num].filename = g_strdup(filename);
|
||||
fullpath = g_strdup_printf("%s/%s",start_path, filename);
|
||||
def_hash[*num].filename = g_strdup(fullpath);
|
||||
g_free(fullpath);
|
||||
def_hash[*num].line = line;
|
||||
(*num)++;
|
||||
}
|
||||
|
@ -6,4 +6,4 @@ struct def_hash_type {
|
||||
long line;
|
||||
};
|
||||
long get_pos_from(char *str);
|
||||
int set_def_hash(char *tagfile, char *match_func, struct def_hash_type *def_hash, int *num);
|
||||
int set_def_hash(char *tagfile, char *start_path, char *match_func, struct def_hash_type *def_hash, int *num);
|
||||
|
Loading…
Reference in New Issue
Block a user