pike.git / src / modules / Image / encodings / _xpm.c

version» Context lines:

pike.git/src/modules/Image/encodings/_xpm.c:8:   #include "image_machine.h"      #include "interpret.h"   #include "svalue.h"   #include "program.h"   #include "pike_error.h"   #include "stralloc.h"   #include "operators.h"   #include "threads.h"   #include "module_support.h" + #include "pike_types.h"      #include "image.h"   #include "colortable.h"         #define sp Pike_sp      /*! @module Image    *! -  *! @module _XPM +  *! @module XPM    */      extern struct program *image_program;      static int hextoint( int what )   {    if(what >= '0' && what <= '9')    return what-'0';    if(what >= 'a' && what <= 'f')    return 10+what-'a';
pike.git/src/modules/Image/encodings/_xpm.c:81:    return res;    }    if(s->len==4&&(!strncmp(s->str,"None",4)||!strncmp(s->str,"none",4)))    {    res.r = res.g = res.b = 0;    res.alpha = 0;    return res;    }    if(!parse_color)    { -  push_text("Image.Color"); +  push_static_text("Image.Color");    SAFE_APPLY_MASTER( "resolv_or_error", 1 );    _parse_color = sp[-1];    parse_color = &_parse_color;    sp--;    }    push_svalue( parse_color );    push_string(make_shared_binary_string(s->str,s->len));    f_index( 2 );    if(TYPEOF(sp[-1]) != T_OBJECT) {    push_int(0);    stack_swap();    } else { -  push_constant_text( "array" ); -  apply( sp[-2].u.object, "cast", 1 ); +  ref_push_type_value(array_type_string); +  stack_swap(); +  f_cast();    }    if(TYPEOF(sp[-1]) == T_ARRAY && sp[-1].u.array->size == 3)    {    res.r = sp[-1].u.array->item[0].u.integer;    res.g = sp[-1].u.array->item[1].u.integer;    res.b = sp[-1].u.array->item[2].u.integer;    } else {    res.r = res.g = res.b = 0;    }    pop_stack(); /* array */
pike.git/src/modules/Image/encodings/_xpm.c:136:    } else if(toggle>=2)    toggle=3;    else    toggle=0;    break;    case 'c':    if(!toggle) {    toggle=2;    break;    } +  /* FALLTHRU */    default:    if(toggle == 3)    {    s.str = cn->str+i;    toggle = 4;    } else if(toggle != 4)    toggle=1;    }    }    if(toggle==4) {
pike.git/src/modules/Image/encodings/_xpm.c:236:   void f__xpm_write_rows( INT32 args )   {    struct object *img;    struct object *alpha;    struct array *pixels;    struct array *colors;    struct image *iimg, *ialpha;    rgb_group *dst, *adst;    INT_TYPE y,x, bpc;    -  get_all_args("_xpm_write_rows",args,"%o%o%i%a%a", +  get_all_args(NULL,args,"%o%o%i%a%a",    &img,&alpha,&bpc,&colors,&pixels);      #if 0    fprintf(stderr, "_xpm_write_rows(");    print_svalue(stderr, Pike_sp-5);    fprintf(stderr, ", ");    print_svalue(stderr, Pike_sp-4);    fprintf(stderr, ", ");    print_svalue(stderr, Pike_sp-3);    fprintf(stderr, ", ");    print_svalue(stderr, Pike_sp-2);    fprintf(stderr, ", ");    print_svalue(stderr, Pike_sp-1);    fprintf(stderr, ")\n");   #endif /* 0 */    -  iimg = (struct image *)get_storage( img, image_program ); -  ialpha = (struct image *)get_storage( alpha, image_program ); +  iimg = get_storage( img, image_program ); +  ialpha = get_storage( alpha, image_program );    if(!iimg || !ialpha)    Pike_error("Expected images as arguments\n");       if (pixels->size < iimg->ysize + colors->size) {    SIMPLE_ARG_ERROR("_xpm_write_rows", 5, "pixel array is too short.");    }       for(y = 0; y < iimg->ysize + colors->size + 1; y++) {    if ((TYPEOF(pixels->item[y]) != T_STRING) ||    (pixels->item[y].u.string->size_shift)) {
pike.git/src/modules/Image/encodings/_xpm.c:313:    adst->r = adst->g = adst->b = 0;    adst++;    }    }    }    break;    case 3:    {    rgba_group **p_colors;    int i; -  p_colors = (rgba_group **)xalloc(sizeof(rgba_group *)*65536); -  MEMSET(p_colors, 0, sizeof(rgba_group *)*65536); +  p_colors = xcalloc(sizeof(rgba_group *), 65536);    for(i=0; i<colors->size; i++)    {    struct pike_string *c = colors->item[i].u.string;    unsigned char ind = ((unsigned char *)(c->str))[2];    unsigned short id = extract_short((unsigned char *)c->str);    if(!p_colors[id])    { -  p_colors[id] = (rgba_group *)xalloc(sizeof(rgba_group)*128); -  MEMSET(p_colors[id],0,sizeof(rgba_group)*128); +  p_colors[id] = xcalloc(sizeof(rgba_group), 128);    }    if(ind > 127)    { -  p_colors[id] = (rgba_group *)realloc(p_colors[id],sizeof(rgba_group)*256); -  MEMSET(p_colors[id]+128, 0, sizeof(rgba_group)*128); +  p_colors[id] = realloc(p_colors[id],sizeof(rgba_group)*256); +  memset(p_colors[id]+128, 0, sizeof(rgba_group)*128);    }    p_colors[id][ind]=parse_color_line( c, bpc );    }    for(y = 0; y<iimg->ysize; y++)    {    unsigned char *ss = (unsigned char *)pixels->item[y+colors->size+1].    u.string->str;    rgba_group *color, colorp;    for(x = 0; x<iimg->xsize; x++)    {
pike.git/src/modules/Image/encodings/_xpm.c:430:    pop_n_elems(args);    push_int(0);   }      /*! @decl array(string) _xpm_trim_rows(array(string) rows)    */   void f__xpm_trim_rows( INT32 args )   {    struct array *a;    int i,j=0; -  get_all_args("_xpm_trim_rows", args, "%a", &a ); +  get_all_args(NULL, args, "%a", &a );    for(i=0; i<a->size; i++)    {    int len,start;    struct pike_string *s = a->item[i].u.string;    if(TYPEOF(a->item[i]) != T_STRING)    Pike_error("Array must be array(string).\n");    if(s->len > 4)    {    for(start=0; start<s->len; start++)    if(s->str[start] == '/' || s->str[start] == '"')