Merge branch '3876_cleanup'

* 3876_cleanup: (47 commits)
  (mc_deserialize_str): trivial optimization.
  (edit_do_search): use gboolean. Remove unused computations.
  (str_8bit_encodings[], str_utf8_encodings[]): make const.
  (etags_set_definition_hash): make buf stack variable.
  (convert_from_8bit_to_utf_c2): use convert_from_8bit_to_utf_c().
  str_convert_to_input() never returns NULL.
  (edit_collect_completions): str_convert_to_display() never returns NULL.
  lib/charsets.c: fix coding style, trivial optimizations.
  (mc_search__recode_str): minor optimization.
  (mc_search__get_one_symbol): cosmetics.
  strutil: character test functions return gboolean instead of int.
  Use str_move() where possible.
  Use gboolean instead of int in file/dir sort related functions.
  (get_codepage_index): minor optimizations.
  (ftpfs_command): minor optimization.
  FTP: fix some calls of ftpfs_command().
  FISH: optimize creation of FISH commands.
  src/vfs/fish/fish.c: allocate buffer for command dynamically.
  (vfs_url_split): Fix 2 memory leaks found by valgrind.
  smbfs: code cleanup
  ...
This commit is contained in:
Andrew Borodin 2018-02-04 11:31:00 +03:00
commit c9ca0cc01b
271 changed files with 1730 additions and 1618 deletions

View File

@ -2,6 +2,7 @@ m4_include([m4.include/ac_onceonly.m4])
m4_include([m4.include/ax_path_lib_pcre.m4]) m4_include([m4.include/ax_path_lib_pcre.m4])
m4_include([m4.include/dx_doxygen.m4]) m4_include([m4.include/dx_doxygen.m4])
m4_include([m4.include/mc-cflags.m4]) m4_include([m4.include/mc-cflags.m4])
m4_include([m4.include/ax_gcc_func_attribute.m4])
m4_include([m4.include/mc-check-search-type.m4]) m4_include([m4.include/mc-check-search-type.m4])
m4_include([m4.include/mode_t.m4]) m4_include([m4.include/mode_t.m4])
m4_include([m4.include/stat-size.m4]) m4_include([m4.include/stat-size.m4])

View File

@ -45,6 +45,8 @@ if test "x$enable_werror" = xyes; then
mc_CHECK_ONE_CFLAG([-Werror]) mc_CHECK_ONE_CFLAG([-Werror])
fi fi
AX_GCC_FUNC_ATTRIBUTE([fallthrough])
AC_PROG_LIBTOOL AC_PROG_LIBTOOL

View File

@ -503,9 +503,7 @@ To untag files, just retag a tagged file.
.B M\-e .B M\-e
to change charset of panel you may use M\-e (Alt\-e). to change charset of panel you may use M\-e (Alt\-e).
Recoding is made from selected codepage into system codepage. To Recoding is made from selected codepage into system codepage. To
cancel the recoding you may select "directory up" (..) in active panel. cancel the recoding, select "No translation" in the dialog of encodings.
To cancel the charsets in all directories, select "No translation " in
the dialog of encodings.
.TP .TP
.B Alt\-g, Alt\-r, Alt\-j .B Alt\-g, Alt\-r, Alt\-j
used to select the top file in a panel, the middle file and the bottom one, used to select the top file in a panel, the middle file and the bottom one,

View File

@ -8,7 +8,7 @@ mc \- Визуальная оболочка для Unix\-подобных сис
.\"SKIP_SECTION" .\"SKIP_SECTION"
.SH "СИНТАКСИС" .SH "СИНТАКСИС"
.B mc .B mc
[\-abcCdfhPstuUVx] [\-l журнал] [каталог1 [каталог2]] [\-e [файл] . ..] [\-v файл] [\-abcCdfhPstuUVx] [\-l журнал] [каталог1 [каталог2]] [\-e [файл] ...] [\-v файл]
.\"NODE "DESCRIPTION" .\"NODE "DESCRIPTION"
.SH "ОПИСАНИЕ" .SH "ОПИСАНИЕ"
Что такое Midnight Commander Что такое Midnight Commander
@ -495,9 +495,7 @@ Midnight Commander\-а. Для возврата к вашему приложен
.B M\-e .B M\-e
Чтобы поменять кодировку панели, используйте комбинацию M\-e (Alt\-e). Чтобы поменять кодировку панели, используйте комбинацию M\-e (Alt\-e).
Перекодировка производится из выбранной кодировки в системную. Для отмены Перекодировка производится из выбранной кодировки в системную. Для отмены
перекодировки просто перейдите на каталог вверх '..'. Для отмены перекодировки выберите "Без перекодировки" в диалоге выбора кодировок.
перекодировки всех каталогов выберите "Без перекодировки" в диалоге
выбора кодировок.
.TP .TP
.B M\-g, M\-r, M\-j .B M\-g, M\-r, M\-j
Используются для перемещения подсветки, соответственно, на самый Используются для перемещения подсветки, соответственно, на самый

View File

