X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Ffind-dialog.c;h=e617280739153a28c7445bf7b96568b2ac2c8f65;hb=0931dbb924b98df79989e2b4017f538f2ab6b23c;hp=01abc0c81644c2a7d6c8e07a83050bbc641f9428;hpb=5f1ab307d380c4d60410b911a272b6870b65c2d8;p=pspp diff --git a/src/ui/gui/find-dialog.c b/src/ui/gui/find-dialog.c index 01abc0c816..e617280739 100644 --- a/src/ui/gui/find-dialog.c +++ b/src/ui/gui/find-dialog.c @@ -49,13 +49,6 @@ which match particular strings */ #define _(msgid) gettext (msgid) #define N_(msgid) msgid -/* Some systems like MacOS do not have exp10 */ -#ifndef HAVE_EXP10 -inline static double exp10(double x) -{ - return pow(10.0, x); -} -#endif struct find_dialog { @@ -459,6 +452,18 @@ struct regexp_comparator regex_t re; }; +/* Returns 10 raised to the power of X. + X must be a non-negative integer. */ +static inline int +int_pow10 (int x) +{ + int ret = 1; + assert (x >= 0); + while (x--) + ret *= 10; + + return ret; +} static bool value_compare (const struct comparator *cmptr, @@ -467,7 +472,7 @@ value_compare (const struct comparator *cmptr, const struct numeric_comparator *nc = (const struct numeric_comparator *) cmptr; const struct fmt_spec *fs = var_get_print_format (cmptr->var); - double c = nearbyint (v->f * exp10 (fs->d)); + double c = nearbyint (v->f * int_pow10 (fs->d)); return c == nc->rounded_ref; } @@ -599,7 +604,7 @@ numeric_comparator_create (const struct variable *var, const char *target) union value val; text_to_value (target, var, &val); - nc->rounded_ref = nearbyint (val.f * exp10 (fs->d)); + nc->rounded_ref = nearbyint (val.f * int_pow10 (fs->d)); value_destroy (&val, var_get_width (var)); return cmptr;