Merge branch '3051_cleanup'

* 3051_cleanup: (36 commits)
  Ticket #3092: fix some minor manual formatting errors.
  Ticket #3091: iso9660: fix truncated filenames.
  Ticket #3089: (load_panelize): drop deprecated "find -perm +xxx" syntax.
  Clarify usage of SA_RESTART.
  (check_file_access): return FALSE if Esc was pressed.
  NEWS: Fix wording, "ignorance" is inappropriate here.
  mc.1.in: Fix typo with clipboard_paste command.
  Remove input_set_origin(). Use widget_set_size() instead.
  (input_destroy): don't call input_free_completions() twice.
  More tests for canonicalize_pathname().
  Remove redundant checks for g_strdup().
  Use vfs_translate_path() to avoid extra string duplication.
  (vfs_translate_path): return const char *.
  src/vfs/extfs/helpers/urar.in: add comment.
  (extfs_get_path_int): fix memory leak.
  Directory size: rename variables for consistency.
  (do_compute_dir_count): display directory name only.
  Typo.
  (edit_ok_to_exit): get rid of file name string duplication.
  (widget_init): init pos_flags member to WPOS_KEEP_DEFAULT.
  ...
This commit is contained in:
Andrew Borodin 2013-10-04 09:16:07 +04:00
commit f02dff7462
41 changed files with 290 additions and 259 deletions

View File

