1
0
mirror of https://github.com/MidnightCommander/mc synced 2025-03-22 07:42:54 +03:00

Remove min() and max() macros. Use MIN() and MAX() macros from GLib.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2016-04-07 10:52:04 +03:00
parent 3bea889648
commit bc14ff44c8
44 changed files with 151 additions and 162 deletions

@ -100,17 +100,6 @@
#include "lib/logging.h"
#endif
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif
#define min(x, y) ((x) > (y) ? (y) : (x))
#define max(x, y) ((x) > (y) ? (x) : (y))
/* Just for keeping Your's brains from invention a proper size of the buffer :-) */
#define BUF_10K 10240L
#define BUF_8K 8192L

@ -168,7 +168,7 @@ mc_search__cond_struct_new_regex_accum_append (const char *charset, GString * st
one_char =
mc_search__get_one_symbol (charset, &(str_from->str[loop]),
min (str_from->len - loop, 6), &just_letters);
MIN (str_from->len - loop, 6), &just_letters);
one_char_len = strlen (one_char);
if (one_char_len == 0)

@ -231,7 +231,7 @@ str_8bit_length (const char *text)
static int
str_8bit_length2 (const char *text, int size)
{
return (size >= 0) ? min (strlen (text), (gsize) size) : strlen (text);
return (size >= 0) ? MIN (strlen (text), (gsize) size) : strlen (text);
}
/* --------------------------------------------------------------------------------------------- */
@ -441,7 +441,7 @@ str_8bit_term_trim (const char *text, int width)
static int
str_8bit_term_width2 (const char *text, size_t length)
{
return (length != (size_t) (-1)) ? min (strlen (text), length) : strlen (text);
return (length != (size_t) (-1)) ? MIN (strlen (text), length) : strlen (text);
}
/* --------------------------------------------------------------------------------------------- */
@ -659,7 +659,7 @@ str_8bit_compare (const char *t1, const char *t2)
static int
str_8bit_ncompare (const char *t1, const char *t2)
{
return strncmp (t1, t2, min (strlen (t1), strlen (t2)));
return strncmp (t1, t2, MIN (strlen (t1), strlen (t2)));
}
/* --------------------------------------------------------------------------------------------- */
@ -707,7 +707,7 @@ str_8bit_ncasecmp (const char *s1, const char *s2)
g_return_val_if_fail (s1 != NULL, 0);
g_return_val_if_fail (s2 != NULL, 0);
n = min (strlen (s1), strlen (s2));
n = MIN (strlen (s1), strlen (s2));
/* code from GLib */

@ -204,7 +204,7 @@ str_ascii_length (const char *text)
static int
str_ascii_length2 (const char *text, int size)
{
return (size >= 0) ? min (strlen (text), (gsize) size) : strlen (text);
return (size >= 0) ? MIN (strlen (text), (gsize) size) : strlen (text);
}
/* --------------------------------------------------------------------------------------------- */
@ -421,7 +421,7 @@ str_ascii_term_trim (const char *text, int width)
static int
str_ascii_term_width2 (const char *text, size_t length)
{
return (length != (size_t) (-1)) ? min (strlen (text), length) : strlen (text);
return (length != (size_t) (-1)) ? MIN (strlen (text), length) : strlen (text);
}
/* --------------------------------------------------------------------------------------------- */
@ -640,7 +640,7 @@ str_ascii_compare (const char *t1, const char *t2)
static int
str_ascii_ncompare (const char *t1, const char *t2)
{
return strncmp (t1, t2, min (strlen (t1), strlen (t2)));
return strncmp (t1, t2, MIN (strlen (t1), strlen (t2)));
}
/* --------------------------------------------------------------------------------------------- */
@ -656,7 +656,7 @@ str_ascii_casecmp (const char *t1, const char *t2)
static int
str_ascii_ncasecmp (const char *t1, const char *t2)
{
return g_ascii_strncasecmp (t1, t2, min (strlen (t1), strlen (t2)));
return g_ascii_strncasecmp (t1, t2, MIN (strlen (t1), strlen (t2)));
}
/* --------------------------------------------------------------------------------------------- */

@ -358,7 +358,7 @@ str_utf8_length2 (const char *text, int size)
{
if (start != end)
{
result += g_utf8_strlen (start, min (end - start, size));
result += g_utf8_strlen (start, MIN (end - start, size));
size -= end - start;
}
result += (size > 0);
@ -369,7 +369,7 @@ str_utf8_length2 (const char *text, int size)
if (start == text)
result = g_utf8_strlen (text, size);
else if (start[0] != '\0' && start != end && size > 0)
result += g_utf8_strlen (start, min (end - start, size));
result += g_utf8_strlen (start, MIN (end - start, size));
return result;
}
@ -1198,7 +1198,7 @@ str_utf8_ncompare (const char *t1, const char *t2)
l1 = strlen (n1);
l2 = strlen (n2);
result = strncmp (n1, n2, min (l1, l2));
result = strncmp (n1, n2, MIN (l1, l2));
g_free (n1);
g_free (n2);
@ -1239,7 +1239,7 @@ str_utf8_ncasecmp (const char *t1, const char *t2)
l1 = strlen (n1);
l2 = strlen (n2);
result = strncmp (n1, n2, min (l1, l2));
result = strncmp (n1, n2, MIN (l1, l2));
g_free (n1);
g_free (n2);

@ -101,14 +101,14 @@ i18n_checktimelength (void)
{
strftime (buf, sizeof (buf) - 1, user_recent_timeformat, lt);
tlen = (size_t) str_term_width1 (buf);
length = max (tlen, length);
length = MAX (tlen, length);
strftime (buf, sizeof (buf) - 1, user_old_timeformat, lt);
tlen = (size_t) str_term_width1 (buf);
length = max (tlen, length);
length = MAX (tlen, length);
}
tlen = (size_t) str_term_width1 (_(INVALID_TIME_TEXT));
length = max (tlen, length);
length = MAX (tlen, length);
}
/* Don't handle big differences. Use standard value (email bug, please) */

