From b63f768f008e7967431269cf638e7c5343fb3f1d Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sat, 28 Jun 2008 23:50:43 +0200 Subject: [PATCH] MIN/MAX multi-evaluate their arguments. Signed-off-by: Pierre Habouzit Signed-off-by: Julien Danjou --- widgets/progressbar.c | 3 ++- widgets/textbox.c | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/widgets/progressbar.c b/widgets/progressbar.c index 1e707dd23..159653f35 100644 --- a/widgets/progressbar.c +++ b/widgets/progressbar.c @@ -541,7 +541,8 @@ luaA_progressbar_bar_data_add(lua_State *L) if(!bar) bar = progressbar_bar_add(d, title); - bar->value = MAX(bar->min_value, MIN(bar->max_value, luaL_checknumber(L, 3))); + bar->value = luaL_checknumber(L, 3); + bar->value = MAX(bar->min_value, MIN(bar->max_value, bar->value)); widget_invalidate_bywidget(*widget); diff --git a/widgets/textbox.c b/widgets/textbox.c index e342713f4..006965be7 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -58,10 +58,10 @@ textbox_draw(draw_context_t *ctx, int screen __attribute__ ((unused)), else { draw_parser_data_init(&pdata); - w->area.width = MIN(draw_text_extents(ctx->connection, - ctx->phys_screen, - globalconf.font, d->text, &pdata).width, - ctx->width - used); + w->area.width = draw_text_extents(ctx->connection, ctx->phys_screen, + globalconf.font, d->text, &pdata).width; + if(w->area.width > ctx->width - used) + w->area.width = ctx->width - used; if(pdata.bg_image) w->area.width = MAX(w->area.width, pdata.bg_resize ? w->area.height : pdata.bg_image->width);