edit/editcmd.c
* changed searching algorithm of 'TAGS' file * changed #include "etags.h" to "../edit/etags.h" for building outside of sources tree edit/etags.c: * apply template from maint/template.c file * rename all functions with prefix etags_* * make function "etags_get_pos_from" in file-scope visibility edit/etags.h: * added logic block "#ifndef ... #define ... #endif" for correctly processing of header file * remove declaration of file-scope function etags_get_pos_from (ex. get_pos_from)
Этот коммит содержится в:
родитель
ffca67e3cb
Коммит
8abf76df7c
@ -45,7 +45,7 @@
|
|||||||
#include "editlock.h"
|
#include "editlock.h"
|
||||||
#include "editcmddef.h"
|
#include "editcmddef.h"
|
||||||
#include "edit-widget.h"
|
#include "edit-widget.h"
|
||||||
#include "etags.h"
|
#include "../edit/etags.h"
|
||||||
#include "../src/panel.h"
|
#include "../src/panel.h"
|
||||||
|
|
||||||
#include "../src/color.h" /* dialog_colors */
|
#include "../src/color.h" /* dialog_colors */
|
||||||
@ -3133,13 +3133,11 @@ edit_get_match_keyword_cmd (WEdit *edit)
|
|||||||
{
|
{
|
||||||
int word_len = 0, num_def = 0, max_len;
|
int word_len = 0, num_def = 0, max_len;
|
||||||
long word_start = 0;
|
long word_start = 0;
|
||||||
int len = 0;
|
|
||||||
unsigned char *bufpos;
|
unsigned char *bufpos;
|
||||||
char *match_expr;
|
char *match_expr;
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
char *ptr = NULL;
|
char *ptr = NULL;
|
||||||
char *tagfile = NULL;
|
char *tagfile = NULL;
|
||||||
FILE *f;
|
|
||||||
|
|
||||||
struct def_hash_type def_hash[MAX_DEFINITIONS];
|
struct def_hash_type def_hash[MAX_DEFINITIONS];
|
||||||
|
|
||||||
@ -3157,25 +3155,25 @@ edit_get_match_keyword_cmd (WEdit *edit)
|
|||||||
match_expr = g_strdup_printf ("%.*s", word_len, bufpos);
|
match_expr = g_strdup_printf ("%.*s", word_len, bufpos);
|
||||||
|
|
||||||
path = g_strdup_printf ("%s/", g_get_current_dir());
|
path = g_strdup_printf ("%s/", g_get_current_dir());
|
||||||
len = strlen (path);
|
|
||||||
ptr = path + len;
|
|
||||||
|
|
||||||
while ( ptr != path ) {
|
ptr = path;
|
||||||
if ( *ptr == '/' ) {
|
|
||||||
path[len] = '\0';
|
/* Reursive search file 'TAGS' in parent dirs */
|
||||||
g_free (tagfile);
|
do {
|
||||||
tagfile = g_strdup_printf ("%s/TAGS", path);
|
ptr = g_path_get_dirname (path);
|
||||||
f = fopen (tagfile, "r");
|
g_free(path); path = ptr;
|
||||||
if ( f )
|
|
||||||
break;
|
tagfile = g_build_filename (path, "TAGS", NULL);
|
||||||
}
|
if ( exist_file (tagfile) )
|
||||||
ptr--;
|
break;
|
||||||
len--;
|
} while (strcmp( path, G_DIR_SEPARATOR_S) != 0);
|
||||||
|
|
||||||
|
if (tagfile){
|
||||||
|
etags_set_def_hash(tagfile, path, match_expr, (struct def_hash_type *) &def_hash, &num_def);
|
||||||
|
g_free (tagfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_def_hash(tagfile, path, match_expr, (struct def_hash_type *) &def_hash, &num_def);
|
|
||||||
g_free (path);
|
g_free (path);
|
||||||
g_free (tagfile);
|
|
||||||
max_len = 50;
|
max_len = 50;
|
||||||
word_len = 0;
|
word_len = 0;
|
||||||
if ( num_def > 0 ) {
|
if ( num_def > 0 ) {
|
||||||
|
58
edit/etags.c
58
edit/etags.c
@ -1,13 +1,58 @@
|
|||||||
/*find . -type f -name "*.[ch]" | etags -l c --declarations - */
|
/* editor C-code navigation via tags.
|
||||||
|
make TAGS file via command:
|
||||||
|
$ find . -type f -name "*.[ch]" | etags -l c --declarations -
|
||||||
|
|
||||||
|
or, if etags utility not installed:
|
||||||
|
$ ctags --languages=c -e -R -h '[ch]'
|
||||||
|
|
||||||
|
Copyright (C) 2009 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Authors:
|
||||||
|
Ilia Maslakov <il.smind@gmail.com>, 2009
|
||||||
|
Slava Zanko <slavazanko@gmail.com>, 2009
|
||||||
|
|
||||||
|
|
||||||
|
This file is part of the Midnight Commander.
|
||||||
|
|
||||||
|
The Midnight Commander is free software; you can redistribute it
|
||||||
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The Midnight Commander is distributed in the hope that it will be
|
||||||
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||||
|
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "etags.h"
|
|
||||||
|
|
||||||
long get_pos_from(char *str)
|
#include "../src/global.h"
|
||||||
|
#include "../edit/etags.h"
|
||||||
|
|
||||||
|
/*** global variables **************************************************/
|
||||||
|
|
||||||
|
/*** file scope macro definitions **************************************/
|
||||||
|
|
||||||
|
/*** file scope type declarations **************************************/
|
||||||
|
|
||||||
|
/*** file scope variables **********************************************/
|
||||||
|
|
||||||
|
/*** file scope functions **********************************************/
|
||||||
|
|
||||||
|
static long etags_get_pos_from(char *str)
|
||||||
{
|
{
|
||||||
static char buf[16];
|
static char buf[16];
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -25,7 +70,10 @@ long get_pos_from(char *str)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_def_hash(char *tagfile, char *start_path, char *match_func, struct def_hash_type *def_hash, int *num)
|
/*** public functions **************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
int etags_set_def_hash(char *tagfile, char *start_path, char *match_func, struct def_hash_type *def_hash, int *num)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
static char buf[4048];
|
static char buf[4048];
|
||||||
@ -68,7 +116,7 @@ int set_def_hash(char *tagfile, char *start_path, char *match_func, struct def_h
|
|||||||
int l = (int)strlen( buf );
|
int l = (int)strlen( buf );
|
||||||
for ( i = 0; i < l; i++) {
|
for ( i = 0; i < l; i++) {
|
||||||
if ( ( buf[i] == 0x7F || buf[i] == 0x01 ) && isdigit(buf[i+1]) ) {
|
if ( ( buf[i] == 0x7F || buf[i] == 0x01 ) && isdigit(buf[i+1]) ) {
|
||||||
line = get_pos_from(&buf[i+1]);
|
line = etags_get_pos_from(&buf[i+1]);
|
||||||
state = start;
|
state = start;
|
||||||
if ( *num < MAX_DEFINITIONS ) {
|
if ( *num < MAX_DEFINITIONS ) {
|
||||||
def_hash[*num].filename_len = strlen(filename);
|
def_hash[*num].filename_len = strlen(filename);
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
#ifndef MC_EDIT_ETAGS_H
|
||||||
|
#define MC_EDIT_ETAGS_H 1
|
||||||
|
|
||||||
#define MAX_DEFINITIONS 50
|
#define MAX_DEFINITIONS 50
|
||||||
|
|
||||||
struct def_hash_type {
|
struct def_hash_type {
|
||||||
@ -5,5 +8,7 @@ struct def_hash_type {
|
|||||||
unsigned char *filename;
|
unsigned char *filename;
|
||||||
long line;
|
long line;
|
||||||
};
|
};
|
||||||
long get_pos_from(char *str);
|
|
||||||
int set_def_hash(char *tagfile, char *start_path, char *match_func, struct def_hash_type *def_hash, int *num);
|
int etags_set_def_hash(char *tagfile, char *start_path, char *match_func, struct def_hash_type *def_hash, int *num);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user