#include <libpspp/misc.h>
#include <libpspp/str.h>
+#include "minmax.h"
+
#include "gettext.h"
#define _(msgid) gettext (msgid)
move_element (d->var, d->var_cnt, sizeof *d->var, v->index, new_index);
- min_idx = min (v->index, new_index);
- max_idx = max (v->index, new_index);
+ min_idx = MIN (v->index, new_index);
+ max_idx = MAX (v->index, new_index);
for (i = min_idx; i <= max_idx; i++)
d->var[i]->index = i;
}
break;
}
- for ( i = 0 ; i < min(n_vars, dict_get_var_cnt(*dict)) ; ++i )
+ for ( i = 0 ; i < MIN(n_vars, dict_get_var_cnt(*dict)) ; ++i )
{
struct
{
if (var[0]->type == ALPHA)
{
- const int copy_len = min (sizeof label->raw_value,
+ const int copy_len = MIN (sizeof label->raw_value,
sizeof label->label);
memcpy (label->value.s, label->raw_value, copy_len);
} else {
assert (r);
if (buf == NULL && byte_cnt > 0 )
- buf = xmalloc (max (byte_cnt, min_alloc));
+ buf = xmalloc (MAX (byte_cnt, min_alloc));
if ( byte_cnt == 0 )
return buf;
int nm; /* Number of missing values, possibly negative. */
sv.rec_type = 2;
- sv.type = min(v->width, MAX_LONG_STRING);
+ sv.type = MIN(v->width, MAX_LONG_STRING);
sv.has_var_label = (v->label != NULL);
mv_copy (&mv, &v->miss);
int ext_len;
- l.label_len = min (strlen (v->label), 255);
+ l.label_len = MIN (strlen (v->label), 255);
ext_len = ROUND_UP (l.label_len, sizeof l.label_len);
memcpy (l.label, v->label, l.label_len);
memset (&l.label[l.label_len], ' ', ext_len - l.label_len);
memset (&sv.write, 0, sizeof sv.write);
memset (&sv.name, 0, sizeof sv.name);
- pad_count = DIV_RND_UP (min(v->width, MAX_LONG_STRING),
+ pad_count = DIV_RND_UP (MIN(v->width, MAX_LONG_STRING),
(int) sizeof (flt64)) - 1;
for (i = 0; i < pad_count; i++)
buf_write (w, &sv, sizeof sv);
static char *
append_string_max (char *dest, const char *src, const char *end)
{
- int nbytes = min (end - dest, (int) strlen (src));
+ int nbytes = MIN (end - dest, (int) strlen (src));
memcpy (dest, src, nbytes);
return dest + nbytes;
}
#include <libpspp/str.h>
#include "value-labels.h"
+#include "minmax.h"
+
#include "gettext.h"
#define _(msgid) gettext (msgid)
if (width == 0)
return a->f < b->f ? -1 : a->f > b->f;
else
- return memcmp (a->s, b->s, min(MAX_SHORT_STRING, width));
+ return memcmp (a->s, b->s, MIN(MAX_SHORT_STRING, width));
}
/* Create a hash of v */
if ( 0 == width )
id_hash = hsh_hash_double (v->f);
else
- id_hash = hsh_hash_bytes (v->s, min(MAX_SHORT_STRING, width));
+ id_hash = hsh_hash_bytes (v->s, MIN(MAX_SHORT_STRING, width));
return id_hash;
}
#include <output/output.h>
#include <output/table.h>
+#include "minmax.h"
+
#include "gettext.h"
#define _(msgid) gettext (msgid)
struct variable *v = cmd.v_variables[i];
memset (&prc->header[prc->header_rows - 1][x], '-',
- max (v->print.w, (int) strlen (v->name)));
+ MAX (v->print.w, (int) strlen (v->name)));
if ((int) strlen (v->name) < v->print.w)
x += v->print.w - strlen (v->name);
memcpy (&prc->header[0][x], v->name, strlen (v->name));
outp_open_page (d);
max_width = n_chars_width (d);
- largest_page_width = max (largest_page_width, max_width);
+ largest_page_width = MAX (largest_page_width, max_width);
prc = d->prc = xmalloc (sizeof *prc);
prc->type = 0;
for (width = cmd.n_variables - 1, column = 0; column < cmd.n_variables; column++)
{
struct variable *v = cmd.v_variables[column];
- width += max (v->print.w, (int) strlen (v->name));
+ width += MAX (v->print.w, (int) strlen (v->name));
}
if (width <= max_width)
{
{
struct variable *v = cmd.v_variables[column];
int trial_width = (width - v->print.w
- + max (v->print.w, (int) strlen (v->name)));
+ + MAX (v->print.w, (int) strlen (v->name)));
if (trial_width > max_width)
{
for (prc->header_rows = 0, column = 0;
column < prc->n_vertical;
column++)
- prc->header_rows = max (prc->header_rows,
+ prc->header_rows = MAX (prc->header_rows,
strlen (cmd.v_variables[column]->name));
prc->header_rows++;
continue;
int width;
if (prc->type == 0 && column >= prc->n_vertical)
- width = max ((int) strlen (v->name), v->print.w);
+ width = MAX ((int) strlen (v->name), v->print.w);
else
width = v->print.w;
#include <libpspp/pool.h>
#include <libpspp/str.h>
+#include "minmax.h"
#include "size_max.h"
#include "gettext.h"
char s[16];
char *cp;
- memcpy (s, token->string, min (15, token->length));
- s[min (15, token->length)] = 0;
+ memcpy (s, token->string, MIN (15, token->length));
+ s[MIN (15, token->length)] = 0;
for (cp = s; *cp; cp++)
*cp = toupper ((unsigned char) *cp);
#include <output/output.h>
#include <output/table.h>
+#include "minmax.h"
+
#include "gettext.h"
#define _(msgid) gettext (msgid)
int i;
for (p = max; *p; p++)
- t->w[p - max] = min (tab_natural_width (t, d, p - max),
+ t->w[p - max] = MIN (tab_natural_width (t, d, p - max),
*p * d->prop_em_width);
for (i = 0; i < t->nr; i++)
t->h[i] = tab_natural_height (t, d, i);
if (r + 10 + nvl > nr)
{
- nr = max (nr * dict_get_var_cnt (d) / (i + 1), nr);
+ nr = MAX (nr * dict_get_var_cnt (d) / (i + 1), nr);
nr += 10 + nvl;
tab_realloc (t, 4, nr);
}
t->w[0] = tab_natural_width (t, d, 0);
if (_as == AS_DICTIONARY || _as == AS_VARIABLES || _as == AS_LABELS)
{
- t->w[1] = max (tab_natural_width (t, d, 1), d->prop_em_width * 5);
- t->w[2] = max (tab_natural_width (t, d, 2), d->prop_em_width * 35);
+ t->w[1] = MAX (tab_natural_width (t, d, 1), d->prop_em_width * 5);
+ t->w[2] = MAX (tab_natural_width (t, d, 2), d->prop_em_width * 35);
pc = 3;
}
else pc = 1;
if (r + 10 + nvl > nr)
{
- nr = max (nr * n / (i + 1), nr);
+ nr = MAX (nr * n / (i + 1), nr);
nr += 10 + nvl;
tab_realloc (t, nc, nr);
}
#include <math/moments.h>
#include <math/sort.h>
+#include "minmax.h"
+
#include "gettext.h"
#define _(msgid) gettext (msgid)
moments1_add (iter->moments, v->f, weight);
break;
case MAX:
- iter->dbl[0] = max (iter->dbl[0], v->f);
+ iter->dbl[0] = MAX (iter->dbl[0], v->f);
iter->int1 = 1;
break;
case MAX | FSTRING:
iter->int1 = 1;
break;
case MIN:
- iter->dbl[0] = min (iter->dbl[0], v->f);
+ iter->dbl[0] = MIN (iter->dbl[0], v->f);
iter->int1 = 1;
break;
case MIN | FSTRING:
#include <output/output.h>
#include <output/table.h>
+#include "minmax.h"
+
#include "gettext.h"
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
/* Allocate table space for the matrix. */
if (table && tab_row (table) + (n_rows + 1) * num_cells > tab_nr (table))
tab_realloc (table, -1,
- max (tab_nr (table) + (n_rows + 1) * num_cells,
+ MAX (tab_nr (table) + (n_rows + 1) * num_cells,
tab_nr (table) * (pe - pb) / (te - tb)));
if (mode == GENERAL)
{
int x;
- if (min (c, d) < min (a, b))
+ if (MIN (c, d) < MIN (a, b))
swap (&a, &c), swap (&b, &d);
- if (min (b, d) < min (a, c))
+ if (MIN (b, d) < MIN (a, c))
swap (&a, &b), swap (&c, &d);
if (b * c < a * d)
{
calc_symmetric (double v[N_SYMMETRIC], double ase[N_SYMMETRIC],
double t[N_SYMMETRIC])
{
- int q = min (ns_rows, ns_cols);
+ int q = MIN (ns_rows, ns_cols);
if (q <= 1)
return 0;
assert (fmt_subst.type == FMT_A || fmt_subst.type == FMT_AHEX);
if (fmt_subst.type == FMT_A)
- fmt_subst.w = min (8, fmt_subst.w);
+ fmt_subst.w = MIN (8, fmt_subst.w);
else
- fmt_subst.w = min (16, fmt_subst.w);
+ fmt_subst.w = MIN (16, fmt_subst.w);
fp = &fmt_subst;
}
#include <output/manager.h>
#include <output/table.h>
+#include "minmax.h"
+
#include "gettext.h"
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
for ( i = 0 ; i < n_vars ; ++i )
{
- y_max = max (y_max, (*fs)->m[i].max);
- y_min = min (y_min, (*fs)->m[i].min);
+ y_max = MAX (y_max, (*fs)->m[i].max);
+ y_min = MIN (y_min, (*fs)->m[i].min);
}
boxplot_draw_yscale (ch, y_max, y_min);
{
/* Need to make sure that both the scatter plot and the ideal fit into the
plot */
- double x_lower = min (m->min, (yfirst - intercept) / slope) ;
- double x_upper = max (m->max, (ylast - intercept) / slope) ;
+ double x_lower = MIN (m->min, (yfirst - intercept) / slope) ;
+ double x_upper = MAX (m->max, (ylast - intercept) / slope) ;
double slack = (x_upper - x_lower) * 0.05 ;
chart_write_xscale (np_chart, x_lower - slack, x_upper + slack, 5);
#include <libpspp/str.h>
#include "intprops.h"
+#include "minmax.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
for (i = 1; i < 10000000; i++)
{
- int ofs = min (7 - intlog10 (i), len);
+ int ofs = MIN (7 - intlog10 (i), len);
memcpy (n, name, ofs);
sprintf (&n[ofs], "%d", i);
}
else
{
- int width = min (flip->new_names->width, MAX_SHORT_STRING);
+ int width = MIN (flip->new_names->width, MAX_SHORT_STRING);
memcpy (v->name, case_str (c, flip->idx_to_fv[flip->new_names->index]),
width);
v->name[width] = 0;
for (case_idx = 0; case_idx < flip->case_cnt; )
{
- unsigned long read_cases = min (flip->case_cnt - case_idx,
+ unsigned long read_cases = MIN (flip->case_cnt - case_idx,
case_capacity);
size_t i;
int i;
if (lab)
- t->w[0] = min (tab_natural_width (t, d, 0), d->prop_em_width * 15);
+ t->w[0] = MIN (tab_natural_width (t, d, 0), d->prop_em_width * 15);
for (i = lab; i < lab + 5; i++)
- t->w[i] = max (tab_natural_width (t, d, i), d->prop_em_width * 8);
+ t->w[i] = MAX (tab_natural_width (t, d, i), d->prop_em_width * 8);
for (i = 0; i < t->nr; i++)
t->h[i] = d->font_height;
}
static void
condensed_dim (struct tab_table *t, struct outp_driver *d)
{
- int cum_w = max (outp_string_width (d, _("Cum"), OUTP_PROPORTIONAL),
- max (outp_string_width (d, _("Cum"), OUTP_PROPORTIONAL),
+ int cum_w = MAX (outp_string_width (d, _("Cum"), OUTP_PROPORTIONAL),
+ MAX (outp_string_width (d, _("Cum"), OUTP_PROPORTIONAL),
outp_string_width (d, "000", OUTP_PROPORTIONAL)));
int i;
for (i = 0; i < 2; i++)
- t->w[i] = max (tab_natural_width (t, d, i), d->prop_em_width * 8);
+ t->w[i] = MAX (tab_natural_width (t, d, i), d->prop_em_width * 8);
for (i = 2; i < 4; i++)
t->w[i] = cum_w;
for (i = 0; i < t->nr; i++)
+Fri Nov 24 17:27:00 2006 Ben Pfaff <blp@gnu.org>
+
+ * misc.h: (min) Removed. All references updated to use MIN, from
+ minmax.h provided by gnulib.
+ (max) Ditto (for MAX).
+
Sun Nov 19 09:22:26 2006 Ben Pfaff <blp@gnu.org>
* str.c (ss_get_long): New function.
#include <libpspp/assertion.h>
#include "message.h"
+
+#include "minmax.h"
\f
/* Finds an element in ARRAY, which contains COUNT elements of
SIZE bytes each, using COMPARE for comparisons. Returns the
of the array to sort, and END_PTR points at the very last element in
the array (*not* one beyond it!). */
-#define min(x, y) ((x) < (y) ? (x) : (y))
-
{
char *const end_ptr = &first[size * (count - 1)];
char *tmp_ptr = first;
- char *thresh = min(end_ptr, first + max_thresh);
+ char *thresh = MIN (end_ptr, first + max_thresh);
register char *run_ptr;
/* Find smallest element in first threshold and place it at the
#include <ieeefp.h> /* Declares finite() under Solaris. */
#endif
-#ifndef min
-#define min(A, B) ((A) < (B) ? (A) : (B))
-#endif
-
-#ifndef max
-#define max(A, B) ((A) > (B) ? (A) : (B))
-#endif
-
/* Clamps A to be between B and C. */
#define range(A, B, C) ((A) < (B) ? (B) : ((A) > (C) ? (C) : (A)))
02110-1301, USA. */
#include <config.h>
+#include <assert.h>
#include <libpspp/compiler.h>
#include "factor-stats.h"
#include "percentiles.h"
#include <libpspp/misc.h>
+#include "minmax.h"
+
#include "gettext.h"
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
-#include <assert.h>
-
-
struct ptile_params
{
double g1, g1_star;
for ( i = 0 ; i < n_data ; ++i )
{
- c_star = min(c_star, wv[i]->w);
+ c_star = MIN(c_star, wv[i]->w);
}
if ( c_star > 1 ) c_star = 1;
#include <libpspp/misc.h>
#include <libpspp/str.h>
+#include "minmax.h"
+
#include "gettext.h"
#define _(msgid) gettext (msgid)
{
while (xsrt->run_cnt > 1)
{
- int order = min (MAX_MERGE_ORDER, xsrt->run_cnt);
+ int order = MIN (MAX_MERGE_ORDER, xsrt->run_cnt);
int idx = choose_merge (xsrt->runs, xsrt->run_cnt, order);
xsrt->runs[idx] = merge_once (xsrt, xsrt->runs + idx, order);
remove_range (xsrt->runs, xsrt->run_cnt, sizeof *xsrt->runs,
#include <output/chart.h>
#include <libpspp/str.h>
#include <data/value-labels.h>
-#include <libpspp/misc.h>
+
+#include "minmax.h"
/* Pie charts of course need to know Pi :) */
const double centre_x = (ch->data_right + ch->data_left ) / 2.0 ;
const double centre_y = (ch->data_top + ch->data_bottom ) / 2.0 ;
- const double radius = min(
+ const double radius = MIN(
5.0 / 12.0 * (ch->data_top - ch->data_bottom),
1.0 / 4.0 * (ch->data_right - ch->data_left)
);
if (nc > t->cf)
{
- int mr1 = min (nr, t->nr);
- int mc1 = min (nc, t->nc);
+ int mr1 = MIN (nr, t->nr);
+ int mc1 = MIN (nc, t->nc);
struct substring *new_cc;
unsigned char *new_ct;