@ -1,7 +1,7 @@
/* /*
Text conversion from one charset to another. Text conversion from one charset to another.
Copyright (C) 2001-2017 Copyright (C) 2001-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:
@ -106,12 +106,14 @@ load_codepages_list_from_file (GPtrArray ** list, const char *fname)
{ {
/* split string into id and cpname */ /* split string into id and cpname */
char *p = buf; char *p = buf;
size_t buflen = strlen (buf); size_t buflen;
if (*p == '\n' || *p == '\0' || *p == '#') if (*p == '\n' || *p == '\0' || *p == '#')
continue; continue;
if (buflen > 0 && buf[buflen - 1] == '\n') buflen = strlen (buf);
if (buflen != 0 && buf[buflen - 1] == '\n')
buf[buflen - 1] = '\0'; buf[buflen - 1] = '\0';
while (*p != '\0' && !whitespace (*p)) while (*p != '\0' && !whitespace (*p))
++p; ++p;
@ -181,11 +183,10 @@ translate_character (GIConv cd, char c)
gsize bytes_read, bytes_written = 0; gsize bytes_read, bytes_written = 0;
const char *ibuf = &c; const char *ibuf = &c;
char ch = UNKNCHAR; char ch = UNKNCHAR;
int ibuflen = 1; int ibuflen = 1;
tmp_buff = g_convert_with_iconv (ibuf, ibuflen, cd, &bytes_read, &bytes_written, NULL); tmp_buff = g_convert_with_iconv (ibuf, ibuflen, cd, &bytes_read, &bytes_written, NULL);
if (tmp_buff) if (tmp_buff != NULL)
ch = tmp_buff[0]; ch = tmp_buff[0];
g_free (tmp_buff); g_free (tmp_buff);
return ch; return ch;
@ -245,10 +246,11 @@ int
get_codepage_index (const char *id) get_codepage_index (const char *id)
{ {
size_t i; size_t i;
if (strcmp (id, OTHER_8BIT) == 0)
return -1;
if (codepages == NULL) if (codepages == NULL)
return -1; return -1;
if (strcmp (id, OTHER_8BIT) == 0)
return -1;
for (i = 0; i < codepages->len; i++) for (i = 0; i < codepages->len; i++)
if (strcmp (id, ((codepage_desc *) g_ptr_array_index (codepages, i))->id) == 0) if (strcmp (id, ((codepage_desc *) g_ptr_array_index (codepages, i))->id) == 0)
return i; return i;
@ -269,7 +271,9 @@ is_supported_encoding (const char *encoding)
for (t = 0; t < codepages->len; t++) for (t = 0; t < codepages->len; t++)
{ {
const char *id = ((codepage_desc *) g_ptr_array_index (codepages, t))->id; const char *id;
id = ((codepage_desc *) g_ptr_array_index (codepages, t))->id;
result |= (g_ascii_strncasecmp (encoding, id, strlen (id)) == 0); result |= (g_ascii_strncasecmp (encoding, id, strlen (id)) == 0);
} }
@ -292,8 +296,8 @@ init_translation_table (int cpsource, int cpdisplay)
{ {
conv_displ[i] = i; conv_displ[i] = i;
conv_input[i] = i; conv_input[i] = i;
cp_source = cp_display;
} }
cp_source = cp_display;
return NULL; return NULL;
} }
@ -339,14 +343,9 @@ init_translation_table (int cpsource, int cpdisplay)
void void
convert_to_display (char *str) convert_to_display (char *str)
{ {
if (!str) if (str != NULL)
return; for (; *str != '\0'; str++)
*str = conv_displ[(unsigned char) *str];
while (*str)
{
*str = conv_displ[(unsigned char) *str];
str++;
}
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -355,7 +354,6 @@ GString *
str_convert_to_display (const char *str) str_convert_to_display (const char *str)
{ {
return str_nconvert_to_display (str, -1); return str_nconvert_to_display (str, -1);
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -366,7 +364,7 @@ str_nconvert_to_display (const char *str, int len)
GString *buff; GString *buff;
GIConv conv; GIConv conv;
if (!str) if (str == NULL)
return g_string_new (""); return g_string_new ("");
if (cp_display == cp_source) if (cp_display == cp_source)
@ -385,14 +383,9 @@ str_nconvert_to_display (const char *str, int len)
void void
convert_from_input (char *str) convert_from_input (char *str)
{ {
if (!str) if (str != NULL)
return; for (; *str != '\0'; str++)
*str = conv_input[(unsigned char) *str];
while (*str)
{
*str = conv_input[(unsigned char) *str];
str++;
}
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -411,7 +404,7 @@ str_nconvert_to_input (const char *str, int len)
GString *buff; GString *buff;
GIConv conv; GIConv conv;
if (!str) if (str == NULL)
return g_string_new (""); return g_string_new ("");
if (cp_display == cp_source) if (cp_display == cp_source)
@ -530,37 +523,16 @@ convert_from_8bit_to_utf_c (char input_char, GIConv conv)
int int
convert_from_8bit_to_utf_c2 (char input_char) convert_from_8bit_to_utf_c2 (char input_char)
{ {
unsigned char str[2];
int ch = '.'; int ch = '.';
GIConv conv; GIConv conv;
const char *cp_from; const char *cp_from;
str[0] = (unsigned char) input_char;
str[1] = '\0';
cp_from = get_codepage_id (mc_global.source_codepage); cp_from = get_codepage_id (mc_global.source_codepage);
conv = str_crt_conv_to (cp_from);
conv = str_crt_conv_to (cp_from);
if (conv != INVALID_CONV) if (conv != INVALID_CONV)
{ {
unsigned char buf_ch[UTF8_CHAR_LEN + 1]; ch = convert_from_8bit_to_utf_c (input_char, conv);
switch (str_translate_char (conv, (char *) str, -1, (char *) buf_ch, sizeof (buf_ch)))
{
case ESTR_SUCCESS:
{
int res;
res = g_utf8_get_char_validated ((char *) buf_ch, -1);
ch = res >= 0 ? res : buf_ch[0];
break;
}
case ESTR_PROBLEM:
case ESTR_FAILURE:
default:
ch = '.';
break;
}
str_close_conv (conv); str_close_conv (conv);
} }

View File

@ -34,7 +34,7 @@ void mc_event_del (const gchar *, const gchar *, mc_event_callback_func_t, gpoin
void mc_event_destroy (const gchar *, const gchar *); void mc_event_destroy (const gchar *, const gchar *);
void mc_event_group_del (const gchar *); void mc_event_group_del (const gchar *);
gboolean mc_event_present (const gchar *, const gchar *); gboolean mc_event_present (const gchar *, const gchar *);
gboolean mc_event_mass_add (event_init_t *, GError **); gboolean mc_event_mass_add (const event_init_t *, GError **);
/* raise.c: */ /* raise.c: */
gboolean mc_event_raise (const gchar *, const gchar *, gpointer); gboolean mc_event_raise (const gchar *, const gchar *, gpointer);

View File

@ -2,7 +2,7 @@
Handle events in application. Handle events in application.
Interface functions: init/deinit; start/stop Interface functions: init/deinit; start/stop
Copyright (C) 2011-2017 Copyright (C) 2011-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:
@ -92,7 +92,7 @@ mc_event_deinit (GError ** mcerror)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
gboolean gboolean
mc_event_mass_add (event_init_t * events, GError ** mcerror) mc_event_mass_add (const event_init_t * events, GError ** mcerror)
{ {
size_t array_index; size_t array_index;

View File

@ -2,7 +2,7 @@
Handle any events in application. Handle any events in application.
Manage events: add, delete, destroy, search Manage events: add, delete, destroy, search
Copyright (C) 2011-2017 Copyright (C) 2011-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -2,7 +2,7 @@
Handle any events in application. Handle any events in application.
Raise events. Raise events.
Copyright (C) 2011-2017 Copyright (C) 2011-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -2,7 +2,7 @@
File highlight plugin. File highlight plugin.
Interface functions Interface functions
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -2,7 +2,7 @@
File highlight plugin. File highlight plugin.
Interface functions. get color pair index for highlighted file. Interface functions. get color pair index for highlighted file.
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -2,7 +2,7 @@
File highlight plugin. File highlight plugin.
Reading and parse rules from ini-files Reading and parse rules from ini-files
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
GLIB - Library of useful routines for C programming GLIB - Library of useful routines for C programming
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Global structure for some library-related variables Global structure for some library-related variables
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -27,6 +27,12 @@
/* for sig_atomic_t */ /* for sig_atomic_t */
#include <signal.h> #include <signal.h>
#ifdef HAVE_FUNC_ATTRIBUTE_FALLTHROUGH
#define MC_FALLTHROUGH __attribute__((fallthrough))
#else
#define MC_FALLTHROUGH
#endif
/*** typedefs(not structures) and defined constants **********************************************/ /*** typedefs(not structures) and defined constants **********************************************/
/* The O_BINARY definition was taken from gettext */ /* The O_BINARY definition was taken from gettext */
@ -128,7 +134,7 @@
#define TMPDIR_DEFAULT "/tmp" #define TMPDIR_DEFAULT "/tmp"
#define SCRIPT_SUFFIX "" #define SCRIPT_SUFFIX ""
#define get_default_editor() "vi" #define get_default_editor() "vi"
#define OS_SORT_CASE_SENSITIVE_DEFAULT 1 #define OS_SORT_CASE_SENSITIVE_DEFAULT TRUE
#define UTF8_CHAR_LEN 6 #define UTF8_CHAR_LEN 6
/* Used to distinguish between a normal MC termination and */ /* Used to distinguish between a normal MC termination and */

View File

@ -4,7 +4,7 @@
Slavaz: Warning! this file is deprecated and should be replaced Slavaz: Warning! this file is deprecated and should be replaced
by mcevents functional. by mcevents functional.
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Definitions of key bindings. Definitions of key bindings.
Copyright (C) 2005-2017 Copyright (C) 2005-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
File locking File locking
Copyright (C) 2003-2017 Copyright (C) 2003-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Provides a log file to ease tracing the program. Provides a log file to ease tracing the program.
Copyright (C) 2006-2017 Copyright (C) 2006-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Configure module for the Midnight Commander Configure module for the Midnight Commander
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of the Midnight Commander. This file is part of the Midnight Commander.

View File

@ -1,7 +1,7 @@
/* /*
Configure module for the Midnight Commander Configure module for the Midnight Commander
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of the Midnight Commander. This file is part of the Midnight Commander.

View File

@ -1,7 +1,7 @@
/* /*
paths to configuration files paths to configuration files
Copyright (C) 2010-2017 Copyright (C) 2010-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Configure module for the Midnight Commander Configure module for the Midnight Commander
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of the Midnight Commander. This file is part of the Midnight Commander.

View File

@ -2,7 +2,7 @@
Search text engine. Search text engine.
Glob-style pattern matching Glob-style pattern matching
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -2,7 +2,7 @@
Search text engine. Search text engine.
HEX-style pattern matching HEX-style pattern matching
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -2,7 +2,7 @@
Search text engine. Search text engine.
Common share code for module. Common share code for module.
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:
@ -61,31 +61,27 @@ gchar *
mc_search__recode_str (const char *str, gsize str_len, mc_search__recode_str (const char *str, gsize str_len,
const char *charset_from, const char *charset_to, gsize * bytes_written) const char *charset_from, const char *charset_to, gsize * bytes_written)
{ {
gchar *ret; gchar *ret = NULL;
gsize bytes_read;
GIConv conv;
if (charset_from == NULL || charset_to == NULL if (charset_from != NULL && charset_to != NULL
|| g_ascii_strcasecmp (charset_to, charset_from) == 0) && g_ascii_strcasecmp (charset_to, charset_from) != 0)
{ {
*bytes_written = str_len; GIConv conv;
return g_strndup (str, str_len);
}
conv = g_iconv_open (charset_to, charset_from); conv = g_iconv_open (charset_to, charset_from);
if (conv == INVALID_CONV) if (conv != INVALID_CONV)
{ {
*bytes_written = str_len; gsize bytes_read;
return g_strndup (str, str_len);
}
ret = g_convert_with_iconv (str, str_len, conv, &bytes_read, bytes_written, NULL); ret = g_convert_with_iconv (str, str_len, conv, &bytes_read, bytes_written, NULL);
g_iconv_close (conv); g_iconv_close (conv);
}
}
if (ret == NULL) if (ret == NULL)
{ {
*bytes_written = str_len; *bytes_written = str_len;
return g_strndup (str, str_len); ret = g_strndup (str, str_len);
} }
return ret; return ret;
@ -125,13 +121,8 @@ mc_search__get_one_symbol (const char *charset, const char *str, gsize str_len,
converted_str2 = converted_str2 =
mc_search__recode_str (converted_str, tmp_len, cp_display, charset, &converted_str_len); mc_search__recode_str (converted_str, tmp_len, cp_display, charset, &converted_str_len);
#endif #endif
if (just_letters) if (just_letters != NULL)
{ *just_letters = str_isalnum (converted_str) && !str_isdigit (converted_str);
if (str_isalnum (converted_str) && !str_isdigit (converted_str))
*just_letters = TRUE;
else
*just_letters = FALSE;
}
#ifdef HAVE_CHARSET #ifdef HAVE_CHARSET
g_free (converted_str); g_free (converted_str);
return converted_str2; return converted_str2;

View File

@ -2,7 +2,7 @@
Search text engine. Search text engine.
Plain search Plain search
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:
@ -71,7 +71,7 @@ mc_search__normal_translate_to_regex (const GString * astr)
case '-': case '-':
case '|': case '|':
g_string_append_c (buff, '\\'); g_string_append_c (buff, '\\');
/* fall through */ MC_FALLTHROUGH;
default: default:
g_string_append_c (buff, str[loop]); g_string_append_c (buff, str[loop]);
break; break;

View File

@ -2,7 +2,7 @@
Search text engine. Search text engine.
Regex search Regex search
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -2,7 +2,7 @@
Search text engine. Search text engine.
Interface functions Interface functions
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Provides a serialize/unserialize functionality for INI-like formats. Provides a serialize/unserialize functionality for INI-like formats.
Copyright (C) 2011-2017 Copyright (C) 2011-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:
@ -133,7 +133,7 @@ mc_deserialize_str (const char prefix, const char *data, GError ** error)
{ {
size_t data_len; size_t data_len;
if ((data == NULL) || (strlen (data) == 0)) if ((data == NULL) || (*data == '\0'))
{ {
g_set_error (error, MC_ERROR, 0, FUNC_NAME ": Input data is NULL or empty."); g_set_error (error, MC_ERROR, 0, FUNC_NAME ": Input data is NULL or empty.");
return NULL; return NULL;

View File

@ -1,7 +1,7 @@
/* /*
Provides a functions for working with shell. Provides a functions for working with shell.
Copyright (C) 2006-2017 Copyright (C) 2006-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -2,7 +2,7 @@
Skins engine. Skins engine.
Work with colors - backward compatibility Work with colors - backward compatibility
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -2,7 +2,7 @@
Skins engine. Skins engine.
Work with colors Work with colors
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -2,7 +2,7 @@
Skins engine. Skins engine.
Interface functions Interface functions
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -2,7 +2,7 @@
Skins engine. Skins engine.
Set of hardcoded skins Set of hardcoded skins
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -2,7 +2,7 @@
Skins engine. Skins engine.
Reading and parse ini-files Reading and parse ini-files
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -2,7 +2,7 @@
Skins engine. Skins engine.
Work with line draving chars. Work with line draving chars.
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -103,10 +103,11 @@ typedef enum
/* all functions in str_class must be defined for every encoding */ /* all functions in str_class must be defined for every encoding */
struct str_class struct str_class
{ {
/* *INDENT-OFF* */
gchar *(*conv_gerror_message) (GError * error, const char *def_msg); gchar *(*conv_gerror_message) (GError * error, const char *def_msg);
/*I*/ estr_t (*vfs_convert_to) (GIConv coder, const char *string, int size, GString * buffer); /*I*/ estr_t (*vfs_convert_to) (GIConv coder, const char *string, int size, GString * buffer);
/*I*/ void (*insert_replace_char) (GString * buffer); /*I*/ void (*insert_replace_char) (GString * buffer);
int (*is_valid_string) (const char *); gboolean (*is_valid_string) (const char *);
/*I*/ int (*is_valid_char) (const char *, size_t); /*I*/ int (*is_valid_char) (const char *, size_t);
/*I*/ void (*cnext_char) (const char **); /*I*/ void (*cnext_char) (const char **);
void (*cprev_char) (const char **); void (*cprev_char) (const char **);
@ -114,17 +115,17 @@ struct str_class
/*I*/ void (*cprev_char_safe) (const char **); /*I*/ void (*cprev_char_safe) (const char **);
/*I*/ int (*cnext_noncomb_char) (const char **text); /*I*/ int (*cnext_noncomb_char) (const char **text);
/*I*/ int (*cprev_noncomb_char) (const char **text, const char *begin); /*I*/ int (*cprev_noncomb_char) (const char **text, const char *begin);
/*I*/ int (*char_isspace) (const char *); /*I*/ gboolean (*char_isspace) (const char *);
/*I*/ int (*char_ispunct) (const char *); /*I*/ gboolean (*char_ispunct) (const char *);
/*I*/ int (*char_isalnum) (const char *); /*I*/ gboolean (*char_isalnum) (const char *);
/*I*/ int (*char_isdigit) (const char *); /*I*/ gboolean (*char_isdigit) (const char *);
/*I*/ int (*char_isprint) (const char *); /*I*/ gboolean (*char_isprint) (const char *);
/*I*/ gboolean (*char_iscombiningmark) (const char *); /*I*/ gboolean (*char_iscombiningmark) (const char *);
/*I*/ int (*length) (const char *); /*I*/ int (*length) (const char *);
/*I*/ int (*length2) (const char *, int); /*I*/ int (*length2) (const char *, int);
/*I*/ int (*length_noncomb) (const char *); /*I*/ int (*length_noncomb) (const char *);
/*I*/ int (*char_toupper) (const char *, char **, size_t *); /*I*/ gboolean (*char_toupper) (const char *, char **, size_t *);
int (*char_tolower) (const char *, char **, size_t *); gboolean (*char_tolower) (const char *, char **, size_t *);
void (*fix_string) (char *); void (*fix_string) (char *);
/*I*/ const char *(*term_form) (const char *); /*I*/ const char *(*term_form) (const char *);
/*I*/ const char *(*fit_to_term) (const char *, int, align_crt_t); /*I*/ const char *(*fit_to_term) (const char *, int, align_crt_t);
@ -136,21 +137,22 @@ struct str_class
/*I*/ const char *(*trunc) (const char *, int); /*I*/ const char *(*trunc) (const char *, int);
/*I*/ int (*offset_to_pos) (const char *, size_t); /*I*/ int (*offset_to_pos) (const char *, size_t);
/*I*/ int (*column_to_pos) (const char *, size_t); /*I*/ int (*column_to_pos) (const char *, size_t);
/*I*/ char *(*create_search_needle) (const char *, int); /*I*/ char *(*create_search_needle) (const char *, gboolean);
void (*release_search_needle) (char *, int); void (*release_search_needle) (char *, gboolean);
const char *(*search_first) (const char *, const char *, int); const char *(*search_first) (const char *, const char *, gboolean);
const char *(*search_last) (const char *, const char *, int); const char *(*search_last) (const char *, const char *, gboolean);
int (*compare) (const char *, const char *); int (*compare) (const char *, const char *);
/*I*/ int (*ncompare) (const char *, const char *); /*I*/ int (*ncompare) (const char *, const char *);
/*I*/ int (*casecmp) (const char *, const char *); /*I*/ int (*casecmp) (const char *, const char *);
/*I*/ int (*ncasecmp) (const char *, const char *); /*I*/ int (*ncasecmp) (const char *, const char *);
/*I*/ int (*prefix) (const char *, const char *); /*I*/ int (*prefix) (const char *, const char *);
/*I*/ int (*caseprefix) (const char *, const char *); /*I*/ int (*caseprefix) (const char *, const char *);
/*I*/ char *(*create_key) (const char *text, int case_sen); /*I*/ char *(*create_key) (const char *text, gboolean case_sen);
/*I*/ char *(*create_key_for_filename) (const char *text, int case_sen); /*I*/ char *(*create_key_for_filename) (const char *text, gboolean case_sen);
/*I*/ int (*key_collate) (const char *t1, const char *t2, int case_sen); /*I*/ int (*key_collate) (const char *t1, const char *t2, gboolean case_sen);
/*I*/ void (*release_key) (char *key, int case_sen); /*I*/ void (*release_key) (char *key, gboolean case_sen);
/*I*/}; /* *INDENT-ON* */
};
/*** global variables defined in .c file *********************************************************/ /*** global variables defined in .c file *********************************************************/
@ -245,7 +247,7 @@ estr_t str_translate_char (GIConv conv, const char *ch, size_t ch_size,
/* test, if text is valid in terminal encoding /* test, if text is valid in terminal encoding
* I * I
*/ */
int str_is_valid_string (const char *text); gboolean str_is_valid_string (const char *text);
/* test, if first char of ch is valid /* test, if first char of ch is valid
* size, how many bytes characters occupied, could be (size_t)(-1) * size, how many bytes characters occupied, could be (size_t)(-1)
@ -322,27 +324,27 @@ int str_cprev_noncomb_char (const char **text, const char *begin);
/* if first characters in ch is space, tabulator or new lines /* if first characters in ch is space, tabulator or new lines
* I * I
*/ */
int str_isspace (const char *ch); gboolean str_isspace (const char *ch);
/* if first characters in ch is punctuation or symbol /* if first characters in ch is punctuation or symbol
* I * I
*/ */
int str_ispunct (const char *ch); gboolean str_ispunct (const char *ch);
/* if first characters in ch is alphanum /* if first characters in ch is alphanum
* I * I
*/ */
int str_isalnum (const char *ch); gboolean str_isalnum (const char *ch);
/* if first characters in ch is digit /* if first characters in ch is digit
* I * I
*/ */
int str_isdigit (const char *ch); gboolean str_isdigit (const char *ch);
/* if first characters in ch is printable /* if first characters in ch is printable
* I * I
*/ */
int str_isprint (const char *ch); gboolean str_isprint (const char *ch);
/* if first characters in ch is a combining mark (only in utf-8) /* if first characters in ch is a combining mark (only in utf-8)
* combining makrs are assumed to be zero width * combining makrs are assumed to be zero width
@ -354,13 +356,13 @@ gboolean str_iscombiningmark (const char *ch);
* decrase remain by size of returned characters * decrase remain by size of returned characters
* if out is not big enough, do nothing * if out is not big enough, do nothing
*/ */
int str_toupper (const char *ch, char **out, size_t * remain); gboolean str_toupper (const char *ch, char **out, size_t * remain);
/* write upper from of fisrt characters in ch into out /* write upper from of fisrt characters in ch into out
* decrase remain by size of returned characters * decrase remain by size of returned characters
* if out is not big enough, do nothing * if out is not big enough, do nothing
*/ */
int str_tolower (const char *ch, char **out, size_t * remain); gboolean str_tolower (const char *ch, char **out, size_t * remain);
/* return length of text in characters /* return length of text in characters
* I * I
@ -455,19 +457,19 @@ const char *str_trunc (const char *text, int width);
* so needle can be reused * so needle can be reused
* in UTF-8 return normalized form of needle * in UTF-8 return normalized form of needle
*/ */
char *str_create_search_needle (const char *needle, int case_sen); char *str_create_search_needle (const char *needle, gboolean case_sen);
/* free needle returned by str_create_search_needle /* free needle returned by str_create_search_needle
*/ */
void str_release_search_needle (char *needle, int case_sen); void str_release_search_needle (char *needle, gboolean case_sen);
/* search for first occurrence of search in text /* search for first occurrence of search in text
*/ */
const char *str_search_first (const char *text, const char *needle, int case_sen); const char *str_search_first (const char *text, const char *needle, gboolean case_sen);
/* search for last occurrence of search in text /* search for last occurrence of search in text
*/ */
const char *str_search_last (const char *text, const char *needle, int case_sen); const char *str_search_last (const char *text, const char *needle, gboolean case_sen);
/* case sensitive compare two strings /* case sensitive compare two strings
* I * I
@ -507,25 +509,25 @@ int str_caseprefix (const char *text, const char *prefix);
/* create a key that is used by str_key_collate /* create a key that is used by str_key_collate
* I * I
*/ */
char *str_create_key (const char *text, int case_sen); char *str_create_key (const char *text, gboolean case_sen);
/* create a key that is used by str_key_collate /* create a key that is used by str_key_collate
* should aware dot '.' in text * should aware dot '.' in text
* I * I
*/ */
char *str_create_key_for_filename (const char *text, int case_sen); char *str_create_key_for_filename (const char *text, gboolean case_sen);
/* compare two string using LC_COLLATE, if is possible /* compare two string using LC_COLLATE, if is possible
* if case_sen is set, comparing is case sensitive, * if case_sen is set, comparing is case sensitive,
* case_sen must be same for str_create_key, str_key_collate and str_release_key * case_sen must be same for str_create_key, str_key_collate and str_release_key
* I * I
*/ */
int str_key_collate (const char *t1, const char *t2, int case_sen); int str_key_collate (const char *t1, const char *t2, gboolean case_sen);
/* release_key created by str_create_key, only rigth way to release key /* release_key created by str_create_key, only rigth way to release key
* I * I
*/ */
void str_release_key (char *key, int case_sen); void str_release_key (char *key, gboolean case_sen);
/* return TRUE if codeset_name is utf8 or utf-8 /* return TRUE if codeset_name is utf8 or utf-8
* I * I

View File

@ -1,7 +1,7 @@
/* /*
Functions for replacing substrings in strings. Functions for replacing substrings in strings.
Copyright (C) 2013-2017 Copyright (C) 2013-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Functions for escaping and unescaping strings Functions for escaping and unescaping strings
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Common strings utilities Common strings utilities
Copyright (C) 2007-2017 Copyright (C) 2007-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:
@ -47,14 +47,14 @@ GIConv str_cnv_not_convert = INVALID_CONV;
/*** file scope variables ************************************************************************/ /*** file scope variables ************************************************************************/
/* names, that are used for utf-8 */ /* names, that are used for utf-8 */
static const char *str_utf8_encodings[] = { static const char *const str_utf8_encodings[] = {
"utf-8", "utf-8",
"utf8", "utf8",
NULL NULL
}; };
/* standard 8bit encodings, no wide or multibytes characters */ /* standard 8bit encodings, no wide or multibytes characters */
static const char *str_8bit_encodings[] = { static const char *const str_8bit_encodings[] = {
"cp-1251", "cp-1251",
"cp1251", "cp1251",
"cp-1250", "cp-1250",
@ -219,7 +219,7 @@ _str_convert (GIConv coder, const char *string, int size, GString * buffer)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static int
str_test_encoding_class (const char *encoding, const char **table) str_test_encoding_class (const char *encoding, const char *const *table)
{ {
int result = 0; int result = 0;
@ -714,7 +714,7 @@ str_column_to_pos (const char *text, size_t pos)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
int gboolean
str_isspace (const char *ch) str_isspace (const char *ch)
{ {
return used_class.char_isspace (ch); return used_class.char_isspace (ch);
@ -722,7 +722,7 @@ str_isspace (const char *ch)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
int gboolean
str_ispunct (const char *ch) str_ispunct (const char *ch)
{ {
return used_class.char_ispunct (ch); return used_class.char_ispunct (ch);
@ -730,7 +730,7 @@ str_ispunct (const char *ch)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
int gboolean
str_isalnum (const char *ch) str_isalnum (const char *ch)
{ {
return used_class.char_isalnum (ch); return used_class.char_isalnum (ch);
@ -738,7 +738,7 @@ str_isalnum (const char *ch)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
int gboolean
str_isdigit (const char *ch) str_isdigit (const char *ch)
{ {
return used_class.char_isdigit (ch); return used_class.char_isdigit (ch);
@ -746,7 +746,7 @@ str_isdigit (const char *ch)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
int gboolean
str_toupper (const char *ch, char **out, size_t * remain) str_toupper (const char *ch, char **out, size_t * remain)
{ {
return used_class.char_toupper (ch, out, remain); return used_class.char_toupper (ch, out, remain);
@ -754,7 +754,7 @@ str_toupper (const char *ch, char **out, size_t * remain)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
int gboolean
str_tolower (const char *ch, char **out, size_t * remain) str_tolower (const char *ch, char **out, size_t * remain)
{ {
return used_class.char_tolower (ch, out, remain); return used_class.char_tolower (ch, out, remain);
@ -762,7 +762,7 @@ str_tolower (const char *ch, char **out, size_t * remain)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
int gboolean
str_isprint (const char *ch) str_isprint (const char *ch)
{ {
return used_class.char_isprint (ch); return used_class.char_isprint (ch);
@ -787,7 +787,7 @@ str_trunc (const char *text, int width)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
char * char *
str_create_search_needle (const char *needle, int case_sen) str_create_search_needle (const char *needle, gboolean case_sen)
{ {
return used_class.create_search_needle (needle, case_sen); return used_class.create_search_needle (needle, case_sen);
} }
@ -795,7 +795,7 @@ str_create_search_needle (const char *needle, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
void void
str_release_search_needle (char *needle, int case_sen) str_release_search_needle (char *needle, gboolean case_sen)
{ {
used_class.release_search_needle (needle, case_sen); used_class.release_search_needle (needle, case_sen);
} }
@ -803,7 +803,7 @@ str_release_search_needle (char *needle, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
const char * const char *
str_search_first (const char *text, const char *search, int case_sen) str_search_first (const char *text, const char *search, gboolean case_sen)
{ {
return used_class.search_first (text, search, case_sen); return used_class.search_first (text, search, case_sen);
} }
@ -811,14 +811,14 @@ str_search_first (const char *text, const char *search, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
const char * const char *
str_search_last (const char *text, const char *search, int case_sen) str_search_last (const char *text, const char *search, gboolean case_sen)
{ {
return used_class.search_last (text, search, case_sen); return used_class.search_last (text, search, case_sen);
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
int gboolean
str_is_valid_string (const char *text) str_is_valid_string (const char *text)
{ {
return used_class.is_valid_string (text); return used_class.is_valid_string (text);
@ -883,7 +883,7 @@ str_fix_string (char *text)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
char * char *
str_create_key (const char *text, int case_sen) str_create_key (const char *text, gboolean case_sen)
{ {
return used_class.create_key (text, case_sen); return used_class.create_key (text, case_sen);
} }
@ -891,7 +891,7 @@ str_create_key (const char *text, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
char * char *
str_create_key_for_filename (const char *text, int case_sen) str_create_key_for_filename (const char *text, gboolean case_sen)
{ {
return used_class.create_key_for_filename (text, case_sen); return used_class.create_key_for_filename (text, case_sen);
} }
@ -899,7 +899,7 @@ str_create_key_for_filename (const char *text, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
int int
str_key_collate (const char *t1, const char *t2, int case_sen) str_key_collate (const char *t1, const char *t2, gboolean case_sen)
{ {
return used_class.key_collate (t1, t2, case_sen); return used_class.key_collate (t1, t2, case_sen);
} }
@ -907,7 +907,7 @@ str_key_collate (const char *t1, const char *t2, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
void void
str_release_key (char *key, int case_sen) str_release_key (char *key, gboolean case_sen)
{ {
used_class.release_key (key, case_sen); used_class.release_key (key, case_sen);
} }

View File

@ -1,7 +1,7 @@
/* /*
8bit strings utilities 8bit strings utilities
Copyright (C) 2007-2017 Copyright (C) 2007-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:
@ -84,11 +84,11 @@ str_8bit_insert_replace_char (GString * buffer)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_8bit_is_valid_string (const char *text) str_8bit_is_valid_string (const char *text)
{ {
(void) text; (void) text;
return 1; return TRUE;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -143,42 +143,42 @@ str_8bit_cprev_noncomb_char (const char **text, const char *begin)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_8bit_isspace (const char *text) str_8bit_isspace (const char *text)
{ {
return char_isspace (text[0]); return char_isspace (text[0]) != 0;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_8bit_ispunct (const char *text) str_8bit_ispunct (const char *text)
{ {
return char_ispunct (text[0]); return char_ispunct (text[0]) != 0;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_8bit_isalnum (const char *text) str_8bit_isalnum (const char *text)
{ {
return char_isalnum (text[0]); return char_isalnum (text[0]) != 0;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_8bit_isdigit (const char *text) str_8bit_isdigit (const char *text)
{ {
return char_isdigit (text[0]); return char_isdigit (text[0]) != 0;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_8bit_isprint (const char *text) str_8bit_isprint (const char *text)
{ {
return char_isprint (text[0]); return char_isprint (text[0]) != 0;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -196,26 +196,26 @@ static int
str_8bit_toupper (const char *text, char **out, size_t * remain) str_8bit_toupper (const char *text, char **out, size_t * remain)
{ {
if (*remain <= 1) if (*remain <= 1)
return 0; return FALSE;
(*out)[0] = char_toupper (text[0]); (*out)[0] = char_toupper (text[0]);
(*out)++; (*out)++;
(*remain)--; (*remain)--;
return 1; return TRUE;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_8bit_tolower (const char *text, char **out, size_t * remain) str_8bit_tolower (const char *text, char **out, size_t * remain)
{ {
if (*remain <= 1) if (*remain <= 1)
return 0; return FALSE;
(*out)[0] = char_tolower (text[0]); (*out)[0] = char_tolower (text[0]);
(*out)++; (*out)++;
(*remain)--; (*remain)--;
return 1; return TRUE;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -553,7 +553,7 @@ str_8bit_column_to_pos (const char *text, size_t pos)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static char * static char *
str_8bit_create_search_needle (const char *needle, int case_sen) str_8bit_create_search_needle (const char *needle, gboolean case_sen)
{ {
(void) case_sen; (void) case_sen;
return (char *) needle; return (char *) needle;
@ -562,7 +562,7 @@ str_8bit_create_search_needle (const char *needle, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static void static void
str_8bit_release_search_needle (char *needle, int case_sen) str_8bit_release_search_needle (char *needle, gboolean case_sen)
{ {
(void) case_sen; (void) case_sen;
(void) needle; (void) needle;
@ -589,14 +589,14 @@ str_8bit_strdown (const char *str)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static const char * static const char *
str_8bit_search_first (const char *text, const char *search, int case_sen) str_8bit_search_first (const char *text, const char *search, gboolean case_sen)
{ {
char *fold_text; char *fold_text;
char *fold_search; char *fold_search;
const char *match; const char *match;
fold_text = (case_sen) ? (char *) text : str_8bit_strdown (text); fold_text = case_sen ? (char *) text : str_8bit_strdown (text);
fold_search = (case_sen) ? (char *) search : str_8bit_strdown (search); fold_search = case_sen ? (char *) search : str_8bit_strdown (search);
match = g_strstr_len (fold_text, -1, fold_search); match = g_strstr_len (fold_text, -1, fold_search);
if (match != NULL) if (match != NULL)
@ -619,14 +619,14 @@ str_8bit_search_first (const char *text, const char *search, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static const char * static const char *
str_8bit_search_last (const char *text, const char *search, int case_sen) str_8bit_search_last (const char *text, const char *search, gboolean case_sen)
{ {
char *fold_text; char *fold_text;
char *fold_search; char *fold_search;
const char *match; const char *match;
fold_text = (case_sen) ? (char *) text : str_8bit_strdown (text); fold_text = case_sen ? (char *) text : str_8bit_strdown (text);
fold_search = (case_sen) ? (char *) search : str_8bit_strdown (search); fold_search = case_sen ? (char *) search : str_8bit_strdown (search);
match = g_strrstr_len (fold_text, -1, fold_search); match = g_strrstr_len (fold_text, -1, fold_search);
if (match != NULL) if (match != NULL)
@ -775,26 +775,23 @@ str_8bit_fix_string (char *text)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static char * static char *
str_8bit_create_key (const char *text, int case_sen) str_8bit_create_key (const char *text, gboolean case_sen)
{ {
return (case_sen) ? (char *) text : str_8bit_strdown (text); return case_sen ? (char *) text : str_8bit_strdown (text);
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static int
str_8bit_key_collate (const char *t1, const char *t2, int case_sen) str_8bit_key_collate (const char *t1, const char *t2, gboolean case_sen)
{ {
if (case_sen) return case_sen ? strcmp (t1, t2) : strcoll (t1, t2);
return strcmp (t1, t2);
else
return strcoll (t1, t2);
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static void static void
str_8bit_release_key (char *key, int case_sen) str_8bit_release_key (char *key, gboolean case_sen)
{ {
if (!case_sen) if (!case_sen)
g_free (key); g_free (key);

View File

@ -1,7 +1,7 @@
/* /*
ASCII strings utilities ASCII strings utilities
Copyright (C) 2007-2017 Copyright (C) 2007-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:
@ -57,11 +57,11 @@ str_ascii_insert_replace_char (GString * buffer)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_ascii_is_valid_string (const char *text) str_ascii_is_valid_string (const char *text)
{ {
(void) text; (void) text;
return 1; return TRUE;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -116,7 +116,7 @@ str_ascii_cprev_noncomb_char (const char **text, const char *begin)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_ascii_isspace (const char *text) str_ascii_isspace (const char *text)
{ {
return g_ascii_isspace ((gchar) text[0]); return g_ascii_isspace ((gchar) text[0]);
@ -124,7 +124,7 @@ str_ascii_isspace (const char *text)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_ascii_ispunct (const char *text) str_ascii_ispunct (const char *text)
{ {
return g_ascii_ispunct ((gchar) text[0]); return g_ascii_ispunct ((gchar) text[0]);
@ -132,7 +132,7 @@ str_ascii_ispunct (const char *text)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_ascii_isalnum (const char *text) str_ascii_isalnum (const char *text)
{ {
return g_ascii_isalnum ((gchar) text[0]); return g_ascii_isalnum ((gchar) text[0]);
@ -140,7 +140,7 @@ str_ascii_isalnum (const char *text)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_ascii_isdigit (const char *text) str_ascii_isdigit (const char *text)
{ {
return g_ascii_isdigit ((gchar) text[0]); return g_ascii_isdigit ((gchar) text[0]);
@ -148,7 +148,7 @@ str_ascii_isdigit (const char *text)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_ascii_isprint (const char *text) str_ascii_isprint (const char *text)
{ {
return g_ascii_isprint ((gchar) text[0]); return g_ascii_isprint ((gchar) text[0]);
@ -169,26 +169,26 @@ static int
str_ascii_toupper (const char *text, char **out, size_t * remain) str_ascii_toupper (const char *text, char **out, size_t * remain)
{ {
if (*remain <= 1) if (*remain <= 1)
return 0; return FALSE;
(*out)[0] = (char) g_ascii_toupper ((gchar) text[0]); (*out)[0] = (char) g_ascii_toupper ((gchar) text[0]);
(*out)++; (*out)++;
(*remain)--; (*remain)--;
return 1; return TRUE;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_ascii_tolower (const char *text, char **out, size_t * remain) str_ascii_tolower (const char *text, char **out, size_t * remain)
{ {
if (*remain <= 1) if (*remain <= 1)
return 0; return FALSE;
(*out)[0] = (char) g_ascii_tolower ((gchar) text[0]); (*out)[0] = (char) g_ascii_tolower ((gchar) text[0]);
(*out)++; (*out)++;
(*remain)--; (*remain)--;
return 1; return TRUE;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -551,7 +551,7 @@ str_ascii_column_to_pos (const char *text, size_t pos)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static char * static char *
str_ascii_create_search_needle (const char *needle, int case_sen) str_ascii_create_search_needle (const char *needle, gboolean case_sen)
{ {
(void) case_sen; (void) case_sen;
return (char *) needle; return (char *) needle;
@ -560,7 +560,7 @@ str_ascii_create_search_needle (const char *needle, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static void static void
str_ascii_release_search_needle (char *needle, int case_sen) str_ascii_release_search_needle (char *needle, gboolean case_sen)
{ {
(void) case_sen; (void) case_sen;
(void) needle; (void) needle;
@ -570,14 +570,14 @@ str_ascii_release_search_needle (char *needle, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static const char * static const char *
str_ascii_search_first (const char *text, const char *search, int case_sen) str_ascii_search_first (const char *text, const char *search, gboolean case_sen)
{ {
char *fold_text; char *fold_text;
char *fold_search; char *fold_search;
const char *match; const char *match;
fold_text = (case_sen) ? (char *) text : g_ascii_strdown (text, -1); fold_text = case_sen ? (char *) text : g_ascii_strdown (text, -1);
fold_search = (case_sen) ? (char *) search : g_ascii_strdown (search, -1); fold_search = case_sen ? (char *) search : g_ascii_strdown (search, -1);
match = g_strstr_len (fold_text, -1, fold_search); match = g_strstr_len (fold_text, -1, fold_search);
if (match != NULL) if (match != NULL)
@ -600,14 +600,14 @@ str_ascii_search_first (const char *text, const char *search, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static const char * static const char *
str_ascii_search_last (const char *text, const char *search, int case_sen) str_ascii_search_last (const char *text, const char *search, gboolean case_sen)
{ {
char *fold_text; char *fold_text;
char *fold_search; char *fold_search;
const char *match; const char *match;
fold_text = (case_sen) ? (char *) text : g_ascii_strdown (text, -1); fold_text = case_sen ? (char *) text : g_ascii_strdown (text, -1);
fold_search = (case_sen) ? (char *) search : g_ascii_strdown (search, -1); fold_search = case_sen ? (char *) search : g_ascii_strdown (search, -1);
match = g_strrstr_len (fold_text, -1, fold_search); match = g_strrstr_len (fold_text, -1, fold_search);
if (match != NULL) if (match != NULL)
@ -671,7 +671,7 @@ str_ascii_fix_string (char *text)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static char * static char *
str_ascii_create_key (const char *text, int case_sen) str_ascii_create_key (const char *text, gboolean case_sen)
{ {
(void) case_sen; (void) case_sen;
return (char *) text; return (char *) text;
@ -680,15 +680,15 @@ str_ascii_create_key (const char *text, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static int
str_ascii_key_collate (const char *t1, const char *t2, int case_sen) str_ascii_key_collate (const char *t1, const char *t2, gboolean case_sen)
{ {
return (case_sen) ? strcmp (t1, t2) : g_ascii_strcasecmp (t1, t2); return case_sen ? strcmp (t1, t2) : g_ascii_strcasecmp (t1, t2);
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static void static void
str_ascii_release_key (char *key, int case_sen) str_ascii_release_key (char *key, gboolean case_sen)
{ {
(void) key; (void) key;
(void) case_sen; (void) case_sen;

View File

@ -1,7 +1,7 @@
/* /*
UTF-8 strings utilities UTF-8 strings utilities
Copyright (C) 2007-2017 Copyright (C) 2007-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:
@ -84,7 +84,7 @@ str_utf8_insert_replace_char (GString * buffer)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_utf8_is_valid_string (const char *text) str_utf8_is_valid_string (const char *text)
{ {
return g_utf8_validate (text, -1, NULL); return g_utf8_validate (text, -1, NULL);
@ -171,7 +171,7 @@ str_utf8_fix_string (char *text)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_utf8_isspace (const char *text) str_utf8_isspace (const char *text)
{ {
gunichar uni; gunichar uni;
@ -182,7 +182,7 @@ str_utf8_isspace (const char *text)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_utf8_ispunct (const char *text) str_utf8_ispunct (const char *text)
{ {
gunichar uni; gunichar uni;
@ -193,7 +193,7 @@ str_utf8_ispunct (const char *text)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_utf8_isalnum (const char *text) str_utf8_isalnum (const char *text)
{ {
gunichar uni; gunichar uni;
@ -204,7 +204,7 @@ str_utf8_isalnum (const char *text)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_utf8_isdigit (const char *text) str_utf8_isdigit (const char *text)
{ {
gunichar uni; gunichar uni;
@ -215,7 +215,7 @@ str_utf8_isdigit (const char *text)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_utf8_isprint (const char *ch) str_utf8_isprint (const char *ch)
{ {
gunichar uni; gunichar uni;
@ -273,7 +273,7 @@ str_utf8_cprev_noncomb_char (const char **text, const char *begin)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_utf8_toupper (const char *text, char **out, size_t * remain) str_utf8_toupper (const char *text, char **out, size_t * remain)
{ {
gunichar uni; gunichar uni;
@ -281,22 +281,22 @@ str_utf8_toupper (const char *text, char **out, size_t * remain)
uni = g_utf8_get_char_validated (text, -1); uni = g_utf8_get_char_validated (text, -1);
if (uni == (gunichar) (-1) || uni == (gunichar) (-2)) if (uni == (gunichar) (-1) || uni == (gunichar) (-2))
return 0; return FALSE;
uni = g_unichar_toupper (uni); uni = g_unichar_toupper (uni);
left = g_unichar_to_utf8 (uni, NULL); left = g_unichar_to_utf8 (uni, NULL);
if (left >= *remain) if (left >= *remain)
return 0; return FALSE;
left = g_unichar_to_utf8 (uni, *out); left = g_unichar_to_utf8 (uni, *out);
(*out) += left; (*out) += left;
(*remain) -= left; (*remain) -= left;
return 1; return TRUE;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static gboolean
str_utf8_tolower (const char *text, char **out, size_t * remain) str_utf8_tolower (const char *text, char **out, size_t * remain)
{ {
gunichar uni; gunichar uni;
@ -304,17 +304,17 @@ str_utf8_tolower (const char *text, char **out, size_t * remain)
uni = g_utf8_get_char_validated (text, -1); uni = g_utf8_get_char_validated (text, -1);
if (uni == (gunichar) (-1) || uni == (gunichar) (-2)) if (uni == (gunichar) (-1) || uni == (gunichar) (-2))
return 0; return FALSE;
uni = g_unichar_tolower (uni); uni = g_unichar_tolower (uni);
left = g_unichar_to_utf8 (uni, NULL); left = g_unichar_to_utf8 (uni, NULL);
if (left >= *remain) if (left >= *remain)
return 0; return FALSE;
left = g_unichar_to_utf8 (uni, *out); left = g_unichar_to_utf8 (uni, *out);
(*out) += left; (*out) += left;
(*remain) -= left; (*remain) -= left;
return 1; return TRUE;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -956,7 +956,7 @@ str_utf8_column_to_pos (const char *text, size_t pos)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static char * static char *
str_utf8_create_search_needle (const char *needle, int case_sen) str_utf8_create_search_needle (const char *needle, gboolean case_sen)
{ {
char *fold, *result; char *fold, *result;
@ -966,7 +966,6 @@ str_utf8_create_search_needle (const char *needle, int case_sen)
if (case_sen) if (case_sen)
return g_utf8_normalize (needle, -1, G_NORMALIZE_ALL); return g_utf8_normalize (needle, -1, G_NORMALIZE_ALL);
fold = g_utf8_casefold (needle, -1); fold = g_utf8_casefold (needle, -1);
result = g_utf8_normalize (fold, -1, G_NORMALIZE_ALL); result = g_utf8_normalize (fold, -1, G_NORMALIZE_ALL);
g_free (fold); g_free (fold);
@ -976,7 +975,7 @@ str_utf8_create_search_needle (const char *needle, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static void static void
str_utf8_release_search_needle (char *needle, int case_sen) str_utf8_release_search_needle (char *needle, gboolean case_sen)
{ {
(void) case_sen; (void) case_sen;
g_free (needle); g_free (needle);
@ -985,7 +984,7 @@ str_utf8_release_search_needle (char *needle, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static const char * static const char *
str_utf8_search_first (const char *text, const char *search, int case_sen) str_utf8_search_first (const char *text, const char *search, gboolean case_sen)
{ {
char *fold_text; char *fold_text;
char *deco_text; char *deco_text;
@ -993,7 +992,7 @@ str_utf8_search_first (const char *text, const char *search, int case_sen)
const char *result = NULL; const char *result = NULL;
const char *m; const char *m;
fold_text = (case_sen) ? (char *) text : g_utf8_casefold (text, -1); fold_text = case_sen ? (char *) text : g_utf8_casefold (text, -1);
deco_text = g_utf8_normalize (fold_text, -1, G_NORMALIZE_ALL); deco_text = g_utf8_normalize (fold_text, -1, G_NORMALIZE_ALL);
match = deco_text; match = deco_text;
@ -1029,7 +1028,7 @@ str_utf8_search_first (const char *text, const char *search, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static const char * static const char *
str_utf8_search_last (const char *text, const char *search, int case_sen) str_utf8_search_last (const char *text, const char *search, gboolean case_sen)
{ {
char *fold_text; char *fold_text;
char *deco_text; char *deco_text;
@ -1037,7 +1036,7 @@ str_utf8_search_last (const char *text, const char *search, int case_sen)
const char *result = NULL; const char *result = NULL;
const char *m; const char *m;
fold_text = (case_sen) ? (char *) text : g_utf8_casefold (text, -1); fold_text = case_sen ? (char *) text : g_utf8_casefold (text, -1);
deco_text = g_utf8_normalize (fold_text, -1, G_NORMALIZE_ALL); deco_text = g_utf8_normalize (fold_text, -1, G_NORMALIZE_ALL);
do do
@ -1343,7 +1342,7 @@ str_utf8_caseprefix (const char *text, const char *prefix)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static char * static char *
str_utf8_create_key_gen (const char *text, int case_sen, str_utf8_create_key_gen (const char *text, gboolean case_sen,
gchar * (*keygen) (const gchar * text, gssize size)) gchar * (*keygen) (const gchar * text, gssize size))
{ {
char *result; char *result;
@ -1417,7 +1416,7 @@ str_utf8_create_key_gen (const char *text, int case_sen,
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static char * static char *
str_utf8_create_key (const char *text, int case_sen) str_utf8_create_key (const char *text, gboolean case_sen)
{ {
return str_utf8_create_key_gen (text, case_sen, g_utf8_collate_key); return str_utf8_create_key_gen (text, case_sen, g_utf8_collate_key);
} }
@ -1426,7 +1425,7 @@ str_utf8_create_key (const char *text, int case_sen)
#ifdef MC__USE_STR_UTF8_CREATE_KEY_FOR_FILENAME #ifdef MC__USE_STR_UTF8_CREATE_KEY_FOR_FILENAME
static char * static char *
str_utf8_create_key_for_filename (const char *text, int case_sen) str_utf8_create_key_for_filename (const char *text, gboolean case_sen)
{ {
return str_utf8_create_key_gen (text, case_sen, g_utf8_collate_key_for_filename); return str_utf8_create_key_gen (text, case_sen, g_utf8_collate_key_for_filename);
} }
@ -1435,7 +1434,7 @@ str_utf8_create_key_for_filename (const char *text, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static int
str_utf8_key_collate (const char *t1, const char *t2, int case_sen) str_utf8_key_collate (const char *t1, const char *t2, gboolean case_sen)
{ {
(void) case_sen; (void) case_sen;
return strcmp (t1, t2); return strcmp (t1, t2);
@ -1444,7 +1443,7 @@ str_utf8_key_collate (const char *t1, const char *t2, int case_sen)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static void static void
str_utf8_release_key (char *key, int case_sen) str_utf8_release_key (char *key, gboolean case_sen)
{ {
(void) case_sen; (void) case_sen;
g_free (key); g_free (key);

View File

@ -1,7 +1,7 @@
/* /*
Compare strings while treating digits characters numerically. Compare strings while treating digits characters numerically.
Copyright (C) 1997-2017 Copyright (C) 1997-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.

View File

@ -1,6 +1,6 @@
/* A more useful interface to strtol. /* A more useful interface to strtol.
Copyright (C) 1995-2017 Copyright (C) 1995-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify

View File

@ -1,7 +1,7 @@
/* /*
Time formatting functions Time formatting functions
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Simple timer for the Midnight Commander. Simple timer for the Midnight Commander.
Copyright (C) 2013-2017 Copyright (C) 2013-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Internal stuff of color setup Internal stuff of color setup
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Color setup for NCurses screen library Color setup for NCurses screen library
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Color setup for S_Lang screen library Color setup for S_Lang screen library
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -2,7 +2,7 @@
Color setup. Color setup.
Interface functions. Interface functions.
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Keyboard support routines. Keyboard support routines.
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -3,7 +3,7 @@
/* /*
Additional keyboard support routines. Additional keyboard support routines.
Copyright (C) 1998-2017 Copyright (C) 1998-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Mouse managing Mouse managing
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -2,7 +2,7 @@
Interface to the terminal controlling library. Interface to the terminal controlling library.
Ncurses wrapper. Ncurses wrapper.
Copyright (C) 2005-2017 Copyright (C) 2005-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -2,7 +2,7 @@
Interface to the terminal controlling library. Interface to the terminal controlling library.
Slang wrapper. Slang wrapper.
Copyright (C) 2005-2017 Copyright (C) 2005-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Interface to the terminal controlling library. Interface to the terminal controlling library.
Copyright (C) 2005-2017 Copyright (C) 2005-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Terminal management xterm and rxvt support Terminal management xterm and rxvt support
Copyright (C) 1995-2017 Copyright (C) 1995-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
X11 support for the Midnight Commander. X11 support for the Midnight Commander.
Copyright (C) 2005-2017 Copyright (C) 2005-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Various utilities Various utilities
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -214,11 +214,7 @@ char *tilde_expand (const char *);
void custom_canonicalize_pathname (char *, CANON_PATH_FLAGS); void custom_canonicalize_pathname (char *, CANON_PATH_FLAGS);
void canonicalize_pathname (char *); void canonicalize_pathname (char *);
#ifdef HAVE_REALPATH
#define mc_realpath realpath
#else
char *mc_realpath (const char *path, char *resolved_path); char *mc_realpath (const char *path, char *resolved_path);
#endif
/* Looks for "magic" bytes at the start of the VFS file to guess the /* Looks for "magic" bytes at the start of the VFS file to guess the
* compression type. Side effect: modifies the file position. */ * compression type. Side effect: modifies the file position. */

View File

@ -1,7 +1,7 @@
/* /*
Various utilities - Unix variants Various utilities - Unix variants
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:
@ -454,6 +454,7 @@ my_systemv (const char *command, char *const argv[])
execvp (command, argv); execvp (command, argv);
my_exit (127); /* Exec error */ my_exit (127); /* Exec error */
} }
MC_FALLTHROUGH;
/* no break here, or unreachable-code warning by no returning my_exit() */ /* no break here, or unreachable-code warning by no returning my_exit() */
default: default:
status = 0; status = 0;
@ -1093,150 +1094,179 @@ gettimeofday (struct timeval *tp, void *tzp)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
#ifndef HAVE_REALPATH
char * char *
mc_realpath (const char *path, char *resolved_path) mc_realpath (const char *path, char *resolved_path)
{ {
char copy_path[PATH_MAX]; #ifdef HAVE_CHARSET
char got_path[PATH_MAX]; const char *p = path;
char *new_path = got_path; gboolean absolute_path = FALSE;
char *max_path;
if (IS_PATH_SEP (*p))
{
absolute_path = TRUE;
p++;
}
/* ignore encoding: skip "#enc:" */
if (g_str_has_prefix (p, VFS_ENCODING_PREFIX))
{
p += strlen (VFS_ENCODING_PREFIX);
p = strchr (p, PATH_SEP);
if (p != NULL)
{
if (!absolute_path && p[1] != '\0')
p++;
path = p;
}
}
#endif /* HAVE_CHARSET */
#ifdef HAVE_REALPATH
return realpath (path, resolved_path);
#else
{
char copy_path[PATH_MAX];
char got_path[PATH_MAX];
char *new_path = got_path;
char *max_path;
#ifdef S_IFLNK #ifdef S_IFLNK
char link_path[PATH_MAX]; char link_path[PATH_MAX];
int readlinks = 0; int readlinks = 0;
int n; int n;
#endif /* S_IFLNK */ #endif /* S_IFLNK */
/* Make a copy of the source path since we may need to modify it. */ /* Make a copy of the source path since we may need to modify it. */
if (strlen (path) >= PATH_MAX - 2) if (strlen (path) >= PATH_MAX - 2)
{
errno = ENAMETOOLONG;
return NULL;
}
strcpy (copy_path, path);
path = copy_path;
max_path = copy_path + PATH_MAX - 2;
/* If it's a relative pathname use getwd for starters. */
if (!IS_PATH_SEP (*path))
{
new_path = g_get_current_dir ();
if (new_path == NULL)
{ {
strcpy (got_path, ""); errno = ENAMETOOLONG;
return NULL;
}
strcpy (copy_path, path);
path = copy_path;
max_path = copy_path + PATH_MAX - 2;
/* If it's a relative pathname use getwd for starters. */
if (!IS_PATH_SEP (*path))
{
new_path = g_get_current_dir ();
if (new_path == NULL)
{
strcpy (got_path, "");
}
else
{
g_snprintf (got_path, sizeof (got_path), "%s", new_path);
g_free (new_path);
new_path = got_path;
}
new_path += strlen (got_path);
if (!IS_PATH_SEP (new_path[-1]))
*new_path++ = PATH_SEP;
} }
else else
{ {
g_snprintf (got_path, sizeof (got_path), "%s", new_path);
g_free (new_path);
new_path = got_path;
}
new_path += strlen (got_path);
if (!IS_PATH_SEP (new_path[-1]))
*new_path++ = PATH_SEP; *new_path++ = PATH_SEP;
}
else
{
*new_path++ = PATH_SEP;
path++;
}
/* Expand each slash-separated pathname component. */
while (*path != '\0')
{
/* Ignore stray "/". */
if (IS_PATH_SEP (*path))
{
path++; path++;
continue;
} }
if (*path == '.') /* Expand each slash-separated pathname component. */
while (*path != '\0')
{ {
/* Ignore ".". */ /* Ignore stray "/". */
if (path[1] == '\0' || IS_PATH_SEP (path[1])) if (IS_PATH_SEP (*path))
{ {
path++; path++;
continue; continue;
} }
if (path[1] == '.') if (*path == '.')
{ {
if (path[2] == '\0' || IS_PATH_SEP (path[2])) /* Ignore ".". */
if (path[1] == '\0' || IS_PATH_SEP (path[1]))
{ {
path += 2; path++;
/* Ignore ".." at root. */
if (new_path == got_path + 1)
continue;
/* Handle ".." by backing up. */
while (!IS_PATH_SEP ((--new_path)[-1]))
;
continue; continue;
} }
if (path[1] == '.')
{
if (path[2] == '\0' || IS_PATH_SEP (path[2]))
{
path += 2;
/* Ignore ".." at root. */
if (new_path == got_path + 1)
continue;
/* Handle ".." by backing up. */
while (!IS_PATH_SEP ((--new_path)[-1]))
;
continue;
}
}
} }
} /* Safely copy the next pathname component. */
/* Safely copy the next pathname component. */ while (*path != '\0' && !IS_PATH_SEP (*path))
while (*path != '\0' && !IS_PATH_SEP (*path))
{
if (path > max_path)
{ {
errno = ENAMETOOLONG; if (path > max_path)
return NULL; {
errno = ENAMETOOLONG;
return NULL;
}
*new_path++ = *path++;
} }
*new_path++ = *path++;
}
#ifdef S_IFLNK #ifdef S_IFLNK
/* Protect against infinite loops. */ /* Protect against infinite loops. */
if (readlinks++ > MAXSYMLINKS) if (readlinks++ > MAXSYMLINKS)
{
errno = ELOOP;
return NULL;
}
/* See if latest pathname component is a symlink. */
*new_path = '\0';
n = readlink (got_path, link_path, PATH_MAX - 1);
if (n < 0)
{
/* EINVAL means the file exists but isn't a symlink. */
if (errno != EINVAL)
{ {
/* Make sure it's null terminated. */ errno = ELOOP;
*new_path = '\0';
strcpy (resolved_path, got_path);
return NULL; return NULL;
} }
} /* See if latest pathname component is a symlink. */
else *new_path = '\0';
{ n = readlink (got_path, link_path, PATH_MAX - 1);
/* Note: readlink doesn't add the null byte. */ if (n < 0)
link_path[n] = '\0'; {
if (IS_PATH_SEP (*link_path)) /* EINVAL means the file exists but isn't a symlink. */
/* Start over for an absolute symlink. */ if (errno != EINVAL)
new_path = got_path; {
/* Make sure it's null terminated. */
*new_path = '\0';
strcpy (resolved_path, got_path);
return NULL;
}
}
else else
/* Otherwise back up over this component. */
while (!IS_PATH_SEP (*(--new_path)))
;
/* Safe sex check. */
if (strlen (path) + n >= PATH_MAX - 2)
{ {
errno = ENAMETOOLONG; /* Note: readlink doesn't add the null byte. */
return NULL; link_path[n] = '\0';
if (IS_PATH_SEP (*link_path))
/* Start over for an absolute symlink. */
new_path = got_path;
else
/* Otherwise back up over this component. */
while (!IS_PATH_SEP (*(--new_path)))
;
/* Safe sex check. */
if (strlen (path) + n >= PATH_MAX - 2)
{
errno = ENAMETOOLONG;
return NULL;
}
/* Insert symlink contents into path. */
strcat (link_path, path);
strcpy (copy_path, link_path);
path = copy_path;
} }
/* Insert symlink contents into path. */
strcat (link_path, path);
strcpy (copy_path, link_path);
path = copy_path;
}
#endif /* S_IFLNK */ #endif /* S_IFLNK */
*new_path++ = PATH_SEP; *new_path++ = PATH_SEP;
}
/* Delete trailing slash but don't whomp a lone slash. */
if (new_path != got_path + 1 && IS_PATH_SEP (new_path[-1]))
new_path--;
/* Make sure it's null terminated. */
*new_path = '\0';
strcpy (resolved_path, got_path);
return resolved_path;
} }
/* Delete trailing slash but don't whomp a lone slash. */
if (new_path != got_path + 1 && IS_PATH_SEP (new_path[-1]))
new_path--;
/* Make sure it's null terminated. */
*new_path = '\0';
strcpy (resolved_path, got_path);
return resolved_path;
}
#endif /* HAVE_REALPATH */ #endif /* HAVE_REALPATH */
}
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
/** /**

View File

@ -1,7 +1,7 @@
/* /*
Directory cache support Directory cache support
Copyright (C) 1998-2017 Copyright (C) 1998-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:
@ -141,7 +141,7 @@ vfs_s_resolve_symlink (struct vfs_class *me, struct vfs_s_entry *entry, int foll
return entry; return entry;
if (follow == 0) if (follow == 0)
ERRNOR (ELOOP, NULL); ERRNOR (ELOOP, NULL);
if (!entry) if (entry == NULL)
ERRNOR (ENOENT, NULL); ERRNOR (ENOENT, NULL);
if (!S_ISLNK (entry->ino->st.st_mode)) if (!S_ISLNK (entry->ino->st.st_mode))
return entry; return entry;
@ -164,7 +164,7 @@ vfs_s_resolve_symlink (struct vfs_class *me, struct vfs_s_entry *entry, int foll
} }
} }
target = (MEDATA->find_entry) (me, entry->dir->super->root, linkname, follow - 1, 0); target = MEDATA->find_entry (me, entry->dir->super->root, linkname, follow - 1, 0);
g_free (fullname); g_free (fullname);
return target; return target;
} }
@ -300,7 +300,7 @@ vfs_s_find_entry_linear (struct vfs_class *me, struct vfs_s_inode *root,
vfs_die ("find_linear: success but directory is not there\n"); vfs_die ("find_linear: success but directory is not there\n");
#if 0 #if 0
if (!vfs_s_resolve_symlink (me, ent, follow)) if (vfs_s_resolve_symlink (me, ent, follow) == NULL)
{ {
g_free (path); g_free (path);
return NULL; return NULL;
@ -345,7 +345,7 @@ vfs_s_free_super (struct vfs_class *me, struct vfs_s_super *super)
#if 0 #if 0
/* FIXME: We currently leak small ammount of memory, sometimes. Fix it if you can. */ /* FIXME: We currently leak small ammount of memory, sometimes. Fix it if you can. */
if (super->ino_usage) if (super->ino_usage != 0)
message (D_ERROR, "Direntry warning", message (D_ERROR, "Direntry warning",
"Super ino_usage is %d, memory leak", super->ino_usage); "Super ino_usage is %d, memory leak", super->ino_usage);
@ -385,7 +385,7 @@ vfs_s_inode_from_path (const vfs_path_t * vpath, int flags)
vfs_s_find_inode (path_element->class, super, q, vfs_s_find_inode (path_element->class, super, q,
(flags & FL_FOLLOW) != 0 ? LINK_FOLLOW : LINK_NO_FOLLOW, (flags & FL_FOLLOW) != 0 ? LINK_FOLLOW : LINK_NO_FOLLOW,
flags & ~FL_FOLLOW); flags & ~FL_FOLLOW);
if ((!ino) && (!*q)) if (ino == NULL && *q == '\0')
/* We are asking about / directory of ftp server: assume it exists */ /* We are asking about / directory of ftp server: assume it exists */
ino = ino =
vfs_s_find_inode (path_element->class, super, q, vfs_s_find_inode (path_element->class, super, q,
@ -474,7 +474,7 @@ vfs_s_chdir (const vfs_path_t * vpath)
data = vfs_s_opendir (vpath); data = vfs_s_opendir (vpath);
if (data == NULL) if (data == NULL)
return -1; return (-1);
vfs_s_closedir (data); vfs_s_closedir (data);
return 0; return 0;
} }
@ -489,7 +489,7 @@ vfs_s_internal_stat (const vfs_path_t * vpath, struct stat *buf, int flag)
ino = vfs_s_inode_from_path (vpath, flag); ino = vfs_s_inode_from_path (vpath, flag);
if (ino == NULL) if (ino == NULL)
return -1; return (-1);
*buf = ino->st; *buf = ino->st;
return 0; return 0;
} }
@ -506,19 +506,19 @@ vfs_s_readlink (const vfs_path_t * vpath, char *buf, size_t size)
path_element = vfs_path_get_by_index (vpath, -1); path_element = vfs_path_get_by_index (vpath, -1);
ino = vfs_s_inode_from_path (vpath, 0); ino = vfs_s_inode_from_path (vpath, 0);
if (!ino) if (ino == NULL)
return -1; return (-1);
if (!S_ISLNK (ino->st.st_mode)) if (!S_ISLNK (ino->st.st_mode))
{ {
path_element->class->verrno = EINVAL; path_element->class->verrno = EINVAL;
return -1; return (-1);
} }
if (ino->linkname == NULL) if (ino->linkname == NULL)
{ {
path_element->class->verrno = EFAULT; path_element->class->verrno = EFAULT;
return -1; return (-1);
} }
len = strlen (ino->linkname); len = strlen (ino->linkname);
@ -538,8 +538,8 @@ vfs_s_read (void *fh, char *buffer, size_t count)
if (FH->linear == LS_LINEAR_PREOPEN) if (FH->linear == LS_LINEAR_PREOPEN)
{ {
if (!MEDATA->linear_start (me, FH, FH->pos)) if (MEDATA->linear_start (me, FH, FH->pos) == 0)
return -1; return (-1);
} }
if (FH->linear == LS_LINEAR_CLOSED) if (FH->linear == LS_LINEAR_CLOSED)
@ -558,7 +558,7 @@ vfs_s_read (void *fh, char *buffer, size_t count)
return n; return n;
} }
vfs_die ("vfs_s_read: This should not happen\n"); vfs_die ("vfs_s_read: This should not happen\n");
return -1; return (-1);
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -568,10 +568,10 @@ vfs_s_write (void *fh, const char *buffer, size_t count)
{ {
struct vfs_class *me = FH_SUPER->me; struct vfs_class *me = FH_SUPER->me;
if (FH->linear) if (FH->linear != LS_NOT_LINEAR)
vfs_die ("no writing to linear files, please"); vfs_die ("no writing to linear files, please");
FH->changed = 1; FH->changed = TRUE;
if (FH->handle != -1) if (FH->handle != -1)
{ {
ssize_t n; ssize_t n;
@ -597,7 +597,9 @@ vfs_s_lseek (void *fh, off_t offset, int whence)
if (FH->handle != -1) if (FH->handle != -1)
{ /* If we have local file opened, we want to work with it */ { /* If we have local file opened, we want to work with it */
off_t retval = lseek (FH->handle, offset, whence); off_t retval;
retval = lseek (FH->handle, offset, whence);
if (retval == -1) if (retval == -1)
FH->ino->super->me->verrno = errno; FH->ino->super->me->verrno = errno;
return retval; return retval;
@ -635,17 +637,20 @@ vfs_s_close (void *fh)
return (-1); return (-1);
FH_SUPER->fd_usage--; FH_SUPER->fd_usage--;
if (!FH_SUPER->fd_usage) if (FH_SUPER->fd_usage == 0)
vfs_stamp_create (me, FH_SUPER); vfs_stamp_create (me, FH_SUPER);
if (FH->linear == LS_LINEAR_OPEN) if (FH->linear == LS_LINEAR_OPEN)
MEDATA->linear_close (me, fh); MEDATA->linear_close (me, fh);
if (MEDATA->fh_close) if (MEDATA->fh_close != NULL)
res = MEDATA->fh_close (me, fh); res = MEDATA->fh_close (me, fh);
if ((MEDATA->flags & VFS_S_USETMP) && FH->changed && MEDATA->file_store) if ((MEDATA->flags & VFS_S_USETMP) != 0 && FH->changed && MEDATA->file_store != NULL)
{ {
char *s = vfs_s_fullpath (me, FH->ino); char *s;
if (!s)
s = vfs_s_fullpath (me, FH->ino);
if (s == NULL)
res = -1; res = -1;
else else
{ {
@ -728,7 +733,7 @@ vfs_s_getlocalcopy (const vfs_path_t * vpath)
const struct vfs_class *me; const struct vfs_class *me;
me = vfs_path_get_by_index (vpath, -1)->class; me = vfs_path_get_by_index (vpath, -1)->class;
if ((MEDATA->flags & VFS_S_USETMP) != 0 && (fh->ino != NULL)) if ((MEDATA->flags & VFS_S_USETMP) != 0 && fh->ino != NULL)
local = vfs_path_from_str_flags (fh->ino->localname, VPF_NO_CANON); local = vfs_path_from_str_flags (fh->ino->localname, VPF_NO_CANON);
vfs_s_close (fh); vfs_s_close (fh);
@ -770,11 +775,11 @@ vfs_s_setctl (const vfs_path_t * vpath, int ctlop, void *arg)
ino = vfs_s_inode_from_path (vpath, 0); ino = vfs_s_inode_from_path (vpath, 0);
if (ino == NULL) if (ino == NULL)
return 0; return 0;
if (arg) if (arg != NULL)
ino->super->want_stale = 1; ino->super->want_stale = TRUE;
else else
{ {
ino->super->want_stale = 0; ino->super->want_stale = FALSE;
vfs_s_invalidate (path_element->class, ino->super); vfs_s_invalidate (path_element->class, ino->super);
} }
return 1; return 1;
@ -831,16 +836,15 @@ vfs_s_dir_uptodate (struct vfs_class *me, struct vfs_s_inode *ino)
{ {
struct timeval tim; struct timeval tim;
if (MEDATA->flush) if (MEDATA->flush != 0)
{ {
MEDATA->flush = 0; MEDATA->flush = 0;
return 0; return 0;
} }
gettimeofday (&tim, NULL); gettimeofday (&tim, NULL);
if (tim.tv_sec < ino->timestamp.tv_sec)
return 1; return (tim.tv_sec < ino->timestamp.tv_sec ? 1 : 0);
return 0;
} }
@ -857,7 +861,7 @@ vfs_s_new_inode (struct vfs_class *me, struct vfs_s_super *super, struct stat *i
if (ino == NULL) if (ino == NULL)
return NULL; return NULL;
if (initstat) if (initstat != NULL)
ino->st = *initstat; ino->st = *initstat;
ino->super = super; ino->super = super;
ino->st.st_nlink = 0; ino->st.st_nlink = 0;
@ -917,7 +921,6 @@ vfs_s_new_entry (struct vfs_class *me, const char *name, struct vfs_s_inode *ino
return entry; return entry;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
void void
@ -1047,8 +1050,8 @@ vfs_s_find_inode (struct vfs_class *me, const struct vfs_s_super *super,
if (((MEDATA->flags & VFS_S_REMOTE) == 0) && (*path == '\0')) if (((MEDATA->flags & VFS_S_REMOTE) == 0) && (*path == '\0'))
return super->root; return super->root;
ent = (MEDATA->find_entry) (me, super->root, path, follow, flags); ent = MEDATA->find_entry (me, super->root, path, follow, flags);
return (ent != NULL) ? ent->ino : NULL; return (ent != NULL ? ent->ino : NULL);
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -1072,7 +1075,7 @@ vfs_get_super_by_vpath (const vfs_path_t * vpath)
vfs_path_t *vpath_archive; vfs_path_t *vpath_archive;
path_element = vfs_path_get_by_index (vpath, -1); path_element = vfs_path_get_by_index (vpath, -1);
subclass = ((struct vfs_s_subclass *) path_element->class->data); subclass = (struct vfs_s_subclass *) path_element->class->data;
if (subclass == NULL) if (subclass == NULL)
return NULL; return NULL;
@ -1135,7 +1138,7 @@ vfs_s_get_path (const vfs_path_t * vpath, struct vfs_s_super **archive, int flag
if (super != NULL) if (super != NULL)
goto return_success; goto return_success;
if (flags & FL_NO_OPEN) if ((flags & FL_NO_OPEN) != 0)
{ {
path_element->class->verrno = EIO; path_element->class->verrno = EIO;
return NULL; return NULL;
@ -1143,7 +1146,7 @@ vfs_s_get_path (const vfs_path_t * vpath, struct vfs_s_super **archive, int flag
super = vfs_s_new_super (path_element->class); super = vfs_s_new_super (path_element->class);
subclass = ((struct vfs_s_subclass *) path_element->class->data); subclass = (struct vfs_s_subclass *) path_element->class->data;
if (subclass->open_archive != NULL) if (subclass->open_archive != NULL)
{ {
vfs_path_t *vpath_archive; vfs_path_t *vpath_archive;
@ -1160,9 +1163,9 @@ vfs_s_get_path (const vfs_path_t * vpath, struct vfs_s_super **archive, int flag
path_element->class->verrno = EIO; path_element->class->verrno = EIO;
return NULL; return NULL;
} }
if (!super->name) if (super->name == NULL)
vfs_die ("You have to fill name\n"); vfs_die ("You have to fill name\n");
if (!super->root) if (super->root == NULL)
vfs_die ("You have to fill root inode\n"); vfs_die ("You have to fill root inode\n");
vfs_s_insert_super (path_element->class, super); vfs_s_insert_super (path_element->class, super);
@ -1190,19 +1193,24 @@ vfs_s_invalidate (struct vfs_class *me, struct vfs_s_super *super)
char * char *
vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino) vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino)
{ {
if (!ino->ent) if (ino->ent == NULL)
ERRNOR (EAGAIN, NULL); ERRNOR (EAGAIN, NULL);
if ((MEDATA->flags & VFS_S_USETMP) == 0) if ((MEDATA->flags & VFS_S_USETMP) == 0)
{ {
/* archives */ /* archives */
char *newpath; char *path;
char *path = g_strdup (ino->ent->name);
while (1) path = g_strdup (ino->ent->name);
while (TRUE)
{ {
char *newpath;
ino = ino->ent->dir; ino = ino->ent->dir;
if (ino == ino->super->root) if (ino == ino->super->root)
break; break;
newpath = g_strconcat (ino->ent->name, PATH_SEP_STR, path, (char *) NULL); newpath = g_strconcat (ino->ent->name, PATH_SEP_STR, path, (char *) NULL);
g_free (path); g_free (path);
path = newpath; path = newpath;
@ -1211,7 +1219,7 @@ vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino)
} }
/* remote systems */ /* remote systems */
if ((!ino->ent->dir) || (!ino->ent->dir->ent)) if (ino->ent->dir == NULL || ino->ent->dir->ent == NULL)
return g_strdup (ino->ent->name); return g_strdup (ino->ent->name);
return g_strconcat (ino->ent->dir->ent->name, PATH_SEP_STR, ino->ent->name, (char *) NULL); return g_strconcat (ino->ent->dir->ent->name, PATH_SEP_STR, ino->ent->name, (char *) NULL);
@ -1223,7 +1231,7 @@ vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino)
void * void *
vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode) vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode)
{ {
int was_changed = 0; gboolean was_changed = FALSE;
vfs_file_handler_t *fh; vfs_file_handler_t *fh;
struct vfs_s_super *super; struct vfs_s_super *super;
const char *q; const char *q;
@ -1236,19 +1244,20 @@ vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode)
if (q == NULL) if (q == NULL)
return NULL; return NULL;
ino = vfs_s_find_inode (path_element->class, super, q, LINK_FOLLOW, FL_NONE); ino = vfs_s_find_inode (path_element->class, super, q, LINK_FOLLOW, FL_NONE);
if (ino && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))) if (ino != NULL && (flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
{ {
path_element->class->verrno = EEXIST; path_element->class->verrno = EEXIST;
return NULL; return NULL;
} }
if (!ino)
if (ino == NULL)
{ {
char *dirname, *name; char *dirname, *name;
struct vfs_s_entry *ent; struct vfs_s_entry *ent;
struct vfs_s_inode *dir; struct vfs_s_inode *dir;
/* If the filesystem is read-only, disable file creation */ /* If the filesystem is read-only, disable file creation */
if (!(flags & O_CREAT) || !(path_element->class->write)) if ((flags & O_CREAT) == 0 || path_element->class->write == NULL)
return NULL; return NULL;
dirname = g_path_get_dirname (q); dirname = g_path_get_dirname (q);
@ -1260,6 +1269,7 @@ vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode)
g_free (name); g_free (name);
return NULL; return NULL;
} }
ent = vfs_s_generate_entry (path_element->class, name, dir, 0755); ent = vfs_s_generate_entry (path_element->class, name, dir, 0755);
ino = ent->ino; ino = ent->ino;
vfs_s_insert_entry (path_element->class, dir, ent); vfs_s_insert_entry (path_element->class, dir, ent);
@ -1282,7 +1292,7 @@ vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode)
} }
g_free (dirname); g_free (dirname);
g_free (name); g_free (name);
was_changed = 1; was_changed = TRUE;
} }
if (S_ISDIR (ino->st.st_mode)) if (S_ISDIR (ino->st.st_mode))
@ -1296,12 +1306,12 @@ vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode)
fh->ino = ino; fh->ino = ino;
fh->handle = -1; fh->handle = -1;
fh->changed = was_changed; fh->changed = was_changed;
fh->linear = 0; fh->linear = LS_NOT_LINEAR;
fh->data = NULL; fh->data = NULL;
if (IS_LINEAR (flags)) if (IS_LINEAR (flags))
{ {
if (VFSDATA (path_element)->linear_start) if (VFSDATA (path_element)->linear_start != NULL)
{ {
vfs_print_message ("%s", _("Starting linear transfer...")); vfs_print_message ("%s", _("Starting linear transfer..."));
fh->linear = LS_LINEAR_PREOPEN; fh->linear = LS_LINEAR_PREOPEN;
@ -1379,7 +1389,7 @@ vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino)
vfs_path_t *tmp_vpath; vfs_path_t *tmp_vpath;
if ((MEDATA->flags & VFS_S_USETMP) == 0) if ((MEDATA->flags & VFS_S_USETMP) == 0)
return -1; return (-1);
memset (&fh, 0, sizeof (fh)); memset (&fh, 0, sizeof (fh));
@ -1395,16 +1405,17 @@ vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino)
goto error_4; goto error_4;
} }
if (!MEDATA->linear_start (me, &fh, 0)) if (MEDATA->linear_start (me, &fh, 0) == 0)
goto error_3; goto error_3;
/* Clear the interrupt status */ /* Clear the interrupt status */
tty_got_interrupt (); tty_got_interrupt ();
tty_enable_interrupt_key (); tty_enable_interrupt_key ();
while ((n = MEDATA->linear_read (me, &fh, buffer, sizeof (buffer)))) while ((n = MEDATA->linear_read (me, &fh, buffer, sizeof (buffer))) != 0)
{ {
int t; int t;
if (n < 0) if (n < 0)
goto error_1; goto error_1;
@ -1438,7 +1449,7 @@ vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino)
error_4: error_4:
MC_PTR_FREE (ino->localname); MC_PTR_FREE (ino->localname);
g_free (fh.data); g_free (fh.data);
return -1; return (-1);
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -1453,10 +1464,8 @@ vfs_s_init_class (struct vfs_class *vclass, struct vfs_s_subclass *sub)
vclass->open = vfs_s_open; vclass->open = vfs_s_open;
vclass->close = vfs_s_close; vclass->close = vfs_s_close;
vclass->read = vfs_s_read; vclass->read = vfs_s_read;
if (!(sub->flags & VFS_S_READONLY)) if ((sub->flags & VFS_S_READONLY) == 0)
{
vclass->write = vfs_s_write; vclass->write = vfs_s_write;
}
vclass->opendir = vfs_s_opendir; vclass->opendir = vfs_s_opendir;
vclass->readdir = vfs_s_readdir; vclass->readdir = vfs_s_readdir;
vclass->closedir = vfs_s_closedir; vclass->closedir = vfs_s_closedir;
@ -1509,13 +1518,14 @@ vfs_s_select_on_two (int fd1, int fd2)
fd_set set; fd_set set;
struct timeval time_out; struct timeval time_out;
int v; int v;
int maxfd = (fd1 > fd2 ? fd1 : fd2) + 1; int maxfd = MAX (fd1, fd2) + 1;
time_out.tv_sec = 1; time_out.tv_sec = 1;
time_out.tv_usec = 0; time_out.tv_usec = 0;
FD_ZERO (&set); FD_ZERO (&set);
FD_SET (fd1, &set); FD_SET (fd1, &set);
FD_SET (fd2, &set); FD_SET (fd2, &set);
v = select (maxfd, &set, 0, 0, &time_out); v = select (maxfd, &set, 0, 0, &time_out);
if (v <= 0) if (v <= 0)
return v; return v;
@ -1523,7 +1533,7 @@ vfs_s_select_on_two (int fd1, int fd2)
return 1; return 1;
if (FD_ISSET (fd2, &set)) if (FD_ISSET (fd2, &set))
return 2; return 2;
return -1; return (-1);
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -1539,30 +1549,34 @@ vfs_s_get_line (struct vfs_class *me, int sock, char *buf, int buf_len, char ter
{ {
if (read (sock, buf, sizeof (char)) <= 0) if (read (sock, buf, sizeof (char)) <= 0)
return 0; return 0;
if (logfile)
if (logfile != NULL)
{ {
size_t ret1; size_t ret1;
int ret2; int ret2;
ret1 = fwrite (buf, 1, 1, logfile); ret1 = fwrite (buf, 1, 1, logfile);
ret2 = fflush (logfile); ret2 = fflush (logfile);
(void) ret1; (void) ret1;
(void) ret2; (void) ret2;
} }
if (*buf == term) if (*buf == term)
{ {
*buf = 0; *buf = '\0';
return 1; return 1;
} }
} }
/* Line is too long - terminate buffer and discard the rest of line */ /* Line is too long - terminate buffer and discard the rest of line */
*buf = 0; *buf = '\0';
while (read (sock, &c, sizeof (c)) > 0) while (read (sock, &c, sizeof (c)) > 0)
{ {
if (logfile) if (logfile != NULL)
{ {
size_t ret1; size_t ret1;
int ret2; int ret2;
ret1 = fwrite (&c, 1, 1, logfile); ret1 = fwrite (&c, 1, 1, logfile);
ret2 = fflush (logfile); ret2 = fflush (logfile);
(void) ret1; (void) ret1;
@ -1632,10 +1646,13 @@ vfs_s_normalize_filename_leading_spaces (struct vfs_s_inode *root_inode, size_t
for (iter = root_inode->subdir; iter != NULL; iter = g_list_next (iter)) for (iter = root_inode->subdir; iter != NULL; iter = g_list_next (iter))
{ {
struct vfs_s_entry *entry = (struct vfs_s_entry *) iter->data; struct vfs_s_entry *entry = (struct vfs_s_entry *) iter->data;
if ((size_t) entry->ino->data_offset > final_num_spaces) if ((size_t) entry->ino->data_offset > final_num_spaces)
{ {
char *source_name = entry->name; char *source_name = entry->name;
char *spacer = g_strnfill (entry->ino->data_offset - final_num_spaces, ' '); char *spacer;
spacer = g_strnfill (entry->ino->data_offset - final_num_spaces, ' ');
entry->name = g_strdup_printf ("%s%s", spacer, source_name); entry->name = g_strdup_printf ("%s%s", spacer, source_name);
g_free (spacer); g_free (spacer);
g_free (source_name); g_free (source_name);

View File

@ -1,7 +1,7 @@
/* /*
Virtual File System garbage collection code Virtual File System garbage collection code
Copyright (C) 2003-2017 Copyright (C) 2003-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Virtual File System: interface functions Virtual File System: interface functions
Copyright (C) 2011-2017 Copyright (C) 2011-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Network utilities for the Midnight Commander Virtual File System. Network utilities for the Midnight Commander Virtual File System.
Copyright (C) 1995-2017 Copyright (C) 1995-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of the Midnight Commander. This file is part of the Midnight Commander.

View File

@ -1,7 +1,7 @@
/* /*
Routines for parsing output from the 'ls' command. Routines for parsing output from the 'ls' command.
Copyright (C) 1988-2017 Copyright (C) 1988-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Copyright (C) 1995, 1996 Miguel de Icaza Copyright (C) 1995, 1996 Miguel de Icaza

View File

@ -1,7 +1,7 @@
/* /*
Virtual File System path handlers Virtual File System path handlers
Copyright (C) 2011-2017 Copyright (C) 2011-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:
@ -236,13 +236,11 @@ static void
vfs_path_url_split (vfs_path_element_t * path_element, const char *path) vfs_path_url_split (vfs_path_element_t * path_element, const char *path)
{ {
char *pcopy; char *pcopy;
const char *pend;
char *colon, *at, *rest; char *colon, *at, *rest;
path_element->port = 0; path_element->port = 0;
pcopy = g_strdup (path); pcopy = g_strdup (path);
pend = pcopy + strlen (pcopy);
/* search for any possible user */ /* search for any possible user */
at = strrchr (pcopy, '@'); at = strrchr (pcopy, '@');
@ -252,9 +250,12 @@ vfs_path_url_split (vfs_path_element_t * path_element, const char *path)
rest = pcopy; rest = pcopy;
else else
{ {
const char *pend;
char *inner_colon; char *inner_colon;
pend = strchr (at, '\0');
*at = '\0'; *at = '\0';
inner_colon = strchr (pcopy, ':'); inner_colon = strchr (pcopy, ':');
if (inner_colon != NULL) if (inner_colon != NULL)
{ {
@ -280,9 +281,9 @@ vfs_path_url_split (vfs_path_element_t * path_element, const char *path)
colon = strchr (++rest, ']'); colon = strchr (++rest, ']');
if (colon != NULL) if (colon != NULL)
{ {
colon[0] = '\0'; *colon = '\0';
colon[1] = '\0';
colon++; colon++;
*colon = '\0';
path_element->ipv6 = TRUE; path_element->ipv6 = TRUE;
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
Utilities for VFS modules. Utilities for VFS modules.
Copyright (C) 1988-2017 Copyright (C) 1988-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Copyright (C) 1995, 1996 Miguel de Icaza Copyright (C) 1995, 1996 Miguel de Icaza
@ -177,13 +177,13 @@ int
vfs_mkstemps (vfs_path_t ** pname_vpath, const char *prefix, const char *param_basename) vfs_mkstemps (vfs_path_t ** pname_vpath, const char *prefix, const char *param_basename)
{ {
const char *p; const char *p;
char *suffix, *q; GString *suffix;
int shift; int shift;
int fd; int fd;
/* Strip directories */ /* Strip directories */
p = strrchr (param_basename, PATH_SEP); p = strrchr (param_basename, PATH_SEP);
if (!p) if (p == NULL)
p = param_basename; p = param_basename;
else else
p++; p++;
@ -193,20 +193,16 @@ vfs_mkstemps (vfs_path_t ** pname_vpath, const char *prefix, const char *param_b
if (shift > 0) if (shift > 0)
p += shift; p += shift;
suffix = g_malloc (MC_MAXPATHLEN); suffix = g_string_sized_new (32);
/* Protection against unusual characters */ /* Protection against unusual characters */
q = suffix; for (; *p != '\0' && *p != '#'; p++)
while (*p && (*p != '#')) if (strchr (".-_@", *p) != NULL || g_ascii_isalnum (*p))
{ g_string_append_c (suffix, *p);
if (strchr (".-_@", *p) || isalnum ((unsigned char) *p))
*q++ = *p; fd = mc_mkstemps (pname_vpath, prefix, suffix->str);
p++; g_string_free (suffix, TRUE);
}
*q = 0;
fd = mc_mkstemps (pname_vpath, prefix, suffix);
g_free (suffix);
return fd; return fd;
} }
@ -240,7 +236,7 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
char *pcopy; char *pcopy;
size_t pcopy_len; size_t pcopy_len;
const char *pend; const char *pend;
char *dir, *colon, *at, *rest; char *colon, *at, *rest;
path_element = g_new0 (vfs_path_element_t, 1); path_element = g_new0 (vfs_path_element_t, 1);
path_element->port = default_port; path_element->port = default_port;
@ -248,10 +244,11 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
pcopy_len = strlen (path); pcopy_len = strlen (path);
pcopy = g_strndup (path, pcopy_len); pcopy = g_strndup (path, pcopy_len);
pend = pcopy + pcopy_len; pend = pcopy + pcopy_len;
dir = pcopy;
if ((flags & URL_NOSLASH) == 0) if ((flags & URL_NOSLASH) == 0)
{ {
char *dir = pcopy;
/* locate path component */ /* locate path component */
while (!IS_PATH_SEP (*dir) && *dir != '\0') while (!IS_PATH_SEP (*dir) && *dir != '\0')
dir++; dir++;
@ -293,8 +290,10 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
} }
if ((flags & URL_USE_ANONYMOUS) == 0) if ((flags & URL_USE_ANONYMOUS) == 0)
{
g_free (path_element->user);
path_element->user = vfs_get_local_username (); path_element->user = vfs_get_local_username ();
}
/* Check if the host comes with a port spec, if so, chop it */ /* Check if the host comes with a port spec, if so, chop it */
if (*rest != '[') if (*rest != '[')
colon = strchr (rest, ':'); colon = strchr (rest, ':');
@ -310,6 +309,7 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
else else
{ {
vfs_path_element_free (path_element); vfs_path_element_free (path_element);
g_free (pcopy);
return NULL; return NULL;
} }
} }
@ -341,6 +341,7 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
} }
path_element->host = g_strdup (rest); path_element->host = g_strdup (rest);
g_free (pcopy);
#ifdef HAVE_CHARSET #ifdef HAVE_CHARSET
path_element->dir.converter = INVALID_CONV; path_element->dir.converter = INVALID_CONV;
#endif #endif

View File

@ -1,7 +1,7 @@
/* /*
Virtual File System switch code Virtual File System switch code
Copyright (C) 1995-2017 Copyright (C) 1995-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: 1995 Miguel de Icaza Written by: 1995 Miguel de Icaza

View File

@ -41,11 +41,6 @@
#define FH ((vfs_file_handler_t *) fh) #define FH ((vfs_file_handler_t *) fh)
#define FH_SUPER FH->ino->super #define FH_SUPER FH->ino->super
#define LS_NOT_LINEAR 0
#define LS_LINEAR_CLOSED 1
#define LS_LINEAR_OPEN 2
#define LS_LINEAR_PREOPEN 3
/*** enums ***************************************************************************************/ /*** enums ***************************************************************************************/
/* For vfs_s_subclass->flags */ /* For vfs_s_subclass->flags */
@ -56,6 +51,14 @@ typedef enum
VFS_S_USETMP = 1L << 2, VFS_S_USETMP = 1L << 2,
} vfs_subclass_flags_t; } vfs_subclass_flags_t;
typedef enum
{
LS_NOT_LINEAR = 0,
LS_LINEAR_CLOSED = 1,
LS_LINEAR_OPEN = 2,
LS_LINEAR_PREOPEN = 3
} vfs_linear_state_t;
/*** structures declarations (and typedefs of structures)*****************************************/ /*** structures declarations (and typedefs of structures)*****************************************/
/* Single connection or archive */ /* Single connection or archive */
@ -66,7 +69,7 @@ struct vfs_s_super
char *name; /* My name, whatever it means */ char *name; /* My name, whatever it means */
int fd_usage; /* Number of open files */ int fd_usage; /* Number of open files */
int ino_usage; /* Usage count of this superblock */ int ino_usage; /* Usage count of this superblock */
int want_stale; /* If set, we do not flush cache properly */ gboolean want_stale; /* If set, we do not flush cache properly */
#ifdef ENABLE_VFS_NET #ifdef ENABLE_VFS_NET
vfs_path_element_t *path_element; vfs_path_element_t *path_element;
#endif /* ENABLE_VFS_NET */ #endif /* ENABLE_VFS_NET */
@ -106,8 +109,8 @@ typedef struct
struct vfs_s_inode *ino; struct vfs_s_inode *ino;
off_t pos; /* This is for module's use */ off_t pos; /* This is for module's use */
int handle; /* This is for module's use, but if != -1, will be mc_close()d */ int handle; /* This is for module's use, but if != -1, will be mc_close()d */
int changed; /* Did this file change? */ gboolean changed; /* Did this file change? */
int linear; /* Is that file open with O_LINEAR? */ vfs_linear_state_t linear; /* Is that file open with O_LINEAR? */
void *data; /* This is for filesystem-specific use */ void *data; /* This is for filesystem-specific use */
} vfs_file_handler_t; } vfs_file_handler_t;

View File

@ -1,7 +1,7 @@
/* /*
Widgets for the Midnight Commander Widgets for the Midnight Commander
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Authors: Authors:

View File

@ -1,7 +1,7 @@
/* /*
Widgets for the Midnight Commander Widgets for the Midnight Commander
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Authors: Authors:

View File

@ -1,7 +1,7 @@
/* /*
Widgets for the Midnight Commander Widgets for the Midnight Commander
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Authors: Authors:

View File

@ -3,7 +3,7 @@
Original idea and code: Oleg "Olegarch" Konovalov <olegarch@linuxinside.com> Original idea and code: Oleg "Olegarch" Konovalov <olegarch@linuxinside.com>
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Dialog box features module for the Midnight Commander Dialog box features module for the Midnight Commander
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of the Midnight Commander. This file is part of the Midnight Commander.

View File

@ -1,7 +1,7 @@
/* /*
Widgets for the Midnight Commander Widgets for the Midnight Commander
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Authors: Authors:

View File

@ -1,7 +1,7 @@
/* /*
Widgets for the Midnight Commander Widgets for the Midnight Commander
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Authors: Authors:

View File

@ -1,7 +1,7 @@
/* /*
Widgets for the Midnight Commander Widgets for the Midnight Commander
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Authors: Authors:

View File

@ -1,7 +1,7 @@
/* /*
Widgets for the Midnight Commander Widgets for the Midnight Commander
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Authors: Authors:

View File

@ -1,7 +1,7 @@
/* /*
Widgets for the Midnight Commander Widgets for the Midnight Commander
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Authors: Authors:
@ -155,14 +155,12 @@ delete_region (WInput * in, int x_first, int x_last)
{ {
int first = MIN (x_first, x_last); int first = MIN (x_first, x_last);
int last = MAX (x_first, x_last); int last = MAX (x_first, x_last);
size_t len;
input_mark_cmd (in, FALSE); input_mark_cmd (in, FALSE);
in->point = first; in->point = first;
last = str_offset_to_pos (in->buffer, last); last = str_offset_to_pos (in->buffer, last);
first = str_offset_to_pos (in->buffer, first); first = str_offset_to_pos (in->buffer, first);
len = strlen (&in->buffer[last]) + 1; str_move (in->buffer + first, in->buffer + last);
memmove (&in->buffer[first], &in->buffer[last], len);
in->charpoint = 0; in->charpoint = 0;
in->need_push = TRUE; in->need_push = TRUE;
} }

View File

@ -2,7 +2,7 @@
Input line filename/username/hostname/variable/command completion. Input line filename/username/hostname/variable/command completion.
(Let mc type for you...) (Let mc type for you...)
Copyright (C) 1995-2017 Copyright (C) 1995-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:
@ -641,7 +641,7 @@ command_completion_function (const char *text, int state, input_complete_t flags
} }
phase++; phase++;
words = bash_builtins; words = bash_builtins;
/* fallthrough */ MC_FALLTHROUGH;
case 1: /* Builtin commands */ case 1: /* Builtin commands */
for (; *words != NULL; words++) for (; *words != NULL; words++)
if (strncmp (*words, u_text, text_len) == 0) if (strncmp (*words, u_text, text_len) == 0)
@ -654,7 +654,7 @@ command_completion_function (const char *text, int state, input_complete_t flags
break; break;
cur_path = path; cur_path = path;
cur_word = NULL; cur_word = NULL;
/* fallthrough */ MC_FALLTHROUGH;
case 2: /* And looking through the $PATH */ case 2: /* And looking through the $PATH */
while (found == NULL) while (found == NULL)
{ {
@ -675,7 +675,7 @@ command_completion_function (const char *text, int state, input_complete_t flags
if (found == NULL) if (found == NULL)
MC_PTR_FREE (cur_word); MC_PTR_FREE (cur_word);
} }
/* fallthrough */ MC_FALLTHROUGH;
default: default:
break; break;
} }
@ -887,11 +887,8 @@ try_complete_find_start_sign (try_complete_automation_state_t * state)
/* don't substitute variable in \$ case */ /* don't substitute variable in \$ case */
if (strutils_is_char_escaped (state->word, state->q)) if (strutils_is_char_escaped (state->word, state->q))
{ {
size_t qlen;
qlen = strlen (state->q);
/* drop '\\' */ /* drop '\\' */
memmove (state->q - 1, state->q, qlen + 1); str_move (state->q - 1, state->q);
/* adjust flags */ /* adjust flags */
state->flags &= ~INPUT_COMPLETE_VARIABLES; state->flags &= ~INPUT_COMPLETE_VARIABLES;
state->q = NULL; state->q = NULL;
@ -1107,7 +1104,7 @@ query_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
{ {
case -1: case -1:
bl = 0; bl = 0;
/* fallthrough */ MC_FALLTHROUGH;
case -2: case -2:
return MSG_HANDLED; return MSG_HANDLED;
default: default:

View File

@ -1,7 +1,7 @@
/* /*
Widgets for the Midnight Commander Widgets for the Midnight Commander
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Authors: Authors:

View File

@ -1,7 +1,7 @@
/* /*
Widget based utility functions. Widget based utility functions.
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Authors: Authors:

View File

@ -1,7 +1,7 @@
/* /*
Widgets for the Midnight Commander Widgets for the Midnight Commander
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Authors: Authors:

View File

@ -1,7 +1,7 @@
/* /*
Pulldown menu code Pulldown menu code
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Widgets for the Midnight Commander Widgets for the Midnight Commander
Copyright (C) 2016-2017 Copyright (C) 2016-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Authors: Authors:

View File

@ -1,7 +1,7 @@
/* /*
Widget based utility functions. Widget based utility functions.
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Authors: Authors:
@ -441,7 +441,7 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
break; break;
} }
} }
/* fall through */ MC_FALLTHROUGH;
case quick_checkbox: case quick_checkbox:
case quick_radio: case quick_radio:
if (item->widget->x != x1) if (item->widget->x != x1)

View File

@ -1,7 +1,7 @@
/* /*
Widgets for the Midnight Commander Widgets for the Midnight Commander
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Authors: Authors:

View File

@ -1,7 +1,7 @@
/* /*
Widgets for the Midnight Commander Widgets for the Midnight Commander
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Authors: Authors:

View File

@ -1,7 +1,7 @@
/* /*
Widget based utility functions. Widget based utility functions.
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Authors: Authors:
@ -105,7 +105,7 @@ query_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
return MSG_HANDLED; return MSG_HANDLED;
} }
/* fallthrough */ MC_FALLTHROUGH;
default: default:
return dlg_default_callback (w, sender, msg, parm, data); return dlg_default_callback (w, sender, msg, parm, data);

View File

@ -0,0 +1,238 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_GCC_FUNC_ATTRIBUTE(ATTRIBUTE)
#
# DESCRIPTION
#
# This macro checks if the compiler supports one of GCC's function
# attributes; many other compilers also provide function attributes with
# the same syntax. Compiler warnings are used to detect supported
# attributes as unsupported ones are ignored by default so quieting
# warnings when using this macro will yield false positives.
#
# The ATTRIBUTE parameter holds the name of the attribute to be checked.
#
# If ATTRIBUTE is supported define HAVE_FUNC_ATTRIBUTE_<ATTRIBUTE>.
#
# The macro caches its result in the ax_cv_have_func_attribute_<attribute>
# variable.
#
# The macro currently supports the following function attributes:
#
# alias
# aligned
# alloc_size
# always_inline
# artificial
# cold
# const
# constructor
# constructor_priority for constructor attribute with priority
# deprecated
# destructor
# dllexport
# dllimport
# error
# externally_visible
# fallthrough
# flatten
# format
# format_arg
# gnu_inline
# hot
# ifunc
# leaf
# malloc
# noclone
# noinline
# nonnull
# noreturn
# nothrow
# optimize
# pure
# sentinel
# sentinel_position
# unused
# used
# visibility
# warning
# warn_unused_result
# weak
# weakref
#
# Unsupported function attributes will be tested with a prototype
# returning an int and not accepting any arguments and the result of the
# check might be wrong or meaningless so use with care.
#
# LICENSE
#
# Copyright (c) 2013 Gabriele Svelto <gabriele.svelto@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 9
AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [
AS_VAR_PUSHDEF([ac_var], [ax_cv_have_func_attribute_$1])
AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([
m4_case([$1],
[alias], [
int foo( void ) { return 0; }
int bar( void ) __attribute__(($1("foo")));
],
[aligned], [
int foo( void ) __attribute__(($1(32)));
],
[alloc_size], [
void *foo(int a) __attribute__(($1(1)));
],
[always_inline], [
inline __attribute__(($1)) int foo( void ) { return 0; }
],
[artificial], [
inline __attribute__(($1)) int foo( void ) { return 0; }
],
[cold], [
int foo( void ) __attribute__(($1));
],
[const], [
int foo( void ) __attribute__(($1));
],
[constructor_priority], [
int foo( void ) __attribute__((__constructor__(65535/2)));
],
[constructor], [
int foo( void ) __attribute__(($1));
],
[deprecated], [
int foo( void ) __attribute__(($1("")));
],
[destructor], [
int foo( void ) __attribute__(($1));
],
[dllexport], [
__attribute__(($1)) int foo( void ) { return 0; }
],
[dllimport], [
int foo( void ) __attribute__(($1));
],
[error], [
int foo( void ) __attribute__(($1("")));
],
[externally_visible], [
int foo( void ) __attribute__(($1));
],
[fallthrough], [
int foo( void ) {switch (0) { case 1: __attribute__(($1)); case 2: break ; }};
],
[flatten], [
int foo( void ) __attribute__(($1));
],
[format], [
int foo(const char *p, ...) __attribute__(($1(printf, 1, 2)));
],
[format_arg], [
char *foo(const char *p) __attribute__(($1(1)));
],
[gnu_inline], [
inline __attribute__(($1)) int foo( void ) { return 0; }
],
[hot], [
int foo( void ) __attribute__(($1));
],
[ifunc], [
int my_foo( void ) { return 0; }
static int (*resolve_foo(void))(void) { return my_foo; }
int foo( void ) __attribute__(($1("resolve_foo")));
],
[leaf], [
__attribute__(($1)) int foo( void ) { return 0; }
],
[malloc], [
void *foo( void ) __attribute__(($1));
],
[noclone], [
int foo( void ) __attribute__(($1));
],
[noinline], [
__attribute__(($1)) int foo( void ) { return 0; }
],
[nonnull], [
int foo(char *p) __attribute__(($1(1)));
],
[noreturn], [
void foo( void ) __attribute__(($1));
],
[nothrow], [
int foo( void ) __attribute__(($1));
],
[optimize], [
__attribute__(($1(3))) int foo( void ) { return 0; }
],
[pure], [
int foo( void ) __attribute__(($1));
],
[sentinel], [
int foo(void *p, ...) __attribute__(($1));
],
[sentinel_position], [
int foo(void *p, ...) __attribute__(($1(1)));
],
[returns_nonnull], [
void *foo( void ) __attribute__(($1));
],
[unused], [
int foo( void ) __attribute__(($1));
],
[used], [
int foo( void ) __attribute__(($1));
],
[visibility], [
int foo_def( void ) __attribute__(($1("default")));
int foo_hid( void ) __attribute__(($1("hidden")));
int foo_int( void ) __attribute__(($1("internal")));
int foo_pro( void ) __attribute__(($1("protected")));
],
[warning], [
int foo( void ) __attribute__(($1("")));
],
[warn_unused_result], [
int foo( void ) __attribute__(($1));
],
[weak], [
int foo( void ) __attribute__(($1));
],
[weakref], [
static int foo( void ) { return 0; }
static int bar( void ) __attribute__(($1("foo")));
],
[
m4_warn([syntax], [Unsupported attribute $1, the test may fail])
int foo( void ) __attribute__(($1));
]
)], [])
],
dnl GCC doesn't exit with an error if an unknown attribute is
dnl provided but only outputs a warning, so accept the attribute
dnl only if no warning were issued.
[AS_IF([test -s conftest.err],
[AS_VAR_SET([ac_var], [no])],
[AS_VAR_SET([ac_var], [yes])])],
[AS_VAR_SET([ac_var], [no])])
])
AS_IF([test yes = AS_VAR_GET([ac_var])],
[AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_FUNC_ATTRIBUTE_$1), 1,
[Define to 1 if the system has the `$1' function attribute])], [])
AS_VAR_POPDEF([ac_var])
])

View File

@ -1,7 +1,7 @@
# serial 31 # serial 32
# Obtaining file system usage information. # Obtaining file system usage information.
# Copyright (C) 1997-1998, 2000-2001, 2003-2016 Free Software Foundation, Inc. # Copyright (C) 1997-1998, 2000-2001, 2003-2017 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -295,17 +295,6 @@ if test $ac_fsusage_space = no; then
fi fi
fi fi
if test $ac_fsusage_space = no; then
# SVR2
# (AIX, HP-UX, OSF/1 already handled above.)
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <sys/filsys.h>
]])],
[AC_DEFINE([STAT_READ_FILSYS], [1],
[Define if there is no specific function for reading file systems usage
information and you have the <sys/filsys.h> header file. (SVR2)])
ac_fsusage_space=yes])
fi
AS_IF([test $ac_fsusage_space = yes], [$1], [$2]) AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
]) ])
@ -342,6 +331,6 @@ choke -- this is a workaround for a Sun-specific problem
# Prerequisites of lib/fsusage.c not done by gl_FILE_SYSTEM_USAGE. # Prerequisites of lib/fsusage.c not done by gl_FILE_SYSTEM_USAGE.
AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA], AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA],
[ [
AC_CHECK_HEADERS([dustat.h sys/fs/s5param.h sys/filsys.h sys/statfs.h]) AC_CHECK_HEADERS([dustat.h sys/fs/s5param.h sys/statfs.h])
gl_STATFS_TRUNCATES gl_STATFS_TRUNCATES
]) ])

View File

@ -63,6 +63,7 @@ dnl Sorted -W options:
mc_CHECK_ONE_CFLAG([-Wformat-security]) mc_CHECK_ONE_CFLAG([-Wformat-security])
mc_CHECK_ONE_CFLAG([-Wformat-signedness]) mc_CHECK_ONE_CFLAG([-Wformat-signedness])
mc_CHECK_ONE_CFLAG([-Wimplicit]) mc_CHECK_ONE_CFLAG([-Wimplicit])
mc_CHECK_ONE_CFLAG([-Wimplicit-fallthrough])
mc_CHECK_ONE_CFLAG([-Wignored-qualifiers]) mc_CHECK_ONE_CFLAG([-Wignored-qualifiers])
mc_CHECK_ONE_CFLAG([-Wlogical-not-parentheses]) mc_CHECK_ONE_CFLAG([-Wlogical-not-parentheses])
mc_CHECK_ONE_CFLAG([-Wmaybe-uninitialized]) mc_CHECK_ONE_CFLAG([-Wmaybe-uninitialized])

View File

@ -1,7 +1,7 @@
/* /*
Handle command line arguments. Handle command line arguments.
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:
@ -831,7 +831,7 @@ mc_setup_by_args (int argc, char **argv, GError ** mcerror)
_("Two files are required to envoke the diffviewer.")); _("Two files are required to envoke the diffviewer."));
return FALSE; return FALSE;
} }
/* fallthrough */ MC_FALLTHROUGH;
#endif /* USE_DIFF_VIEW */ #endif /* USE_DIFF_VIEW */
case MC_RUN_FULL: case MC_RUN_FULL:

View File

@ -2,7 +2,7 @@
/* Background support. /* Background support.
Copyright (C) 1996-2017 Copyright (C) 1996-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Util for external clipboard. Util for external clipboard.
Copyright (C) 2009-2017 Copyright (C) 2009-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by: Written by:

View File

@ -1,7 +1,7 @@
/* /*
Client interface for General purpose Linux console save/restore server Client interface for General purpose Linux console save/restore server
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of the Midnight Commander. This file is part of the Midnight Commander.
@ -42,7 +42,7 @@
#include "lib/unixcompat.h" #include "lib/unixcompat.h"
#include "lib/tty/tty.h" #include "lib/tty/tty.h"
#include "lib/skin.h" /* tty_set_normal_attrs */ #include "lib/tty/color.h" /* tty_set_normal_attrs */
#include "lib/tty/win.h" #include "lib/tty/win.h"
#include "lib/util.h" /* mc_build_filename() */ #include "lib/util.h" /* mc_build_filename() */

View File

@ -11,7 +11,7 @@
Partly rewritten by Jakub Jelinek <jakub@redhat.com>. Partly rewritten by Jakub Jelinek <jakub@redhat.com>.
Copyright (C) 1994-2017 Copyright (C) 1994-2018
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of the Midnight Commander. This file is part of the Midnight Commander.

Some files were not shown because too many files have changed in this diff Show More