pike.git / src / modules / Image / colors.c

version» Context lines:

pike.git/src/modules/Image/colors.c:746:   **! method array|string cast()   **! cast the object to an array, representing red, green   **! and blue (equal to <tt>-><ref>rgb</ref>()</tt>), or   **! to a string, giving the name (equal to <tt>-><ref>name</ref>()</tt>).   **! returns the name as string or rgb as array   **! see also: rgb, name   */      static void image_color_cast(INT32 args)   { -  if (args!=1 || -  TYPEOF(sp[-1]) != T_STRING) -  bad_arg_error("cast",sp-args,args,0,"",sp-args, -  "Bad arguments to cast.\n"); +  struct pike_string *str; +  get_all_args("cast", args, "%n", &str);    -  if (sp[-1].u.string==literal_array_string) +  if (str==literal_array_string)    {    image_color_rgb(args);    return;    } -  if (sp[-1].u.string==literal_string_string) +  if (str==literal_string_string)    {    image_color_name(args);    return;    } -  if (sp[-1].u.string==literal_int_string) +  if (str==literal_int_string)    {    pop_stack();    push_int( (THIS->rgb.r << 8 | THIS->rgb.g) << 8 | THIS->rgb.b );    return;    }    pop_stack();    push_undefined();   }      static void image_color__sprintf(INT32 args)
pike.git/src/modules/Image/colors.c:1402:       /* try other stuff here */       pop_stack();    push_undefined();    return;   }      static void image_guess_color(INT32 args)   { -  if (args!=1 && TYPEOF(sp[-args]) != T_STRING) -  bad_arg_error("guess",sp-args,args,0,"",sp-args, -  "Bad arguments to guess.\n"); +  check_all_args("guess", args, BIT_STRING, 0);       f_lower_case(1);    push_static_text(" ");    o_subtract();       stack_dup();    image_get_color(1);    if (TYPEOF(sp[-1]) == T_OBJECT)    {    stack_swap();
pike.git/src/modules/Image/colors.c:1649:       get_all_args("greylevel",args,"%i",&i);    pop_n_elems(args);       _image_make_rgb_color(i,i,i);   }      static void image_make_html_color(INT32 args)   {    int i; +  check_all_args("html", args, BIT_STRING, 0);    -  if (args!=1 || -  TYPEOF(sp[-1]) != T_STRING) -  { -  bad_arg_error("html",sp-args,args,0,"",sp-args, -  "Bad arguments to html.\n"); -  return; -  } -  +     f_lower_case(1);    for (i=0; (size_t)i<sizeof(html_color)/sizeof(html_color[0]); i++)    if (html_color[i].pname==sp[-1].u.string)    {    _image_make_rgb_color(html_color[i].r,    html_color[i].g,    html_color[i].b);    return;    }