Branch: Tag:

1999-05-24

1999-05-24 12:09:35 by Mirar (Pontus Hagland) <pike@sort.mirar.org>

bugfix: color argument other then color object bugged

Rev: src/modules/Image/colors.c:1.18

1:   /*   **! module Image   **! note - **! $Id: colors.c,v 1.17 1999/05/23 17:46:38 mirar Exp $ + **! $Id: colors.c,v 1.18 1999/05/24 12:09:35 mirar Exp $   **! submodule Color   **!   **! This module keeps names and easy handling
97:   #include "global.h"   #include <config.h>    - RCSID("$Id: colors.c,v 1.17 1999/05/23 17:46:38 mirar Exp $"); + RCSID("$Id: colors.c,v 1.18 1999/05/24 12:09:35 mirar Exp $");      #include "config.h"   
946:    if (sp[-1].type==T_OBJECT)    {    struct color_struct *cs=(struct color_struct*) -  get_storage(v->u.object,image_color_program); +  get_storage(sp[-1].u.object,image_color_program);    *rgb=cs->rgb;    pop_stack();    return 1;
995:    if (!colors)    make_colors();    +  if (sp[-1].type==T_STRING) +  {    mapping_index_no_free(&s,colors,sp-1); -  if (s.type==T_INT) +  if (s.type==T_OBJECT)    { -  object_index_no_free2(&s,THISOBJ,sp-1); -  if (s.type!=T_INT) -  { +     pop_stack();    *(sp++)=s;    return;    } -  +  else +  free_svalue(&s); +  }       if (sp[-1].type==T_STRING &&    sp[-1].u.string->size_shift==0)
1146:    return;    }    -  pop_stack(); -  *(sp++)=s; - } -  +    static void image_guess_color(INT32 args)   {    struct svalue s;
1177:    image_get_color(1);   }    + static void image_colors_index(INT32 args) + { +  struct svalue s; +  object_index_no_free2(&s,THISOBJ,sp-1); +  if (s.type!=T_INT) +  { +  pop_stack(); +  *(sp++)=s; +  return; +  } +  image_get_color(args); + } +    static void image_make_color(INT32 args)   {    struct svalue s;
1476:       /* this is the Image.Color stuff */    -  ADD_FUNCTION("`[]",image_get_color,tFunc(tStr,tObj),0); -  ADD_FUNCTION("`()",image_make_color,tFuncV(,tOr(tStr,tInt),tObj),0); +  ADD_FUNCTION("`[]",image_colors_index,tFunc(tStr,tObj),0); +  ADD_FUNCTION("`()",image_make_color, +  tOr(tFunc(tStr,tObj), +  tFunc(tInt tInt tInt,tObj)),0);    ADD_FUNCTION("rgb",image_make_rgb_color,tFunc(tInt tInt tInt,tObj),0);    ADD_FUNCTION("hsv",image_make_hsv_color,    tOr(tFunc(tInt tInt tInt,tObj),