* ext.c (exec_extension): Eliminate unused argument.
(regex_command): Remove support for user actions. Return int. Adjust all dependencies.
Этот коммит содержится в:
родитель
369316e6f0
Коммит
c46d1f590b
@ -1,5 +1,9 @@
|
||||
2002-08-09 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* ext.c (exec_extension): Eliminate unused argument.
|
||||
(regex_command): Remove support for user actions. Return int.
|
||||
Adjust all dependencies.
|
||||
|
||||
* ext.c (exec_extension): Make static. Remove support for Drop,
|
||||
Title and Icon actions. Adjust all dependencies.
|
||||
|
||||
|
47
src/ext.c
47
src/ext.c
@ -64,7 +64,7 @@ flush_extension_file (void)
|
||||
typedef char *(*quote_func_t)(const char *name, int i);
|
||||
|
||||
static void
|
||||
exec_extension (const char *filename, const char *data, int *move_dir, int start_line, int needs_term)
|
||||
exec_extension (const char *filename, const char *data, int *move_dir, int start_line)
|
||||
{
|
||||
char *file_name;
|
||||
int cmd_file_fd;
|
||||
@ -276,28 +276,24 @@ exec_extension (const char *filename, const char *data, int *move_dir, int start
|
||||
# define FILE_CMD "file "
|
||||
#endif
|
||||
|
||||
/* The second argument is action, i.e. Open, View, Edit, or NULL if
|
||||
* we want regex_command to return a list of all user defined actions.
|
||||
/* The second argument is action, i.e. Open, View or Edit
|
||||
*
|
||||
* This function returns:
|
||||
*
|
||||
* If action != NULL, then it returns "Success" (not allocated) if it ran
|
||||
* some command or NULL if not.
|
||||
*
|
||||
* If action == NULL, it returns NULL if there are no user defined commands
|
||||
* or an allocated space separated list of user defined Actions.
|
||||
* 1 if it ran some command or 0 otherwise.
|
||||
*
|
||||
* If action == "View" then a parameter is checked in the form of "View:%d",
|
||||
* if the value for %d exists, then the viewer is started up at that line number.
|
||||
*/
|
||||
char *regex_command (char *filename, char *action, int *move_dir)
|
||||
int
|
||||
regex_command (char *filename, char *action, int *move_dir)
|
||||
{
|
||||
char *p, *q, *r, c;
|
||||
int file_len = strlen (filename);
|
||||
int found = 0;
|
||||
char content_string [2048];
|
||||
int content_shift = 0;
|
||||
char *to_return = NULL;
|
||||
int ret = 0;
|
||||
int old_patterns;
|
||||
struct stat mystat;
|
||||
int asked_file;
|
||||
@ -312,7 +308,7 @@ char *regex_command (char *filename, char *action, int *move_dir)
|
||||
#endif
|
||||
|
||||
/* Check for the special View:%d parameter */
|
||||
if (action && strncmp (action, "View:", 5) == 0){
|
||||
if (strncmp (action, "View:", 5) == 0){
|
||||
view_at_line_number = atoi (action + 5);
|
||||
action [4] = 0;
|
||||
} else {
|
||||
@ -398,10 +394,6 @@ file as an example of how to write it.\n\
|
||||
if (p == q) { /* i.e. starts in the first column, should be
|
||||
* keyword/descNL
|
||||
*/
|
||||
if (found && action == NULL) /* We have already accumulated all
|
||||
* the user actions
|
||||
*/
|
||||
break;
|
||||
found = 0;
|
||||
q = strchr (p, '\n');
|
||||
if (q == NULL)
|
||||
@ -554,24 +546,7 @@ match_file_output:
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
if (action == NULL) {
|
||||
if (strcmp (p, "Open") &&
|
||||
strcmp (p, "View") &&
|
||||
strcmp (p, "Edit") &&
|
||||
strcmp (p, "Include")) {
|
||||
/* I.e. this is a name of a user defined action */
|
||||
static char *q;
|
||||
|
||||
if (to_return == NULL) {
|
||||
to_return = g_malloc (512);
|
||||
q = to_return;
|
||||
} else
|
||||
*(q++) = '='; /* Mark separator */
|
||||
strcpy (q, p);
|
||||
q = strchr (q, 0);
|
||||
}
|
||||
*r = c;
|
||||
} else if (!strcmp (action, p)) {
|
||||
if (!strcmp (action, p)) {
|
||||
*r = c;
|
||||
for (p = r + 1; *p == ' ' || *p == '\t'; p++)
|
||||
;
|
||||
@ -587,10 +562,10 @@ match_file_output:
|
||||
if (p < q) {
|
||||
char *filename_copy = g_strdup (filename);
|
||||
|
||||
exec_extension (filename_copy, r + 1, move_dir, view_at_line_number, 0);
|
||||
exec_extension (filename_copy, r + 1, move_dir, view_at_line_number);
|
||||
g_free (filename_copy);
|
||||
|
||||
to_return = "Success";
|
||||
ret = 1;
|
||||
}
|
||||
break;
|
||||
} else
|
||||
@ -603,5 +578,5 @@ match_file_output:
|
||||
}
|
||||
}
|
||||
easy_patterns = old_patterns;
|
||||
return to_return;
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef __EXT_H
|
||||
#define __EXT_H
|
||||
|
||||
char *regex_command (char *filename, char *action, int *move_dir);
|
||||
int regex_command (char *filename, char *action, int *move_dir);
|
||||
|
||||
/* Call it after the user has edited the mc.ext file,
|
||||
* to flush the cached mc.ext file
|
||||
|
@ -1933,7 +1933,6 @@ static int
|
||||
do_enter_on_file_entry (file_entry *fe)
|
||||
{
|
||||
char *full_name;
|
||||
char *p;
|
||||
|
||||
/* Directory or link to directory - change directory */
|
||||
if (S_ISDIR (fe->buf.st_mode) || link_isdir (fe)) {
|
||||
@ -1942,8 +1941,7 @@ do_enter_on_file_entry (file_entry *fe)
|
||||
}
|
||||
|
||||
/* Try associated command */
|
||||
p = regex_command (fe->fname, "Open", 0);
|
||||
if (p && (strcmp (p, "Success") == 0))
|
||||
if (regex_command (fe->fname, "Open", 0))
|
||||
return 1;
|
||||
|
||||
/* Check if the file is executable */
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user