From 80f30bff2caea4a58e0107f6995337130c9bad44 Mon Sep 17 00:00:00 2001 From: "Mirar (Pontus Hagland)" <pike@sort.mirar.org> Date: Fri, 18 Jun 1999 21:19:29 +0200 Subject: [PATCH] autoconverted a lot of 'bad arg' and 'out of memory' type errors Rev: src/modules/Image/blit.c:1.37 Rev: src/modules/Image/colors.c:1.22 Rev: src/modules/Image/colortable.c:1.71 Rev: src/modules/Image/dct.c:1.14 Rev: src/modules/Image/font.c:1.52 Rev: src/modules/Image/image.c:1.146 Rev: src/modules/Image/matrix.c:1.20 Rev: src/modules/Image/orient.c:1.12 Rev: src/modules/Image/search.c:1.12 --- src/modules/Image/blit.c | 33 ++++--- src/modules/Image/colors.c | 13 +-- src/modules/Image/colortable.c | 103 +++++++++++++--------- src/modules/Image/dct.c | 15 ++-- src/modules/Image/font.c | 14 +-- src/modules/Image/image.c | 153 +++++++++++++++++++-------------- src/modules/Image/matrix.c | 76 ++++++++-------- src/modules/Image/orient.c | 14 +-- src/modules/Image/search.c | 23 +++-- 9 files changed, 257 insertions(+), 187 deletions(-) diff --git a/src/modules/Image/blit.c b/src/modules/Image/blit.c index 9831054948..43ca8fad8b 100644 --- a/src/modules/Image/blit.c +++ b/src/modules/Image/blit.c @@ -1,10 +1,10 @@ -/* $Id: blit.c,v 1.36 1999/05/25 12:00:22 mirar Exp $ */ +/* $Id: blit.c,v 1.37 1999/06/18 19:19:14 mirar Exp $ */ #include "global.h" /* **! module Image **! note -**! $Id: blit.c,v 1.36 1999/05/25 12:00:22 mirar Exp $ +**! $Id: blit.c,v 1.37 1999/06/18 19:19:14 mirar Exp $ **! class Image */ @@ -217,7 +217,7 @@ void img_crop(struct image *dest, *dest=*img; new=malloc( (x2-x1+1)*(y2-y1+1)*sizeof(rgb_group) + 1); if (!new) - error("Out of memory.\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); THREADS_ALLOW(); MEMCPY(new,img->img,(x2-x1+1)*(y2-y1+1)*sizeof(rgb_group)); THREADS_DISALLOW(); @@ -227,7 +227,7 @@ void img_crop(struct image *dest, new=malloc( (x2-x1+1)*(y2-y1+1)*sizeof(rgb_group) +1); if (!new) - error("Out of memory.\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); img_clear(new,THIS->rgb,(x2-x1+1)*(y2-y1+1)); @@ -258,7 +258,7 @@ void img_clone(struct image *newimg,struct image *img) { if (newimg->img) free(newimg->img); newimg->img=malloc(sizeof(rgb_group)*img->xsize*img->ysize +1); - if (!newimg->img) error("Out of memory!\n"); + if (!newimg->img) resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); THREADS_ALLOW(); MEMCPY(newimg->img,img->img,sizeof(rgb_group)*img->xsize*img->ysize); THREADS_DISALLOW(); @@ -291,7 +291,8 @@ void image_paste(INT32 args) if (args<1 || sp[-args].type!=T_OBJECT || !(img=(struct image*)get_storage(sp[-args].u.object,image_program))) - error("illegal argument 1 to image->paste()\n"); + bad_arg_error("image->paste",sp-args,args,1,"",sp+1-1-args, + "Bad argument 1 to image->paste()\n"); if (!THIS->img) return; if (!img->img) return; @@ -301,7 +302,8 @@ void image_paste(INT32 args) if (args<3 || sp[1-args].type!=T_INT || sp[2-args].type!=T_INT) - error("illegal arguments to image->paste()\n"); + bad_arg_error("image->paste",sp-args,args,0,"",sp-args, + "Bad arguments to image->paste()\n"); x1=sp[1-args].u.integer; y1=sp[2-args].u.integer; } @@ -369,7 +371,8 @@ void image_paste_alpha(INT32 args) || !sp[-args].u.object || !(img=(struct image*)get_storage(sp[-args].u.object,image_program)) || sp[1-args].type!=T_INT) - error("illegal arguments to image->paste_alpha()\n"); + bad_arg_error("image->paste_alpha",sp-args,args,0,"",sp-args, + "Bad arguments to image->paste_alpha()\n"); if (!THIS->img) return; if (!img->img) return; THIS->alpha=(unsigned char)(sp[1-args].u.integer); @@ -378,7 +381,8 @@ void image_paste_alpha(INT32 args) { if (sp[2-args].type!=T_INT || sp[3-args].type!=T_INT) - error("illegal arguments to image->paste_alpha()\n"); + bad_arg_error("image->paste_alpha",sp-args,args,0,"",sp-args, + "Bad arguments to image->paste_alpha()\n"); x1=sp[2-args].u.integer; y1=sp[3-args].u.integer; } @@ -454,10 +458,12 @@ CHRONO("image_paste_mask init"); error("illegal number of arguments to image->paste_mask()\n"); if (sp[-args].type!=T_OBJECT || !(img=(struct image*)get_storage(sp[-args].u.object,image_program))) - error("illegal argument 1 to image->paste_mask()\n"); + bad_arg_error("image->paste_mask",sp-args,args,1,"",sp+1-1-args, + "Bad argument 1 to image->paste_mask()\n"); if (sp[1-args].type!=T_OBJECT || !(mask=(struct image*)get_storage(sp[1-args].u.object,image_program))) - error("illegal argument 2 to image->paste_mask()\n"); + bad_arg_error("image->paste_mask",sp-args,args,2,"",sp+2-1-args, + "Bad argument 2 to image->paste_mask()\n"); if (!THIS->img) return; if (!mask->img) return; @@ -554,11 +560,12 @@ void image_paste_alpha_color(INT32 args) int arg=1; if (args<1) - error("too few arguments to image->paste_alpha_color()\n"); + SIMPLE_TOO_FEW_ARGS_ERROR("image->paste_alpha_color",1); if (sp[-args].type!=T_OBJECT || !sp[-args].u.object || !(mask=(struct image*)get_storage(sp[-args].u.object,image_program))) - error("illegal argument 1 to image->paste_alpha_color()\n"); + bad_arg_error("image->paste_alpha_color",sp-args,args,1,"",sp+1-1-args, + "Bad argument 1 to image->paste_alpha_color()\n"); if (!THIS->img) return; if (!mask->img) return; diff --git a/src/modules/Image/colors.c b/src/modules/Image/colors.c index 0d59c3964f..783827981b 100644 --- a/src/modules/Image/colors.c +++ b/src/modules/Image/colors.c @@ -1,7 +1,7 @@ /* **! module Image **! note -**! $Id: colors.c,v 1.21 1999/06/14 22:16:02 mirar Exp $ +**! $Id: colors.c,v 1.22 1999/06/18 19:19:15 mirar Exp $ **! submodule Color **! **! This module keeps names and easy handling @@ -182,7 +182,7 @@ #include "global.h" -RCSID("$Id: colors.c,v 1.21 1999/06/14 22:16:02 mirar Exp $"); +RCSID("$Id: colors.c,v 1.22 1999/06/18 19:19:15 mirar Exp $"); #include "image_machine.h" @@ -678,7 +678,8 @@ static void image_color_cast(INT32 args) { if (args!=1 || sp[-1].type!=T_STRING) - error("Image.Color.Color->cast(): Illegal argument(s)\n"); + bad_arg_error("Image.Color.Color->cast",sp-args,args,0,"",sp-args, + "Bad arguments to Image.Color.Color->cast()\n"); if (sp[-1].u.string==str_array) { @@ -1238,7 +1239,8 @@ static void image_guess_color(INT32 args) struct svalue s; if (args!=1 && sp[-args].type!=T_STRING) - error("Image.Color->guess(): illegal argument(s)\n"); + bad_arg_error("Image.Color->guess",sp-args,args,0,"",sp-args, + "Bad arguments to Image.Color->guess()\n"); f_lower_case(1); push_text(" "); @@ -1460,7 +1462,8 @@ static void image_make_html_color(INT32 args) if (args!=1 || sp[-1].type!=T_STRING) { - error("Image.Color.html(): illegal arguments\n"); + bad_arg_error("Image.Color.html",sp-args,args,0,"",sp-args, + "Bad arguments to Image.Color.html()\n"); return; } diff --git a/src/modules/Image/colortable.c b/src/modules/Image/colortable.c index ba0edfac09..3f0f5cff18 100644 --- a/src/modules/Image/colortable.c +++ b/src/modules/Image/colortable.c @@ -1,11 +1,11 @@ #include "global.h" -/* $Id: colortable.c,v 1.70 1999/06/18 14:45:04 mast Exp $ */ +/* $Id: colortable.c,v 1.71 1999/06/18 19:19:16 mirar Exp $ */ /* **! module Image **! note -**! $Id: colortable.c,v 1.70 1999/06/18 14:45:04 mast Exp $ +**! $Id: colortable.c,v 1.71 1999/06/18 19:19:16 mirar Exp $ **! class Colortable **! **! This object keeps colortable information, @@ -20,7 +20,7 @@ #undef COLORTABLE_DEBUG #undef COLORTABLE_REDUCE_DEBUG -RCSID("$Id: colortable.c,v 1.70 1999/06/18 14:45:04 mast Exp $"); +RCSID("$Id: colortable.c,v 1.71 1999/06/18 19:19:16 mirar Exp $"); #include <math.h> /* fabs() */ @@ -610,7 +610,7 @@ static struct nct_flat _img_reduce_number_of_colors(struct nct_flat flat, flat.entries=realloc(newe,i*sizeof(struct nct_flat_entry)); flat.numentries=i; - if (!flat.entries) { free(newe); error("out of memory\n"); } + if (!flat.entries) { free(newe); resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } for (j=0; j<i; j++) flat.entries[j].no=j; @@ -766,7 +766,7 @@ rerun_rehash: if (!hash) { free(oldhash); - error("out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } k=hashsize; while (k--) hash[k].pixels=0; @@ -809,7 +809,7 @@ rerun_mask: if (!hash) { free(oldhash); - error("out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } k=hashsize; @@ -852,7 +852,7 @@ rerun_mask: if (!flat.entries) { free(hash); - error("out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } j=0; i=hashsize; @@ -1317,7 +1317,7 @@ rerun_rehash_add_1: free(oldhash); free_colortable_struct(&tmp1); free_colortable_struct(&tmp2); - error("out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } k=hashsize; while (k--) hash[k].pixels=0; @@ -1363,7 +1363,7 @@ rerun_rehash_add_2: free(oldhash); free_colortable_struct(&tmp1); free_colortable_struct(&tmp2); - error("out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } i=hashsize; while (i--) hash[i].pixels=0; @@ -1406,7 +1406,7 @@ rerun_rehash_add_2: if (!flat.entries) { free(hash); - error("out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } j=0; i=hashsize; @@ -1499,7 +1499,7 @@ rerun_rehash_add_1: free(oldhash); free_colortable_struct(&tmp1); free_colortable_struct(&tmp2); - error("out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } k=hashsize; while (k--) hash[k].pixels=0; @@ -1545,7 +1545,7 @@ rerun_rehash_add_2: free(oldhash); free_colortable_struct(&tmp1); free_colortable_struct(&tmp2); - error("out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } i=hashsize; while (i--) hash[i].pixels=0; @@ -1582,7 +1582,7 @@ rerun_rehash_add_2: if (!flat.entries) { free(hash); - error("out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } j=0; i=hashsize; @@ -2181,7 +2181,8 @@ static void image_colortable_add(INT32 args) } } else - error("Illegal argument 2 to Image.Colortable->add|create\n"); + bad_arg_error("Image",sp-args,args,2,"",sp+2-1-args, + "Bad argument 2 to Image()\n"); else { THIS->u.flat=_img_get_flat_from_image(img,256); @@ -2191,7 +2192,8 @@ static void image_colortable_add(INT32 args) THIS->type=NCT_FLAT; } } - else error("Illegal argument 1 to Image.Colortable->add|create\n"); + else bad_arg_error("Image",sp-args,args,1,"",sp+1-1-args, + "Bad argument 1 to Image()\n"); } else if (sp[-args].type==T_ARRAY) { @@ -2229,7 +2231,8 @@ static void image_colortable_add(INT32 args) THIS->u.cube=_img_get_cube_from_args(args); THIS->type=NCT_CUBE; } - else error("Illegal argument(s) to Image.Colortable->add|create\n"); + else bad_arg_error("Image",sp-args,args,0,"",sp-args, + "Bad arguments to Image()\n"); pop_n_elems(args); ref_push_object(THISOBJ); @@ -2391,7 +2394,8 @@ void image_colortable_operator_plus(INT32 args) if (!src) abort(); } else { - error("Image-colortable->`+: Illegal argument %d\n",i+2); + bad_arg_error("Image-colortable->`+",sp-args,args,0,"",sp-args, + "Bad arguments to Image-colortable->`+()\n"); /* Not reached, but keeps the compiler happy. */ src = NULL; } @@ -2432,14 +2436,16 @@ void image_colortable_operator_minus(INT32 args) if (!src) { free_object(o); - error("Illegal argument %d to Image.Colortable->`-",i+2); + bad_arg_error("Image",sp-args,args,i+2,"",sp+i+2-1-args, + "Bad argument %d to Image()\n",i+2); } _img_sub_colortable(dest,src); } else { free_object(o); - error("Illegal argument %d to Image.Colortable->`-",i+2); + bad_arg_error("Image",sp-args,args,i+2,"",sp+i+2-1-args, + "Bad argument %d to Image()\n",i+2); } pop_n_elems(args); push_object(o); @@ -2844,7 +2850,8 @@ void image_colortable_cubicles(INT32 args) THIS->lu.cubicles.accur=CUBICLE_DEFAULT_ACCUR; } else - error("Illegal arguments to colortable->cubicles()\n"); + bad_arg_error("colortable->cubicles",sp-args,args,0,"",sp-args, + "Bad arguments to colortable->cubicles()\n"); else { THIS->lu.cubicles.r=CUBICLE_DEFAULT_R; @@ -3128,7 +3135,7 @@ static INLINE void _build_cubicle(struct neo_colortable *nct, int *p=malloc(n*sizeof(struct nctlu_cubicle)); int *pp; /* write */ - if (!p) error("out of memory (kablamm, typ) in _build_cubicle in colortable->map()\n"); + if (!p) resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); rmin=(r*256)/red; rmax=((r+1)*256)/red-1; gmin=(g*256)/green; gmax=((g+1)*256)/green-1; @@ -3510,7 +3517,7 @@ void image_colortable_map(INT32 args) struct object *o; if (args<1) - error("too few arguments to colortable->map()\n"); + SIMPLE_TOO_FEW_ARGS_ERROR("colortable->map",1); if (sp[-args].type==T_STRING) { @@ -3584,10 +3591,11 @@ void image_colortable_map(INT32 args) if (sp[-args].type!=T_OBJECT || ! (src=(struct image*)get_storage(sp[-args].u.object,image_program))) - error("illegal argument 1 to colortable->map(), expecting image object\n"); + bad_arg_error("colortable->map",sp-args,args,1,"",sp+1-1-args, + "Bad argument 1 to colortable->map()\n"); if (!src->img) - error("colortable->map(): source image is empty\n"); + error("Called Image.Image object is not initialized\n");; o=clone_object(image_program,0); dest=(struct image*)(o->storage); @@ -3597,7 +3605,7 @@ void image_colortable_map(INT32 args) if (!dest->img) { free_object(o); - error("colortable->map(): out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } if (!image_colortable_map_image(THIS,src->img,dest->img, @@ -3666,12 +3674,13 @@ void image_colortable_index_32bit(INT32 args) void image_colortable_spacefactors(INT32 args) { if (args<3) - error("Too few arguments to colortable->spacefactors()\n"); + SIMPLE_TOO_FEW_ARGS_ERROR("colortable->spacefactors",1); if (sp[0-args].type!=T_INT || sp[1-args].type!=T_INT || sp[2-args].type!=T_INT) - error("Illegal argument(s) to colortable->spacefactors()\n"); + bad_arg_error("colortable->spacefactors",sp-args,args,0,"",sp-args, + "Bad arguments to colortable->spacefactors()\n"); THIS->spacefactor.r=sp[0-args].u.integer; THIS->spacefactor.g=sp[1-args].u.integer; @@ -3725,7 +3734,8 @@ void image_colortable_floyd_steinberg(INT32 args) if (args>=1) if (sp[-args].type!=T_INT) - error("colortable->spacefactors(): Illegal argument 1\n"); + bad_arg_error("colortable->spacefactors",sp-args,args,0,"",sp-args, + "Bad arguments to colortable->spacefactors()\n"); else THIS->du.floyd_steinberg.dir=sp[-args].u.integer; else @@ -3736,7 +3746,8 @@ void image_colortable_floyd_steinberg(INT32 args) else if (sp[5-args].type==T_INT) factor=(float)sp[5-args].u.integer; else - error("colortable->spacefactors(): Illegal argument 6\n"); + bad_arg_error("colortable->spacefactors",sp-args,args,0,"",sp-args, + "Bad arguments to colortable->spacefactors()\n"); if (args>=5) { if (sp[1-args].type==T_FLOAT) @@ -3744,25 +3755,29 @@ void image_colortable_floyd_steinberg(INT32 args) else if (sp[1-args].type==T_INT) forward=(float)sp[1-args].u.integer; else - error("colortable->spacefactors(): Illegal argument 2\n"); + bad_arg_error("colortable->spacefactors",sp-args,args,0,"",sp-args, + "Bad arguments to colortable->spacefactors()\n"); if (sp[2-args].type==T_FLOAT) downforward=(float)sp[2-args].u.float_number; else if (sp[2-args].type==T_INT) downforward=(float)sp[2-args].u.integer; else - error("colortable->spacefactors(): Illegal argument 3\n"); + bad_arg_error("colortable->spacefactors",sp-args,args,0,"",sp-args, + "Bad arguments to colortable->spacefactors()\n"); if (sp[3-args].type==T_FLOAT) down=(float)sp[3-args].u.float_number; else if (sp[3-args].type==T_INT) down=(float)sp[3-args].u.integer; else - error("colortable->spacefactors(): Illegal argument 4\n"); + bad_arg_error("colortable->spacefactors",sp-args,args,0,"",sp-args, + "Bad arguments to colortable->spacefactors()\n"); if (sp[4-args].type==T_FLOAT) downback=(float)sp[4-args].u.float_number; else if (sp[4-args].type==T_INT) downback=(float)sp[4-args].u.integer; else - error("colortable->spacefactors(): Illegal argument 5\n"); + bad_arg_error("colortable->spacefactors",sp-args,args,0,"",sp-args, + "Bad arguments to colortable->spacefactors()\n"); } sum=forward+downforward+down+downback; @@ -3875,7 +3890,8 @@ void image_colortable_randomcube(INT32 args) if (sp[-args].type!=T_INT|| sp[1-args].type!=T_INT|| sp[2-args].type!=T_INT) - error("Image.Colortable->randomcube(): illegal argument(s)\n"); + bad_arg_error("Image.Colortable->randomcube",sp-args,args,0,"",sp-args, + "Bad arguments to Image.Colortable->randomcube()\n"); else { THIS->du.randomcube.r=sp[-args].u.integer; @@ -3908,7 +3924,8 @@ void image_colortable_randomgrey(INT32 args) if (args) if (sp[-args].type!=T_INT) - error("Image.Colortable->randomgrey(): illegal argument(s)\n"); + bad_arg_error("Image.Colortable->randomgrey",sp-args,args,0,"",sp-args, + "Bad arguments to Image.Colortable->randomgrey()\n"); else THIS->du.randomcube.r=sp[-args].u.integer; else if (THIS->type==NCT_CUBE && THIS->u.cube.r) @@ -4139,7 +4156,8 @@ void image_colortable_ordered(INT32 args) sp[1-args].type!=T_INT|| sp[2-args].type!=T_INT) { - error("Image.Colortable->ordered(): illegal argument(s)\n"); + bad_arg_error("Image.Colortable->ordered",sp-args,args,0,"",sp-args, + "Bad arguments to Image.Colortable->ordered()\n"); /* Not reached, but keep the compiler happy */ r = 0; g = 0; @@ -4178,7 +4196,8 @@ void image_colortable_ordered(INT32 args) { if (sp[3-args].type!=T_INT|| sp[4-args].type!=T_INT) - error("Image.Colortable->ordered(): illegal argument(s)\n"); + bad_arg_error("Image.Colortable->ordered",sp-args,args,0,"",sp-args, + "Bad arguments to Image.Colortable->ordered()\n"); else { xsize=MAX(sp[3-args].u.integer,1); @@ -4194,7 +4213,8 @@ void image_colortable_ordered(INT32 args) sp[8-args].type!=T_INT|| sp[9-args].type!=T_INT|| sp[10-args].type!=T_INT) - error("Image.Colortable->ordered(): illegal argument(s)\n"); + bad_arg_error("Image.Colortable->ordered",sp-args,args,0,"",sp-args, + "Bad arguments to Image.Colortable->ordered()\n"); else { THIS->du.ordered.rx=sp[5-args].u.integer; @@ -4209,7 +4229,8 @@ void image_colortable_ordered(INT32 args) { if (sp[5-args].type!=T_INT|| sp[6-args].type!=T_INT) - error("Image.Colortable->ordered(): illegal argument(s)\n"); + bad_arg_error("Image.Colortable->ordered",sp-args,args,0,"",sp-args, + "Bad arguments to Image.Colortable->ordered()\n"); else { THIS->du.ordered.rx= @@ -4224,7 +4245,7 @@ void image_colortable_ordered(INT32 args) errors=ordered_calculate_errors(xsize,ysize); if (!errors) { - error("out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); return; } @@ -4249,7 +4270,7 @@ void image_colortable_ordered(INT32 args) if (THIS->du.ordered.rdiff) free(THIS->du.ordered.rdiff); if (THIS->du.ordered.gdiff) free(THIS->du.ordered.gdiff); if (THIS->du.ordered.bdiff) free(THIS->du.ordered.bdiff); - error("out of memory!\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); return; } diff --git a/src/modules/Image/dct.c b/src/modules/Image/dct.c index f10cadb334..e8f313056d 100644 --- a/src/modules/Image/dct.c +++ b/src/modules/Image/dct.c @@ -1,9 +1,9 @@ -/* $Id: dct.c,v 1.13 1999/04/22 12:40:29 mirar Exp $ */ +/* $Id: dct.c,v 1.14 1999/06/18 19:19:20 mirar Exp $ */ /* **! module Image **! note -**! $Id: dct.c,v 1.13 1999/04/22 12:40:29 mirar Exp $ +**! $Id: dct.c,v 1.14 1999/06/18 19:19:20 mirar Exp $ **! class Image */ @@ -78,19 +78,19 @@ void image_dct(INT32 args) double *costbl; rgb_group *pix; - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; fprintf(stderr,"%lu bytes, %lu bytes\n", (unsigned long)(sizeof(rgbd_group)*THIS->xsize*THIS->ysize), (unsigned long)(sizeof(rgb_group)*THIS->xsize*THIS->ysize+1)); if (!(area=malloc(sizeof(rgbd_group)*THIS->xsize*THIS->ysize+1))) - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); if (!(costbl=malloc(sizeof(double)*THIS->xsize+1))) { free(area); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } o=clone_object(image_program,0); @@ -104,7 +104,8 @@ void image_dct(INT32 args) img->xsize=MAXIMUM(1,sp[-args].u.integer); img->ysize=MAXIMUM(1,sp[1-args].u.integer); } - else error("Illegal arguments to image->dct()\n"); + else bad_arg_error("image->dct",sp-args,args,0,"",sp-args, + "Bad arguments to image->dct()\n"); if (!(img->img=(rgb_group*)malloc(sizeof(rgb_group)* img->xsize*img->ysize+1))) @@ -112,7 +113,7 @@ void image_dct(INT32 args) free(area); free(costbl); free_object(o); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } xsz2=THIS->xsize*2.0; diff --git a/src/modules/Image/font.c b/src/modules/Image/font.c index bab620811d..156c5705c0 100644 --- a/src/modules/Image/font.c +++ b/src/modules/Image/font.c @@ -1,4 +1,4 @@ -/* $Id: font.c,v 1.51 1999/06/03 17:20:11 mirar Exp $ */ +/* $Id: font.c,v 1.52 1999/06/18 19:19:21 mirar Exp $ */ #include "global.h" #define SPACE_CHAR 'i' @@ -9,7 +9,7 @@ extern unsigned char * image_default_font; /* **! module Image **! note -**! $Id: font.c,v 1.51 1999/06/03 17:20:11 mirar Exp $ +**! $Id: font.c,v 1.52 1999/06/18 19:19:21 mirar Exp $ **! class Font **! **! note @@ -557,13 +557,14 @@ void font_write(INT32 args) maxwidth2=1; width_of=(int *)malloc((args+1)*sizeof(int)); - if(!width_of) error("Out of memory\n"); + if(!width_of) resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); for (j=0; j<args; j++) { int max; if (sp[j-args].type!=T_STRING) - error("font->write: illegal argument(s)\n"); + bad_arg_error("font->write",sp-args,args,0,"",sp-args, + "Bad arguments to font->write()\n"); xsize = max = 1; to_write_len = sp[j-args].u.string->len; @@ -625,7 +626,7 @@ void font_write(INT32 args) img->rgb.r=img->rgb.g=img->rgb.b=255; img->img=malloc(img->xsize*img->ysize*sizeof(rgb_group)+1); - if (!img) { free_object(o); free(width_of); error("Out of memory\n"); } + if (!img) { free_object(o); free(width_of); resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } MEMSET(img->img,0,img->xsize*img->ysize*sizeof(rgb_group)); @@ -757,7 +758,8 @@ void font_text_extents(INT32 args) p_wchar2 *to_write2; int to_write_len; if (sp[j-args].type!=T_STRING) - error("font->write: illegal argument(s)\n"); + bad_arg_error("font->write",sp-args,args,0,"",sp-args, + "Bad arguments to font->write()\n"); xsize = max = 1; to_write_len = sp[j-args].u.string->len; diff --git a/src/modules/Image/image.c b/src/modules/Image/image.c index ef2041759d..8f882b76a2 100644 --- a/src/modules/Image/image.c +++ b/src/modules/Image/image.c @@ -1,9 +1,9 @@ -/* $Id: image.c,v 1.145 1999/06/09 19:41:45 mirar Exp $ */ +/* $Id: image.c,v 1.146 1999/06/18 19:19:23 mirar Exp $ */ /* **! module Image **! note -**! $Id: image.c,v 1.145 1999/06/09 19:41:45 mirar Exp $ +**! $Id: image.c,v 1.146 1999/06/18 19:19:23 mirar Exp $ **! class Image **! **! The main object of the <ref>Image</ref> module, this object @@ -97,7 +97,7 @@ #include "stralloc.h" #include "global.h" -RCSID("$Id: image.c,v 1.145 1999/06/09 19:41:45 mirar Exp $"); +RCSID("$Id: image.c,v 1.146 1999/06/18 19:19:23 mirar Exp $"); #include "pike_macros.h" #include "object.h" #include "constants.h" @@ -395,7 +395,7 @@ THREADS_ALLOW(); d=malloc(sizeof(rgb_group)*img->xsize*img->ysize +1); THREADS_DISALLOW(); - if(!d) error("Out of memory.\n"); + if(!d) resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); THREADS_ALLOW(); CHRONO("apply_matrix, one"); @@ -536,7 +536,8 @@ void image_create(INT32 args) if (args<2) return; if (sp[-args].type!=T_INT|| sp[1-args].type!=T_INT) - error("Image.Image->create(): Illegal arguments\n"); + bad_arg_error("Image.Image->create",sp-args,args,0,"",sp-args, + "Bad arguments to Image.Image->create()\n"); getrgb(THIS,2,args,args,"Image.Image->create()"); @@ -552,7 +553,7 @@ void image_create(INT32 args) THIS->img=malloc(sizeof(rgb_group)*THIS->xsize*THIS->ysize +1); if (!THIS->img) - error("Image.Image->create(): out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); img_clear(THIS->img,THIS->rgb,THIS->xsize*THIS->ysize); pop_n_elems(args); @@ -601,7 +602,8 @@ void image_clone(INT32 args) if (args<2|| sp[-args].type!=T_INT|| sp[1-args].type!=T_INT) - error("Illegal arguments to Image.Image->clone()\n"); + bad_arg_error("Image",sp-args,args,0,"",sp-args, + "Bad arguments to Image()\n"); o=clone_object(image_program,0); img=(struct image*)(o->storage); @@ -627,7 +629,7 @@ void image_clone(INT32 args) if (!img->img) { free_object(o); - error("out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } if (img->xsize==THIS->xsize && img->ysize==THIS->ysize) @@ -683,7 +685,7 @@ void image_clear(INT32 args) if (!img->img) { free_object(o); - error("out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } img_clear(img->img,img->rgb,img->xsize*img->ysize); @@ -749,9 +751,10 @@ void image_copy(INT32 args) sp[1-args].type!=T_INT|| sp[2-args].type!=T_INT|| sp[3-args].type!=T_INT) - error("illegal arguments to Image.Image->copy()\n"); + bad_arg_error("Image",sp-args,args,0,"",sp-args, + "Bad arguments to Image()\n"); - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; getrgb(THIS,4,args,args,"Image.Image->copy()"); @@ -794,11 +797,11 @@ static void image_change_color(INT32 args) struct image *img; int arg; - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; to=THIS->rgb; if (!(arg=getrgb(THIS,0,args,3,"Image.Image->change_color()"))) - error("too few arguments to Image.Image->change_color()\n"); + SIMPLE_TOO_FEW_ARGS_ERROR("Image",1); from=THIS->rgb; if (getrgb(THIS,arg,args,args,"Image.Image->change_color()")) to=THIS->rgb; @@ -810,7 +813,7 @@ static void image_change_color(INT32 args) if (!(img->img=malloc(sizeof(rgb_group)*img->xsize*img->ysize +1))) { free_object(o); - error("out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } left=THIS->xsize*THIS->ysize; @@ -894,7 +897,8 @@ void image_autocrop(INT32 args) if (args) if (sp[-args].type!=T_INT) - error("Illegal argument to Image.Image->autocrop()\n"); + bad_arg_error("Image",sp-args,args,0,"",sp-args, + "Bad arguments to Image()\n"); else border=sp[-args].u.integer; @@ -910,7 +914,7 @@ void image_autocrop(INT32 args) if (!THIS->img) { - error("no image\n"); + error("Called Image.Image object is not initialized\n");; return; } @@ -961,7 +965,8 @@ void image_autocrop(INT32 args) void image_setcolor(INT32 args) { if (args<3) - error("illegal arguments to Image.Image->setcolor()\n"); + bad_arg_error("Image",sp-args,args,0,"",sp-args, + "Bad arguments to Image()\n"); getrgb(THIS,0,args,args,"Image.Image->setcolor()"); pop_n_elems(args); ref_push_object(THISOBJ); @@ -998,7 +1003,8 @@ void image_setpixel(INT32 args) if (args<2|| sp[-args].type!=T_INT|| sp[1-args].type!=T_INT) - error("Illegal arguments to Image.Image->setpixel()\n"); + bad_arg_error("Image",sp-args,args,0,"",sp-args, + "Bad arguments to Image()\n"); getrgb(THIS,2,args,args,"Image.Image->setpixel()"); if (!THIS->img) return; x=sp[-args].u.integer; @@ -1026,9 +1032,10 @@ void image_getpixel(INT32 args) if (args<2|| sp[-args].type!=T_INT|| sp[1-args].type!=T_INT) - error("Illegal arguments to Image.Image->getpixel()\n"); + bad_arg_error("Image",sp-args,args,0,"",sp-args, + "Bad arguments to Image()\n"); - if (!THIS->img) error("No image.\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; x=sp[-args].u.integer; y=sp[1-args].u.integer; @@ -1080,7 +1087,8 @@ void image_line(INT32 args) sp[1-args].type!=T_INT|| sp[2-args].type!=T_INT|| sp[3-args].type!=T_INT) - error("Illegal arguments to Image.Image->line()\n"); + bad_arg_error("Image",sp-args,args,0,"",sp-args, + "Bad arguments to Image()\n"); getrgb(THIS,4,args,args,"Image.Image->line()"); if (!THIS->img) return; @@ -1127,7 +1135,8 @@ void image_box(INT32 args) sp[1-args].type!=T_INT|| sp[2-args].type!=T_INT|| sp[3-args].type!=T_INT) - error("Illegal arguments to Image.Image->box()\n"); + bad_arg_error("Image",sp-args,args,0,"",sp-args, + "Bad arguments to Image()\n"); getrgb(THIS,4,args,args,"Image.Image->box()"); if (!THIS->img) return; @@ -1178,7 +1187,8 @@ void image_circle(INT32 args) sp[1-args].type!=T_INT|| sp[2-args].type!=T_INT|| sp[3-args].type!=T_INT) - error("illegal arguments to Image.Image->circle()\n"); + bad_arg_error("Image",sp-args,args,0,"",sp-args, + "Bad arguments to Image()\n"); getrgb(THIS,4,args,args,"Image.Image->circle()"); if (!THIS->img) return; @@ -1383,7 +1393,7 @@ void image_tuned_box(INT32 args) error("Illegal number of arguments to Image.Image->tuned_box()\n"); if (!THIS->img) - error("no image\n"); + error("Called Image.Image object is not initialized\n");; x1=sp[-args].u.integer; y1=sp[1-args].u.integer; @@ -1580,13 +1590,14 @@ static void image_gradients(INT32 args) a->item[4].type!=T_INT) { while (first) { c=first; first=c->next; free(c); } - error("Image.Image->gradients: Illegal argument %d\n",n); + bad_arg_error("Image.Image->gradients",sp-args,args,0,"",sp-args, + "Bad arguments to Image.Image->gradients()\n"); } c=malloc(sizeof(struct gr_point)); if (!c) { while (first) { c=first; first=c->next; free(c); } - error("Image.Image->gradients: out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } c->next=first; c->x=a->item[0].u.integer; @@ -1600,7 +1611,7 @@ static void image_gradients(INT32 args) } if (!first) - error("Image.Image->gradients: need at least one argument\n"); + SIMPLE_TOO_FEW_ARGS_ERROR("Image.Image->gradients",1); THREADS_ALLOW(); @@ -1790,7 +1801,7 @@ void image_grey(INT32 args) if (!(img->img=malloc(sizeof(rgb_group)*THIS->xsize*THIS->ysize+1))) { free_object(o); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } d=img->img; @@ -1852,7 +1863,7 @@ void image_color(INT32 args) struct object *o; struct image *img; - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; if (args<3) { if (args>0 && sp[-args].type==T_INT) @@ -1871,7 +1882,7 @@ void image_color(INT32 args) if (!(img->img=malloc(sizeof(rgb_group)*THIS->xsize*THIS->ysize+1))) { free_object(o); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } d=img->img; @@ -1919,7 +1930,7 @@ void image_invert(INT32 args) struct object *o; struct image *img; - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; o=clone_object(image_program,0); img=(struct image*)o->storage; @@ -1927,7 +1938,7 @@ void image_invert(INT32 args) if (!(img->img=malloc(sizeof(rgb_group)*THIS->xsize*THIS->ysize+1))) { free_object(o); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } d=img->img; @@ -1989,7 +2000,7 @@ void image_threshold(INT32 args) struct object *o; struct image *img; - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; getrgb(THIS,0,args,args,"Image.Image->threshold()"); @@ -1999,7 +2010,7 @@ void image_threshold(INT32 args) if (!(img->img=malloc(sizeof(rgb_group)*THIS->xsize*THIS->ysize+1))) { free_object(o); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } d=img->img; @@ -2101,7 +2112,7 @@ void image_hsv_to_rgb(INT32 args) struct object *o; struct image *img; char *err = NULL; - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; o=clone_object(image_program,0); img=(struct image*)o->storage; @@ -2110,7 +2121,7 @@ void image_hsv_to_rgb(INT32 args) if (!(img->img=malloc(sizeof(rgb_group)*THIS->xsize*THIS->ysize+1))) { free_object(o); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } d=img->img; @@ -2186,7 +2197,7 @@ void image_rgb_to_hsv(INT32 args) rgb_group *s,*d; struct object *o; struct image *img; - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; o=clone_object(image_program,0); img=(struct image*)o->storage; @@ -2195,7 +2206,7 @@ void image_rgb_to_hsv(INT32 args) if (!(img->img=malloc(sizeof(rgb_group)*THIS->xsize*THIS->ysize+1))) { free_object(o); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } d=img->img; @@ -2280,7 +2291,7 @@ void image_distancesq(INT32 args) struct object *o; struct image *img; - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; getrgb(THIS,0,args,args,"Image.Image->distancesq()"); @@ -2290,7 +2301,7 @@ void image_distancesq(INT32 args) if (!(img->img=malloc(sizeof(rgb_group)*THIS->xsize*THIS->ysize+1))) { free_object(o); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } d=img->img; @@ -2451,16 +2462,18 @@ void image_select_from(INT32 args) struct image *img; INT32 low_limit=0; - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; if (args<2 || sp[-args].type!=T_INT || sp[1-args].type!=T_INT) - error("Illegal argument(s) to Image.Image->select_from()\n"); + bad_arg_error("Image",sp-args,args,0,"",sp-args, + "Bad arguments to Image()\n"); if (args>=3) if (sp[2-args].type!=T_INT) - error("Illegal argument 3 (edge value) to Image.Image->select_from()\n"); + bad_arg_error("Image",sp-args,args,3,"",sp+3-1-args, + "Bad argument 3 (edge value) to Image()\n"); else low_limit=MAXIMUM(0,sp[2-args].u.integer); else @@ -2473,7 +2486,7 @@ void image_select_from(INT32 args) if (!(img->img=malloc(sizeof(rgb_group)*THIS->xsize*THIS->ysize+1))) { free_object(o); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } MEMSET(img->img,0,sizeof(rgb_group)*img->xsize*img->ysize); @@ -2641,7 +2654,8 @@ CHRONO("apply_matrix"); if (args<1 || sp[-args].type!=T_ARRAY) - error("Illegal arguments to Image.Image->apply_matrix()\n"); + bad_arg_error("Image",sp-args,args,0,"",sp-args, + "Bad arguments to Image()\n"); if (args>3) if (sp[1-args].type!=T_INT || @@ -2691,7 +2705,7 @@ CHRONO("apply_matrix"); if (width==-1) width=0; matrix=malloc(sizeof(rgbd_group)*width*height+1); - if (!matrix) error("Out of memory"); + if (!matrix) resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); for (i=0; i<height; i++) { @@ -2807,7 +2821,7 @@ static void _image_outline(INT32 args,int mask) struct image *img; if (!THIS->img || !THIS->xsize || !THIS->ysize) - error("Image.Image->outline: no image\n"); + error("Called Image.Image object is not initialized\n");; if (args && sp[-args].type==T_ARRAY) { @@ -2828,7 +2842,7 @@ static void _image_outline(INT32 args,int mask) if (width==-1) width=0; matrix=malloc(sizeof(int)*width*height+1); - if (!matrix) error("Out of memory"); + if (!matrix) resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); for (i=0; i<height; i++) { @@ -2852,7 +2866,7 @@ static void _image_outline(INT32 args,int mask) img->rgb=THIS->rgb; tmp=malloc((THIS->xsize+width)*(THIS->ysize+height)); - if (!tmp) { free_object(o); error("out of memory\n"); } + if (!tmp) { free_object(o); resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } MEMSET(tmp,0,(THIS->xsize+width)*(THIS->ysize+height)); s=THIS->img; @@ -3015,16 +3029,16 @@ void image_modify_by_intensity(INT32 args) struct image *img; long div; - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; if (args<5) - error("too few arguments to Image.Image->modify_by_intensity()\n"); + SIMPLE_TOO_FEW_ARGS_ERROR("Image",1); getrgbl(&rgb,0,args,"Image.Image->modify_by_intensity()"); div=rgb.r+rgb.g+rgb.b; if (!div) div=1; s=malloc(sizeof(rgb_group)*(args-3)+1); - if (!s) error("Out of memory\n"); + if (!s) resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); for (x=0; x<args-3; x++) { @@ -3052,7 +3066,7 @@ void image_modify_by_intensity(INT32 args) if (!list) { free(s); - error("out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } for (x=0; x<args-4; x++) { @@ -3076,7 +3090,7 @@ void image_modify_by_intensity(INT32 args) if (!(img->img=malloc(sizeof(rgb_group)*THIS->xsize*THIS->ysize+1))) { free_object(o); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } d=img->img; @@ -3158,24 +3172,28 @@ void image_gamma(INT32 args) float gammar,gammab,gammag; COLORTYPE newr[256]; - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; if (args==1) if (sp[-args].type==T_INT) gammar=gammab=gammag=(float)sp[-args].u.integer; else if (sp[-args].type==T_FLOAT) gammar=gammab=gammag=sp[-args].u.float_number; - else error("Image.Image->gamma(): illegal argument 1\n"); + else bad_arg_error("Image.Image->gamma",sp-args,args,0,"",sp-args, + "Bad arguments to Image.Image->gamma()\n"); else if (args==3) { if (sp[-args].type==T_INT) gammar=(float)sp[-args].u.integer; else if (sp[-args].type==T_FLOAT) gammar=sp[-args].u.float_number; - else error("Image.Image->gamma(): illegal argument 1\n"); + else bad_arg_error("Image.Image->gamma",sp-args,args,0,"",sp-args, + "Bad arguments to Image.Image->gamma()\n"); if (sp[1-args].type==T_INT) gammag=(float)sp[1-args].u.integer; else if (sp[1-args].type==T_FLOAT) gammag=sp[1-args].u.float_number; - else error("Image.Image->gamma(): illegal argument 2\n"); + else bad_arg_error("Image.Image->gamma",sp-args,args,0,"",sp-args, + "Bad arguments to Image.Image->gamma()\n"); if (sp[2-args].type==T_INT) gammab=(float)sp[2-args].u.integer; else if (sp[2-args].type==T_FLOAT) gammab=sp[2-args].u.float_number; - else error("Image.Image->gamma(): illegal argument 3\n"); + else bad_arg_error("Image.Image->gamma",sp-args,args,0,"",sp-args, + "Bad arguments to Image.Image->gamma()\n"); } else error("Image.Image->gamma(): illegal number of arguments\n"); @@ -3203,7 +3221,7 @@ void image_gamma(INT32 args) if (!(img->img=malloc(sizeof(rgb_group)*THIS->xsize*THIS->ysize+1))) { free_object(o); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } d=img->img; @@ -3286,7 +3304,8 @@ void image_select_colors(INT32 args) if (args<1 || sp[-args].type!=T_INT) - error("Illegal argument to Image.Image->select_colors()\n"); + bad_arg_error("Image",sp-args,args,0,"",sp-args, + "Bad arguments to Image()\n"); colors=sp[-args].u.integer; pop_n_elems(args); @@ -3326,7 +3345,8 @@ void image_write_lsb_rgb(INT32 args) if (args<1 || sp[-args].type!=T_STRING) - error("Illegal argument to Image.Image->write_lowbit()\n"); + bad_arg_error("Image",sp-args,args,0,"",sp-args, + "Bad arguments to Image()\n"); s=sp[-args].u.string->str; l=sp[-args].u.string->len; @@ -3395,7 +3415,8 @@ void image_write_lsb_grey(INT32 args) if (args<1 || sp[-args].type!=T_STRING) - error("Illegal argument to Image.Image->write_lowbit()\n"); + bad_arg_error("Image",sp-args,args,0,"",sp-args, + "Bad arguments to Image()\n"); s=sp[-args].u.string->str; l=sp[-args].u.string->len; @@ -3479,7 +3500,7 @@ void image_cast(INT32 args) int i,j; rgb_group *s=THIS->img; - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; pop_n_elems(args); @@ -3498,7 +3519,7 @@ void image_cast(INT32 args) } if (strncmp(sp[-args].u.string->str,"string",6)==0) { - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; pop_n_elems(args); push_string(make_shared_binary_string((char *)THIS->img, @@ -3520,7 +3541,7 @@ void image_tobitmap(INT32 args) rgb_group *s; pop_n_elems(args); - if (!THIS->img) error("No image.\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; xs=(THIS->xsize+7)>>3; diff --git a/src/modules/Image/matrix.c b/src/modules/Image/matrix.c index ebcd60188c..a8e9f97064 100644 --- a/src/modules/Image/matrix.c +++ b/src/modules/Image/matrix.c @@ -1,9 +1,9 @@ -/* $Id: matrix.c,v 1.19 1999/05/20 17:34:37 mirar Exp $ */ +/* $Id: matrix.c,v 1.20 1999/06/18 19:19:27 mirar Exp $ */ /* **! module Image **! note -**! $Id: matrix.c,v 1.19 1999/05/20 17:34:37 mirar Exp $ +**! $Id: matrix.c,v 1.20 1999/06/18 19:19:27 mirar Exp $ **! class Image */ @@ -185,7 +185,7 @@ CHRONO("scale begin"); if (newy<1) newy=1; new=malloc(newx*newy*sizeof(rgbd_group) +1); - if (!new) error("Out of memory!\n"); + if (!new) resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); THREADS_ALLOW(); for (y=0; y<newx*newy; y++) @@ -239,7 +239,7 @@ CHRONO("scale end"); THREADS_DISALLOW(); if (!d) - error("Out of memory!\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } /* Special, faster, case for scale=1/2 */ @@ -254,7 +254,7 @@ void img_scale2(struct image *dest, struct image *source) if (!THIS->img || newx<=0 || newy<=0) return; /* no way */ new=malloc(newx*newy*sizeof(rgb_group) +1); - if (!new) error("Out of memory\n"); + if (!new) resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); THREADS_ALLOW(); MEMSET(new,0,newx*newy*sizeof(rgb_group)); @@ -361,7 +361,8 @@ void image_scale(INT32 args) else { free_object(o); - error("illegal arguments to image->scale()\n"); + bad_arg_error("image->scale",sp-args,args,0,"",sp-args, + "Bad arguments to image->scale()\n"); } pop_n_elems(args); push_object(o); @@ -393,7 +394,7 @@ void image_ccw(INT32 args) pop_n_elems(args); - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; o=clone_object(image_program,0); img=(struct image*)o->storage; @@ -401,7 +402,7 @@ void image_ccw(INT32 args) if (!(img->img=malloc(sizeof(rgb_group)*THIS->xsize*THIS->ysize+1))) { free_object(o); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } img->xsize=THIS->ysize; img->ysize=THIS->xsize; @@ -431,7 +432,7 @@ static void img_cw(struct image *is,struct image *id) if (id->img) free(id->img); *id=*is; if (!(id->img=malloc(sizeof(rgb_group)*is->xsize*is->ysize+1))) - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); id->xsize=is->ysize; id->ysize=is->xsize; @@ -457,7 +458,7 @@ void img_ccw(struct image *is,struct image *id) if (id->img) free(id->img); *id=*is; if (!(id->img=malloc(sizeof(rgb_group)*is->xsize*is->ysize+1))) - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); id->xsize=is->ysize; id->ysize=is->xsize; @@ -500,7 +501,7 @@ void image_cw(INT32 args) pop_n_elems(args); - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; o=clone_object(image_program,0); img=(struct image*)o->storage; @@ -508,7 +509,7 @@ void image_cw(INT32 args) if (!(img->img=malloc(sizeof(rgb_group)*THIS->xsize*THIS->ysize+1))) { free_object(o); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } ys=img->xsize=THIS->ysize; i=xs=img->ysize=THIS->xsize; @@ -552,7 +553,7 @@ void image_mirrorx(INT32 args) pop_n_elems(args); - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; o=clone_object(image_program,0); img=(struct image*)o->storage; @@ -560,7 +561,7 @@ void image_mirrorx(INT32 args) if (!(img->img=malloc(sizeof(rgb_group)*THIS->xsize*THIS->ysize+1))) { free_object(o); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } i=THIS->ysize; @@ -601,7 +602,7 @@ void image_mirrory(INT32 args) pop_n_elems(args); - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; o=clone_object(image_program,0); img=(struct image*)o->storage; @@ -609,7 +610,7 @@ void image_mirrory(INT32 args) if (!(img->img=malloc(sizeof(rgb_group)*THIS->xsize*THIS->ysize+1))) { free_object(o); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } i=THIS->ysize; @@ -829,15 +830,16 @@ void image_skewx(INT32 args) struct object *o; if (args<1) - error("too few arguments to image->skewx()\n"); + SIMPLE_TOO_FEW_ARGS_ERROR("image->skewx",1); else if (sp[-args].type==T_FLOAT) diff=THIS->ysize*sp[-args].u.float_number; else if (sp[-args].type==T_INT) diff=sp[-args].u.integer; else - error("illegal argument to image->skewx()\n"); + bad_arg_error("image->skewx",sp-args,args,0,"",sp-args, + "Bad arguments to image->skewx()\n"); - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; o=clone_object(image_program,0); @@ -892,15 +894,16 @@ void image_skewy(INT32 args) struct object *o; if (args<1) - error("too few arguments to image->skewy()\n"); + SIMPLE_TOO_FEW_ARGS_ERROR("image->skewy",1); else if (sp[-args].type==T_FLOAT) diff=THIS->xsize*sp[-args].u.float_number; else if (sp[-args].type==T_INT) diff=sp[-args].u.integer; else - error("illegal argument to image->skewx()\n"); + bad_arg_error("image->skewx",sp-args,args,0,"",sp-args, + "Bad arguments to image->skewx()\n"); - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; o=clone_object(image_program,0); @@ -919,15 +922,16 @@ void image_skewx_expand(INT32 args) struct object *o; if (args<1) - error("too few arguments to image->skewx()\n"); + SIMPLE_TOO_FEW_ARGS_ERROR("image->skewx",1); else if (sp[-args].type==T_FLOAT) diff=THIS->ysize*sp[-args].u.float_number; else if (sp[-args].type==T_INT) diff=sp[-args].u.integer; else - error("illegal argument to image->skewx()\n"); + bad_arg_error("image->skewx",sp-args,args,0,"",sp-args, + "Bad arguments to image->skewx()\n"); - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; o=clone_object(image_program,0); @@ -946,15 +950,16 @@ void image_skewy_expand(INT32 args) struct object *o; if (args<1) - error("too few arguments to image->skewy()\n"); + SIMPLE_TOO_FEW_ARGS_ERROR("image->skewy",1); else if (sp[-args].type==T_FLOAT) diff=THIS->xsize*sp[-args].u.float_number; else if (sp[-args].type==T_INT) diff=sp[-args].u.integer; else - error("illegal argument to image->skewx()\n"); + bad_arg_error("image->skewx",sp-args,args,0,"",sp-args, + "Bad arguments to image->skewx()\n"); - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; o=clone_object(image_program,0); @@ -976,15 +981,16 @@ void img_rotate(INT32 args,int xpn) struct image *dest,d0,dest2; if (args<1) - error("too few arguments to image->rotate()\n"); + SIMPLE_TOO_FEW_ARGS_ERROR("image->rotate",1); else if (sp[-args].type==T_FLOAT) angle=sp[-args].u.float_number; else if (sp[-args].type==T_INT) angle=sp[-args].u.integer; else - error("illegal argument to image->rotate()\n"); + bad_arg_error("image->rotate",sp-args,args,0,"",sp-args, + "Bad arguments to image->rotate()\n"); - if (!THIS->img) error("no image\n"); + if (!THIS->img) error("Called Image.Image object is not initialized\n");; dest2.img=d0.img=NULL; @@ -1082,11 +1088,13 @@ void img_translate(INT32 args,int expand) if (sp[-args].type==T_FLOAT) xt=sp[-args].u.float_number; else if (sp[-args].type==T_INT) xt=sp[-args].u.integer; - else error("illegal argument 1 to image->translate()\n"); + else bad_arg_error("image->translate",sp-args,args,1,"",sp+1-1-args, + "Bad argument 1 to image->translate()\n"); if (sp[1-args].type==T_FLOAT) yt=sp[1-args].u.float_number; else if (sp[1-args].type==T_INT) yt=sp[1-args].u.integer; - else error("illegal argument 2 to image->translate()\n"); + else bad_arg_error("image->translate",sp-args,args,2,"",sp+2-1-args, + "Bad argument 2 to image->translate()\n"); getrgb(THIS,2,args,"image->translate()\n"); @@ -1102,7 +1110,7 @@ void img_translate(INT32 args,int expand) if (!(img->img=malloc(sizeof(rgb_group)*img->xsize*img->ysize+1))) { free_object(o); - error("Out of memory\n"); + resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); } if (!xt) diff --git a/src/modules/Image/orient.c b/src/modules/Image/orient.c index a7c8d057f9..42dc72e58d 100644 --- a/src/modules/Image/orient.c +++ b/src/modules/Image/orient.c @@ -1,9 +1,9 @@ -/* $Id: orient.c,v 1.11 1999/04/13 12:32:29 mirar Exp $ */ +/* $Id: orient.c,v 1.12 1999/06/18 19:19:28 mirar Exp $ */ /* **! module Image **! note -**! $Id: orient.c,v 1.11 1999/04/13 12:32:29 mirar Exp $ +**! $Id: orient.c,v 1.12 1999/06/18 19:19:28 mirar Exp $ **! class Image */ @@ -159,7 +159,7 @@ void image_orient(INT32 args) float mag; int i, w, h; - if (!THIS->img) { error("no image\n"); return; } + if (!THIS->img) { error("Called Image.Image object is not initialized\n");; return; } this=THIS; @@ -170,7 +170,8 @@ void image_orient(INT32 args) else if (sp[-args].type==T_FLOAT) mag=sp[-args].u.float_number; else { - error("Illegal argument 1 to image->orient\n"); + bad_arg_error("image->orient\\n",sp-args,args,1,"",sp+1-1-args, + "Bad argument 1 to image->orient\n()\n"); /* Not reached, but keeps the compiler happy. */ mag = 0.0; } @@ -183,7 +184,8 @@ void image_orient(INT32 args) if (args>1) { if (sp[1-args].type!=T_ARRAY) - error("Illegal argument 2 to image->orient\n"); + bad_arg_error("image->orient\\n",sp-args,args,2,"",sp+2-1-args, + "Bad argument 2 to image->orient\n()\n"); if (sp[1-args].u.array->size!=4) error("The array given as argument 2 to image->orient do not have size 4\n"); for(i=0; i<4; i++) @@ -271,7 +273,7 @@ void image_orient4(INT32 args) struct object *o[5]; struct image *img[5]; - if (!THIS->img) { error("no image\n"); return; } + if (!THIS->img) { error("Called Image.Image object is not initialized\n");; return; } pop_n_elems(args); _image_orient(THIS,o,img); diff --git a/src/modules/Image/search.c b/src/modules/Image/search.c index 93bf71bc5e..1d7c3e1a13 100644 --- a/src/modules/Image/search.c +++ b/src/modules/Image/search.c @@ -244,23 +244,27 @@ void image_make_ascii(INT32 args) int i, x, y,xy=0,y2=0, xmax=0,ymax=0,max,sum0,sum1,sum2,sum3; struct pike_string *s; - if (!THIS->img) { error("no image\n"); return; } + if (!THIS->img) { error("Called Image.Image object is not initialized\n");; return; } this=THIS; if (args<4) { - error("Too few arguments to image->make_ascii\n"); + SIMPLE_TOO_FEW_ARGS_ERROR("image->make_ascii\\n",1); } if (sp[-args].type!=T_OBJECT) - error("Illegal argument 1 to image->make_ascii\n"); + bad_arg_error("image->make_ascii\\n",sp-args,args,1,"",sp+1-1-args, + "Bad argument 1 to image->make_ascii\n()\n"); if (sp[1-args].type!=T_OBJECT) - error("Illegal argument 2 to image->make_ascii\n"); + bad_arg_error("image->make_ascii\\n",sp-args,args,2,"",sp+2-1-args, + "Bad argument 2 to image->make_ascii\n()\n"); if (sp[2-args].type!=T_OBJECT) - error("Illegal argument 3 to image->make_ascii\n"); + bad_arg_error("image->make_ascii\\n",sp-args,args,3,"",sp+3-1-args, + "Bad argument 3 to image->make_ascii\n()\n"); if (sp[3-args].type!=T_OBJECT) - error("Illegal argument 4 to image->make_ascii\n"); + bad_arg_error("image->make_ascii\\n",sp-args,args,4,"",sp+4-1-args, + "Bad argument 4 to image->make_ascii\n()\n"); img[0]=(struct image*)sp[-args].u.object->storage; img[1]=(struct image*)sp[1-args].u.object->storage; img[2]=(struct image*)sp[2-args].u.object->storage; @@ -512,7 +516,7 @@ THREADS_ALLOW(); d=malloc(sizeof(rgb_group)*img->xsize*img->ysize +1); THREADS_DISALLOW(); - if(!d) error("Out of memory.\n"); + if(!d) resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); THREADS_ALLOW(); @@ -601,7 +605,8 @@ void image_apply_max(INT32 args) if (args<1 || sp[-args].type!=T_ARRAY) - error("Illegal arguments to Image.Image->apply_max()\n"); + bad_arg_error("Image",sp-args,args,0,"",sp-args, + "Bad arguments to Image()\n"); if (args>3) if (sp[1-args].type!=T_INT || @@ -651,7 +656,7 @@ void image_apply_max(INT32 args) if (width==-1) width=0; matrix=malloc(sizeof(rgbd_group)*width*height+1); - if (!matrix) error("Out of memory"); + if (!matrix) resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); for (i=0; i<height; i++) { -- GitLab