1
1

Merge branch '1845_code_cleanup'

* 1845_code_cleanup: (30 commits)
  editcmd.c 'eval_marks': removed unused variable 'diff'
  The check result of g_new(), g_new0(), g_malloc(), g_malloc0() and g_realloc() is useless.
  Remove declaration of unused function.
  Added glib library for mcserv
  rearranging some lines in src_skin_colors.c mc_skin_color_parse_ini_file()
  missing check in src_mcconfig_get.c-mc_config_get_groups()_-2
  Unifying of g_strconcat() calls
  Types accuracy, minor optimization, removed unneeded goto and return.
  Fixed i18n of file operation dialog titles.
  added NULL check before call g_utf8_find_prev_char, g_utf8_get_char_validated for more safety.
  More usage of GLib functions.
  No need to call done_menu() at MC exit.
  Optimization of DLG_RESIZE message handling.
  doxygen: various warning fixes
  Fixed forgotten call of va_end() in mc_log().
  src/boxes.c (configure_vfs): fixed #ifdef directive.
  m4.include/mc-cflags.m4: added -fdiagnostics-show-option (exact warning option)
  configure.ac: guard $CFLAGS with "" in tests
  m4.include/mc-cflags.m4: sorted CFLAGS (no flags were added or removed)
  cflags: enable -Wformat in maintainer mode
  ...
Этот коммит содержится в:
Slava Zanko 2009-12-16 11:11:31 +02:00
родитель a45d0ba6c2 26689fc39e
Коммит a958fc9136
53 изменённых файлов: 440 добавлений и 464 удалений

Просмотреть файл

@ -515,7 +515,11 @@ fi
MC_CHECK_CFLAGS
CFLAGS_OPTS=" -O2 "
CFLAGS_OPTS=""
if test "x$CFLAGS" = "x"; then
CFLAGS_OPTS=" -O2 "
fi
if test x$USE_MAINTAINER_MODE = xyes; then
CFLAGS_OPTS="-g3 -O -ggdb"
@ -530,8 +534,7 @@ AC_ARG_ENABLE(
if test "x$enable_werror" = xyes; then
MC_CHECK_ONE_CFLAG([-Werror])
fi
CFLAGS="$CFLAGS $mc_configured_cflags $CFLAGS_OPTS"
CFLAGS="$mc_configured_cflags $CFLAGS_OPTS $CFLAGS"
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)

Просмотреть файл

@ -123,8 +123,8 @@ typedef struct edit_stack_type {
} edit_stack_type;
struct macro {
short command;
short ch;
unsigned long command;
int ch;
};
/* type for file which is currently being edited */
@ -278,7 +278,7 @@ void edit_mail_dialog (WEdit *edit);
void format_paragraph (WEdit *edit, int force);
/* either command or char_for_insertion must be passed as -1 */
void edit_execute_cmd (WEdit *edit, int command, int char_for_insertion);
void edit_execute_cmd (WEdit *edit, unsigned long command, int char_for_insertion);
#define get_sys_error(s) (s)

Просмотреть файл