@ -614,7 +614,7 @@ try_channels (int set_timeout)
FD_ZERO (&select_set);
FD_SET (input_fd, &select_set); /* Add stdin */
maxfdp = max (add_selects (&select_set), input_fd);
maxfdp = MAX (add_selects (&select_set), input_fd);
if (set_timeout)
{
@ -1710,7 +1710,7 @@ is_idle (void)
FD_ZERO (&select_set);
FD_SET (input_fd, &select_set);
nfd = max (0, input_fd) + 1;
nfd = MAX (0, input_fd) + 1;
time_out.tv_sec = 0;
time_out.tv_usec = 0;
#ifdef HAVE_LIBGPM
@ -1719,7 +1719,7 @@ is_idle (void)
if (gpm_fd >= 0)
{
FD_SET (gpm_fd, &select_set);
nfd = max (nfd, gpm_fd + 1);
nfd = MAX (nfd, gpm_fd + 1);
}
else
{
@ -1988,7 +1988,7 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block)
FD_ZERO (&select_set);
FD_SET (input_fd, &select_set);
nfd = max (add_selects (&select_set), max (0, input_fd)) + 1;
nfd = MAX (add_selects (&select_set), MAX (0, input_fd)) + 1;
#ifdef HAVE_LIBGPM
if (mouse_enabled && (use_mouse_p == MOUSE_GPM))
@ -1996,7 +1996,7 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block)
if (gpm_fd >= 0)
{
FD_SET (gpm_fd, &select_set);
nfd = max (nfd, gpm_fd + 1);
nfd = MAX (nfd, gpm_fd + 1);
}
else
{

@ -604,7 +604,7 @@ mc_pread (mc_pipe_t * p, GError ** error)
if (read_err)
{
FD_SET (p->err.fd, &fds);
maxfd = max (maxfd, p->err.fd);
maxfd = MAX (maxfd, p->err.fd);
}
/* no timeout */

@ -147,7 +147,7 @@ _vfs_translate_path (const char *path, int size, GIConv defcnv, GString * buffer
slash = NULL;
ms = (slash != NULL) ? slash - semi : (int) strlen (semi);
ms = min ((unsigned int) ms, sizeof (encoding) - 1);
ms = MIN ((unsigned int) ms, sizeof (encoding) - 1);
/* limit encoding size (ms) to path size (size) */
if (semi + ms > path + size)
ms = path + size - semi;

@ -230,7 +230,7 @@ dialog_switch_list (void)
if (mc_global.midnight_shutdown || mc_current == NULL)
return;
lines = min ((size_t) (LINES * 2 / 3), dlg_num);
lines = MIN ((size_t) (LINES * 2 / 3), dlg_num);
cols = COLS * 2 / 3;
listbox = create_listbox_window (lines, cols, _("Screens"), "[Screen selector]");

@ -87,13 +87,13 @@ history_dlg_reposition (WDialog * dlg_head)
if (he <= y || y > (LINES - 6))
{
he = min (he, y - 1);
he = MIN (he, y - 1);
y -= he;
}
else
{
y++;
he = min (he, LINES - y);
he = MIN (he, LINES - y);
}
if (data->widget->x > 2)
@ -103,7 +103,7 @@ history_dlg_reposition (WDialog * dlg_head)
if ((wi + x) > COLS)
{
wi = min (wi, COLS);
wi = MIN (wi, COLS);
x = COLS - wi;
}
@ -305,7 +305,7 @@ history_show (GList ** history, Widget * widget, int current)
size_t i;
i = str_term_width1 ((char *) z->data);
maxlen = max (maxlen, i);
maxlen = MAX (maxlen, i);
count++;
entry = g_new0 (WLEntry, 1);

@ -138,8 +138,8 @@ input_eval_marks (WInput * in, long *start_mark, long *end_mark)
{
if (in->mark >= 0)
{
*start_mark = min (in->mark, in->point);
*end_mark = max (in->mark, in->point);
*start_mark = MIN (in->mark, in->point);
*end_mark = MAX (in->mark, in->point);
return TRUE;
}
@ -152,8 +152,8 @@ input_eval_marks (WInput * in, long *start_mark, long *end_mark)
static void
delete_region (WInput * in, int x_first, int x_last)
{
int first = min (x_first, x_last);
int last = max (x_first, x_last);
int first = MIN (x_first, x_last);
int last = MAX (x_first, x_last);
size_t len;
input_mark_cmd (in, FALSE);
@ -486,8 +486,8 @@ delete_char (WInput * in)
static void
copy_region (WInput * in, int x_first, int x_last)
{
int first = min (x_first, x_last);
int last = max (x_first, x_last);
int first = MIN (x_first, x_last);
int last = MAX (x_first, x_last);
if (last == first)
{
@ -767,7 +767,7 @@ input_execute_cmd (WInput * in, long command)
input_mark_cmd (in, TRUE);
break;
case CK_Remove:
delete_region (in, in->point, max (in->mark, 0));
delete_region (in, in->point, MAX (in->mark, 0));
break;
case CK_DeleteToEnd:
kill_line (in);
@ -776,13 +776,13 @@ input_execute_cmd (WInput * in, long command)
clear_line (in);
break;
case CK_Store:
copy_region (in, max (in->mark, 0), in->point);
copy_region (in, MAX (in->mark, 0), in->point);
break;
case CK_Cut:
{
long m;
m = max (in->mark, 0);
m = MAX (in->mark, 0);
copy_region (in, m, in->point);
delete_region (in, in->point, m);
}
@ -1208,7 +1208,7 @@ input_assign_text (WInput * in, const char *text)
in->charpoint = 0;
text_len = strlen (text);
buffer_len = 1 + max ((size_t) w->cols, text_len);
buffer_len = 1 + MAX ((size_t) w->cols, text_len);
in->current_max_size = buffer_len;
if (buffer_len > (size_t) w->cols)
in->buffer = g_realloc (in->buffer, buffer_len);
@ -1248,7 +1248,7 @@ input_set_point (WInput * in, int pos)
int max_pos;
max_pos = str_length (in->buffer);
pos = min (pos, max_pos);
pos = MIN (pos, max_pos);
if (pos != in->point)
input_free_completions (in);
in->point = pos;
@ -1280,7 +1280,7 @@ input_update (WInput * in, gboolean clear_first)
buf_len = str_length (in->buffer);
/* Adjust the mark */
in->mark = min (in->mark, buf_len);
in->mark = MIN (in->mark, buf_len);
pw = str_term_width2 (in->buffer, in->point);
@ -1333,7 +1333,7 @@ input_update (WInput * in, gboolean clear_first)
widget_move (in, 0, m1 - in->term_first_shown);
buf_width = str_term_width2 (in->buffer, m1);
sel_width =
min (m2 - m1, (w->cols - has_history) - (buf_width - in->term_first_shown));
MIN (m2 - m1, (w->cols - has_history) - (buf_width - in->term_first_shown));
tty_print_string (str_term_substring (in->buffer, m1, sel_width));
}
}

@ -968,7 +968,7 @@ insert_text (WInput * in, char *text, ssize_t size)
int buff_len;
buff_len = str_length (in->buffer);
size = min (size, (ssize_t) strlen (text)) + start - end;
size = MIN (size, (ssize_t) strlen (text)) + start - end;
if (strlen (in->buffer) + size >= (size_t) in->current_max_size)
{
/* Expand the buffer */

@ -66,17 +66,17 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
dlg_flags_t dlg_flags = DLG_TRYUP;
/* Adjust sizes */
lines = min (lines, LINES - 6);
lines = MIN (lines, LINES - 6);
if (title != NULL)
{
int len;
len = str_term_width1 (title) + 4;
cols = max (cols, len);
cols = MAX (cols, len);
}
cols = min (cols, COLS - 6);
cols = MIN (cols, COLS - 6);
/* adjust position */
if ((center_y < 0) || (center_x < 0))

@ -221,7 +221,7 @@ listbox_check_hotkey (WListbox * l, int key)
static int
listbox_y_pos (WListbox * l, int y)
{
return min (l->top + y, LISTBOX_LAST (l));
return MIN (l->top + y, LISTBOX_LAST (l));
}
/* --------------------------------------------------------------------------------------------- */
@ -240,7 +240,7 @@ listbox_fwd (WListbox * l, gboolean wrap)
static void
listbox_fwd_n (WListbox * l, int n)
{
listbox_select_entry (l, min (l->pos + n, LISTBOX_LAST (l)));
listbox_select_entry (l, MIN (l->pos + n, LISTBOX_LAST (l)));
}
/* --------------------------------------------------------------------------------------------- */
@ -259,7 +259,7 @@ listbox_back (WListbox * l, gboolean wrap)
static void
listbox_back_n (WListbox * l, int n)
{
listbox_select_entry (l, max (l->pos - n, 0));
listbox_select_entry (l, MAX (l->pos - n, 0));
}
/* --------------------------------------------------------------------------------------------- */

@ -96,7 +96,7 @@ menu_arrange (menu_t * menu, dlg_shortcut_str get_shortcut)
size_t len;
len = (size_t) hotkey_width (entry->text);
menu->max_hotkey_len = max (menu->max_hotkey_len, len);
menu->max_hotkey_len = MAX (menu->max_hotkey_len, len);
if (get_shortcut != NULL)
entry->shortcut = get_shortcut (entry->command);
@ -104,7 +104,7 @@ menu_arrange (menu_t * menu, dlg_shortcut_str get_shortcut)
if (entry->shortcut != NULL)
{
len = (size_t) str_term_width1 (entry->shortcut);
max_shortcut_len = max (max_shortcut_len, len);
max_shortcut_len = MAX (max_shortcut_len, len);
}
}
}

@ -104,7 +104,7 @@ quick_create_labeled_input (GArray * widgets, int *y, int x, quick_widget_t * qu
in.quick_widget = quick_widget;
g_array_append_val (widgets, in);
*width = max (label.widget->cols, in.widget->cols);
*width = MAX (label.widget->cols, in.widget->cols);
break;
case input_label_left:
@ -140,7 +140,7 @@ quick_create_labeled_input (GArray * widgets, int *y, int x, quick_widget_t * qu
*y += label.widget->lines - 1;
g_array_append_val (widgets, label);
*width = max (label.widget->cols, in.widget->cols);
*width = MAX (label.widget->cols, in.widget->cols);
break;
default:
@ -185,7 +185,7 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
int return_val;
len = str_term_width1 (I18N (quick_dlg->title)) + 6;
quick_dlg->cols = max (quick_dlg->cols, len);
quick_dlg->cols = MAX (quick_dlg->cols, len);
y = 1;
x = x1;
@ -210,9 +210,9 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
if (g != NULL)
width += 2;
if (two_columns)
width2 = max (width2, width);
width2 = MAX (width2, width);
else
width1 = max (width1, width);
width1 = MAX (width1, width);
break;
case quick_button:
@ -227,9 +227,9 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
if (g != NULL)
width += 2;
if (two_columns)
width2 = max (width2, width);
width2 = MAX (width2, width);
else
width1 = max (width1, width);
width1 = MAX (width1, width);
break;
case quick_input:
@ -249,9 +249,9 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
if (g != NULL)
width += 2;
if (two_columns)
width2 = max (width2, width);
width2 = MAX (width2, width);
else
width1 = max (width1, width);
width1 = MAX (width1, width);
break;
case quick_label:
@ -262,9 +262,9 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
if (g != NULL)
width += 2;
if (two_columns)
width2 = max (width2, width);
width2 = MAX (width2, width);
else
width1 = max (width1, width);
width1 = MAX (width1, width);
break;
case quick_radio:
@ -288,9 +288,9 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
if (g != NULL)
width += 2;
if (two_columns)
width2 = max (width2, width);
width2 = MAX (width2, width);
else
width1 = max (width1, width);
width1 = MAX (width1, width);
}
break;
@ -339,7 +339,7 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
case quick_stop_columns:
x = x1;
y = max (y1, y);
y = MAX (y1, y);
g_array_append_val (widgets, item);
two_columns = FALSE;
break;
@ -383,7 +383,7 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
}
/* adjust dialog width */
quick_dlg->cols = max (quick_dlg->cols, blen + 6);
quick_dlg->cols = MAX (quick_dlg->cols, blen + 6);
if (have_groupbox)
{
if (width1 != 0)
@ -397,10 +397,10 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
{
len = width2 * 2 + 7;
if (width1 != 0)
len = max (len, width1 + 6);
len = MAX (len, width1 + 6);
}
quick_dlg->cols = max (quick_dlg->cols, len);
quick_dlg->cols = MAX (quick_dlg->cols, len);
width1 = quick_dlg->cols - 6;
width2 = (quick_dlg->cols - 7) / 2;

@ -186,7 +186,7 @@ radio_new (int y, int x, int count, const char **texts)
r->texts[i] = parse_hotkey (texts[i]);
width = hotkey_width (r->texts[i]);
wmax = max (width, wmax);
wmax = MAX (width, wmax);
}
/* 4 is width of "(*) " */

@ -299,7 +299,7 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
/* count coordinates */
str_msg_term_size (text, &lines, &cols);
cols = 6 + max (win_len, max (str_term_width1 (header), cols));
cols = 6 + MAX (win_len, MAX (str_term_width1 (header), cols));
lines += 4 + (count > 0 ? 2 : 0);
/* prepare dialog */
@ -585,7 +585,7 @@ status_msg_init (status_msg_t * sm, const char *title, double delay, status_msg_
start = mc_timer_elapsed (mc_global.timer);
sm->dlg = dlg_create (TRUE, 0, 0, 7, min (max (40, COLS / 2), COLS), dialog_colors,
sm->dlg = dlg_create (TRUE, 0, 0, 7, MIN (MAX (40, COLS / 2), COLS), dialog_colors,
NULL, NULL, NULL, title, DLG_CENTER);
sm->start = start;
sm->delay = (guint64) (delay * G_USEC_PER_SEC);
@ -697,7 +697,7 @@ simple_status_msg_init_cb (status_msg_t * sm)
#endif
b_width = str_term_width1 (b_name) + 4;
wd_width = max (wd->cols, b_width + 6);
wd_width = MAX (wd->cols, b_width + 6);
y = 2;
ssm->label = label_new (y++, 3, "");

@ -638,7 +638,7 @@ dview_str_utf8_offset_to_pos (const char *text, size_t length)
result = g_utf8_offset_to_pointer (tmpbuf, length) - tmpbuf;
g_free (buffer);
}
return max (length, (size_t) result);
return MAX (length, (size_t) result);
}
#endif /*HAVE_CHARSET */
@ -1567,7 +1567,7 @@ cvt_fget (FBUF * f, off_t off, char *dst, size_t dstsize, int skip, int ts, gboo
size_t sz;
int lastch = '\0';
const char *q = NULL;
char tmp[BUFSIZ]; /* XXX capacity must be >= max{dstsize + 1, amount} */
char tmp[BUFSIZ]; /* XXX capacity must be >= MAX{dstsize + 1, amount} */
char cvt[BUFSIZ]; /* XXX capacity must be >= MAX_TAB_WIDTH * amount */
if (sizeof (tmp) < amount || sizeof (tmp) <= dstsize || sizeof (cvt) < 8 * amount)
@ -2016,9 +2016,9 @@ get_current_hunk (WDiff * dview, int *start_line1, int *end_line1, int *start_li
l0 = ((DIFFLN *) & g_array_index (a0, DIFFLN, pos))->line;
l1 = ((DIFFLN *) & g_array_index (a1, DIFFLN, pos))->line;
if (l0 > 0)
*end_line1 = max (*start_line1, l0);
*end_line1 = MAX (*start_line1, l0);
if (l1 > 0)
*end_line2 = max (*start_line2, l1);
*end_line2 = MAX (*start_line2, l1);
pos++;
}
}

@ -159,7 +159,7 @@ edit_load_status_update_cb (status_msg_t * sm)
int wd_width;
Widget *lw = WIDGET (ssm->label);
wd_width = max (wd->cols, lw->cols + 6);
wd_width = MAX (wd->cols, lw->cols + 6);
widget_set_size (wd, wd->y, wd->x, wd->lines, wd_width);
widget_set_size (lw, lw->y, wd->x + (wd->cols - lw->cols) / 2, lw->lines, lw->cols);
rsm->first = FALSE;
@ -3099,7 +3099,7 @@ edit_mark_current_word_cmd (WEdit * edit)
if ((my_type_of (c1) & my_type_of (c2)) == 0)
break;
}
edit->mark2 = min (pos + 1, edit->buffer.size);
edit->mark2 = MIN (pos + 1, edit->buffer.size);
edit->force |= REDRAW_LINE_ABOVE | REDRAW_AFTER_CURSOR;
}

@ -330,8 +330,8 @@ edit_buffer_count_lines (const edit_buffer_t * buf, off_t first, off_t last)
{
long lines = 0;
first = max (first, 0);
last = min (last, buf->size);
first = MAX (first, 0);
last = MIN (last, buf->size);
while (first < last)
if (edit_buffer_get_byte (buf, first++) == '\n')
@ -596,7 +596,7 @@ edit_buffer_get_forward_offset (const edit_buffer_t * buf, off_t current, long l
if (upto != 0)
return (off_t) edit_buffer_count_lines (buf, current, upto);
lines = max (lines, 0);
lines = MAX (lines, 0);
while (lines-- != 0)
{
@ -625,7 +625,7 @@ edit_buffer_get_forward_offset (const edit_buffer_t * buf, off_t current, long l
off_t
edit_buffer_get_backward_offset (const edit_buffer_t * buf, off_t current, long lines)
{
lines = max (lines, 0);
lines = MAX (lines, 0);
current = edit_buffer_get_bol (buf, current);
while (lines-- != 0 && current != 0)

@ -145,7 +145,7 @@ edit_search_status_update_cb (status_msg_t * sm)
int wd_width;
Widget *lw = WIDGET (ssm->label);
wd_width = max (wd->cols, lw->cols + 6);
wd_width = MAX (wd->cols, lw->cols + 6);
widget_set_size (wd, wd->y, wd->x, wd->lines, wd_width);
widget_set_size (lw, lw->y, wd->x + (wd->cols - lw->cols) / 2, lw->lines, lw->cols);
esm->first = FALSE;
@ -546,8 +546,8 @@ edit_delete_column_of_text (WEdit * edit)
n = edit_buffer_get_forward_offset (&edit->buffer, m1, 0, m2) + 1;
c = (long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, m1), 0, m1);
d = (long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, m2), 0, m2);
b = max (min (c, d), min (edit->column1, edit->column2));
c = max (c, max (edit->column1, edit->column2));
b = MAX (MIN (c, d), MIN (edit->column1, edit->column2));
c = MAX (c, MAX (edit->column1, edit->column2));
while (n--)
{
@ -601,8 +601,8 @@ edit_block_delete (WEdit * edit)
return 1;
}
}
c1 = min (edit->column1, edit->column2);
c2 = max (edit->column1, edit->column2);
c1 = MIN (edit->column1, edit->column2);
c2 = MAX (edit->column1, edit->column2);
edit->column1 = c1;
edit->column2 = c2;
@ -858,7 +858,7 @@ editcmd_find (edit_search_status_msg_t * esm, gsize * len)
else
{
if (edit_search_options.backwards)
end_mark = max (1, edit->buffer.curs1) - 1;
end_mark = MAX (1, edit->buffer.curs1) - 1;
}
/* search */
@ -1288,7 +1288,7 @@ edit_collect_completions (WEdit * edit, off_t word_start, gsize word_len,
{
if (strncmp
((char *) &compl[i]->str[word_len],
(char *) &temp->str[word_len], max (len, compl[i]->len) - word_len) == 0)
(char *) &temp->str[word_len], MAX (len, compl[i]->len) - word_len) == 0)
{
GString *this = compl[i];
for (++i; i < *num; i++)
@ -2290,13 +2290,13 @@ eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark)
if (edit->mark2 >= 0)
{
*start_mark = min (edit->mark1, edit->mark2);
*end_mark = max (edit->mark1, edit->mark2);
*start_mark = MIN (edit->mark1, edit->mark2);
*end_mark = MAX (edit->mark1, edit->mark2);
}
else
{
*start_mark = min (edit->mark1, end_mark_curs);
*end_mark = max (edit->mark1, end_mark_curs);
*start_mark = MIN (edit->mark1, end_mark_curs);
*end_mark = MAX (edit->mark1, end_mark_curs);
edit->column2 = edit->curs_col + edit->over_col;
}
@ -2313,8 +2313,8 @@ eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark)
start_eol = edit_buffer_get_eol (&edit->buffer, start_bol - 1) + 1;
end_bol = edit_buffer_get_bol (&edit->buffer, *end_mark);
end_eol = edit_buffer_get_eol (&edit->buffer, *end_mark);
col1 = min (edit->column1, edit->column2);
col2 = max (edit->column1, edit->column2);
col1 = MIN (edit->column1, edit->column2);
col2 = MAX (edit->column1, edit->column2);
diff1 = edit_move_forward3 (edit, start_bol, col2, 0) -
edit_move_forward3 (edit, start_bol, col1, 0);
@ -2323,8 +2323,8 @@ eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark)
*start_mark -= diff1;
*end_mark += diff2;
*start_mark = max (*start_mark, start_eol);
*end_mark = min (*end_mark, end_eol);
*start_mark = MAX (*start_mark, start_eol);
*end_mark = MIN (*end_mark, end_eol);
}
return TRUE;
}
@ -2407,8 +2407,8 @@ edit_block_move_cmd (WEdit * edit)
long c1, c2, b_width;
long x, x2;
c1 = min (edit->column1, edit->column2);
c2 = max (edit->column1, edit->column2);
c1 = MIN (edit->column1, edit->column2);
c2 = MAX (edit->column1, edit->column2);
b_width = c2 - c1;
edit_update_curs_col (edit);
@ -2435,7 +2435,7 @@ edit_block_move_cmd (WEdit * edit)
/* remove current selection */
edit_block_delete_cmd (edit);
edit->over_col = max (0, edit->over_col - b_width);
edit->over_col = MAX (0, edit->over_col - b_width);
/* calculate the cursor pos after delete block */
current = edit_move_forward3 (edit, edit_buffer_get_current_bol (&edit->buffer), x, 0);
edit_cursor_move (edit, current - edit->buffer.curs1);
@ -2940,7 +2940,7 @@ edit_save_block (WEdit * edit, const char *filename, off_t start, off_t finish)
buf = g_malloc0 (TEMP_BUF_LEN);
while (start != finish)
{
end = min (finish, start + TEMP_BUF_LEN);
end = MIN (finish, start + TEMP_BUF_LEN);
for (; i < end; i++)
buf[i - start] = edit_buffer_get_byte (&edit->buffer, i);
len -= mc_write (file, (char *) buf, end - start);

@ -317,7 +317,7 @@ editcmd_dialog_raw_key_query (const char *heading, const char *query, gboolean c
w = str_term_width1 (heading) + 6;
wq = str_term_width1 (query);
w = max (w, wq + 3 * 2 + 1 + 2);
w = MAX (w, wq + 3 * 2 + 1 + 2);
raw_dlg =
dlg_create (TRUE, 0, 0, cancel ? 7 : 5, w, dialog_colors, editcmd_dialog_raw_key_query_cb,

@ -603,8 +603,8 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
long c1, c2;
x = (long) edit_move_forward3 (edit, b, 0, q);
c1 = min (edit->column1, edit->column2);
c2 = max (edit->column1, edit->column2);
c1 = MIN (edit->column1, edit->column2);
c2 = MAX (edit->column1, edit->column2);
if (x >= c1 && x < c2)
p->style |= MOD_MARKED;
}
@ -1092,8 +1092,8 @@ edit_scroll_screen_over_cursor (WEdit * edit)
t_extreme = EDIT_TOP_EXTREME;
if (edit->found_len != 0)
{
b_extreme = max (w->lines / 4, b_extreme);
t_extreme = max (w->lines / 4, t_extreme);
b_extreme = MAX (w->lines / 4, b_extreme);
t_extreme = MAX (w->lines / 4, t_extreme);
}
if (b_extreme + t_extreme + 1 > w->lines)
{

@ -327,7 +327,7 @@ edit_window_list (const WDialog * h)
int i = 0;
int rv;
lines = min ((size_t) (LINES * 2 / 3), dlg_num);
lines = MIN ((size_t) (LINES * 2 / 3), dlg_num);
cols = COLS * 2 / 3;
listbox = create_listbox_window (lines, cols, _("Open files"), "[Open files]");
@ -1045,8 +1045,8 @@ edit_mouse_handle_move_resize (Widget * w, mouse_msg_t msg, mouse_event_t * even
}
else if (edit->drag_state == MCEDIT_DRAG_RESIZE)
{
w->lines = max (WINDOW_MIN_LINES, global_y - w->y + 1);
w->cols = max (WINDOW_MIN_COLS, global_x - w->x + 1);
w->lines = MAX (WINDOW_MIN_LINES, global_y - w->y + 1);
w->cols = MAX (WINDOW_MIN_COLS, global_x - w->x + 1);
}
edit->force |= REDRAW_COMPLETELY; /* Not really needed as WEdit's MSG_DRAW already does this. */

@ -99,15 +99,15 @@ spell_dialog_spell_suggest_show (WEdit * edit, const char *word, char **new_word
cancel_button = button_new (11, 28, B_CANCEL, NORMAL_BUTTON, _("&Cancel"), 0);
cancel_len = button_get_len (cancel_button);
max_btn_len = max (replace_len, skip_len);
max_btn_len = max (max_btn_len, cancel_len);
max_btn_len = MAX (replace_len, skip_len);
max_btn_len = MAX (max_btn_len, cancel_len);
lang_label = g_strdup_printf ("%s: %s", _("Language"), aspell_get_lang ());
word_label = g_strdup_printf ("%s: %s", _("Misspelled"), word);
word_label_len = str_term_width1 (word_label) + 5;
sug_dlg_w += max_btn_len;
sug_dlg_w = max (sug_dlg_w, word_label_len) + 1;
sug_dlg_w = MAX (sug_dlg_w, word_label_len) + 1;
sug_dlg = dlg_create (TRUE, ypos, xpos, sug_dlg_h, sug_dlg_w,
dialog_colors, NULL, NULL, "[ASpell]", _("Check word"), DLG_COMPACT);

@ -836,7 +836,7 @@ chown_advanced_cmd (void)
/* Number of files at startup */
int files_on_begin;
files_on_begin = max (1, current_panel->marked);
files_on_begin = MAX (1, current_panel->marked);
do
{ /* do while any files remaining */

@ -1235,7 +1235,7 @@ jobs_cmd (void)
}
x += (int) n_but - 1;
cols = max (cols, x + 6);
cols = MAX (cols, x + 6);
jobs_dlg = dlg_create (TRUE, 0, 0, lines, cols, dialog_colors, NULL, NULL,
"[Background jobs]", _("Background jobs"), DLG_CENTER);

@ -157,7 +157,7 @@ chmod_i18n (void)
for (i = 0; i < check_perm_num; i++)
{
len = str_term_width1 (check_perm[i].text);
check_perm_len = max (check_perm_len, len);
check_perm_len = MAX (check_perm_len, len);
}
check_perm_len += 1 + 3 + 1; /* mark, [x] and space */
@ -165,7 +165,7 @@ chmod_i18n (void)
for (i = 0; i < file_info_labels_num; i++)
{
len = str_term_width1 (file_info_labels[i]) + 2; /* spaces around */
file_info_labels_len = max (file_info_labels_len, len);
file_info_labels_len = MAX (file_info_labels_len, len);
}
for (i = 0; i < chmod_but_num; i++)
@ -292,7 +292,7 @@ init_chmod (const char *fname, const struct stat *sf_stat)
perm_gb_len = check_perm_len + 2;
file_gb_len = file_info_labels_len + 2;
cols = str_term_width1 (fname) + 2 + 1;
file_gb_len = max (file_gb_len, cols);
file_gb_len = MAX (file_gb_len, cols);
lines = single_set ? 20 : 23;
cols = perm_gb_len + file_gb_len + 1 + 6;

@ -287,7 +287,7 @@ dir_list_grow (dir_list * list, int delta)
list->size = size;
}
list->len = clear_flag ? 0 : min (list->len, size);
list->len = clear_flag ? 0 : MIN (list->len, size);
return TRUE;
}

@ -2498,7 +2498,7 @@ dirsize_status_init_cb (status_msg_t * sm)
if (dsm->allow_skip)
b_width += str_term_width1 (b2_name) + 4 + 1;
ui_width = max (COLS / 2, b_width + 6);
ui_width = MAX (COLS / 2, b_width + 6);
dsm->dirname = label_new (2, 3, "");
add_widget (sm->dlg, dsm->dirname);
dsm->count_size = label_new (3, 3, "");

@ -500,7 +500,7 @@ overwrite_query_dialog (file_op_context_t * ctx, enum OperationMode mode)
* longest of "Overwrite..." labels
* (assume "Target date..." are short enough)
*/
l1 = max (widgets_len[9], widgets_len[4]);
l1 = MAX (widgets_len[9], widgets_len[4]);
/* longest of button rows */
l = l2 = 0;
@ -511,17 +511,17 @@ overwrite_query_dialog (file_op_context_t * ctx, enum OperationMode mode)
if (row != rd_widgets[i].ypos)
{
row = rd_widgets[i].ypos;
l2 = max (l2, l);
l2 = MAX (l2, l);
l = 0;
}
l += widgets_len[i] + 4;
}
l2 = max (l2, l); /* last row */
rd_xlen = max (rd_xlen, l1 + l2 + 8);
/* rd_xlen = max (rd_xlen, str_term_width1 (title) + 2); */
l2 = MAX (l2, l); /* last row */
rd_xlen = MAX (rd_xlen, l1 + l2 + 8);
/* rd_xlen = MAX (rd_xlen, str_term_width1 (title) + 2); */
stripped_name_len = str_term_width1 (stripped_name);
rd_xlen = max (rd_xlen, min (COLS, stripped_name_len + 8));
rd_xlen = MAX (rd_xlen, MIN (COLS, stripped_name_len + 8));
/* Now place widgets */
l1 += 5; /* start of first button in the row */
@ -557,12 +557,12 @@ overwrite_query_dialog (file_op_context_t * ctx, enum OperationMode mode)
size_trunc_len (fsize_buffer, sizeof (fsize_buffer), ui->s_stat->st_size, 0,
panels_options.kilobyte_si);
ADD_RD_LABEL (2, file_date (ui->s_stat->st_mtime), fsize_buffer, y++);
rd_xlen = max (rd_xlen, label2->cols + 8);
rd_xlen = MAX (rd_xlen, label2->cols + 8);
/* destination date and size */
size_trunc_len (fsize_buffer, sizeof (fsize_buffer), ui->d_stat->st_size, 0,
panels_options.kilobyte_si);
ADD_RD_LABEL (3, file_date (ui->d_stat->st_mtime), fsize_buffer, y++);
rd_xlen = max (rd_xlen, label2->cols + 8);
rd_xlen = MAX (rd_xlen, label2->cols + 8);
add_widget (ui->replace_dlg, hline_new (y++, -1, -1));
@ -844,11 +844,11 @@ file_op_context_create_ui (file_op_context_t * ctx, gboolean with_eta,
add_widget (ui->op_dlg, progress_buttons[3].w);
buttons_width = 2 +
progress_buttons[0].len + max (progress_buttons[1].len, progress_buttons[2].len) +
progress_buttons[0].len + MAX (progress_buttons[1].len, progress_buttons[2].len) +
progress_buttons[3].len;
/* adjust dialog sizes */
dlg_set_size (ui->op_dlg, y + 3, max (COLS * 2 / 3, buttons_width + 6));
dlg_set_size (ui->op_dlg, y + 3, MAX (COLS * 2 / 3, buttons_width + 6));
place_progress_buttons (ui->op_dlg, FALSE);
@ -1209,7 +1209,7 @@ file_mask_dialog (file_op_context_t * ctx, FileOperation operation,
if (format_len + text_len <= max_len)
{
fmd_xlen = format_len + text_len + 6;
fmd_xlen = max (fmd_xlen, 68);
fmd_xlen = MAX (fmd_xlen, 68);
}
else
{
@ -1222,7 +1222,7 @@ file_mask_dialog (file_op_context_t * ctx, FileOperation operation,
else
{
fmd_xlen = COLS * 2 / 3;
fmd_xlen = max (fmd_xlen, 68);
fmd_xlen = MAX (fmd_xlen, 68);
g_snprintf (fmd_buf, sizeof (fmd_buf), format, *(const int *) text);
}

@ -697,7 +697,7 @@ init_i18n_stuff (int list_type, int cols)
(len[0])--;
(len[1])--;
cols = max (cols, max (len[0], len[1]));
cols = MAX (cols, MAX (len[0], len[1]));
/* arrange buttons */
for (i = 0; i < hotlist_but_num; i++)

@ -831,9 +831,9 @@ format_file (WPanel * panel, int file_index, int width, int attr, gboolean issta
*field_length = len + 1;
str_len = str_length (txt);
i = max (0, str_len - len);
panel->max_shift = max (panel->max_shift, i);
i = min (panel->content_shift, i);
i = MAX (0, str_len - len);
panel->max_shift = MAX (panel->max_shift, i);
i = MIN (panel->content_shift, i);
if (i > -1)
{
@ -1310,7 +1310,7 @@ show_dir (const WPanel * panel)
tty_setcolor (REVERSE_COLOR);
tmp = panel_correct_path_to_show (panel);
tty_printf (" %s ", str_term_trim (tmp, min (max (w->cols - 12, 0), w->cols)));
tty_printf (" %s ", str_term_trim (tmp, MIN (MAX (w->cols - 12, 0), w->cols)));
g_free (tmp);
if (!panels_options.show_mini_info)
@ -2453,7 +2453,7 @@ mark_file_right (WPanel * panel)
state_mark = selection (panel)->f.marked ? 0 : 1;
lines = panel_lines (panel);
lines = min (lines, panel->dir.len - panel->selected - 1);
lines = MIN (lines, panel->dir.len - panel->selected - 1);
for (; lines != 0; lines--)
{
do_file_mark (panel, panel->selected, state_mark);
@ -2473,7 +2473,7 @@ mark_file_left (WPanel * panel)
state_mark = selection (panel)->f.marked ? 0 : 1;
lines = panel_lines (panel);
lines = min (lines, panel->selected + 1);
lines = MIN (lines, panel->selected + 1);
for (; lines != 0; lines--)
{
do_file_mark (panel, panel->selected, state_mark);

@ -165,7 +165,7 @@ init_panelize (void)
}
panelize_cols = COLS - 6;
panelize_cols = max (panelize_cols, blen + 4);
panelize_cols = MAX (panelize_cols, blen + 4);
panelize_dlg =
dlg_create (TRUE, 0, 0, 20, panelize_cols, dialog_colors, panelize_callback, NULL,

@ -1069,7 +1069,7 @@ user_menu_cmd (const WEdit * edit_widget, const char *menu_file, int selected_en
menu_lines++;
accept_entry = TRUE;
}
max_cols = max (max_cols, col);
max_cols = MAX (max_cols, col);
col = 0;
}
else
@ -1093,7 +1093,7 @@ user_menu_cmd (const WEdit * edit_widget, const char *menu_file, int selected_en
{
Listbox *listbox;
max_cols = min (max (max_cols, col), MAX_ENTRY_LEN);
max_cols = MIN (MAX (max_cols, col), MAX_ENTRY_LEN);
/* Create listbox */
listbox = create_listbox_window (menu_lines, max_cols + 2, _("User menu"),

@ -73,7 +73,7 @@
#define MAXLINKNAME 80
#define HISTORY_SIZE 20
#define HELP_WINDOW_WIDTH min(80, COLS - 16)
#define HELP_WINDOW_WIDTH MIN(80, COLS - 16)
#define STRING_LINK_START "\01"
#define STRING_LINK_POINTER "\02"
@ -867,7 +867,7 @@ help_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *da
{
WButtonBar *bb;
help_lines = min (LINES - 4, max (2 * LINES / 3, 18));
help_lines = MIN (LINES - 4, MAX (2 * LINES / 3, 18));
dlg_set_size (h, help_lines + 4, HELP_WINDOW_WIDTH + 4);
bb = find_buttonbar (h);
widget_set_size (WIDGET (bb), LINES - 1, 0, 1, COLS);
@ -1093,7 +1093,7 @@ help_interactive_display (const gchar * event_group_name, const gchar * event_na
}
}
help_lines = min (LINES - 4, max (2 * LINES / 3, 18));
help_lines = MIN (LINES - 4, MAX (2 * LINES / 3, 18));
whelp =
dlg_create (TRUE, 0, 0, help_lines + 4, HELP_WINDOW_WIDTH + 4,

@ -302,7 +302,7 @@ init_learn (void)
label = _(key_name_conv_tab[i].longname);
padding = 16 - str_term_width1 (label);
padding = max (0, padding);
padding = MAX (0, padding);
g_snprintf (buffer, sizeof (buffer), "%s%*s", label, padding, "");
learnkeys[i].button =

@ -519,11 +519,11 @@ feed_subshell (int how, int fail_on_error)
FD_ZERO (&read_set);
FD_SET (mc_global.tty.subshell_pty, &read_set);
FD_SET (subshell_pipe[READ], &read_set);
maxfdp = max (mc_global.tty.subshell_pty, subshell_pipe[READ]);
maxfdp = MAX (mc_global.tty.subshell_pty, subshell_pipe[READ]);
if (how == VISIBLY)
{
FD_SET (STDIN_FILENO, &read_set);
maxfdp = max (maxfdp, STDIN_FILENO);
maxfdp = MAX (maxfdp, STDIN_FILENO);
}
if (select (maxfdp + 1, &read_set, NULL, NULL, wptr) == -1)

@ -81,7 +81,7 @@ mcview_ccache_add_entry (coord_cache_t * cache, size_t pos, const coord_cache_en
if ((cache == NULL) || (entry == NULL))
return;
pos = min (pos, cache->size);
pos = MIN (pos, cache->size);
/* increase cache capacity if needed */
if (cache->size == cache->capacity)

@ -284,12 +284,12 @@ mcview_compute_areas (WView * view)
/* Compute the heights of the areas */
rest = view_area.height;
height = min (rest, 1);
height = MIN (rest, 1);
view->status_area.height = height;
rest -= height;
height = (ruler == RULER_NONE || view->hex_mode) ? 0 : 2;
height = min (rest, height);
height = MIN (rest, height);
view->ruler_area.height = height;
rest -= height;

@ -424,7 +424,7 @@ mcview_load (WView * view, const char *command, const char *file, int start_line
if (max_offset < 0)
new_offset = 0;
else
new_offset = min (new_offset, max_offset);
new_offset = MIN (new_offset, max_offset);
if (!view->hex_mode)
{
view->dpy_start = mcview_bol (view, new_offset, 0);

@ -89,7 +89,7 @@ mcview_search_status_update_cb (status_msg_t * sm)
int wd_width;
Widget *lw = WIDGET (ssm->label);
wd_width = max (wd->cols, lw->cols + 6);
wd_width = MAX (wd->cols, lw->cols + 6);
widget_set_size (wd, wd->y, wd->x, wd->lines, wd_width);
widget_set_size (lw, lw->y, wd->x + (wd->cols - lw->cols) / 2, lw->lines, lw->cols);
vsm->first = FALSE;