@ -699,7 +699,7 @@ Version 4.7.5-pre1
* Incorrect key event handling in "Listing mode" dialog (#2045)
* Usability of field history in "Find file" dialog (#2046, #2407)
* Find "Whole words" search bug (#2396)
* Directory ignorance doesn't work in file find (#2366, #2434)
* List of ignored directories doesn't work in file find (#2366, #2434)
* Incorrect line jump when started as editor (#2344)
* User menu in standalone mcedit doesn't show filetype-specific items (#1651)
* Configure script doesn't set samba configdir (#2419)

View File

@ -2949,8 +2949,7 @@ por segunda vez; con la primera Midnight Commander solo emite un pitido.
.PP
Aplica escapes a los símbolos
.BR ? ", " * " y " &
(como
.BR \\? ", " \\* ", " \\& )
(como \fB\\?\fR, \fB\\*\fR, \fB\\&\fR )
en los nombres de archivo para evitar su interpretación en expresiones
regulares al realizar sustituciones en la línea de entrada.
.\"NODE "Virtual File System"
@ -3937,7 +3936,7 @@ para volcar la selección de X Window a la salida estándar.
Por ejemplo:
.PP
.nf
clipboard_pastee=xclip \-o
clipboard_paste=xclip \-o
.fi
.TP
.I autodetect_codeset
@ -4125,7 +4124,7 @@ carencia de garantía.
.\"NODE "AVAILABILITY"
.SH "DISPONIBILIDAD"
La última versión de este programa se puede encontrar en
http://www.midnight-commander.org/downloads.
http://ftp.midnight\-commander.org/.
.\"NODE "SEE ALSO"
.SH "VÉASE TAMBIÉN"
mcedit(1), sh(1), bash(1), tcsh(1), zsh(1), ed(1), view(1),

View File

@ -3242,7 +3242,7 @@ per i dettagli sulla licenza e sulla mancanza di garanzie.
.\"NODE "AVAILABILITY"
.SH "REPERIBILITA'"
L'ultima versione di questo programma si trova su
ftp://ftp.gnu.org/gnu/mc/.
http://ftp.midnight\-commander.org/.
.\"NODE "SEE ALSO"
.SH "VEDERE ANCHE"
ed(1), gpm(1), terminfo(1), view(1), sh(1), bash(1),

View File

@ -1823,12 +1823,12 @@ is always grown form left to right. If disabled, the growing direction
of progressbar follows to direction of Copy/Move/Delete operation:
from left panel to right one and vice versa. Enabled by default.
.PP
.I Mkdir autoname
.I Mkdir autoname.
When you press F7 to create a new directory, the input line in popup dialog
will be filled by name of current file or directory in active panel.
Disabled by default.
.PP
.I Preallocate space
.I Preallocate space.
Preallocate space for whole target file, if possible, before copy operation.
Disabled by default.
.PP
@ -1858,17 +1858,17 @@ After executing your commands, the Midnight Commander can pause, so
that you can examine the output of the command. There are three
possible settings for this variable:
.PP
.IR Never .
.I Never.
Means that you do not want to see the output of your command. If you
are using the Linux or FreeBSD console or an xterm, you will be able to
see the output of the command by typing C\-o.
.PP
.IR On dumb terminals .
.I On dumb terminals.
You will get the pause message on terminals that are not capable of
showing the output of the last command executed (any terminal that is
not an xterm or the Linux console).
.PP
.IR Always .
.I Always.
The program will pause after executing all of your commands.
.PP
.B Other options
@ -1897,7 +1897,7 @@ command is used. See the section on the
internal file viewer\&.
.\"Internal File Viewer"
.PP
.I Ask new file name
.I Ask new file name.
If this option is enabled, file name is asked before open new file in editor.
.PP
.I Auto menus.
@ -3111,8 +3111,7 @@ for the second time, for the first time MC just beeps.
.PP
Apply escaping of
.BR ? ", " * " and " &
symbols (as
.BR \\? ", " \\* ", " \\& )
symbols (as \fB\\?\fR, \fB\\*\fR, \fB\\&\fR )
in filenames to disallow use them as metasymbols in regular expressions
when substitution is performed in the input line.
@ -4103,7 +4102,7 @@ utility like 'xclip' to print the selection to standard out.
For example:
.PP
.nf
clipboard_pastee=xclip \-o
clipboard_paste=xclip \-o
.fi
.TP
.I autodetect_codeset
@ -4278,7 +4277,7 @@ help for details on the License and the lack of warranty.
.\"NODE "AVAILABILITY"
.SH "AVAILABILITY"
The latest version of this program can be found at
ftp://ftp.gnu.org/gnu/mc/.
http://ftp.midnight\-commander.org/.
.\"NODE "SEE ALSO"
.SH "SEE ALSO"
ed(1), gpm(1), terminfo(1), view(1), sh(1), bash(1),
@ -4297,8 +4296,8 @@ distribution.
See the file TODO in the distribution for information on what remains to
be done.
.PP
If you want to report a problem with the program, please send mail to
this address: mc\-devel@gnome.org.
If you want to report a problem with the program, please create bugreport
at http://www.midnight\-commander.org/.
.PP
Provide a detailed description of the bug, the version of the program
you are running

View File

@ -670,11 +670,11 @@ help of the Midnight Commander for details on the License and the lack
of warranty.
.SH AVAILABILITY
The latest version of this program can be found at
http://midnight\-commander.org/.
http://ftp.midnight\-commander.org/.
.SH SEE ALSO
cooledit(1), mc(1), gpm(1), terminfo(1), scanf(3).
.SH AUTHORS
Paul Sheer (psheer@obsidian.co.za) is the original author of
the Midnight Commander's internal editor.
.SH BUGS
Bugs should be reported to mc\-devel@gnome.org
Bugs should be reported to http://www.midnight\-commander.org/.

View File

@ -87,9 +87,9 @@ help of the Midnight Commander for details on the License and the lack
of warranty.
.SH AVAILABILITY
The latest version of this program can be found at
ftp://ftp.gnu.org/gnu/mc/.
http://ftp.midnight\-commander.org/.
.SH SEE ALSO
mc(1), mcedit(1)
.PP
.SH BUGS
Bugs should be reported to mc\-devel@gnome.org
Bugs should be reported to http://www.midnight\-commander.org/.

View File

@ -1977,17 +1977,17 @@ mc на экране.
паузу, чтобы вы могли просмотреть и изучить вывод команды. Есть три
варианта установки этой опции:
.PP
.IR Никогда.
.I Никогда.
Это значит, что вы не хотите видеть вывод команды. На консоли Linux или
FreeBSD или при использовании xterm вы можете просмотреть этот вывод,
нажав C\-o.
.PP
.IR "На "тупых" терминалах" .
.I "На "тупых" терминалах" .
Пауза будет создаваться на терминалах, которые не способны обеспечить
показ вывода последней из выполнявшихся команд (это любые терминалы,
отличные от xterm или Linux\-консоли).
.PP
.IR Всегда .
.I Всегда.
Программа обеспечит паузу после выполнения любой команды.
.PP
.B Прочие настройки
@ -3404,8 +3404,7 @@ Midnight Commander поддерживает возможность одновр
.PP
Используйте экранирование символов
.BR ? ", " * " и " &
(как
.BR \\? ", " \\* ", " \\& )
(как \fB\\?\fR, \fB\\*\fR, \fB\\&\fR )
в именах файлов, чтобы они не рассматривались как метасимволы в регулярных
выражениях при подстановках в полях ввода.
@ -4683,7 +4682,7 @@ Commander; используется только в тех случаях, ко
.\"NODE "AVAILABILITY"
.SH "Обновление версий"
Последние версии программы Midnight Commander можно найти на сайте
ftp://ftp.gnu.org/gnu/mc/.
http://ftp.midnight\-commander.org/.
.\"NODE "SEE ALSO"
.SH "Другие источники"
ed(1), gpm(1), terminfo(1), view(1), sh(1), bash(1), tcsh(1),
@ -4743,12 +4742,12 @@ and Wim Osterholt (wim@djo.wtm.tudelft.nl).
который можно найти в составе поставляемого пакета.
.PP
Если вы обнаружили в программе какие\-то недостатки или недоработки,
пришлите, пожалуйста, ваши замечания по e\-mail на адрес:
.IR mc\-devel@gnome.org .
оформите, пожалуйста, ваши замечания по адресу
.IR http://www.midnight\-commander.org/ .
.PP
Дайте в письме подробное описание обнаруженных недостатков (и/или ваших
Дайте подробное описание обнаруженных недостатков (и/или ваших
предложений по усовершенствованию программы), сообщите версию программы
с которой вы работаете (для получения номера версии используйте команду
mc \-V), в какой операционной системе вы запускали программу. В случае
фатальной ошибки программы, мы будем очень благодарны, если вы пришлете
фатальной ошибки программы мы будем очень благодарны, если вы пришлете
след вызовов.

View File

@ -3248,7 +3248,7 @@ insert=\\e[Op
.\"NODE "AVAILABILITY"
.SH "ДОСТУПНОСТ"
Најновија верзија овог програма се може наћи на адреси
ftp://ftp.gnu.org/gnu/mc/.
http://ftp.midnight\-commander.org/.
.\"NODE "SEE ALSO"
.SH "ВИДИТЕ И"
ed(1), gpm(1), terminfo(1), view(1), sh(1), bash(1),

View File

@ -47,8 +47,6 @@ gchar *mc_search__recode_str (const char *, gsize, const char *, const char *, g
gchar *mc_search__get_one_symbol (const char *, const char *, gsize, gboolean *);
mc_search_cbret_t mc_search__get_char (mc_search_t *, const void *, gsize, int *);
GString *mc_search__tolower_case_str (const char *, const char *, gsize);
GString *mc_search__toupper_case_str (const char *, const char *, gsize);

View File

@ -2,11 +2,12 @@
Search text engine.
Common share code for module.
Copyright (C) 2009, 2011
Copyright (C) 2009, 2011, 2013
The Free Software Foundation, Inc.
Written by:
Slava Zanko <slavazanko@gmail.com>, 2009.
Slava Zanko <slavazanko@gmail.com>, 2009, 2011
Andrew Borodin <aborodin@vmail.ru>, 2013
This file is part of the Midnight Commander.
@ -140,22 +141,6 @@ mc_search__get_one_symbol (const char *charset, const char *str, gsize str_len,
/* --------------------------------------------------------------------------------------------- */
mc_search_cbret_t
mc_search__get_char (mc_search_t * lc_mc_search, const void *user_data, gsize current_pos,
int *current_char)
{
unsigned char *data;
if (lc_mc_search->search_fn != NULL)
return lc_mc_search->search_fn (user_data, current_pos, current_char);
data = (unsigned char *) user_data;
*current_char = (int) data[current_pos];
return (*current_char == 0) ? MC_SEARCH_CB_ABORT : MC_SEARCH_CB_OK;
}
/* --------------------------------------------------------------------------------------------- */
GString *
mc_search__tolower_case_str (const char *charset, const char *str, gsize str_len)
{

View File

@ -2,12 +2,13 @@
Search text engine.
Regex search
Copyright (C) 2009, 2011
Copyright (C) 2009, 2011, 2013
The Free Software Foundation, Inc.
Written by:
Slava Zanko <slavazanko@gmail.com>, 2009, 2010, 2011
Vitaliy Filippov <vitalif@yourcmc.ru>, 2011
Andrew Borodin <aborodin@vmail.ru>, 2013
This file is part of the Midnight Commander.
@ -118,12 +119,12 @@ mc_search__regex_str_append_if_special (GString * copy_to, const GString * regex
}
/* --------------------------------------------------------------------------------------------- */
static void
mc_search__cond_struct_new_regex_hex_add (const char *charset, GString * str_to,
const char *one_char, gsize str_len)
{
GString *upp, *low;
gchar *tmp_str;
gsize loop;
upp = mc_search__toupper_case_str (charset, one_char, str_len);
@ -131,23 +132,20 @@ mc_search__cond_struct_new_regex_hex_add (const char *charset, GString * str_to,
for (loop = 0; loop < upp->len; loop++)
{
gchar tmp_str[10 + 1]; /* longest content is "[\\x%02X\\x%02X]" */
gint tmp_len;
if (loop < low->len)
{
if (upp->str[loop] == low->str[loop])
tmp_str = g_strdup_printf ("\\x%02X", (unsigned char) upp->str[loop]);
if (loop >= low->len || upp->str[loop] == low->str[loop])
tmp_len =
g_snprintf (tmp_str, sizeof (tmp_str), "\\x%02X", (unsigned char) upp->str[loop]);
else
tmp_str =
g_strdup_printf ("[\\x%02X\\x%02X]", (unsigned char) upp->str[loop],
(unsigned char) low->str[loop]);
}
else
{
tmp_str = g_strdup_printf ("\\x%02X", (unsigned char) upp->str[loop]);
}
g_string_append (str_to, tmp_str);
g_free (tmp_str);
tmp_len =
g_snprintf (tmp_str, sizeof (tmp_str), "[\\x%02X\\x%02X]",
(unsigned char) upp->str[loop], (unsigned char) low->str[loop]);
g_string_append_len (str_to, tmp_str, tmp_len);
}
g_string_free (upp, TRUE);
g_string_free (low, TRUE);
}
@ -190,7 +188,7 @@ mc_search__cond_struct_new_regex_accum_append (const char *charset, GString * st
g_free (one_char);
}
g_string_append (str_to, recoded_part->str);
g_string_append_len (str_to, recoded_part->str, recoded_part->len);
g_string_free (recoded_part, TRUE);
g_string_set_size (str_from, 0);
}
@ -548,61 +546,59 @@ static void
mc_search_regex__process_append_str (GString * dest_str, const char *from, gsize len,
replace_transform_type_t * replace_flags)
{
gsize loop = 0;
gsize loop;
gsize char_len;
char *tmp_str;
GString *tmp_string;
if (len == (gsize) (-1))
len = strlen (from);
if (*replace_flags == REPLACE_T_NO_TRANSFORM)
if ((*replace_flags == REPLACE_T_NO_TRANSFORM) != 0)
{
g_string_append_len (dest_str, from, len);
return;
}
while (loop < len)
for (loop = 0; loop < len; loop += char_len)
{
GString *tmp_string = NULL;
char *tmp_str;
tmp_str = mc_search__get_one_symbol (NULL, from + loop, len - loop, NULL);
char_len = strlen (tmp_str);
if (*replace_flags & REPLACE_T_UPP_TRANSFORM_CHAR)
if ((*replace_flags & REPLACE_T_UPP_TRANSFORM_CHAR) != 0)
{
*replace_flags &= ~REPLACE_T_UPP_TRANSFORM_CHAR;
tmp_string = mc_search__toupper_case_str (NULL, tmp_str, char_len);
g_string_append (dest_str, tmp_string->str);
g_string_append_len (dest_str, tmp_string->str, tmp_string->len);
g_string_free (tmp_string, TRUE);
}
else if (*replace_flags & REPLACE_T_LOW_TRANSFORM_CHAR)
else if ((*replace_flags & REPLACE_T_LOW_TRANSFORM_CHAR) != 0)
{
*replace_flags &= ~REPLACE_T_LOW_TRANSFORM_CHAR;
tmp_string = mc_search__toupper_case_str (NULL, tmp_str, char_len);
g_string_append (dest_str, tmp_string->str);
tmp_string = mc_search__tolower_case_str (NULL, tmp_str, char_len);
g_string_append_len (dest_str, tmp_string->str, tmp_string->len);
g_string_free (tmp_string, TRUE);
}
else if (*replace_flags & REPLACE_T_UPP_TRANSFORM)
else if ((*replace_flags & REPLACE_T_UPP_TRANSFORM) != 0)
{
tmp_string = mc_search__toupper_case_str (NULL, tmp_str, char_len);
g_string_append (dest_str, tmp_string->str);
g_string_append_len (dest_str, tmp_string->str, tmp_string->len);
g_string_free (tmp_string, TRUE);
}
else if (*replace_flags & REPLACE_T_LOW_TRANSFORM)
else if ((*replace_flags & REPLACE_T_LOW_TRANSFORM) != 0)
{
tmp_string = mc_search__tolower_case_str (NULL, tmp_str, char_len);
g_string_append (dest_str, tmp_string->str);
g_string_append_len (dest_str, tmp_string->str, tmp_string->len);
g_string_free (tmp_string, TRUE);
}
else
{
g_string_append (dest_str, tmp_str);
}
g_free (tmp_str);
loop += char_len;
g_string_append_len (dest_str, tmp_str, tmp_string->len);
}
g_free (tmp_str);
}
}
/* --------------------------------------------------------------------------------------------- */
@ -806,11 +802,17 @@ mc_search__run_regex (mc_search_t * lc_mc_search, const void *user_data,
g_string_set_size (lc_mc_search->regex_buffer, 0);
lc_mc_search->start_buffer = current_pos;
while (TRUE)
if (lc_mc_search->search_fn != NULL)
{
int current_chr = '\n'; /* stop search symbol */
int current_chr;
do
{
/* stop search symbol */
current_chr = '\n';
ret = lc_mc_search->search_fn (user_data, current_pos, &current_chr);
ret = mc_search__get_char (lc_mc_search, user_data, current_pos, &current_chr);
if (ret == MC_SEARCH_CB_ABORT)
break;
@ -825,9 +827,31 @@ mc_search__run_regex (mc_search_t * lc_mc_search, const void *user_data,
virtual_pos++;
g_string_append_c (lc_mc_search->regex_buffer, (char) current_chr);
}
while ((char) current_chr != '\n' && virtual_pos <= end_search);
}
else
{
char current_chr;
if ((char) current_chr == '\n' || virtual_pos > end_search)
/* optimization for standard case (for search from file manager)
* where there is no MC_SEARCH_CB_INVALID or MC_SEARCH_CB_SKIP
* return codes, so we can copy line at regex buffer all at once
*/
do
{
current_chr = ((char *) user_data)[current_pos];
if (current_chr == '\0')
break;
current_pos++;
}
while (current_chr != '\n' && current_pos <= end_search);
/* use virtual_pos as index of start of current chunk */
g_string_append_len (lc_mc_search->regex_buffer, (char *) user_data + virtual_pos,
current_pos - virtual_pos);
virtual_pos = current_pos;
}
switch (mc_search__regex_found_cond (lc_mc_search, lc_mc_search->regex_buffer))

View File

@ -116,15 +116,7 @@ mc_search__cond_struct_free (mc_search_cond_t * mc_search_cond)
static void
mc_search__conditions_free (GPtrArray * array)
{
gsize loop1;
for (loop1 = 0; loop1 < array->len; loop1++)
{
mc_search_cond_t *lc_mc_search;
lc_mc_search = (mc_search_cond_t *) g_ptr_array_index (array, loop1);
mc_search__cond_struct_free (lc_mc_search);
}
g_ptr_array_foreach (array, (GFunc) mc_search__cond_struct_free, NULL);
g_ptr_array_free (array, TRUE);
}

View File

@ -148,11 +148,11 @@ mc_skin_colors_old_configure_one (mc_skin_t * mc_skin, const char *the_color_str
if (the_color_string == NULL)
return;
orig_colors = colors = g_strsplit (the_color_string, ":", -1);
if (colors == NULL)
orig_colors = g_strsplit (the_color_string, ":", -1);
if (orig_colors == NULL)
return;
for (; *colors != NULL; colors++)
for (colors = orig_colors; *colors != NULL; colors++)
{
gchar **key_val;
const gchar *skin_group, *skin_key;

View File

@ -236,9 +236,9 @@ tty_color_set_defaults (const char *fgcolor, const char *bgcolor, const char *at
g_free (tty_color_defaults__bg);
g_free (tty_color_defaults__attrs);
tty_color_defaults__fg = (fgcolor != NULL) ? g_strdup (fgcolor) : NULL;
tty_color_defaults__bg = (bgcolor != NULL) ? g_strdup (bgcolor) : NULL;
tty_color_defaults__attrs = (attrs != NULL) ? g_strdup (attrs) : NULL;
tty_color_defaults__fg = g_strdup (fgcolor);
tty_color_defaults__bg = g_strdup (bgcolor);
tty_color_defaults__attrs = g_strdup (attrs);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -1471,10 +1471,10 @@ lookup_key (const char *name, char **label)
return 0;
name = g_strstrip (g_strdup (name));
p = lc_keys = g_strsplit_set (name, "-+ ", -1);
lc_keys = g_strsplit_set (name, "-+ ", -1);
g_free ((char *) name);
while ((p != NULL) && (*p != NULL))
for (p = lc_keys; p != NULL && *p != NULL; p++)
{
if ((*p)[0] != '\0')
{
@ -1495,8 +1495,6 @@ lookup_key (const char *name, char **label)
break;
}
}
p++;
}
g_strfreev (lc_keys);
@ -1505,7 +1503,6 @@ lookup_key (const char *name, char **label)
if (k <= 0)
return 0;
if (label != NULL)
{
GString *s;

View File

@ -92,11 +92,13 @@ tty_setup_sigwinch (void (*handler) (int))
{
#if (NCURSES_VERSION_MAJOR >= 4) && defined (SIGWINCH)
struct sigaction act, oact;
act.sa_handler = handler;
sigemptyset (&act.sa_mask);
act.sa_flags = 0;
#ifdef SA_RESTART
act.sa_flags |= SA_RESTART;
act.sa_flags = SA_RESTART;
#else
act.sa_flags = 0;
#endif /* SA_RESTART */
sigaction (SIGWINCH, &act, &oact);
#endif /* SIGWINCH */

View File

@ -61,10 +61,6 @@ extern int reset_hp_softkeys;
/*** file scope macro definitions ****************************************************************/
#ifndef SA_RESTART
#define SA_RESTART 0
#endif
#ifndef SLTT_MAX_SCREEN_COLS
#define SLTT_MAX_SCREEN_COLS 512
#endif

View File

@ -120,7 +120,11 @@ tty_start_interrupt_key (void)
act.sa_handler = sigintr_handler;
sigemptyset (&act.sa_mask);
#ifdef SA_RESTART
act.sa_flags = SA_RESTART;
#else
act.sa_flags = 0;
#endif /* SA_RESTART */
sigaction (SIGINT, &act, NULL);
}

View File

@ -844,7 +844,7 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
while (p >= lpath && *p != PATH_SEP)
p--;
if (p != NULL)
if (p >= lpath)
continue;
}
#endif /* HAVE_CHARSET */
@ -856,7 +856,6 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
else
s[-1] = '\0';
}
break;
}
break;

View File

@ -1338,19 +1338,22 @@ vfs_path_tokens_count (const vfs_path_t * vpath)
for (element_index = 0; element_index < vfs_path_elements_count (vpath); element_index++)
{
const vfs_path_element_t *element;
char **path_tokens, **iterator;
const char *token, *prev_token;
element = vfs_path_get_by_index (vpath, element_index);
path_tokens = iterator = g_strsplit (element->path, PATH_SEP_STR, -1);
while (*iterator != NULL)
for (prev_token = element->path; (token = strchr (prev_token, PATH_SEP)) != NULL;
prev_token = token + 1)
{
if (**iterator != '\0')
/* skip empty substring */
if (token != prev_token)
count_tokens++;
iterator++;
}
g_strfreev (path_tokens);
if (*prev_token != '\0')
count_tokens++;
}
return count_tokens;
}
@ -1405,9 +1408,9 @@ vfs_path_tokens_get (const vfs_path_t * vpath, ssize_t start_position, ssize_t l
g_string_assign (element_tokens, "");
element = vfs_path_get_by_index (vpath, element_index);
path_tokens = iterator = g_strsplit (element->path, PATH_SEP_STR, -1);
path_tokens = g_strsplit (element->path, PATH_SEP_STR, -1);
while (*iterator != NULL)
for (iterator = path_tokens; *iterator != NULL; iterator++)
{
if (**iterator != '\0')
{
@ -1428,7 +1431,6 @@ vfs_path_tokens_get (const vfs_path_t * vpath, ssize_t start_position, ssize_t l
else
start_position--;
}
iterator++;
}
g_strfreev (path_tokens);
vfs_path_tokens_add_class_info (element, ret_tokens, element_tokens);

View File

@ -336,17 +336,13 @@ vfs_strip_suffix_from_filename (const char *filename)
/* --------------------------------------------------------------------------------------------- */
char *
const char *
vfs_translate_path (const char *path)
{
estr_t state;
g_string_set_size (vfs_str_buffer, 0);
state = _vfs_translate_path (path, -1, str_cnv_from_term, vfs_str_buffer);
/*
strict version
return (state == 0) ? vfs_str_buffer->data : NULL;
*/
return (state != ESTR_FAILURE) ? vfs_str_buffer->str : NULL;
}
@ -355,10 +351,10 @@ vfs_translate_path (const char *path)
char *
vfs_translate_path_n (const char *path)
{
char *result;
const char *result;
result = vfs_translate_path (path);
return (result != NULL) ? g_strdup (result) : NULL;
return g_strdup (result);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -247,7 +247,7 @@ vfs_class_flags_t vfs_file_class_flags (const vfs_path_t * vpath);
/* translate path back to terminal encoding, remove all #enc:
* every invalid character is replaced with question mark
* return static buffer */
char *vfs_translate_path (const char *path);
const char *vfs_translate_path (const char *path);
/* return new string */
char *vfs_translate_path_n (const char *path);

View File

@ -800,7 +800,7 @@ dlg_create (gboolean modal, int y1, int x1, int lines, int cols,
g_free (t);
}
/* unique name got event group for this dialog */
/* unique name of event group for this dialog */
new_d->event_group = g_strdup_printf ("%s_%p", MCEVENT_GROUP_DIALOG, (void *) new_d);
return new_d;

View File

@ -917,7 +917,6 @@ input_destroy (WInput * in)
g_free (in->history_name);
g_free (in->buffer);
input_free_completions (in);
g_free (in->init_text);
g_free (kill_buffer);
@ -1100,10 +1099,12 @@ input_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
case MSG_ACTION:
return input_execute_cmd (in, parm);
case MSG_RESIZE:
in->field_width = WIDGET (in)->cols;
/* fall through */
case MSG_FOCUS:
case MSG_UNFOCUS:
case MSG_DRAW:
case MSG_RESIZE:
input_update (in, FALSE);
return MSG_HANDLED;
@ -1144,16 +1145,6 @@ input_get_default_colors (void)
/* --------------------------------------------------------------------------------------------- */
void
input_set_origin (WInput * in, int x, int field_width)
{
WIDGET (in)->x = x;
in->field_width = WIDGET (in)->cols = field_width;
input_update (in, FALSE);
}
/* --------------------------------------------------------------------------------------------- */
cb_ret_t
input_handle_char (WInput * in, int key)
{

View File

@ -85,7 +85,6 @@ WInput *input_new (int y, int x, const int *input_colors,
/* callbac is public; needed for command line */
cb_ret_t input_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data);
const int *input_get_default_colors (void);
void input_set_origin (WInput * i, int x, int field_width);
cb_ret_t input_handle_char (WInput * in, int key);
int input_key_is_in_map (WInput * in, int key);
void input_assign_text (WInput * in, const char *text);

View File

@ -493,7 +493,8 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
}
/* forced update internal variables of inpuit line */
input_set_origin (INPUT (item->widget), item->widget->x, item->widget->cols);
widget_set_size (item->widget, item->widget->y, item->widget->x, 1,
item->widget->cols);
}
break;

View File

@ -145,6 +145,7 @@ widget_init (Widget * w, int y, int x, int lines, int cols,
w->y = y;
w->cols = cols;
w->lines = lines;
w->pos_flags = WPOS_KEEP_DEFAULT;
w->callback = callback;
w->mouse = mouse_handler;
w->set_options = widget_default_set_options_callback;

View File

@ -167,9 +167,7 @@ edit_load_file_fast (edit_buffer_t * buf, const vfs_path_t * filename_vpath)
}
ret = (edit_buffer_read_file (buf, file, buf->size) == buf->size);
if (ret)
buf->lines = edit_buffer_count_lines (buf, 0, buf->size);
else
if (!ret)
{
gchar *errmsg;
@ -320,7 +318,7 @@ check_file_access (WEdit * edit, const vfs_path_t * filename_vpath, struct stat
g_free (errmsg);
errmsg = NULL;
if (act == 1)
if (act != 0)
ret = FALSE;
}

View File

@ -640,10 +640,11 @@ off_t
edit_buffer_read_file (edit_buffer_t * buf, int fd, off_t size)
{
off_t ret = 0;
off_t i;
off_t i, j;
off_t data_size;
void *b;
buf->lines = 0;
buf->curs2 = size;
i = buf->curs2 >> S_EDIT_BUF_SIZE;
@ -653,10 +654,16 @@ edit_buffer_read_file (edit_buffer_t * buf, int fd, off_t size)
{
b = g_malloc0 (EDIT_BUF_SIZE);
g_ptr_array_add (buf->b2, b);
ret = mc_read (fd, (char *) b + EDIT_BUF_SIZE - data_size, data_size);
b = (char *) b + EDIT_BUF_SIZE - data_size;
ret = mc_read (fd, b, data_size);
/* count lines */
for (j = 0; j < ret; j++)
if (*((char *) b + j) == '\n')
buf->lines++;
if (ret < 0 || ret != data_size)
return ret;
}
/* fulfill other parts of b2 from end to begin */
@ -670,6 +677,12 @@ edit_buffer_read_file (edit_buffer_t * buf, int fd, off_t size)
sz = mc_read (fd, b, data_size);
if (sz >= 0)
ret += sz;
/* count lines */
for (j = 0; j < sz; j++)
if (*((char *) b + j) == '\n')
buf->lines++;
if (sz != data_size)
break;
}

View File

@ -1935,26 +1935,23 @@ edit_load_macro_cmd (WEdit * edit)
if (macros_config == NULL || macros_list == NULL || macros_list->len != 0)
return FALSE;
profile_keys = keys = mc_config_get_keys (macros_config, section_name, &len);
while (*profile_keys != NULL)
keys = mc_config_get_keys (macros_config, section_name, &len);
for (profile_keys = keys; *profile_keys != NULL; profile_keys++)
{
gboolean have_macro;
gboolean have_macro = FALSE;
GArray *macros;
macros_t macro;
macros = g_array_new (TRUE, FALSE, sizeof (macro_action_t));
curr_values = values = mc_config_get_string_list (macros_config, section_name,
*profile_keys, &values_len);
values =
mc_config_get_string_list (macros_config, section_name, *profile_keys, &values_len);
hotkey = lookup_key (*profile_keys, NULL);
have_macro = FALSE;
while (*curr_values != NULL && *curr_values[0] != '\0')
for (curr_values = values; *curr_values != NULL && *curr_values[0] != '\0'; curr_values++)
{
char **macro_pair = NULL;
macro_pair = g_strsplit (*curr_values, ":", 2);
if (macro_pair != NULL)
{
macro_action_t m_act;
@ -1988,7 +1985,6 @@ edit_load_macro_cmd (WEdit * edit)
g_strfreev (macro_pair);
macro_pair = NULL;
}
curr_values++;
}
if (have_macro)
{
@ -1996,7 +1992,6 @@ edit_load_macro_cmd (WEdit * edit)
macro.macro = macros;
g_array_append_val (macros_list, macro);
}
profile_keys++;
g_strfreev (values);
}
g_strfreev (keys);
@ -2762,7 +2757,7 @@ edit_search_cmd (WEdit * edit, gboolean again)
gboolean
edit_ok_to_exit (WEdit * edit)
{
char *fname = (char *) N_("[NoName]");
const char *fname = N_("[NoName]");
char *msg;
int act;
@ -2770,22 +2765,16 @@ edit_ok_to_exit (WEdit * edit)
return TRUE;
if (edit->filename_vpath != NULL)
fname = g_strdup (vfs_path_as_str (edit->filename_vpath));
fname = vfs_path_as_str (edit->filename_vpath);
#ifdef ENABLE_NLS
else
fname = g_strdup (_(fname));
#else
else
fname = g_strdup (fname);
fname = _(fname);
#endif
if (!mc_global.midnight_shutdown)
{
if (!edit_check_newline (&edit->buffer))
{
g_free (fname);
return FALSE;
}
query_set_sel (2);
@ -2804,7 +2793,6 @@ edit_ok_to_exit (WEdit * edit)
}
g_free (msg);
g_free (fname);
switch (act)
{

View File

@ -1624,7 +1624,7 @@ single_dirsize_cmd (void)
entry = &(panel->dir.list[panel->selected]);
if (S_ISDIR (entry->st.st_mode) && !DIR_IS_DOTDOT (entry->fname))
{
size_t marked = 0;
size_t count = 0;
uintmax_t total = 0;
ComputeDirSizeUI *ui;
vfs_path_t *p;
@ -1632,7 +1632,7 @@ single_dirsize_cmd (void)
ui = compute_dir_size_create_ui (FALSE);
p = vfs_path_from_str (entry->fname);
if (compute_dir_size (p, ui, compute_dir_size_update_ui, &marked, &total, TRUE) ==
if (compute_dir_size (p, ui, compute_dir_size_update_ui, &count, &total, TRUE) ==
FILE_CONT)
{
entry->st.st_size = (off_t) total;
@ -1671,12 +1671,12 @@ dirsizes_cmd (void)
|| !panel->dirs_marked) && !DIR_IS_DOTDOT (panel->dir.list[i].fname))
{
vfs_path_t *p;
size_t marked = 0;
size_t count = 0;
uintmax_t total = 0;
gboolean ok;
p = vfs_path_from_str (panel->dir.list[i].fname);
ok = compute_dir_size (p, ui, compute_dir_size_update_ui, &marked, &total,
ok = compute_dir_size (p, ui, compute_dir_size_update_ui, &count, &total,
TRUE) != FILE_CONT;
vfs_path_free (p);

View File

@ -549,7 +549,8 @@ do_compute_dir_size (const vfs_path_t * dirname_vpath, void *ui,
update_ui_count++;
if ((update_ui_count & 31) == 0)
ret =
(cback == NULL) ? FILE_CONT : cback (ui, tmp_vpath, *dir_count, *ret_total);
(cback == NULL) ? FILE_CONT : cback (ui, dirname_vpath, *dir_count,
*ret_total);
}
}
@ -1233,7 +1234,7 @@ panel_get_file (WPanel * panel)
static FileProgressStatus
panel_compute_totals (const WPanel * panel, void *ui, compute_dir_size_callback cback,
size_t * ret_marked, uintmax_t * ret_total, gboolean compute_symlinks)
size_t * ret_count, uintmax_t * ret_total, gboolean compute_symlinks)
{
int i;
@ -1252,7 +1253,7 @@ panel_compute_totals (const WPanel * panel, void *ui, compute_dir_size_callback
FileProgressStatus status;
p = vfs_path_append_new (panel->cwd_vpath, panel->dir.list[i].fname, NULL);
status = compute_dir_size (p, ui, cback, ret_marked, ret_total, compute_symlinks);
status = compute_dir_size (p, ui, cback, ret_count, ret_total, compute_symlinks);
vfs_path_free (p);
if (status != FILE_CONT)
@ -1260,7 +1261,7 @@ panel_compute_totals (const WPanel * panel, void *ui, compute_dir_size_callback
}
else
{
(*ret_marked)++;
(*ret_count)++;
*ret_total += (uintmax_t) s->st_size;
}
}
@ -2565,11 +2566,11 @@ compute_dir_size_update_ui (void *ui, const vfs_path_t * dirname_vpath, size_t d
FileProgressStatus
compute_dir_size (const vfs_path_t * dirname_vpath, void *ui, compute_dir_size_callback cback,
size_t * ret_marked, uintmax_t * ret_total, gboolean compute_symlinks)
size_t * ret_count, uintmax_t * ret_total, gboolean compute_symlinks)
{
size_t dir_count = 0;
size_t marked = 0;
return do_compute_dir_size (dirname_vpath, ui, cback, &dir_count, ret_marked, ret_total,
return do_compute_dir_size (dirname_vpath, ui, cback, ret_count, &marked, ret_total,
compute_symlinks);
}

View File

@ -55,7 +55,7 @@ FileProgressStatus file_error (const char *format, const char *file);
/* return value is FILE_CONT or FILE_ABORT */
FileProgressStatus compute_dir_size (const vfs_path_t * dirname_vpath, void *ui,
compute_dir_size_callback cback,
size_t * ret_marked, uintmax_t * ret_total,
size_t * ret_count, uintmax_t * ret_total,
gboolean compute_symlinks);
ComputeDirSizeUI *compute_dir_size_create_ui (gboolean allow_skip);

View File

@ -284,8 +284,8 @@ statvfs_works (void)
if (statvfs_works_cache < 0)
statvfs_works_cache = (uname (&name) == 0 && 0 <= str_verscmp (name.release, "2.6.36"));
return statvfs_works_cache;
}
#endif
}
#endif
/* --------------------------------------------------------------------------------------------- */

View File

@ -733,7 +733,6 @@ setup_panels (void)
else
{
widget_set_size (WIDGET (cmdline), 0, 0, 0, 0);
input_set_origin (cmdline, 0, 0);
widget_set_size (WIDGET (the_prompt), LINES, COLS, 0, 0);
}
@ -850,7 +849,6 @@ setup_cmdline (void)
widget_set_size (WIDGET (the_prompt), y, 0, 1, prompt_len);
label_set_text (the_prompt, mc_prompt);
widget_set_size (WIDGET (cmdline), y, prompt_len, 1, COLS - prompt_len);
input_set_origin (cmdline, prompt_len, COLS - prompt_len);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -258,22 +258,17 @@ add2panelize (char *label, char *command)
static void
add2panelize_cmd (void)
{
if (pname->buffer != NULL && *pname->buffer != '\0')
{
char *label;
if (pname->buffer && (*pname->buffer))
{
label = input_dialog (_("Add to external panelize"),
_("Enter command label:"), MC_HISTORY_FM_PANELIZE_ADD, "",
INPUT_COMPLETE_NONE);
if (!label)
return;
if (!*label)
{
if (label == NULL || *label == '\0')
g_free (label);
return;
}
else
add2panelize (label, g_strdup (pname->buffer));
}
}
@ -423,14 +418,14 @@ do_panelize_cd (struct WPanel *panel)
else
{
vfs_path_t *tmp_vpath;
const char *tmp_path;
const char *fname;
tmp_vpath =
vfs_path_append_new (panelized_panel.root_vpath, panelized_panel.list.list[i].fname,
NULL);
tmp_path = vfs_path_as_str (tmp_vpath);
list->list[i].fnamelen = strlen (tmp_path);
list->list[i].fname = g_strndup (tmp_path, list->list[i].fnamelen);
fname = vfs_path_as_str (tmp_vpath);
list->list[i].fnamelen = strlen (fname);
list->list[i].fname = g_strndup (fname, list->list[i].fnamelen);
vfs_path_free (tmp_vpath);
}
list->list[i].f.link_to_dir = panelized_panel.list.list[i].f.link_to_dir;
@ -565,17 +560,14 @@ external_panelize (void)
void
load_panelize (void)
{
gchar **profile_keys, **keys;
char **keys;
gsize len;
GIConv conv;
conv = str_crt_conv_from ("UTF-8");
profile_keys = keys = mc_config_get_keys (mc_main_config, panelize_section, &len);
keys = mc_config_get_keys (mc_main_config, panelize_section, &len);
add2panelize (g_strdup (_("Other command")), g_strdup (""));
if (!profile_keys || *profile_keys == NULL)
if (keys == NULL || *keys == NULL)
{
add2panelize (g_strdup (_("Modified git files")), g_strdup ("git ls-files --modified"));
add2panelize (g_strdup (_("Find rejects after patching")),
@ -584,11 +576,16 @@ load_panelize (void)
g_strdup ("find . -name \\*.orig -print"));
add2panelize (g_strdup (_("Find SUID and SGID programs")),
g_strdup
("find . \\( \\( -perm -04000 -a -perm +011 \\) -o \\( -perm -02000 -a -perm +01 \\) \\) -print"));
return;
("find . \\( \\( -perm -04000 -a -perm /011 \\) -o \\( -perm -02000 -a -perm /01 \\) \\) -print"));
}
else
{
GIConv conv;
char **profile_keys;
while (*profile_keys)
conv = str_crt_conv_from ("UTF-8");
for (profile_keys = keys; *profile_keys != NULL; profile_keys++)
{
GString *buffer;
@ -602,12 +599,14 @@ load_panelize (void)
}
add2panelize (g_string_free (buffer, FALSE),
mc_config_get_string (mc_main_config, panelize_section, *profile_keys, ""));
profile_keys++;
mc_config_get_string (mc_main_config, panelize_section, *profile_keys,
""));
}
str_close_conv (conv);
}
g_strfreev (keys);
str_close_conv (conv);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -924,8 +924,6 @@ init_subshell (void)
int
invoke_subshell (const char *command, int how, vfs_path_t ** new_dir_vpath)
{
char *pcwd;
/* Make the MC terminal transparent */
tcsetattr (STDOUT_FILENO, TCSANOW, &raw_mode);
@ -957,11 +955,14 @@ invoke_subshell (const char *command, int how, vfs_path_t ** new_dir_vpath)
feed_subshell (how, FALSE);
pcwd = vfs_translate_path_n (vfs_path_as_str (current_panel->cwd_vpath));
if (new_dir_vpath != NULL && subshell_alive)
{
const char *pcwd;
if (new_dir_vpath != NULL && subshell_alive && strcmp (subshell_cwd, pcwd))
pcwd = vfs_translate_path (vfs_path_as_str (current_panel->cwd_vpath));
if (strcmp (subshell_cwd, pcwd) != 0)
*new_dir_vpath = vfs_path_from_str (subshell_cwd); /* Make MC change to the subshell's CWD */
g_free (pcwd);
}
/* Restart the subshell if it has died by SIGHUP, SIGQUIT, etc. */
while (!subshell_alive && quit == 0 && mc_global.tty.use_subshell)
@ -1175,9 +1176,9 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt)
if (vpath != NULL)
{
char *translate;
const char *translate;
translate = vfs_translate_path_n (vfs_path_as_str (vpath));
translate = vfs_translate_path (vfs_path_as_str (vpath));
if (translate != NULL)
{
GString *temp;
@ -1185,8 +1186,6 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt)
temp = subshell_name_quote (translate);
write_all (mc_global.tty.subshell_pty, temp->str, temp->len);
g_string_free (temp, TRUE);
g_free (translate);
}
else
{

View File

@ -449,7 +449,7 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
current_archive = g_new (struct archive, 1);
current_archive->fstype = fstype;
current_archive->name = (name != NULL) ? g_strdup (name) : NULL;
current_archive->name = g_strdup (name);
current_archive->local_name = g_strdup (vfs_path_get_last_path_str (local_name_vpath));
if (local_name_vpath != NULL)
@ -690,6 +690,7 @@ extfs_get_path_int (const vfs_path_t * vpath, struct archive **archive, gboolean
if (strcmp (parc->name, archive_name) == 0)
{
vfs_stamp (&vfs_extfs_ops, (vfsid) parc);
g_free (archive_name);
goto return_success;
}
}

View File

@ -41,7 +41,7 @@ xorriso_list() {
dir="$2"
$XORRISO -dev stdio:"$1" -cd "$dir" -lsl 2> /dev/null | @GREP@ "^[-d]" | \
while read attr ln usr gr sz dt1 dt2 dt3 nm ; do
len=$((${#nm} - 2))
len=$((${#nm} - 1))
name=$(printf "$nm" | cut -c2-$len) # remove quotes
if test $(printf "$nm" | cut -c1-2) != "d"; then
printf "%s %s %s %s %s %s %s %s %s/%s\n" "$attr" "$ln" "$usr" "$gr" "$sz" "$dt1" "$dt2" "$dt3" "$dir" "$name"

View File

@ -4,6 +4,9 @@
# (C) 1996 2:5020/337.13@fidonet.org
# Updated by christian.gennerat@alcatel.fr 1999
# Andrew V. Samoilov <sav@bcs.zp.ua> 2000
# Andrew Borodin <aborodin@vmail.ru>
# 2013: support unrar5
#
# beta version 2.0
#
# rar and unrar can be found on http://www.rarlabs.com/

View File

@ -27,6 +27,10 @@
#include "tests/mctest.h"
#ifdef HAVE_CHARSET
#include "lib/charsets.h"
#endif
#include "lib/strutil.h"
#include "lib/util.h"
#include "lib/vfs/xdirentry.h"
@ -48,6 +52,11 @@ setup (void)
init_localfs ();
vfs_setup_work_dir ();
#ifdef HAVE_CHARSET
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
load_codepages_list ();
#endif
vfs_s_init_class (&vfs_test_ops, &test_subclass);
vfs_test_ops.name = "testfs";
@ -63,6 +72,10 @@ setup (void)
static void
teardown (void)
{
#ifdef HAVE_CHARSET
free_codepages_list ();
#endif
vfs_shut ();
str_uninit_strings ();
}
@ -117,6 +130,40 @@ static const struct test_canonicalize_path_ds
"ftp://user/../../",
".."
},
#ifdef HAVE_CHARSET
{ /* 10. Supported encoding */
"/b/#enc:utf-8/../c",
"/c"
},
{ /* 11. Unsupported encoding */
"/b/#enc:aaaa/../c",
"/b/c"
},
{ /* 12. Supported encoding */
"/b/../#enc:utf-8/c",
"/#enc:utf-8/c"
},
{ /* 13. Unsupported encoding */
"/b/../#enc:aaaa/c",
"/#enc:aaaa/c"
},
{ /* 14. Supported encoding */
"/b/c/#enc:utf-8/..",
"/b"
},
{ /* 15. Unsupported encoding */
"/b/c/#enc:aaaa/..",
"/b/c"
},
{ /* 16. Supported encoding */
"/b/c/../#enc:utf-8",
"/b/#enc:utf-8"
},
{ /* 17. Unsupported encoding */
"/b/c/../#enc:aaaa",
"/b/#enc:aaaa"
},
#endif /* HAVE_CHARSET */
};
/* *INDENT-ON* */