@ -140,7 +140,6 @@ int edit_get_byte (WEdit * edit, long byte_index)
char *edit_get_byte_ptr (WEdit * edit, long byte_index)
{
unsigned long p;
if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0)
return NULL;
@ -156,13 +155,11 @@ char *edit_get_buf_ptr (WEdit * edit, long byte_index)
{
unsigned long p;
if (byte_index >= (edit->curs1 + edit->curs2) ) {
byte_index -= 1;
};
if (byte_index >= (edit->curs1 + edit->curs2))
byte_index--;
if ( byte_index < 0 ) {
if (byte_index < 0)
return NULL;
}
if (byte_index >= edit->curs1) {
p = edit->curs1 + edit->curs2 - 1;
@ -185,18 +182,23 @@ int edit_get_utf (WEdit * edit, long byte_index, int *char_width)
return '\n';
}
str = edit_get_byte_ptr (edit, byte_index);
if (str == NULL) {
*char_width = 0;
return 0;
}
res = g_utf8_get_char_validated (str, -1);
if ( res < 0 ) {
if (res < 0) {
ch = *str;
width = 0;
} else {
ch = res;
/* Calculate UTF-8 char width */
next_ch = g_utf8_next_char(str);
if ( next_ch ) {
next_ch = g_utf8_next_char (str);
if (next_ch) {
width = next_ch - str;
} else {
ch = 0;
@ -215,36 +217,41 @@ int edit_get_prev_utf (WEdit * edit, long byte_index, int *char_width)
gchar *next_ch = NULL;
int width = 0;
if ( byte_index > 0 ) {
if (byte_index > 0)
byte_index--;
}
ch = edit_get_utf (edit, byte_index, &width);
if ( width == 1 ) {
*char_width = width;
return ch;
}
if ( byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0 ) {
if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0) {
*char_width = 0;
return 0;
}
ch = edit_get_utf (edit, byte_index, &width);
if (width == 1) {
*char_width = width;
return ch;
}
str = edit_get_byte_ptr (edit, byte_index);
buf = edit_get_buf_ptr (edit, byte_index);
if (str == NULL || buf == NULL) {
*char_width = 0;
return 0;
}
/* get prev utf8 char */
if ( str != buf )
if (str != buf)
str = g_utf8_find_prev_char (buf, str);
res = g_utf8_get_char_validated (str, -1);
if ( res < 0 ) {
if (res < 0) {
ch = *str;
width = 0;
} else {
ch = res;
/* Calculate UTF-8 char width */
next_ch = g_utf8_next_char(str);
if ( next_ch ) {
if (next_ch) {
width = next_ch - str;
} else {
ch = 0;
@ -270,7 +277,7 @@ edit_init_buffers (WEdit *edit)
edit->curs1 = 0;
edit->curs2 = 0;
edit->buffers2[0] = g_malloc (EDIT_BUF_SIZE);
edit->buffers2[0] = g_malloc0 (EDIT_BUF_SIZE);
}
/*
@ -294,7 +301,7 @@ edit_load_file_fast (WEdit *edit, const char *filename)
}
if (!edit->buffers2[buf2])
edit->buffers2[buf2] = g_malloc (EDIT_BUF_SIZE);
edit->buffers2[buf2] = g_malloc0 (EDIT_BUF_SIZE);
mc_read (file,
(char *) edit->buffers2[buf2] + EDIT_BUF_SIZE -
@ -304,7 +311,7 @@ edit_load_file_fast (WEdit *edit, const char *filename)
for (buf = buf2 - 1; buf >= 0; buf--) {
/* edit->buffers2[0] is already allocated */
if (!edit->buffers2[buf])
edit->buffers2[buf] = g_malloc (EDIT_BUF_SIZE);
edit->buffers2[buf] = g_malloc0 (EDIT_BUF_SIZE);
mc_read (file, (char *) edit->buffers2[buf], EDIT_BUF_SIZE);
}
@ -352,7 +359,7 @@ edit_get_filter (const char *filename)
return 0;
quoted_name = name_quote (filename, 0);
l = str_term_width1 (quoted_name);
p = g_malloc (str_term_width1 (all_filters[i].read) + l + 2);
p = g_malloc0 (str_term_width1 (all_filters[i].read) + l + 2);
sprintf (p, all_filters[i].read, quoted_name);
g_free (quoted_name);
return p;
@ -368,7 +375,7 @@ edit_get_write_filter (const char *write_name, const char *filename)
return 0;
writename = name_quote (write_name, 0);
l = str_term_width1 (writename);
p = g_malloc (str_term_width1 (all_filters[i].write) + l + 2);
p = g_malloc0 (str_term_width1 (all_filters[i].write) + l + 2);
sprintf (p, all_filters[i].write, writename);
g_free (writename);
return p;
@ -509,7 +516,7 @@ edit_insert_file (WEdit *edit, const char *filename)
char *buf;
if ((file = mc_open (filename, O_RDONLY | O_BINARY)) == -1)
return 0;
buf = g_malloc (TEMP_BUF_LEN);
buf = g_malloc0 (TEMP_BUF_LEN);
blocklen = mc_read (file, buf, sizeof(VERTICAL_MAGIC));
if (blocklen > 0) {
/* if contain signature VERTICAL_MAGIC tnen it vertical block */
@ -590,7 +597,6 @@ check_file_access (WEdit *edit, const char *filename, struct stat *st)
if (st->st_size >= SIZE_LIMIT) {
g_string_sprintf (errmsg = g_string_new (NULL),
_(" File %s is too large "), filename);
goto cleanup;
}
cleanup:
@ -711,7 +717,7 @@ edit_save_position (WEdit *edit)
static void
edit_purge_widget (WEdit *edit)
{
int len = sizeof (WEdit) - sizeof (Widget);
size_t len = sizeof (WEdit) - sizeof (Widget);
char *start = (char *) edit + sizeof (Widget);
memset (start, 0, len);
edit->macro_i = -1; /* not recording a macro */
@ -793,7 +799,7 @@ edit_init (WEdit *edit, int lines, int columns, const char *filename,
edit_set_filename (edit, filename);
edit->stack_size = START_STACK_SIZE;
edit->stack_size_mask = START_STACK_SIZE - 1;
edit->undo_stack = g_malloc ((edit->stack_size + 10) * sizeof (long));
edit->undo_stack = g_malloc0 ((edit->stack_size + 10) * sizeof (long));
if (edit_load_file (edit)) {
/* edit_load_file already gives an error message */
if (to_free)
@ -888,18 +894,15 @@ edit_clean (WEdit *edit)
return 1;
}
/* returns 1 on success */
int edit_renew (WEdit * edit)
int
edit_renew (WEdit * edit)
{
int lines = edit->num_widget_lines;
int columns = edit->num_widget_columns;
int retval = 1;
edit_clean (edit);
if (!edit_init (edit, lines, columns, "", 0))
retval = 0;
return retval;
return (edit_init (edit, lines, columns, "", 0) != NULL);
}
/*
@ -1068,8 +1071,8 @@ void edit_push_action (WEdit * edit, long c,...)
}
}
edit->undo_stack[sp] = c;
check_bottom:
check_bottom:
edit->stack_pointer = (edit->stack_pointer + 1) & edit->stack_size_mask;
/* if the sp wraps round and catches the stack_bottom then erase
@ -1174,7 +1177,7 @@ edit_insert (WEdit *edit, int c)
/* add a new buffer if we've reached the end of the last one */
if (!(edit->curs1 & M_EDIT_BUF_SIZE))
edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] =
g_malloc (EDIT_BUF_SIZE);
g_malloc0 (EDIT_BUF_SIZE);
/* perform the insertion */
edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE][edit->
@ -1223,7 +1226,7 @@ void edit_insert_ahead (WEdit * edit, int c)
edit->last_get_rule += (edit->last_get_rule >= edit->curs1);
if (!((edit->curs2 + 1) & M_EDIT_BUF_SIZE))
edit->buffers2[(edit->curs2 + 1) >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE);
edit->buffers2[(edit->curs2 + 1) >> S_EDIT_BUF_SIZE] = g_malloc0 (EDIT_BUF_SIZE);
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - (edit->curs2 & M_EDIT_BUF_SIZE) - 1] = c;
edit->last_byte++;
@ -1346,7 +1349,7 @@ int
edit_move_backward_lots (WEdit *edit, long increment)
{
int r, s, t;
unsigned char *p;
unsigned char *p = NULL;
if (increment > edit->curs1)
increment = edit->curs1;
@ -1359,7 +1362,6 @@ edit_move_backward_lots (WEdit *edit, long increment)
r = increment;
s = edit->curs1 & M_EDIT_BUF_SIZE;
p = 0;
if (s > r) {
memqcpy (edit,
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] + t - r,
@ -1386,7 +1388,7 @@ edit_move_backward_lots (WEdit *edit, long increment)
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = p;
else
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] =
g_malloc (EDIT_BUF_SIZE);
g_malloc0 (EDIT_BUF_SIZE);
} else {
g_free (p);
}
@ -1424,7 +1426,7 @@ edit_move_backward_lots (WEdit *edit, long increment)
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = p;
else
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] =
g_malloc (EDIT_BUF_SIZE);
g_malloc0 (EDIT_BUF_SIZE);
} else {
g_free (p);
}
@ -1456,7 +1458,7 @@ void edit_cursor_move (WEdit * edit, long increment)
c = edit_get_byte (edit, edit->curs1 - 1);
if (!((edit->curs2 + 1) & M_EDIT_BUF_SIZE))
edit->buffers2[(edit->curs2 + 1) >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE);
edit->buffers2[(edit->curs2 + 1) >> S_EDIT_BUF_SIZE] = g_malloc0 (EDIT_BUF_SIZE);
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - (edit->curs2 & M_EDIT_BUF_SIZE) - 1] = c;
edit->curs2++;
c = edit->buffers1[(edit->curs1 - 1) >> S_EDIT_BUF_SIZE][(edit->curs1 - 1) & M_EDIT_BUF_SIZE];
@ -1480,7 +1482,7 @@ void edit_cursor_move (WEdit * edit, long increment)
c = edit_get_byte (edit, edit->curs1);
if (!(edit->curs1 & M_EDIT_BUF_SIZE))
edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE);
edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = g_malloc0 (EDIT_BUF_SIZE);
edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE][edit->curs1 & M_EDIT_BUF_SIZE] = c;
edit->curs1++;
c = edit->buffers2[(edit->curs2 - 1) >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - ((edit->curs2 - 1) & M_EDIT_BUF_SIZE) - 1];
@ -1820,10 +1822,8 @@ int line_is_blank (WEdit * edit, long line)
before a non-blank line is reached */
static void edit_move_up_paragraph (WEdit * edit, int scroll)
{
int i;
if (edit->curs_line <= 1) {
i = 0;
} else {
int i = 0;
if (edit->curs_line > 1) {
if (line_is_blank (edit, edit->curs_line)) {
if (line_is_blank (edit, edit->curs_line - 1)) {
for (i = edit->curs_line - 1; i; i--)
@ -2298,7 +2298,7 @@ edit_delete_line (WEdit *edit)
*/
while (edit_get_byte (edit, edit->curs1 - 1) != '\n') {
(void) edit_backspace (edit, 1);
};
}
}
void insert_spaces_tab (WEdit * edit, int half)
@ -2315,9 +2315,8 @@ void insert_spaces_tab (WEdit * edit, int half)
static int is_aligned_on_a_tab (WEdit * edit)
{
edit_update_curs_col (edit);
if ((edit->curs_col % (TAB_SIZE * space_width)) && edit->curs_col % (TAB_SIZE * space_width) != (HALF_TAB_SIZE * space_width))
return 0; /* not alligned on a tab */
return 1;
return !((edit->curs_col % (TAB_SIZE * space_width))
&& edit->curs_col % (TAB_SIZE * space_width) != (HALF_TAB_SIZE * space_width));
}
static int right_of_four_spaces (WEdit *edit)
@ -2377,7 +2376,8 @@ edit_auto_indent (WEdit * edit)
}
}
static void edit_double_newline (WEdit * edit)
static inline void
edit_double_newline (WEdit * edit)
{
edit_insert (edit, '\n');
if (edit_get_byte (edit, edit->curs1) == '\n')
@ -2388,7 +2388,8 @@ static void edit_double_newline (WEdit * edit)
edit_insert (edit, '\n');
}
static void edit_tab_cmd (WEdit * edit)
static inline void
edit_tab_cmd (WEdit * edit)
{
int i;
@ -2412,7 +2413,6 @@ static void edit_tab_cmd (WEdit * edit)
} else {
edit_insert (edit, '\t');
}
return;
}
static void check_and_wrap_line (WEdit * edit)
@ -2441,7 +2441,7 @@ static void check_and_wrap_line (WEdit * edit)
}
}
static void edit_execute_macro (WEdit *edit, struct macro macro[], int n);
static inline void edit_execute_macro (WEdit *edit, struct macro macro[], int n);
void edit_push_key_press (WEdit * edit)
{
@ -2508,15 +2508,17 @@ void edit_find_bracket (WEdit * edit)
last_bracket = edit->bracket;
}
static void edit_goto_matching_bracket (WEdit *edit)
static inline void
edit_goto_matching_bracket (WEdit *edit)
{
long q;
q = edit_get_bracket (edit, 0, 0);
if (q < 0)
return;
edit->bracket = edit->curs1;
edit->force |= REDRAW_PAGE;
edit_cursor_move (edit, q - edit->curs1);
if (q >= 0) {
edit->bracket = edit->curs1;
edit->force |= REDRAW_PAGE;
edit_cursor_move (edit, q - edit->curs1);
}
}
/*
@ -2564,7 +2566,7 @@ static const char * const shell_cmd[] = SHELL_COMMANDS_i;
all of them. It also does not check for the Undo command.
*/
void
edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
edit_execute_cmd (WEdit *edit, unsigned long command, int char_for_insertion)
{
edit->force |= REDRAW_LINE;
@ -2620,12 +2622,10 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
edit_insert (edit, char_for_insertion);
i++;
}
} else {
} else
#endif
edit_insert (edit, char_for_insertion);
#ifdef HAVE_CHARSET
}
#endif
if (option_auto_para_formatting) {
format_paragraph (edit, 0);
edit->force |= REDRAW_PAGE;

Просмотреть файл

@ -366,7 +366,7 @@ edit_save_file (WEdit *edit, const char *filename)
if (this_save_mode == EDIT_DO_BACKUP) {
assert (option_backup_ext != NULL);
tmp = g_strconcat (real_filename, option_backup_ext,(char *) NULL);
tmp = g_strconcat (real_filename, option_backup_ext, (char *) NULL);
if (mc_rename (real_filename, tmp) == -1){
g_free(tmp);
goto error_save;
@ -708,13 +708,13 @@ edit_delete_macro (WEdit * edit, int k)
if (!n || n == EOF)
break;
n = 0;
while (fscanf (f, "%hd %hd, ", &macro[n].command, &macro[n].ch))
while (fscanf (f, "%lu %d, ", &macro[n].command, &macro[n].ch))
n++;
fscanf (f, ";\n");
if (s != k) {
fprintf (g, ("key '%d 0': "), s);
for (i = 0; i < n; i++)
fprintf (g, "%hd %hd, ", macro[i].command, macro[i].ch);
fprintf (g, "%lu %d, ", macro[i].command, macro[i].ch);
fprintf (g, ";\n");
}
}
@ -754,7 +754,7 @@ int edit_save_macro_cmd (WEdit * edit, struct macro macro[], int n)
if (f) {
fprintf (f, ("key '%d 0': "), s);
for (i = 0; i < n; i++)
fprintf (f, "%hd %hd, ", macro[i].command, macro[i].ch);
fprintf (f, "%lu %d, ", macro[i].command, macro[i].ch);
fprintf (f, ";\n");
fclose (f);
if (saved_macros_loaded) {
@ -768,17 +768,16 @@ int edit_save_macro_cmd (WEdit * edit, struct macro macro[], int n)
return 0;
}
void edit_delete_macro_cmd (WEdit * edit)
void
edit_delete_macro_cmd (WEdit * edit)
{
int command;
command = editcmd_dialog_raw_key_query (_ (" Delete macro "),
_ (" Press macro hotkey: "), 1);
if (!command)
return;
edit_delete_macro (edit, command);
if (command != 0)
edit_delete_macro (edit, command);
}
/* return 0 on error */
@ -804,10 +803,10 @@ int edit_load_macro_cmd (WEdit * edit, struct macro macro[], int *n, int k)
saved_macro[i++] = s;
if (!found) {
*n = 0;
while (*n < MAX_MACRO_LENGTH && 2 == fscanf (f, "%hd %hd, ", &macro[*n].command, &macro[*n].ch))
while (*n < MAX_MACRO_LENGTH && 2 == fscanf (f, "%lu %d, ", &macro[*n].command, &macro[*n].ch))
(*n)++;
} else {
while (2 == fscanf (f, "%hd %hd, ", &dummy.command, &dummy.ch));
while (2 == fscanf (f, "%lu %d, ", &dummy.command, &dummy.ch));
}
fscanf (f, ";\n");
if (s == k)
@ -836,7 +835,7 @@ int edit_save_confirm_cmd (WEdit * edit)
return 0;
if (edit_confirm_save) {
f = g_strconcat (_(" Confirm save file? : "), edit->filename, " ", NULL);
f = g_strconcat (_(" Confirm save file? : "), edit->filename, " ", (char *) NULL);
if (edit_query_dialog2 (_(" Save file "), f, _("&Save"), _("&Cancel"))){
g_free(f);
return 0;
@ -1039,7 +1038,6 @@ edit_load_cmd (WEdit *edit, edit_current_file_t what)
int eval_marks (WEdit * edit, long *start_mark, long *end_mark)
{
if (edit->mark1 != edit->mark2) {
int diff;
long start_bol, start_eol;
long end_bol, end_eol;
long col1, col2;
@ -1135,7 +1133,7 @@ edit_insert_column_of_text_from_file (WEdit * edit, int file)
unsigned char *data;
cursor = edit->curs1;
col = edit_get_col (edit);
data = g_malloc (TEMP_BUF_LEN);
data = g_malloc0 (TEMP_BUF_LEN);
while ((blocklen = mc_read (file, (char *) data, TEMP_BUF_LEN)) > 0) {
for (width = 0; width < blocklen; width++) {
if (data[width] == '\n')
@ -1287,7 +1285,7 @@ edit_block_move_cmd (WEdit *edit)
edit_push_action (edit, COLUMN_ON);
column_highlighting = 0;
} else {
copy_buf = g_malloc (end_mark - start_mark);
copy_buf = g_malloc0 (end_mark - start_mark);
edit_cursor_move (edit, start_mark - edit->curs1);
edit_scroll_screen_over_cursor (edit);
count = start_mark;
@ -1480,21 +1478,18 @@ editcmd_find (WEdit *edit, gsize *len)
#define is_digit(x) ((x) >= '0' && (x) <= '9')
static char *
edit_replace_cmd__conv_to_display(char *str)
edit_replace_cmd__conv_to_display (char *str)
{
#ifdef HAVE_CHARSET
GString *tmp;
tmp = str_convert_to_display (str);
if (tmp && tmp->len){
g_free(str);
str = tmp->str;
return g_string_free (tmp, FALSE);
}
g_string_free (tmp, FALSE);
return str;
#else
return g_strdup(str);
g_string_free (tmp, TRUE);
#endif
return g_strdup(str);
}
static char *
@ -1505,14 +1500,12 @@ edit_replace_cmd__conv_to_input(char *str)
tmp = str_convert_to_input (str);
if (tmp && tmp->len){
g_free(str);
str = tmp->str;
return g_string_free (tmp, FALSE);
}
g_string_free (tmp, FALSE);
return str;
#else
g_string_free (tmp, TRUE);
return g_strdup(str);
#endif
return g_strdup(str);
}
/* call with edit = 0 before shutdown to close memory leaks */
void
@ -1544,8 +1537,9 @@ edit_replace_cmd (WEdit *edit, int again)
input1 = g_strdup (saved1 ? saved1 : "");
input2 = g_strdup (saved2 ? saved2 : "");
} else {
char *disp1 = edit_replace_cmd__conv_to_display(g_strdup (saved1 ? saved1 : ""));
char *disp2 = edit_replace_cmd__conv_to_display(g_strdup (saved2 ? saved2 : ""));
char *disp1 = edit_replace_cmd__conv_to_display (saved1 ? saved1 : (char *) "");
char *disp2 = edit_replace_cmd__conv_to_display (saved2 ? saved2 : (char *) "");
char *tmp_inp1, *tmp_inp2;
edit_push_action (edit, KEY_PRESS + edit->start_display);
@ -1559,8 +1553,10 @@ edit_replace_cmd (WEdit *edit, int again)
goto cleanup;
}
tmp_inp1 = input1; tmp_inp2 = input2;
input1 = edit_replace_cmd__conv_to_input(input1);
input2 = edit_replace_cmd__conv_to_input(input2);
g_free(tmp_inp1); g_free(tmp_inp2);
g_free (saved1), saved1 = g_strdup (input1);
g_free (saved2), saved2 = g_strdup (input2);
@ -1855,7 +1851,7 @@ static unsigned char *
edit_get_block (WEdit *edit, long start, long finish, int *l)
{
unsigned char *s, *r;
r = s = g_malloc (finish - start + 1);
r = s = g_malloc0 (finish - start + 1);
if (column_highlighting) {
*l = 0;
/* copy from buffer, excluding chars that are out of the column 'margins' */
@ -1911,7 +1907,7 @@ edit_save_block (WEdit * edit, const char *filename, long start,
unsigned char *buf;
int i = start, end;
len = finish - start;
buf = g_malloc (TEMP_BUF_LEN);
buf = g_malloc0 (TEMP_BUF_LEN);
while (start != finish) {
end = min (finish, start + TEMP_BUF_LEN);
for (; i < end; i++)
@ -2275,28 +2271,26 @@ edit_block_process_cmd (WEdit *edit, const char *shell_cmd, int block)
edit->force |= REDRAW_COMPLETELY;
/* insert result block */
if (block) {
if (edit_block_delete_cmd (edit))
goto edit_block_process_cmd__EXIT;
if (block && !edit_block_delete_cmd (edit)) {
edit_insert_file (edit, b);
if ((block_file = fopen (b, "w")))
block_file = fopen (b, "w");
if (block_file != NULL)
fclose (block_file);
goto edit_block_process_cmd__EXIT;
}
edit_block_process_cmd__EXIT:
g_free(b);
g_free(h);
g_free(o);
return;
g_free (b);
g_free (h);
g_free (o);
}
/* prints at the cursor */
/* returns the number of chars printed */
int edit_print_string (WEdit * e, const char *s)
{
int i = 0;
while (s[i])
edit_execute_cmd (e, -1, (unsigned char) s[i++]);
size_t i = 0;
while (s[i] != '\0')
edit_execute_cmd (e, CK_Insert_Char, (unsigned char) s[i++]);
e->force |= REDRAW_COMPLETELY;
edit_update_screen (e);
return i;
@ -2549,7 +2543,7 @@ edit_complete_word_cmd (WEdit *edit)
[word_start & M_EDIT_BUF_SIZE];
/* match_expr = g_strdup_printf ("\\b%.*s[a-zA-Z_0-9]+", word_len, bufpos); */
match_expr = g_strdup_printf ("(^|\\s+|\\b)%.*s[^\\s\\.=\\+\\[\\]\\(\\)\\,\\;\\:\\\"\\'\\-\\?\\/\\|\\\\\\{\\}\\*\\&\\^\\%%\\$#@\\!]+", word_len, bufpos);
match_expr = g_strdup_printf ("(^|\\s+|\\b)%.*s[^\\s\\.=\\+\\[\\]\\(\\)\\,\\;\\:\\\"\\'\\-\\?\\/\\|\\\\\\{\\}\\*\\&\\^\\%%\\$#@\\!]+", (int)word_len, bufpos);
/* collect the possible completions */
/* start search from begin to end of file */
@ -2730,7 +2724,7 @@ edit_get_match_keyword_cmd (WEdit *edit)
/* prepare match expression */
bufpos = &edit->buffers1[word_start >> S_EDIT_BUF_SIZE]
[word_start & M_EDIT_BUF_SIZE];
match_expr = g_strdup_printf ("%.*s", word_len, bufpos);
match_expr = g_strdup_printf ("%.*s", (int)word_len, bufpos);
ptr = g_get_current_dir ();
path = g_strconcat (ptr, G_DIR_SEPARATOR_S, (char *) NULL);

Просмотреть файл

@ -70,7 +70,8 @@
/* Toggles statusbar draw style */
int simple_statusbar = 0;
static void status_string (WEdit * edit, char *s, int w)
static inline void
status_string (WEdit * edit, char *s, int w)
{
char byte_str[16];
unsigned char cur_byte = 0;
@ -276,7 +277,7 @@ struct line_s {
unsigned int style;
};
static void
static inline void
print_to_widget (WEdit *edit, long row, int start_col, int start_col_real,
long end_col, struct line_s line[], char *status)
{
@ -364,7 +365,6 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
long m1 = 0, m2 = 0, q, c1, c2;
int col, start_col_real;
int cw;
unsigned int c;
int color;
int abn_style;
@ -412,7 +412,7 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
eval_marks (edit, &m1, &m2);
if (row <= edit->total_lines - edit->start_line) {
long tws = 0;
long tws = 0;
if (tty_use_colors () && visible_tws) {
tws = edit_eol (edit, b);
while (tws > b && ((c = edit_get_byte (edit, tws - 1)) == ' '
@ -421,6 +421,8 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
}
while (col <= end_col - edit->start_col) {
int cw = 1;
p->ch = 0;
p->style = 0;
if (q == edit->curs1)
@ -441,7 +443,7 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
if (q >= edit->found_start
&& q < edit->found_start + edit->found_len)
p->style |= MOD_BOLD;
cw = 1;
if ( !edit->utf8 ) {
c = edit_get_byte (edit, q);
} else {
@ -529,16 +531,12 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
if ( !edit->utf8 ) {
c = convert_from_8bit_to_utf_c ((unsigned char) c, edit->converter);
}
} else {
if ( edit->utf8 ) {
c = convert_from_utf_to_current_c (c, edit->converter);
} else {
#endif
c = convert_to_display_c (c);
#ifdef HAVE_CHARSET
}
}
} else if ( edit->utf8 )
c = convert_from_utf_to_current_c (c, edit->converter);
else
#endif
c = convert_to_display_c (c);
/* Caret notation for control characters */
if (c < 32) {
p->ch = '^';
@ -582,7 +580,8 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
}
col++;
break;
}
} /* case */
q++;
if ( cw > 1) {
q += cw - 1;
@ -592,21 +591,23 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
} else {
start_col_real = start_col = 0;
}
p->ch = 0;
p->ch = '\0';
print_to_widget (edit, row, start_col, start_col_real, end_col, line, line_stat);
}
#define key_pending(x) (!is_idle())
static void edit_draw_this_char (WEdit * edit, long curs, long row)
static inline void
edit_draw_this_char (WEdit * edit, long curs, long row)
{
int b = edit_bol (edit, curs);
edit_draw_this_line (edit, b, row, 0, edit->num_widget_columns - 1);
}
/* cursor must be in screen for other than REDRAW_PAGE passed in force */
static void
static inline void
render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
long end_column)
{
@ -711,10 +712,9 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
exit_render:
edit->screen_modified = 0;
return;
}
static void
static inline void
edit_render (WEdit * edit, int page, int row_start, int col_start, int row_end, int col_end)
{
if (page) /* if it was an expose event, 'page' would be set */

Просмотреть файл

@ -157,24 +157,6 @@ edit_event (Gpm_Event *event, void *data)
return MOU_NORMAL;
}
static void
edit_adjust_size (Dlg_head *h)
{
WEdit *edit;
WButtonBar *b;
edit = (WEdit *) find_widget_type (h, edit_callback);
b = find_buttonbar (h);
widget_set_size (&edit->widget, 0, 0, LINES - 1, COLS);
widget_set_size (&b->widget , LINES - 1, 0, 1, COLS);
widget_set_size (&edit_menubar->widget, 0, 0, 1, COLS);
#ifdef RESIZABLE_MENUBAR
menubar_arrange (edit_menubar);
#endif
}
static cb_ret_t
edit_command_execute (WEdit *edit, unsigned long command)
{
@ -187,6 +169,21 @@ edit_command_execute (WEdit *edit, unsigned long command)
return MSG_HANDLED;
}
static inline void
edit_set_buttonbar (WEdit *edit, WButtonBar *bb)
{
buttonbar_set_label (bb, 1, Q_("ButtonBar|Help"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 2, Q_("ButtonBar|Save"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 3, Q_("ButtonBar|Mark"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 4, Q_("ButtonBar|Replac"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 5, Q_("ButtonBar|Copy"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 6, Q_("ButtonBar|Move"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 7, Q_("ButtonBar|Search"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 8, Q_("ButtonBar|Delete"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 9, Q_("ButtonBar|PullDn"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 10, Q_("ButtonBar|Quit"), editor_map, (Widget *) edit);
}
/* Callback for the edit dialog */
static cb_ret_t
edit_dialog_callback (Dlg_head *h, Widget *sender,
@ -197,10 +194,26 @@ edit_dialog_callback (Dlg_head *h, Widget *sender,
WButtonBar *buttonbar;
edit = (WEdit *) find_widget_type (h, edit_callback);
menubar = find_menubar (h);
buttonbar = find_buttonbar (h);
switch (msg) {
case DLG_INIT:
edit_set_buttonbar (edit, buttonbar);
return MSG_HANDLED;
case DLG_RESIZE:
edit_adjust_size (h);
widget_set_size (&edit->widget, 0, 0, LINES - 1, COLS);
widget_set_size (&buttonbar->widget , LINES - 1, 0, 1, COLS);
widget_set_size (&menubar->widget, 0, 0, 1, COLS);
menubar_arrange (menubar);
return MSG_HANDLED;
case DLG_ACTION:
if (sender == (Widget *) menubar)
return send_message ((Widget *) edit, WIDGET_COMMAND, parm);
if (sender == (Widget *) buttonbar)
return send_message ((Widget *) edit, WIDGET_COMMAND, parm);
return MSG_HANDLED;
case DLG_VALIDATE:
@ -208,15 +221,6 @@ edit_dialog_callback (Dlg_head *h, Widget *sender,
h->running = 1;
return MSG_HANDLED;
case DLG_ACTION:
menubar = find_menubar (h);
if (sender == (Widget *) menubar)
return send_message ((Widget *) edit, WIDGET_COMMAND, parm);
buttonbar = find_buttonbar (h);
if (sender == (Widget *) buttonbar)
return send_message ((Widget *) edit, WIDGET_COMMAND, parm);
return MSG_HANDLED;
default:
return default_dlg_callback (h, sender, msg, parm, data);
}
@ -270,23 +274,6 @@ edit_get_file_name (const WEdit *edit)
return edit->filename;
}
static void
edit_set_buttonbar (WEdit *edit)
{
WButtonBar *bb = find_buttonbar (edit->widget.parent);
buttonbar_set_label (bb, 1, Q_("ButtonBar|Help"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 2, Q_("ButtonBar|Save"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 3, Q_("ButtonBar|Mark"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 4, Q_("ButtonBar|Replac"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 5, Q_("ButtonBar|Copy"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 6, Q_("ButtonBar|Move"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 7, Q_("ButtonBar|Search"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 8, Q_("ButtonBar|Delete"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 9, Q_("ButtonBar|PullDn"), editor_map, (Widget *) edit);
buttonbar_set_label (bb, 10, Q_("ButtonBar|Quit"), editor_map, (Widget *) edit);
}
void
edit_update_screen (WEdit * e)
{
@ -311,11 +298,6 @@ edit_callback (Widget *w, widget_msg_t msg, int parm)
WEdit *e = (WEdit *) w;
switch (msg) {
case WIDGET_INIT:
e->force |= REDRAW_COMPLETELY;
edit_set_buttonbar (e);
return MSG_HANDLED;
case WIDGET_DRAW:
e->force |= REDRAW_COMPLETELY;
e->num_widget_lines = LINES - 2;
@ -329,22 +311,22 @@ edit_callback (Widget *w, widget_msg_t msg, int parm)
case WIDGET_KEY:
{
int cmd, ch;
cb_ret_t ret = MSG_NOT_HANDLED;
/* The user may override the access-keys for the menu bar. */
if (edit_translate_key (e, parm, &cmd, &ch)) {
edit_execute_key_command (e, cmd, ch);
edit_update_screen (e);
return MSG_HANDLED;
} else if (edit_drop_hotkey_menu (e, parm)) {
return MSG_HANDLED;
} else {
return MSG_NOT_HANDLED;
}
ret = MSG_HANDLED;
} else if (edit_drop_hotkey_menu (e, parm))
ret = MSG_HANDLED;
return ret;
}
case WIDGET_COMMAND:
/* command from menubar or buttonbar */
return edit_command_execute (wedit, parm);
return edit_command_execute (e, parm);
case WIDGET_CURSOR:
widget_move (&e->widget, e->curs_row + EDIT_TEXT_VERTICAL_OFFSET,

Просмотреть файл

@ -490,7 +490,8 @@ static struct syntax_rule edit_get_rule (WEdit * edit, long byte_index)
return edit->rule;
}
static void translate_rule_to_color (WEdit * edit, struct syntax_rule rule, int *color)
static inline void
translate_rule_to_color (WEdit * edit, struct syntax_rule rule, int *color)
{
struct key_word *k;
@ -1089,11 +1090,10 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file,
/* 1: just collecting a list of names of rule sets */
/* Reallocate the list if required */
if (count % NENTRIES == 0) {
if ((tmpnames = (char**) g_realloc (*pnames, (count + NENTRIES
+ 1) * sizeof (char*))) != NULL)
*pnames = tmpnames;
else
abort ();
tmpnames = (char**) g_try_realloc (*pnames, (count + NENTRIES + 1) * sizeof (char*));
if (tmpnames == NULL)
break;
*pnames = tmpnames;
}
(*pnames)[count++] = g_strdup (args[2]);
(*pnames)[count] = NULL;
@ -1149,20 +1149,21 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file,
static char *get_first_editor_line (WEdit * edit)
{
int i;
size_t i;
static char s[256];
s[0] = '\0';
if (!edit)
if (edit == NULL)
return s;
for (i = 0; i < 255; i++) {
for (i = 0; i < sizeof (s) - 1; i++) {
s[i] = edit_get_byte (edit, i);
if (s[i] == '\n') {
s[i] = '\0';
break;
}
}
s[255] = '\0';
s[sizeof(s) - 1] = '\0';
return s;
}

Просмотреть файл

@ -141,13 +141,13 @@ get_paragraph (WEdit *edit, long p, long q, int indent, int *size)
{
unsigned char *s, *t;
#if 0
t = g_malloc ((q - p) + 2 * (q - p) / option_word_wrap_line_length +
t = g_try_malloc ((q - p) + 2 * (q - p) / option_word_wrap_line_length +
10);
#else
t = g_malloc (2 * (q - p) + 100);
t = g_try_malloc (2 * (q - p) + 100);
#endif
if (!t)
return 0;
if (t == NULL)
return NULL;
for (s = t; p < q; p++, s++) {
if (indent)
if (edit_get_byte (edit, p - 1) == '\n')
@ -160,26 +160,28 @@ get_paragraph (WEdit *edit, long p, long q, int indent, int *size)
return t;
}
static void strip_newlines (unsigned char *t, int size)
static inline void
strip_newlines (unsigned char *t, int size)
{
unsigned char *p = t;
while (size--) {
*p = *p == '\n' ? ' ' : *p;
while (size-- != 0) {
if (*p == '\n')
*p = ' ';
p++;
}
}
/*
This is a copy of the function
int calc_text_pos (WEdit * edit, long b, long *q, int l)
in propfont.c :(
It calculates the number of chars in a line specified to length l in pixels
This function calculates the number of chars in a line specified to length l in pixels
*/
static inline int next_tab_pos (int x)
static inline int
next_tab_pos (int x)
{
return x += tab_width - x % tab_width;
}
static int line_pixel_length (unsigned char *t, long b, int l)
static inline int
line_pixel_length (unsigned char *t, long b, int l)
{
int x = 0, c, xn = 0;
for (;;) {
@ -226,7 +228,7 @@ next_word_start (unsigned char *t, int q, int size)
}
/* find the start of a word */
static int
static inline int
word_start (unsigned char *t, int q, int size)
{
int i = q;
@ -246,7 +248,8 @@ word_start (unsigned char *t, int q, int size)
}
/* replaces ' ' with '\n' to properly format a paragraph */
static void format_this (unsigned char *t, int size, int indent)
static inline void
format_this (unsigned char *t, int size, int indent)
{
int q = 0, ww;
strip_newlines (t, size);
@ -274,7 +277,8 @@ static void format_this (unsigned char *t, int size, int indent)
}
}
static void replace_at (WEdit * edit, long q, int c)
static inline void
replace_at (WEdit * edit, long q, int c)
{
edit_cursor_move (edit, q - edit->curs1);
edit_delete (edit, 1);
@ -282,7 +286,7 @@ static void replace_at (WEdit * edit, long q, int c)
}
/* replaces a block of text */
static void
static inline void
put_paragraph (WEdit * edit, unsigned char *t, long p, int indent, int size)
{
long cursor;
@ -321,7 +325,8 @@ put_paragraph (WEdit * edit, unsigned char *t, long p, int indent, int size)
edit_cursor_move (edit, cursor - edit->curs1); /* restore cursor position */
}
static int test_indent (WEdit * edit, long p, long q)
static inline int
test_indent (WEdit * edit, long p, long q)
{
int indent;
indent = edit_indent_width (edit, p++);

Просмотреть файл

@ -36,35 +36,37 @@ AC_DEFUN([MC_CHECK_ONE_CFLAG],[
AC_DEFUN([MC_CHECK_CFLAGS],[
mc_configured_cflags=""
MC_CHECK_ONE_CFLAG([-Wunused-result])
MC_CHECK_ONE_CFLAG([-Wimplicit-int])
dnl Sorted -f options:
MC_CHECK_ONE_CFLAG([-fdiagnostics-show-option])
dnl MC_CHECK_ONE_CFLAG([-fno-stack-protector])
dnl Sorted -W options:
MC_CHECK_ONE_CFLAG([-Wcomment])
MC_CHECK_ONE_CFLAG([-Wdeclaration-after-statement])
MC_CHECK_ONE_CFLAG([-Wformat])
MC_CHECK_ONE_CFLAG([-Wimplicit-function-declaration])
MC_CHECK_ONE_CFLAG([-Wimplicit-int])
MC_CHECK_ONE_CFLAG([-Wmissing-braces])
MC_CHECK_ONE_CFLAG([-Wmissing-declarations])
MC_CHECK_ONE_CFLAG([-Wmissing-parameter-type])
MC_CHECK_ONE_CFLAG([-Wmissing-prototypes])
MC_CHECK_ONE_CFLAG([-Wnested-externs])
MC_CHECK_ONE_CFLAG([-Wno-long-long])
MC_CHECK_ONE_CFLAG([-Wno-unreachable-code])
MC_CHECK_ONE_CFLAG([-Wparentheses])
MC_CHECK_ONE_CFLAG([-Wpointer-sign])
MC_CHECK_ONE_CFLAG([-Wreturn-type])
dnl MC_CHECK_ONE_CFLAG([-Wsequence-point])
MC_CHECK_ONE_CFLAG([-Wshadow])
MC_CHECK_ONE_CFLAG([-Wsign-compare])
dnl MC_CHECK_ONE_CFLAG([-Wstrict-aliasing])
MC_CHECK_ONE_CFLAG([-Wswitch])
MC_CHECK_ONE_CFLAG([-Wuninitialized])
MC_CHECK_ONE_CFLAG([-Wunused-function])
MC_CHECK_ONE_CFLAG([-Wunused-label])
MC_CHECK_ONE_CFLAG([-Wunused-parameter])
MC_CHECK_ONE_CFLAG([-Wunused-result])
MC_CHECK_ONE_CFLAG([-Wunused-value])
MC_CHECK_ONE_CFLAG([-Wunused-variable])
MC_CHECK_ONE_CFLAG([-Wuninitialized])
MC_CHECK_ONE_CFLAG([-Wdeclaration-after-statement])
MC_CHECK_ONE_CFLAG([-Wshadow])
MC_CHECK_ONE_CFLAG([-Wwrite-strings])
MC_CHECK_ONE_CFLAG([-Wsign-compare])
MC_CHECK_ONE_CFLAG([-Wmissing-parameter-type])
MC_CHECK_ONE_CFLAG([-Wmissing-prototypes])
MC_CHECK_ONE_CFLAG([-Wmissing-declarations])
MC_CHECK_ONE_CFLAG([-Wnested-externs])
MC_CHECK_ONE_CFLAG([-Wno-unreachable-code])
MC_CHECK_ONE_CFLAG([-Wno-long-long])
MC_CHECK_ONE_CFLAG([-Wpointer-sign])
MC_CHECK_ONE_CFLAG([-Wcomment])
dnl MC_CHECK_ONE_CFLAG([-fno-stack-protector])
dnl MC_CHECK_ONE_CFLAG([-Wsequence-point])
dnl MC_CHECK_ONE_CFLAG([-Wstrict-aliasing])
dnl MC_CHECK_ONE_CFLAG([-Wformat])
])

Просмотреть файл

@ -743,7 +743,7 @@ configure_vfs (void)
"[Virtual FS]", confvfs_widgets, FALSE
};
#ifdef SE_NETCODE
#ifdef USE_NETCODE
g_snprintf (buffer3, sizeof (buffer3), "%i", ftpfs_directory_timeout);
#endif
g_snprintf (buffer2, sizeof (buffer2), "%i", vfs_timeout);
@ -1064,7 +1064,7 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain,
return_value = 0;
break;
default:
return_value = g_new (struct smb_authinfo, 1);
return_value = g_try_new (struct smb_authinfo, 1);
if (return_value) {
return_value->host = g_strdup (host);
return_value->share = g_strdup (share);

Просмотреть файл

@ -866,16 +866,17 @@ static WInput *input;
static int min_end;
static int start, end;
static int insert_text (WInput *in, char *text, ssize_t size)
static int
insert_text (WInput *in, char *text, ssize_t size)
{
int buff_len = str_length (in->buffer);
size = min (size, (ssize_t) strlen (text)) + start - end;
if (strlen (in->buffer) + size >= (size_t) in->current_max_size){
/* Expand the buffer */
char *narea = g_realloc (in->buffer, in->current_max_size
+ size + in->field_width);
if (narea){
char *narea = g_try_realloc (in->buffer, in->current_max_size
+ size + in->field_width);
if (narea != NULL) {
in->buffer = narea;
in->current_max_size += size + in->field_width;
}

Просмотреть файл

@ -217,11 +217,9 @@ console_init (void)
memset (&screen_shot, 0, sizeof (screen_shot));
screen_shot.xsize = screen_info.mv_csz;
screen_shot.ysize = screen_info.mv_rsz;
if ((screen_shot.buf =
g_malloc (screen_info.mv_csz * screen_info.mv_rsz * 2)) == NULL)
return;
console_flag = 1;
screen_shot.buf = g_try_malloc (screen_info.mv_csz * screen_info.mv_rsz * 2);
if (screen_shot.buf != NULL)
console_flag = 1;
}
static void

Просмотреть файл

@ -265,8 +265,8 @@ set_zero_dir (dir_list *list)
{
/* Need to grow the *list? */
if (list->size == 0) {
list->list = g_realloc (list->list, sizeof (file_entry) *
(list->size + RESIZE_STEPS));
list->list = g_try_realloc (list->list, sizeof (file_entry) *
(list->size + RESIZE_STEPS));
if (list->list == NULL)
return FALSE;
@ -327,10 +327,9 @@ handle_dirent (dir_list *list, const char *filter, struct dirent *dp,
/* Need to grow the *list? */
if (next_free == list->size) {
list->list =
g_realloc (list->list,
sizeof (file_entry) * (list->size + RESIZE_STEPS));
if (!list->list)
list->list = g_try_realloc (list->list, sizeof (file_entry) *
(list->size + RESIZE_STEPS));
if (list->list == NULL)
return -1;
list->size += RESIZE_STEPS;
}
@ -390,9 +389,9 @@ handle_path (dir_list *list, const char *path,
/* Need to grow the *list? */
if (next_free == list->size){
list->list = g_realloc (list->list, sizeof (file_entry) *
(list->size + RESIZE_STEPS));
if (!list->list)
list->list = g_try_realloc (list->list, sizeof (file_entry) *
(list->size + RESIZE_STEPS));
if (list->list == NULL)
return -1;
list->size += RESIZE_STEPS;
}
@ -488,25 +487,15 @@ static dir_list dir_copy = { 0, 0 };
static void
alloc_dir_copy (int size)
{
int i;
if (dir_copy.size < size){
if (dir_copy.list){
for (i = 0; i < dir_copy.size; i++) {
if (dir_copy.size < size) {
if (dir_copy.list) {
int i;
for (i = 0; i < dir_copy.size; i++)
g_free (dir_copy.list [i].fname);
}
g_free (dir_copy.list);
dir_copy.list = 0;
}
dir_copy.list = g_new (file_entry, size);
for (i = 0; i < size; i++) {
dir_copy.list [i].fname = NULL;
dir_copy.list [i].sort_key = NULL;
dir_copy.list [i].second_sort_key = NULL;
}
dir_copy.list = g_new0 (file_entry, size);
dir_copy.size = size;
}
}

Просмотреть файл

@ -310,7 +310,7 @@ get_file_type_local (const char *filename, char *buf, int buflen)
int read_bytes = 0;
char *tmp = name_quote (filename, 0);
char *command = g_strconcat (FILE_CMD, tmp, " 2>/dev/null", (char *) 0);
char *command = g_strconcat (FILE_CMD, tmp, " 2>/dev/null", (char *) NULL);
FILE *f = popen (command, "r");
g_free (tmp);

Просмотреть файл

@ -240,10 +240,10 @@ check_hardlinks (const char *src_name, const char *dst_name, struct stat *pstat)
message (D_ERROR, MSG_ERROR, _(" Cannot make the hardlink "));
return 0;
}
lp = (struct link *) g_malloc (sizeof (struct link) + strlen (src_name)
+ strlen (dst_name) + 1);
lp = (struct link *) g_try_malloc (sizeof (struct link) + strlen (src_name)
+ strlen (dst_name) + 1);
if (lp) {
char *lpdstname;
char *lpdstname;
lp->vfs = my_vfs;
lp->ino = ino;
lp->dev = dev;
@ -1713,7 +1713,7 @@ panel_operate_generate_prompt (const WPanel *panel, const int operation,
#ifdef ENABLE_NLS
static gboolean i18n_flag = FALSE;
if (!i18n_flag) {
int i;
size_t i;
for (i = sizeof (op_names1) / sizeof (op_names1[0]); i--;)
op_names1[i] = Q_(op_names1[i]);
@ -1818,7 +1818,10 @@ int
panel_operate (void *source_panel, FileOperation operation,
int force_single)
{
WPanel *panel = source_panel;
WPanel *panel = (WPanel *) source_panel;
const gboolean single_entry = force_single || (panel->marked <= 1)
|| (get_current_type () == view_tree);
char *source = NULL;
#ifdef WITH_FULL_PATHS
char *source_with_path = NULL;
@ -1828,8 +1831,6 @@ panel_operate (void *source_panel, FileOperation operation,
char *dest = NULL;
char *temp = NULL;
char *save_cwd = NULL, *save_dest = NULL;
int single_entry = (get_current_type () == view_tree)
|| (panel->marked <= 1) || force_single;
struct stat src_stat, dst_stat;
int i;
FileProgressStatus value;
@ -1841,6 +1842,15 @@ panel_operate (void *source_panel, FileOperation operation,
int dst_result;
int do_bg = 0; /* do background operation? */
#ifdef ENABLE_NLS
static gboolean i18n_flag = FALSE;
if (!i18n_flag) {
for (i = sizeof (op_names1) / sizeof (op_names1[0]); i--;)
op_names[i] = Q_(op_names[i]);
i18n_flag = TRUE;
}
#endif /* ENABLE_NLS */
free_linklist (&linklist);
free_linklist (&dest_dirs);
@ -1937,7 +1947,7 @@ panel_operate (void *source_panel, FileOperation operation,
if (safe_delete)
query_set_sel (1);
i = query_dialog (Q_(op_names[operation]), fmd_buf, D_ERROR, 2,
i = query_dialog (op_names[operation], fmd_buf, D_ERROR, 2,
_("&Yes"), _("&No"));
if (i != 0) {
@ -1959,7 +1969,7 @@ panel_operate (void *source_panel, FileOperation operation,
v = do_background (ctx,
g_strconcat (op_names[operation], ": ",
panel->cwd, NULL));
panel->cwd, (char *) NULL));
if (v == -1) {
message (D_ERROR, MSG_ERROR,
_(" Sorry, I could not put the job in background "));

Просмотреть файл

@ -877,10 +877,6 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation,
char *def_text_secure;
int val;
#ifdef ENABLE_NLS
static gboolean i18n = FALSE;
#endif /* !ENABLE_NLS */
QuickWidget fmd_widgets[] =
{
/* 0 */ QUICK_BUTTON (42, 64, 10, FMDY, N_("&Cancel"), B_CANCEL, NULL),
@ -916,13 +912,6 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation,
g_return_val_if_fail (ctx != NULL, NULL);
#ifdef ENABLE_NLS
if (!i18n) {
for (i = sizeof (op_names) / sizeof (op_names[0]); i--;)
op_names[i] = Q_(op_names[i]);
i18n = TRUE;
}
/* buttons */
for (i = 0; i <= 2 - OFFSET; i++)
fmd_widgets[i].u.button.text = _(fmd_widgets[i].u.button.text);

Просмотреть файл

@ -77,7 +77,7 @@ mc_fhl_new (gboolean need_auto_fill)
mc_fhl_t *fhl;
fhl = g_new0 (mc_fhl_t, 1);
fhl = g_try_new0 (mc_fhl_t, 1);
if (fhl == NULL)
return NULL;

Просмотреть файл

@ -88,9 +88,7 @@ mc_fhl_is_link_to_dir (file_entry * fe)
inline static gboolean
mc_fhl_is_stale_link (file_entry * fe)
{
gboolean is_link = mc_fhl_is_link (fe);
return (!is_link && !mc_fhl_is_file (fe)) || (is_link && (fe->f.stale_link));
return mc_fhl_is_link (fe) ? fe->f.stale_link : !mc_fhl_is_file (fe);
}
inline static gboolean

Просмотреть файл

@ -243,12 +243,11 @@ gboolean
mc_fhl_parse_ini_file (mc_fhl_t * fhl)
{
gchar **group_names, **orig_group_names;
gsize ftype_names_size;
mc_fhl_array_free (fhl);
fhl->filters = g_ptr_array_new ();
orig_group_names = group_names = mc_config_get_groups (fhl->config, &ftype_names_size);
orig_group_names = group_names = mc_config_get_groups (fhl->config, NULL);
if (group_names == NULL)
return FALSE;

Просмотреть файл

@ -1089,8 +1089,7 @@ static void remove_from_hotlist (struct hotlist *entry)
title = g_strconcat (_(" Remove: "),
str_trunc (entry->label, 30),
" ",
NULL);
" ", (char *) NULL);
if (safe_delete)
query_set_sel (1);
@ -1111,8 +1110,7 @@ static void remove_from_hotlist (struct hotlist *entry)
header = g_strconcat (_(" Remove: "),
str_trunc (entry->label, 30),
" ",
NULL);
" ", (char *) NULL);
result = query_dialog (header, _("\n Group not empty.\n Remove it?"),
D_ERROR, 2,
_("&Yes"), _("&No"));

Просмотреть файл

@ -198,9 +198,6 @@ static const char *output_lines_label;
static WButton *bleft_widget, *bright_widget;
/* Declarations for static functions */
static void low_level_change_screen_size (void);
static void _check_split (void)
{
if (_horizontal_split){
@ -696,17 +693,7 @@ setup_panels (void)
update_xterm_title_path ();
}
void
sigwinch_handler (int dummy)
{
(void) dummy;
#if !(defined(USE_NCURSES) || defined(USE_NCURSESW)) /* don't do malloc in a signal handler */
low_level_change_screen_size ();
#endif
winch_flag = 1;
}
static void
static inline void
low_level_change_screen_size (void)
{
#if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4
@ -732,6 +719,16 @@ low_level_change_screen_size (void)
#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */
}
void
sigwinch_handler (int dummy)
{
(void) dummy;
#if !(defined(USE_NCURSES) || defined(USE_NCURSESW)) /* don't do malloc in a signal handler */
low_level_change_screen_size ();
#endif
winch_flag = 1;
}
void
change_screen_size (void)
{
@ -758,7 +755,6 @@ change_screen_size (void)
tty_keypad (TRUE);
tty_nodelay (FALSE);
#endif
setup_panels ();
/* Inform all running dialogs */
d = current_dlg;
@ -767,10 +763,6 @@ change_screen_size (void)
d = d->parent;
}
#ifdef RESIZABLE_MENUBAR
menubar_arrange (the_menubar);
#endif
/* Now, force the redraw */
repaint_screen ();
#endif /* TIOCGWINSZ */
@ -800,7 +792,6 @@ void print_vfs_message (const char *msg, ...)
char str [128];
va_start (ap, msg);
g_vsnprintf (str, sizeof (str), msg, ap);
va_end (ap);

Просмотреть файл

@ -71,5 +71,6 @@ mc_log(const char *fmt, ...)
(void)fclose(f);
}
g_free(logfilename);
va_end(args);
}
}

Просмотреть файл

@ -1508,8 +1508,6 @@ done_mc (void)
{
disable_mouse ();
done_menu ();
/* Setup shutdown
*
* We sync the profiles since the hotlist may have changed, while
@ -1552,6 +1550,11 @@ midnight_callback (Dlg_head *h, Widget *sender,
1, LINES - keybar_visible - 1);
return MSG_HANDLED;
case DLG_RESIZE:
setup_panels ();
menubar_arrange (the_menubar);
return MSG_HANDLED;
case DLG_IDLE:
/* We only need the first idle event to show user menu after start */
set_idle_proc (h, 0);
@ -2162,7 +2165,7 @@ main (int argc, char *argv[])
dlg_set_default_colors ();
if ( ! isInitialized ) {
message (D_ERROR, _("Warning"), error->message);
message (D_ERROR, _("Warning"), "%s", error->message);
g_error_free(error);
error = NULL;
}

Просмотреть файл

@ -68,7 +68,7 @@ mc_config_new_or_override_file (mc_config_t * mc_config, const gchar * ini_path,
fd = mc_open (ini_path, O_WRONLY | O_TRUNC | O_SYNC, 0);
if (fd == -1) {
g_propagate_error (error, g_error_new (mc_main_error_quark() ,0, strerror(errno)));
g_propagate_error (error, g_error_new (mc_main_error_quark() ,0, "%s", strerror(errno)));
return FALSE;
}
@ -80,7 +80,7 @@ mc_config_new_or_override_file (mc_config_t * mc_config, const gchar * ini_path,
if (cur_written == -1) {
mc_util_restore_from_backup_if_possible (ini_path, "~");
g_propagate_error (error, g_error_new (mc_main_error_quark() ,0, strerror(errno)));
g_propagate_error (error, g_error_new (mc_main_error_quark() ,0, "%s", strerror(errno)));
return FALSE;
}
@ -209,6 +209,9 @@ mc_config_read_file (mc_config_t * mc_config, const gchar * ini_path)
groups = mc_config_get_groups (tmp_config, NULL);
if (groups == NULL)
return FALSE;
for (curr_grp = groups; *curr_grp != NULL; curr_grp++) {
keys = mc_config_get_keys (tmp_config, *curr_grp, NULL);
for (curr_key = keys; *curr_key != NULL; curr_key++) {

Просмотреть файл

@ -46,7 +46,8 @@ mc_config_get_groups (mc_config_t * mc_config, gsize * len)
if (!mc_config)
{
ret = g_try_malloc0 (sizeof (gchar **));
*len=0;
if (len != NULL)
*len=0;
return ret;
}
ret = g_key_file_get_groups (mc_config->handle, len);
@ -67,7 +68,8 @@ mc_config_get_keys (mc_config_t * mc_config, const gchar * group, gsize * len)
if (!mc_config || !group)
{
ret = g_try_malloc0 (sizeof (gchar **));
*len=0;
if (len != NULL)
*len=0;
return ret;
}
ret = g_key_file_get_keys (mc_config->handle, group, len, NULL);

Просмотреть файл

@ -1004,14 +1004,14 @@ static char
if (semi != NULL) {
slash = strchr (semi, PATH_SEP);
if (slash != NULL) {
result = g_strconcat (path, "/#enc:", encoding, NULL);
result = g_strconcat (path, "/#enc:", encoding, (char *) NULL);
} else {
*semi = 0;
result = g_strconcat (path, "/#enc:", encoding, NULL);
result = g_strconcat (path, "/#enc:", encoding, (char *) NULL);
*semi = '#';
}
} else {
result = g_strconcat (path, "/#enc:", encoding, NULL);
result = g_strconcat (path, "/#enc:", encoding, (char *) NULL);
}
return result;
@ -3311,7 +3311,7 @@ panel_get_sortable_fields(gsize *array_size)
lc_index = panel_get_num_of_sortable_fields();
ret = g_new0 (char *, lc_index + 1);
ret = g_try_new0 (char *, lc_index + 1);
if (ret == NULL)
return NULL;
@ -3391,7 +3391,7 @@ panel_get_user_possible_fields(gsize *array_size)
lc_index = panel_get_num_of_user_possible_fields();
ret = g_new0 (char *, lc_index + 1);
ret = g_try_new0 (char *, lc_index + 1);
if (ret == NULL)
return NULL;

Просмотреть файл

@ -258,7 +258,7 @@ mc_search_get_types_strings_array (size_t *num)
const mc_search_type_str_t *type_str;
const mc_search_type_str_t *types_str = mc_search_types_list_get (&n);
ret = g_new0 (char *, n + 1);
ret = g_try_new0 (char *, n + 1);
if (ret == NULL)
return NULL;

Просмотреть файл

@ -15,7 +15,7 @@ gboolean do_select_codepage (void);
/* some results of select_charset() */
#define SELECT_CHARSET_CANCEL -2
/* select_charset() returns this value if dialog has been cenceled */
/* select_charset() returns this value if dialog has been canceled */
#define SELECT_CHARSET_OTHER_8BIT -1
/* select_charset() returns this value if seldisplay == TRUE
* and the last item has been selected. Last item is "Other 8 bits" */

Просмотреть файл

@ -492,7 +492,6 @@ setup__move_panels_config_into_separate_file(const char*profile)
mc_config_t *tmp_cfg;
char **groups, **curr_grp;
const char *need_grp;
gsize groups_count;
if (!exist_file(profile))
return;
@ -501,7 +500,7 @@ setup__move_panels_config_into_separate_file(const char*profile)
if (!tmp_cfg)
return;
curr_grp = groups = mc_config_get_groups (tmp_cfg, &groups_count);
curr_grp = groups = mc_config_get_groups (tmp_cfg, NULL);
if (!groups)
{
mc_config_deinit(tmp_cfg);

Просмотреть файл

@ -134,7 +134,7 @@ mc_skin_color_get_from_ini_file (mc_skin_t * mc_skin, const gchar * group, const
g_strfreev (values);
return NULL;
}
mc_skin_color = g_new0 (mc_skin_color_t, 1);
mc_skin_color = g_try_new0 (mc_skin_color_t, 1);
if (mc_skin_color == NULL) {
g_strfreev (values);
return NULL;
@ -176,15 +176,14 @@ static void
mc_skin_color_set_default_for_terminal (mc_skin_t * mc_skin)
{
mc_skin_color_t *mc_skin_color;
mc_skin_color = g_new0 (mc_skin_color_t, 1);
if (mc_skin_color == NULL)
return;
mc_skin_color->fgcolor = g_strdup ("default");
mc_skin_color->bgcolor = g_strdup ("default");
mc_skin_color->pair_index =
tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor, FALSE);
mc_skin_color_add_to_hash (mc_skin, "skin", "terminal_default_color", mc_skin_color);
mc_skin_color = g_try_new0 (mc_skin_color_t, 1);
if (mc_skin_color != NULL) {
mc_skin_color->fgcolor = g_strdup ("default");
mc_skin_color->bgcolor = g_strdup ("default");
mc_skin_color->pair_index =
tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor, FALSE);
mc_skin_color_add_to_hash (mc_skin, "skin", "terminal_default_color", mc_skin_color);
}
}
/* --------------------------------------------------------------------------------------------- */
@ -250,13 +249,12 @@ mc_skin_color_check_inisection (const gchar * group)
static void
mc_skin_color_check_bw_mode (mc_skin_t * mc_skin)
{
gsize items_count;
gchar **groups, **orig_groups;
if (!mc_args__disable_colors)
return;
orig_groups = groups = mc_config_get_groups (mc_skin->config, &items_count);
orig_groups = groups = mc_config_get_groups (mc_skin->config, NULL);
if (groups == NULL)
return;
@ -285,9 +283,11 @@ mc_skin_color_parse_ini_file (mc_skin_t * mc_skin)
orig_groups = groups = mc_config_get_groups (mc_skin->config, &items_count);
if (groups == NULL || *groups == NULL) {
if (groups != NULL)
g_strfreev (groups);
if (groups == NULL)
return FALSE;
if (*groups == NULL) {
g_strfreev (groups);
return FALSE;
}
@ -305,9 +305,11 @@ mc_skin_color_parse_ini_file (mc_skin_t * mc_skin)
continue;
orig_keys = keys = mc_config_get_keys (mc_skin->config, *groups, &items_count);
if (keys == NULL || *keys == NULL) {
if (keys != NULL)
g_strfreev (keys);
if (keys == NULL)
continue;
if(*keys == NULL) {
g_strfreev (keys);
continue;
}

Просмотреть файл

@ -153,7 +153,7 @@ strutils_unescape (const char *src, gsize src_len, const char *unescaped_chars,
/** To be compatible with the general posix command lines we have to escape
strings for the command line
\params in
\param src
string for escaping
\returns
@ -187,7 +187,7 @@ strutils_regex_escape (const char *src)
/** Unescape paths or other strings for e.g the internal cd
shell-unescape within a given buffer (writing to it!)
\params src
\param text
string for unescaping
\returns
@ -218,9 +218,12 @@ strutils_regex_unescape (const char *text)
/** Check if char in pointer contain escape'd chars
\params in
\param start
string for checking
\param current
pointer to checked character
\returns
return TRUE if string contain escaped chars
otherwise return FALSE

Просмотреть файл

@ -738,9 +738,9 @@ subshell_name_quote (const char *s)
}
/* Factor 5 because we need \, 0 and 3 other digits per character. */
d = ret = g_malloc (1 + (5 * strlen (s)) + (strlen(quote_cmd_start))
d = ret = g_try_malloc (1 + (5 * strlen (s)) + (strlen(quote_cmd_start))
+ (strlen(quote_cmd_end)));
if (!d)
if (d == NULL)
return NULL;
/* Prevent interpreting leading `-' as a switch for `cd' */

Просмотреть файл

@ -235,10 +235,8 @@ show_tree (WTree *tree)
}
g_free (tree->tree_shown);
tree->tree_shown = g_new (tree_entry*, tree_lines);
tree->tree_shown = g_new0 (tree_entry *, tree_lines);
for (i = 0; i < tree_lines; i++)
tree->tree_shown [i] = NULL;
if (tree->store->tree_first)
topsublevel = tree->store->tree_first->sublevel;
else

Просмотреть файл

@ -61,16 +61,17 @@ static int
mc_tty_color_save_attr_lib (int color_pair, int color_attr)
{
int *attr, *key;
attr = g_new0 (int, 1);
attr = g_try_new0 (int, 1);
if (attr == NULL)
return color_attr;
key = g_new0 (int, 1);
key = g_try_new (int, 1);
if (key == NULL) {
g_free (attr);
return color_attr;
}
memcpy (key, &color_pair, sizeof (int));
*key = color_pair;
if (color_attr != -1)
*attr = color_attr & (A_BOLD | A_REVERSE | A_UNDERLINE);
@ -83,12 +84,10 @@ mc_tty_color_save_attr_lib (int color_pair, int color_attr)
static int
color_get_attr (int color_pair)
{
int *fnd;
int *fnd = NULL;
if (mc_tty_color_color_pair_attrs == NULL)
return 0;
fnd = (int *) g_hash_table_lookup (mc_tty_color_color_pair_attrs, (gpointer) & color_pair);
if (mc_tty_color_color_pair_attrs != NULL)
fnd = (int *) g_hash_table_lookup (mc_tty_color_color_pair_attrs, (gpointer) & color_pair);
return (fnd != NULL) ? *fnd : 0;
}

Просмотреть файл

@ -196,7 +196,7 @@ tty_try_alloc_color_pair2 (const char *fg, const char *bg, gboolean is_temp_colo
return mc_color_pair->pair_index;
}
mc_color_pair = g_new0 (tty_color_pair_t, 1);
mc_color_pair = g_try_new0 (tty_color_pair_t, 1);
if (mc_color_pair == NULL) {
g_free (color_pair);
return 0;

Просмотреть файл

@ -18,6 +18,4 @@
# include <ncursesw/curses.h>
#endif /* USE_NCURSESW */
void init_curses (void);
#endif /* MC_TTY_NCURSES_H */

Просмотреть файл

@ -702,7 +702,7 @@ execute_menu_command (WEdit *edit_widget, const char *commands)
} else {
/* execute the command indirectly to allow execution even
* on no-exec filesystems. */
char *cmd = g_strconcat("/bin/sh ", file_name, (char *)NULL);
char *cmd = g_strconcat("/bin/sh ", file_name, (char *) NULL);
shell_execute (cmd, EXECUTE_HIDE);
g_free(cmd);
}
@ -801,15 +801,15 @@ user_menu_cmd (WEdit *edit_widget)
char ** new_entries;
menu_limit += MAX_ENTRIES;
new_entries = g_realloc (entries, sizeof (new_entries[0]) * menu_limit);
new_entries = g_try_realloc (entries, sizeof (new_entries[0]) * menu_limit);
if (new_entries == 0)
if (new_entries == NULL)
break;
entries = new_entries;
new_entries += menu_limit;
while (--new_entries >= &entries[menu_lines])
*new_entries = 0;
*new_entries = NULL;
}
if (col == 0 && !entries [menu_lines]){
if (*p == '#'){

Просмотреть файл

@ -634,7 +634,7 @@ putenv (char *string)
if (*ep == NULL){
static char **last_environ = NULL;
char **new_environ = g_new (char *, size + 2);
char **new_environ = g_try_new (char *, size + 2);
if (new_environ == NULL)
return -1;
(void) memcpy ((void *) new_environ, (void *) __environ,

Просмотреть файл

@ -216,7 +216,7 @@ mcview_moveto_line_cmd (mcview_t *view)
g_snprintf (prompt, sizeof (prompt),
_(" The current line number is %lld.\n"
" Enter the new line number:"), (line + 1));
" Enter the new line number:"), (long long)(line + 1));
answer = input_dialog (_(" Goto line "), prompt, MC_HISTORY_VIEW_GOTO_LINE, "");
if (answer != NULL && answer[0] != '\0') {
errno = 0;
@ -505,6 +505,27 @@ mcview_handle_key (mcview_t * view, int key)
return MSG_NOT_HANDLED;
}
/* --------------------------------------------------------------------------------------------- */
static inline void
mcview_adjust_size (Dlg_head *h)
{
mcview_t *view;
WButtonBar *b;
/* Look up the viewer and the buttonbar, we assume only two widgets here */
view = (mcview_t *) find_widget_type (h, mcview_callback);
b = find_buttonbar (h);
widget_set_size (&view->widget, 0, 0, LINES - 1, COLS);
widget_set_size (&b->widget , LINES - 1, 0, 1, COLS);
mcview_compute_areas (view);
mcview_update_bytes_per_line (view);
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/

Просмотреть файл

@ -386,25 +386,6 @@ mcview_display_ruler (mcview_t * view)
/* --------------------------------------------------------------------------------------------- */
void
mcview_adjust_size (Dlg_head *h)
{
mcview_t *view;
WButtonBar *b;
/* Look up the viewer and the buttonbar, we assume only two widgets here */
view = (mcview_t *) find_widget_type (h, mcview_callback);
b = find_buttonbar (h);
widget_set_size (&view->widget, 0, 0, LINES - 1, COLS);
widget_set_size (&b->widget , LINES - 1, 0, 1, COLS);
mcview_compute_areas (view);
mcview_update_bytes_per_line (view);
}
/* --------------------------------------------------------------------------------------------- */
void
mcview_percent (mcview_t * view, off_t p)
{

Просмотреть файл

@ -243,7 +243,6 @@ void mcview_update_bytes_per_line (mcview_t *view);
void mcview_display_toggle_ruler (mcview_t *view);
void mcview_display_clean (mcview_t *view);
void mcview_display_ruler (mcview_t *view);
void mcview_adjust_size (Dlg_head *h);
void mcview_percent (mcview_t *view, off_t p);
/* growbuf.c: */

Просмотреть файл

@ -1,4 +1,4 @@
/** \file view.h
/** \file mcviewer.h
* \brief Header: internal file viewer
*/

Просмотреть файл

@ -226,12 +226,12 @@ mcview_nroff_seq_new_num (mcview_t * view, off_t lc_index)
{
mcview_nroff_t *nroff;
nroff = g_malloc0 (sizeof (mcview_nroff_t));
if (nroff == NULL)
return NULL;
nroff->index = lc_index;
nroff->view = view;
mcview_nroff_seq_info (nroff);
nroff = g_try_malloc0 (sizeof (mcview_nroff_t));
if (nroff != NULL) {
nroff->index = lc_index;
nroff->view = view;
mcview_nroff_seq_info (nroff);
}
return nroff;
}

Просмотреть файл

@ -342,7 +342,7 @@ button_get_text (const WButton *b)
{
if (b->text.hotkey != NULL)
return g_strconcat (b->text.start, "&", b->text.hotkey,
b->text.end, NULL);
b->text.end, (char *) NULL);
else
return g_strdup (b->text.start);
}

Просмотреть файл

@ -90,7 +90,7 @@ endif
if ENABLE_MCSERVER
sbin_PROGRAMS = mcserv
mcserv_SOURCES = mcserv.c mcfsutil.c
mcserv_LDADD = $(MCSERVLIBS)
mcserv_LDADD = $(MCSERVLIBS) $(GLIB_LIBS)
endif

Просмотреть файл

@ -57,8 +57,8 @@ vfs_s_new_inode (struct vfs_class *me, struct vfs_s_super *super, struct stat *i
{
struct vfs_s_inode *ino;
ino = g_new0 (struct vfs_s_inode, 1);
if (!ino)
ino = g_try_new0 (struct vfs_s_inode, 1);
if (ino == NULL)
return NULL;
if (initstat)
@ -70,7 +70,7 @@ vfs_s_new_inode (struct vfs_class *me, struct vfs_s_super *super, struct stat *i
super->ino_usage++;
total_inodes++;
CALL (init_inode) (me, ino);
return ino;
@ -237,7 +237,7 @@ vfs_s_resolve_symlink (struct vfs_class *me, struct vfs_s_entry *entry,
if (*linkname != PATH_SEP) {
char *fullpath = vfs_s_fullpath (me, entry->dir);
if (fullpath) {
fullname = g_strconcat (fullpath, "/", linkname, NULL);
fullname = g_strconcat (fullpath, "/", linkname, (char *) NULL);
linkname = fullname;
g_free (fullpath);
}
@ -1017,7 +1017,8 @@ vfs_s_fill_names (struct vfs_class *me, fill_names_f func)
char *name;
while (a){
name = g_strconcat ( a->name, "#", me->prefix, "/", /* a->current_dir->name, */ NULL);
name = g_strconcat ( a->name, "#", me->prefix, "/",
/* a->current_dir->name, */ (char *) NULL);
(*func)(name);
g_free (name);
a = a->next;

Просмотреть файл

@ -711,7 +711,7 @@ extfs_open (struct vfs_class *me, const char *file, int flags, int mode)
if (!created && !(flags & O_TRUNC)
&& extfs_cmd (" copyout ", archive, entry, local_filename)) {
unlink (local_filename);
free (local_filename);
g_free (local_filename);
my_errno = EIO;
return NULL;
}
@ -1223,7 +1223,7 @@ static void extfs_remove_entry (struct entry *e)
if (i <= 0) {
if (e->inode->local_filename != NULL) {
unlink (e->inode->local_filename);
free (e->inode->local_filename);
g_free (e->inode->local_filename);
}
g_free (e->inode->linkname);
g_free (e->inode);
@ -1238,14 +1238,14 @@ static void extfs_free_entry (struct entry *e)
int i = --(e->inode->nlink);
if (S_ISDIR (e->inode->mode) && e->inode->first_in_subdir != NULL) {
struct entry *f = e->inode->first_in_subdir;
e->inode->first_in_subdir = NULL;
extfs_free_entry (f);
}
if (i <= 0) {
if (e->inode->local_filename != NULL) {
unlink (e->inode->local_filename);
free (e->inode->local_filename);
g_free (e->inode->local_filename);
}
g_free (e->inode->linkname);
g_free (e->inode);

Просмотреть файл

@ -34,7 +34,7 @@
* Derived from ftpfs.c
* Read README.fish for protocol specification.
*
* Syntax of path is: /#sh:user@host[:Cr]/path
* Syntax of path is: \verbatim /#sh:user@host[:Cr]/path \endverbatim
* where C means you want compressed connection,
* and r means you want to use rsh
*
@ -492,8 +492,7 @@ fish_dir_load(struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
"else\n"
"echo '### 500'\n"
"fi\n"
,
NULL
, (char *) NULL
);
fish_command (me, super, NONE, shell_commands,

Просмотреть файл

@ -44,11 +44,14 @@ What to do with this?
* NOTE: Usage of tildes is deprecated, consider:
* cd /#ftp:pavel@hobit
* cd ~
* \verbatim
cd /#ftp:pavel@hobit
cd ~
\endverbatim
* And now: what do I want to do? Do I want to go to /home/pavel or to
* /#ftp:hobit/home/pavel? I think first has better sense...
*
\verbatim
{
int f = !strcmp( remote_path, "/~" );
if (f || !strncmp( remote_path, "/~/", 3 )) {
@ -58,8 +61,7 @@ What to do with this?
remote_path = s;
}
}
\endverbatim
*/
/* \todo Fix: Namespace pollution: horrible */
@ -473,8 +475,8 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super,
} else { /* ask user */
char *p;
p = g_strconcat (_(" FTP: Password required for "), SUP.user, " ",
NULL);
p = g_strconcat (_(" FTP: Password required for "),
SUP.user, " ", (char *) NULL);
op = vfs_get_password (p);
g_free (p);
if (op == NULL)
@ -494,7 +496,7 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super,
name =
g_strconcat (SUP.user, "@",
SUP.host[0] == '!' ? SUP.host + 1 : SUP.host,
NULL);
(char *) NULL);
} else
name = g_strdup (SUP.user);
@ -888,7 +890,7 @@ ftpfs_get_current_directory (struct vfs_class *me, struct vfs_s_super *super)
/* If the remote server is an Amiga a leading slash
might be missing. MC needs it because it is used
as separator between hostname and path internally. */
return g_strconcat( "/", bufp, NULL);
return g_strconcat( "/", bufp, (char *) NULL);
}
} else {
ftpfs_errno = EIO;
@ -1051,7 +1053,7 @@ again:
port = ntohs (port);
addr = g_malloc (NI_MAXHOST);
addr = g_try_malloc (NI_MAXHOST);
if (addr == NULL)
ERRNOR (ENOMEM, -1);

Просмотреть файл

@ -338,7 +338,7 @@ send_time (int sock, time_t t)
long ltime = (long) t;
char buf[BUF_SMALL];
snprintf (buf, sizeof (buf), "%lx", ltime);
g_snprintf (buf, sizeof (buf), "%lx", ltime);
rpc_send (sock, RPC_STRING, buf, RPC_END);
}
}
@ -515,7 +515,7 @@ do_readdir (void)
fname_len =
strlen (mcfs_DIR.names[handle]) + strlen (dirent->d_name) + 2;
fname = malloc (fname_len);
snprintf (fname, fname_len, "%s/%s", mcfs_DIR.names[handle],
g_snprintf (fname, fname_len, "%s/%s", mcfs_DIR.names[handle],
dirent->d_name);
n = lstat (fname, &st);
g_free (fname);

Просмотреть файл

@ -27,7 +27,7 @@
* inside. It is somehow similar to extfs, except that extfs makes
* whole virtual trees and we do only single virtual files.
*
* If you want to gunzip something, you should open it with #ugz
* If you want to gunzip something, you should open it with \verbatim #ugz \endverbatim
* suffix, DON'T try to gunzip it yourself.
*
* Namespace: exports vfs_sfs_ops

Просмотреть файл

@ -184,9 +184,9 @@ static void
smbfs_auth_add (const char *host, const char *share, const char *domain,
const char *user, const char *param_password)
{
struct smb_authinfo *auth = g_new (struct smb_authinfo, 1);
if (!auth)
struct smb_authinfo *auth = g_try_new (struct smb_authinfo, 1);
if (auth == NULL)
return;
/* Don't check for NULL, g_strdup already does. */
@ -368,8 +368,7 @@ smbfs_fill_names (struct vfs_class *me, fill_names_f func)
path = g_strconcat (URL_HEADER,
smbfs_connections[i].user, "@",
smbfs_connections[i].host,
"/", smbfs_connections[i].service,
NULL);
"/", smbfs_connections[i].service, (char *) NULL);
(*func)(path);
g_free (path);
}

Просмотреть файл

@ -265,7 +265,13 @@ path_magic (const char *path)
}
/**
* Splits path '/p1#op/inpath' into inpath,op; returns which vfs it is.
* Splits path extracting vfs part.
*
* Splits path
* \verbatim /p1#op/inpath \endverbatim
* into
* \verbatim inpath,op; \endverbatim
* returns which vfs it is.
* What is left in path is p1. You still want to g_free(path), you DON'T
* want to free neither *inpath nor *op
*/
@ -743,29 +749,29 @@ mc_opendir (const char *dirname)
if (dname != NULL) {
vfs = vfs_get_class (dname);
info = vfs->opendir ? (*vfs->opendir)(vfs, dname) : NULL;
g_free (dname);
if (!info){
errno = vfs->opendir ? ferrno (vfs) : E_NOTSUPP;
info = vfs->opendir ? (*vfs->opendir)(vfs, dname) : NULL;
g_free (dname);
if (info == NULL) {
errno = vfs->opendir ? ferrno (vfs) : E_NOTSUPP;
g_free (canon);
return NULL;
}
return NULL;
}
dirinfo = g_new (struct vfs_dirinfo, 1);
dirinfo->info = info;
encoding = vfs_get_encoding (canon);
g_free (canon);
dirinfo->converter = (encoding != NULL) ? str_crt_conv_from (encoding) :
str_cnv_from_term;
if (dirinfo->converter == INVALID_CONV) dirinfo->converter =str_cnv_from_term;
handle = vfs_new_handle (vfs, dirinfo);
handlep = g_new (int, 1);
*handlep = handle;
return (DIR *) handlep;
handlep = g_new (int, 1);
*handlep = handle;
return (DIR *) handlep;
} else {
g_free (canon);
return NULL;
@ -795,7 +801,7 @@ mc_readdir (DIR *dirp)
* structures, holding dirent size. But we don't use it in libc infrastructure.
* TODO: to make simpler homemade dirent-alike structure.
*/
mc_readdir_result = (struct dirent *)malloc(sizeof(struct dirent) + NAME_MAX + 1);
mc_readdir_result = (struct dirent *) g_malloc (sizeof(struct dirent) + NAME_MAX + 1);
}
if (!dirp) {