From 0af18542f3a0f7911f436d049e8000b0053ca8fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Fri, 11 Aug 2000 21:11:42 +0200
Subject: [PATCH] Fixed a few warnings.

Rev: src/modules/Image/blit.c:1.46
Rev: src/modules/Image/colortable.c:1.90
Rev: src/modules/Image/colortable.h:1.22
Rev: src/modules/Image/colortable_lookup.h:1.12
Rev: src/modules/Image/encodings/gif.c:1.56
Rev: src/modules/Image/encodings/iff.c:1.8
Rev: src/modules/Image/encodings/ilbm.c:1.18
Rev: src/modules/Image/encodings/png.c:1.37
Rev: src/modules/Image/encodings/psd.c:1.22
Rev: src/modules/Image/encodings/ras.c:1.10
Rev: src/modules/Image/encodings/x.c:1.30
Rev: src/modules/Image/font.c:1.62
Rev: src/modules/Image/matrix.c:1.28
Rev: src/modules/Image/pattern.c:1.22
---
 src/modules/Image/blit.c              | 19 ++++++-----
 src/modules/Image/colortable.c        | 47 ++++++++++++++-------------
 src/modules/Image/colortable.h        |  4 +--
 src/modules/Image/colortable_lookup.h | 14 ++++----
 src/modules/Image/encodings/gif.c     | 12 +++----
 src/modules/Image/encodings/iff.c     | 14 ++++----
 src/modules/Image/encodings/ilbm.c    | 21 ++++++------
 src/modules/Image/encodings/png.c     |  6 ++--
 src/modules/Image/encodings/psd.c     |  8 +++--
 src/modules/Image/encodings/ras.c     |  8 ++---
 src/modules/Image/encodings/x.c       | 16 ++++-----
 src/modules/Image/font.c              | 27 ++++++++-------
 src/modules/Image/matrix.c            | 10 +++---
 src/modules/Image/pattern.c           | 17 +++++-----
 14 files changed, 117 insertions(+), 106 deletions(-)

diff --git a/src/modules/Image/blit.c b/src/modules/Image/blit.c
index ef1c1ac3e5..882cc0bcf2 100644
--- a/src/modules/Image/blit.c
+++ b/src/modules/Image/blit.c
@@ -1,10 +1,10 @@
-/* $Id: blit.c,v 1.45 2000/08/10 09:51:53 per Exp $ */
+/* $Id: blit.c,v 1.46 2000/08/11 18:46:35 grubba Exp $ */
 #include "global.h"
 
 /*
 **! module Image
 **! note
-**!	$Id: blit.c,v 1.45 2000/08/10 09:51:53 per Exp $
+**!	$Id: blit.c,v 1.46 2000/08/11 18:46:35 grubba Exp $
 **! class Image
 */
 
@@ -417,11 +417,12 @@ void image_paste_alpha(INT32 args)
        for (ix=0; ix<mx; ix++)
        {
 	 x = ix + x1; y = iy + y1;
-	 if(x>=0 && y>=0 && x<xs && y<ys) 
+	 if(x>=0 && y>=0 && x<xs && y<ys) {
 	   if(this->alpha)
 	     set_rgb_group_alpha(this->img[x+y*xs],*(source),this->alpha);
 	   else
 	     this->img[x+y*xs]=*(source);
+	 }
 	 source++;
        }
      THREADS_DISALLOW();
@@ -510,13 +511,13 @@ CHRONO("image_paste_mask begin");
       {
 	 if (m->r==255) d->r=s->r;
 	 else if (m->r==0) {}
-	 else d->r=(unsigned char)(((d->r*(255-m->r))+(s->r*m->r))*q);
+	 else d->r = DOUBLE_TO_COLORTYPE(((d->r*(255-m->r))+(s->r*m->r))*q);
 	 if (m->g==255) d->g=s->g;
 	 else if (m->g==0) {}
-	 else d->g=(unsigned char)(((d->g*(255-m->g))+(s->g*m->g))*q);
+	 else d->g = DOUBLE_TO_COLORTYPE(((d->g*(255-m->g))+(s->g*m->g))*q);
 	 if (m->b==255) d->b=s->b;
 	 else if (m->b==0) {}
-	 else d->b=(unsigned char)(((d->b*(255-m->b))+(s->b*m->b))*q);
+	 else d->b = DOUBLE_TO_COLORTYPE(((d->b*(255-m->b))+(s->b*m->b))*q);
 	 s++; m++; d++;
       }
       s+=smod; m+=mmod; d+=dmod;
@@ -612,13 +613,13 @@ CHRONO("image_paste_alpha_color begin");
       {
 	 if (m->r==255) d->r=rgb.r;
 	 else if (m->r==0) ;
-	 else d->r=(unsigned char)(((d->r*(255-m->r))+(rgb.r*m->r))*q);
+	 else d->r = DOUBLE_TO_COLORTYPE(((d->r*(255-m->r))+(rgb.r*m->r))*q);
 	 if (m->g==255) d->g=rgb.g;
 	 else if (m->g==0) ;
-	 else d->g=(unsigned char)(((d->g*(255-m->g))+(rgb.g*m->g))*q);
+	 else d->g = DOUBLE_TO_COLORTYPE(((d->g*(255-m->g))+(rgb.g*m->g))*q);
 	 if (m->b==255) d->b=rgb.b;
 	 else if (m->b==0) ;
-	 else d->b=(unsigned char)(((d->b*(255-m->b))+(rgb.b*m->b))*q);
+	 else d->b = DOUBLE_TO_COLORTYPE(((d->b*(255-m->b))+(rgb.b*m->b))*q);
 	 m++; d++;
       }
       m+=mmod; d+=dmod;
diff --git a/src/modules/Image/colortable.c b/src/modules/Image/colortable.c
index 8d799ca3a7..a67ed3da88 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.89 2000/08/10 17:05:40 grubba Exp $ */
+/* $Id: colortable.c,v 1.90 2000/08/11 18:59:59 grubba Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: colortable.c,v 1.89 2000/08/10 17:05:40 grubba Exp $
+**!	$Id: colortable.c,v 1.90 2000/08/11 18:59:59 grubba 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.89 2000/08/10 17:05:40 grubba Exp $");
+RCSID("$Id: colortable.c,v 1.90 2000/08/11 18:59:59 grubba Exp $");
 
 #include <math.h> /* fabs() */
 
@@ -79,7 +79,7 @@ RCSID("$Id: colortable.c,v 1.89 2000/08/10 17:05:40 grubba Exp $");
 #endif
 
 #define SQ(x) ((x)*(x))
-static INLINE int sq(int x) { return x*x; }
+static INLINE ptrdiff_t sq(ptrdiff_t x) { return x*x; }
 
 #ifdef THIS
 #undef THIS /* Needed for NT */
@@ -306,7 +306,7 @@ static ptrdiff_t reduce_recurse(struct nct_flat_entry *src,
    rgbl_group sum={0,0,0},diff={0,0,0};
    rgbl_group min={256,256,256},max={0,0,0};
    size_t mmul,tot=0;
-   INT32 gdiff=0;
+   ptrdiff_t gdiff=0;
    ptrdiff_t left, right;
    enum { SORT_R,SORT_G,SORT_B,SORT_GREY } st;
    rgbd_group newpos1,newpos2;
@@ -501,8 +501,8 @@ static ptrdiff_t reduce_recurse(struct nct_flat_entry *src,
          while (left<right) 
 	 { 
 	    struct nct_flat_entry tmp; 
-	    if ((INT32)(src[left].color.r*sf.r+src[left].color.g*sf.g+
-			src[left].color.b*sf.b)>(INT32)g)  
+	    if ((ptrdiff_t)(src[left].color.r*sf.r+src[left].color.g*sf.g+
+			    src[left].color.b*sf.b)>(ptrdiff_t)g)  
 	       tmp=src[left],src[left]=src[right],src[right--]=tmp; 
 	    else left++; 
 	 } 
@@ -635,7 +635,7 @@ struct color_hash_entry
 {
   rgb_group color;
   unsigned long pixels;
-  int no;
+  ptrdiff_t no;
 };
 
 static INLINE struct color_hash_entry *insert_in_hash(rgb_group rgb,
@@ -2511,7 +2511,7 @@ void image_colortable_cast_to_mapping(struct neo_colortable *nct)
    for (i=0; i<flat.numentries; i++)
       if (flat.entries[i].no!=-1)
       {
-	 push_int(flat.entries[i].no);
+	 push_int64(flat.entries[i].no);
 	 _image_make_rgb_color(flat.entries[i].color.r,
 			       flat.entries[i].color.g,
 			       flat.entries[i].color.b);
@@ -2536,7 +2536,7 @@ ptrdiff_t image_colortable_size(struct neo_colortable *nct)
 void image_colortable__sizeof(INT32 args)
 {
    pop_n_elems(args);
-   push_int(image_colortable_size(THIS));
+   push_int64(image_colortable_size(THIS));
 }
 
 void image_colortable_write_rgb(struct neo_colortable *nct,
@@ -2937,7 +2937,8 @@ static void _cub_add_cs_2cub_recur(int *i,int *p,
 				   int rp,int gp,int bp,
 				   int rd1,int gd1,int bd1,
 				   int rd2,int gd2,int bd2,
-				   int *a,int *b,int *c,int *d,
+				   ptrdiff_t *a, ptrdiff_t *b,
+				   ptrdiff_t *c, ptrdiff_t *d,
 				   rgbl_group sf,
 				   int accur)
 {
@@ -2948,7 +2949,7 @@ static void _cub_add_cs_2cub_recur(int *i,int *p,
  1 |   |
    c-j-d */
 
-   int e=-1,f=-1,g=-1,h=-1,j=-1;
+   ptrdiff_t e=-1,f=-1,g=-1,h=-1,j=-1;
    int rm1,gm1,bm1;
    int rm2,gm2,bm2;
 
@@ -2985,13 +2986,13 @@ static void _cub_add_cs_2cub_recur(int *i,int *p,
    _cub_add_cs_2cub_recur(i,p,p2,n2,fe, rp+rd2+rd1,gp+gd2+gd1,bp+bd2+bd1, rm1,gm1,bm1, rm2,gm2,bm2, &f,&g,&j,d,sf,accur);
 }
 
-static INLINE int _cub_find_full_add(int **pp,int *i,int *p,int n,
-				     struct nct_flat_entry *fe,
-				     int r,int g,int b,
-				     rgbl_group sf)
+static INLINE ptrdiff_t _cub_find_full_add(int **pp,int *i,int *p,int n,
+					   struct nct_flat_entry *fe,
+					   int r,int g,int b,
+					   rgbl_group sf)
 {
    int mindist=256*256*100; /* max dist is 256²*3 */
-   int c=0;
+   ptrdiff_t c = 0;
 
    while (n--)
       if (fe->no==-1) fe++;
@@ -3028,7 +3029,8 @@ static void _cub_add_cs_full_recur(int **pp,int *i,int *p,
 				   int rp,int gp,int bp,
 				   int rd1,int gd1,int bd1,
 				   int rd2,int gd2,int bd2,
-				   int *a,int *b,int *c,int *d,
+				   ptrdiff_t *a, ptrdiff_t *b,
+				   ptrdiff_t *c, ptrdiff_t *d,
 				   rgbl_group sf,
 				   int accur)
 {
@@ -3041,7 +3043,7 @@ static void _cub_add_cs_full_recur(int **pp,int *i,int *p,
    c-i-d
  */
 
-   int e,f,g,h,j;
+   ptrdiff_t e,f,g,h,j;
    int rm1,gm1,bm1;
    int rm2,gm2,bm2;
 
@@ -3095,7 +3097,7 @@ static INLINE void _cub_add_cs(struct neo_colortable *nct,
 			       int rd1,int gd1,int bd1,
 			       int rd2,int gd2,int bd2)
 {
-   int a=-1,b=-1,c=-1,d=-1;
+   ptrdiff_t a=-1,b=-1,c=-1,d=-1;
 #if 0
    fprintf(stderr,
 	   " _cub_add_cs %d,%d,%d %d,%d,%d, %d,%d,%d, %d,%d,%d, %d,%d,%d\n",
@@ -3581,7 +3583,7 @@ void image_colortable_map(INT32 args)
 	    
 	    while (n--)
 	    {
-	       if (*s < nct->u.flat.numentries)
+	       if ((size_t)*s < (size_t)nct->u.flat.numentries)
 		  *(d++)=nct->u.flat.entries[*s].color;
 	       else 
 		  d++; /* it's black already, and this is illegal */
@@ -3748,7 +3750,7 @@ void image_colortable_floyd_steinberg(INT32 args)
 	 THIS->du.floyd_steinberg.dir=sp[-args].u.integer;
    else 
       THIS->du.floyd_steinberg.dir=0;
-   if (args>=6) 
+   if (args>=6) {
       if (sp[5-args].type==T_FLOAT)
 	 factor = sp[5-args].u.float_number;
       else if (sp[5-args].type==T_INT)
@@ -3756,6 +3758,7 @@ void image_colortable_floyd_steinberg(INT32 args)
       else
 	 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)
diff --git a/src/modules/Image/colortable.h b/src/modules/Image/colortable.h
index 5d29bc0c70..1fc2c09a26 100644
--- a/src/modules/Image/colortable.h
+++ b/src/modules/Image/colortable.h
@@ -1,7 +1,7 @@
 /*
 **! module Image
 **! note
-**!	$Id: colortable.h,v 1.21 2000/08/10 20:05:05 grubba Exp $
+**!	$Id: colortable.h,v 1.22 2000/08/11 18:51:24 grubba Exp $
 */
 
 #ifdef PIKE_IMAGE_COLORTABLE_H
@@ -19,7 +19,7 @@
 
 #define COLORLOOKUPCACHEHASHSIZE 207
 
-typedef unsigned long nct_weight_t;
+typedef size_t nct_weight_t;
 
 struct nct_flat_entry /* flat colorentry */
 {
diff --git a/src/modules/Image/colortable_lookup.h b/src/modules/Image/colortable_lookup.h
index cb4f8bc493..38da3a1a07 100644
--- a/src/modules/Image/colortable_lookup.h
+++ b/src/modules/Image/colortable_lookup.h
@@ -1,10 +1,10 @@
-/* $Id: colortable_lookup.h,v 1.11 2000/08/10 17:01:27 grubba Exp $ */
+/* $Id: colortable_lookup.h,v 1.12 2000/08/11 19:11:42 grubba Exp $ */
 /* included w/ defines in colortable.c */
 
 /*
 **! module Image
 **! note
-**!	$Id: colortable_lookup.h,v 1.11 2000/08/10 17:01:27 grubba Exp $
+**!	$Id: colortable_lookup.h,v 1.12 2000/08/11 19:11:42 grubba Exp $
 **! class colortable
 */
 
@@ -174,7 +174,7 @@ void NCTLU_FLAT_FULL_NAME(rgb_group *s,
    {
       int rgbr,rgbg,rgbb;
       int mindist;
-      int m;
+      ptrdiff_t m;
       struct nct_flat_entry *fe;
       struct lookupcache *lc;
 	 
@@ -223,7 +223,7 @@ void NCTLU_FLAT_FULL_NAME(rgb_group *s,
 	    {
 	       lc->dest=fe->color;
 	       mindist=dist;
-	       lc->index=fe->no;
+	       lc->index = DO_NOT_WARN((int)fe->no);
 	       NCTLU_CACHE_HIT_WRITE;
 	    }
 	 
@@ -473,9 +473,9 @@ void NCTLU_CUBE_NAME(rgb_group *s,
 	       if (sc->no[i]>=nc) 
 	       {
 		  double f= i * sc->mqsteps;
-		  int drgbr=sc->low.r+(int)(sc->vector.r*f);
-		  int drgbg=sc->low.g+(int)(sc->vector.g*f);
-		  int drgbb=sc->low.b+(int)(sc->vector.b*f);
+		  int drgbr = sc->low.r + DOUBLE_TO_INT(sc->vector.r*f);
+		  int drgbg = sc->low.g + DOUBLE_TO_INT(sc->vector.g*f);
+		  int drgbb = sc->low.b + DOUBLE_TO_INT(sc->vector.b*f);
 
 		  int ldist=sf.r*SQ(val.r-drgbr)+
 		     sf.g*SQ(val.g-drgbg)+sf.b*SQ(val.b-drgbb);
diff --git a/src/modules/Image/encodings/gif.c b/src/modules/Image/encodings/gif.c
index 27eca1e8b0..5d9dea18d1 100644
--- a/src/modules/Image/encodings/gif.c
+++ b/src/modules/Image/encodings/gif.c
@@ -1,9 +1,9 @@
-/* $Id: gif.c,v 1.55 2000/08/08 10:43:13 grubba Exp $ */
+/* $Id: gif.c,v 1.56 2000/08/11 18:19:45 grubba Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: gif.c,v 1.55 2000/08/08 10:43:13 grubba Exp $
+**!	$Id: gif.c,v 1.56 2000/08/11 18:19:45 grubba Exp $
 **! submodule GIF
 **!
 **!	This submodule keep the GIF encode/decode capabilities
@@ -31,7 +31,7 @@
 #include <ctype.h>
 
 #include "stralloc.h"
-RCSID("$Id: gif.c,v 1.55 2000/08/08 10:43:13 grubba Exp $");
+RCSID("$Id: gif.c,v 1.56 2000/08/11 18:19:45 grubba Exp $");
 #include "pike_macros.h"
 #include "object.h"
 #include "constants.h"
@@ -151,7 +151,7 @@ void image_gif_header_block(INT32 args)
    int xs,ys,bkgi=0,aspect=0,gif87a=0;
    struct neo_colortable *nct=NULL;
    int globalpalette=0;
-   int numcolors=0;
+   ptrdiff_t numcolors=0;
    int bpp=1;
    char buf[20];
    struct pike_string *ps;
@@ -671,7 +671,7 @@ void image_gif_render_block(INT32 args)
 {
    struct image *img=NULL,*alpha=NULL;
    struct neo_colortable *nct=NULL;
-   int numcolors;
+   ptrdiff_t numcolors;
    int localpalette,xpos,ypos;
    int alphaidx=-1;
    rgb_group alphacolor;
@@ -978,7 +978,7 @@ void _image_gif_encode(INT32 args,int fs)
    rgbl_group ac={0,0,0};
    int alphaentry=0;
    int trans=0;
-   int tridx=0;
+   ptrdiff_t tridx=0;
 
    int n=0;
    int arg=2;
diff --git a/src/modules/Image/encodings/iff.c b/src/modules/Image/encodings/iff.c
index 0d1ddb5ca2..9fbfa43310 100644
--- a/src/modules/Image/encodings/iff.c
+++ b/src/modules/Image/encodings/iff.c
@@ -1,9 +1,9 @@
-/* $Id: iff.c,v 1.7 2000/08/06 13:53:31 grubba Exp $ */
+/* $Id: iff.c,v 1.8 2000/08/11 18:36:19 grubba Exp $ */
 
 #include "global.h"
 
 #include "stralloc.h"
-RCSID("$Id: iff.c,v 1.7 2000/08/06 13:53:31 grubba Exp $");
+RCSID("$Id: iff.c,v 1.8 2000/08/11 18:36:19 grubba Exp $");
 #include "pike_macros.h"
 #include "object.h"
 #include "constants.h"
@@ -70,7 +70,7 @@ void parse_iff(char *id, unsigned char *data, ptrdiff_t len,
 
 static struct pike_string *low_make_iff(struct svalue *s)
 {
-  ptrdiff_t len;
+  size_t len;
   unsigned char lenb[4];
 
   if(s->type != T_ARRAY || s->u.array->size != 2 ||
@@ -81,10 +81,10 @@ static struct pike_string *low_make_iff(struct svalue *s)
   add_ref(s->u.array);
   push_array_items(s->u.array);
   len = sp[-1].u.string->len;
-  lenb[0] = (len & 0xff000000)>>24;
-  lenb[1] = (len & 0x00ff0000)>>16;
-  lenb[2] = (len & 0x0000ff00)>>8;
-  lenb[3] = (len & 0x000000ff);
+  lenb[0] = DO_NOT_WARN((unsigned char)((len & 0xff000000)>>24));
+  lenb[1] = DO_NOT_WARN((unsigned char)((len & 0x00ff0000)>>16));
+  lenb[2] = DO_NOT_WARN((unsigned char)((len & 0x0000ff00)>>8));
+  lenb[3] = DO_NOT_WARN((unsigned char)(len & 0x000000ff));
   push_string(make_shared_binary_string((char *)lenb, 4));
   stack_swap();
   if(len&1) {
diff --git a/src/modules/Image/encodings/ilbm.c b/src/modules/Image/encodings/ilbm.c
index d75351def7..c16b5cf386 100644
--- a/src/modules/Image/encodings/ilbm.c
+++ b/src/modules/Image/encodings/ilbm.c
@@ -1,9 +1,9 @@
-/* $Id: ilbm.c,v 1.17 2000/08/06 13:53:31 grubba Exp $ */
+/* $Id: ilbm.c,v 1.18 2000/08/11 18:34:07 grubba Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: ilbm.c,v 1.17 2000/08/06 13:53:31 grubba Exp $
+**!	$Id: ilbm.c,v 1.18 2000/08/11 18:34:07 grubba Exp $
 **! submodule ILBM
 **!
 **!	This submodule keep the ILBM encode/decode capabilities
@@ -14,7 +14,7 @@
 #include "global.h"
 
 #include "stralloc.h"
-RCSID("$Id: ilbm.c,v 1.17 2000/08/06 13:53:31 grubba Exp $");
+RCSID("$Id: ilbm.c,v 1.18 2000/08/11 18:34:07 grubba Exp $");
 #include "pike_macros.h"
 #include "object.h"
 #include "constants.h"
@@ -246,7 +246,7 @@ static void planar2chunky(unsigned char *src, int srcmod, int depth,
   }
 }
 
-static void parse_body(struct BMHD *bmhd, unsigned char *body, INT32 blen,
+static void parse_body(struct BMHD *bmhd, unsigned char *body, ptrdiff_t blen,
 		       struct image *img, struct image *alpha,
 		       struct neo_colortable *ctable, int ham)
 {
@@ -255,7 +255,7 @@ static void parse_body(struct BMHD *bmhd, unsigned char *body, INT32 blen,
   int eplanes = (bmhd->masking == mskHasMask? bmhd->nPlanes+1:bmhd->nPlanes);
   unsigned char *line=0;
   unsigned INT32 *cptr, *cline = alloca((rbyt<<3)*sizeof(unsigned INT32));
-  INT32 suse=0;
+  ptrdiff_t suse=0;
   rgb_group *dest = img->img;
   rgb_group *adest = (alpha==NULL? NULL : alpha->img);
 
@@ -339,7 +339,7 @@ static void parse_body(struct BMHD *bmhd, unsigned char *body, INT32 blen,
 	  /* HAM7/HAM8 */
 	  rgb_group hold;
 	  int clr;
-	  unsigned int numcolors = ctable->u.flat.numentries;
+	  size_t numcolors = ctable->u.flat.numentries;
 	  struct nct_flat_entry *entries = ctable->u.flat.entries;
 	  hold.r = hold.g = hold.b = 0;
 	  for(x=0; x<bmhd->w; x++)
@@ -372,7 +372,7 @@ static void parse_body(struct BMHD *bmhd, unsigned char *body, INT32 blen,
 	  /* HAM5/HAM6 */	  
 	  rgb_group hold;
 	  int clr;
-	  unsigned int numcolors = ctable->u.flat.numentries;
+	  size_t numcolors = ctable->u.flat.numentries;
 	  struct nct_flat_entry *entries = ctable->u.flat.entries;
 	  hold.r = hold.g = hold.b = 0;
 	  for(x=0; x<bmhd->w; x++)
@@ -404,7 +404,7 @@ static void parse_body(struct BMHD *bmhd, unsigned char *body, INT32 blen,
 	}
       else {
 	/* normal palette */
-	unsigned int numcolors = ctable->u.flat.numentries;
+	size_t numcolors = ctable->u.flat.numentries;
 	struct nct_flat_entry *entries = ctable->u.flat.entries;
 	for(x=0; x<bmhd->w; x++)
 	  if(*cptr<numcolors)
@@ -495,7 +495,8 @@ static void image_ilbm__decode(INT32 args)
 
   if(ITEM(arr)[3].type == T_STRING && ITEM(arr)[3].u.string->size_shift == 0) {
     unsigned char *pal = STR0(ITEM(arr)[3].u.string);
-    INT32 col, ncol = ITEM(arr)[3].u.string->len/3, mcol = 1<<bmhd.nPlanes;
+    INT32 col, mcol = 1<<bmhd.nPlanes;
+    ptrdiff_t ncol = ITEM(arr)[3].u.string->len/3;
     if((camg & CAMG_HAM))
       mcol = (bmhd.nPlanes>6? 64:16);
     else if((camg & CAMG_EHB))
@@ -775,7 +776,7 @@ static void image_ilbm_encode(INT32 args)
     ct = NULL;
 
   if(ct) {
-    int sz = image_colortable_size(ct);
+    ptrdiff_t sz = image_colortable_size(ct);
     for(bpp=1; (1<<bpp)<sz; bpp++);
   } else
     bpp = 24;
diff --git a/src/modules/Image/encodings/png.c b/src/modules/Image/encodings/png.c
index 907db0835a..99ad2dd0e2 100644
--- a/src/modules/Image/encodings/png.c
+++ b/src/modules/Image/encodings/png.c
@@ -1,5 +1,5 @@
 #include "global.h"
-RCSID("$Id: png.c,v 1.36 2000/08/09 12:55:13 grubba Exp $");
+RCSID("$Id: png.c,v 1.37 2000/08/11 18:22:02 grubba Exp $");
 
 #include "image_machine.h"
 
@@ -1484,8 +1484,8 @@ static void image_png_encode(INT32 args)
 
    if (ct)
    {
-      int sz;
-      sz=image_colortable_size(ct);
+      ptrdiff_t sz;
+      sz = image_colortable_size(ct);
       if (sz>256)
 	 error("Image.PNG.encode: palette size to large; "
 	       "PNG doesn't support bigger palettes then 256 colors\n");
diff --git a/src/modules/Image/encodings/psd.c b/src/modules/Image/encodings/psd.c
index 5bc7216bf3..010057c023 100644
--- a/src/modules/Image/encodings/psd.c
+++ b/src/modules/Image/encodings/psd.c
@@ -1,5 +1,5 @@
 #include "global.h"
-RCSID("$Id: psd.c,v 1.21 2000/08/10 09:51:54 per Exp $");
+RCSID("$Id: psd.c,v 1.22 2000/08/11 18:36:44 grubba Exp $");
 
 #include "image_machine.h"
 
@@ -120,7 +120,8 @@ static char *read_data( struct buffer * from, size_t len )
 {
   char *res;
   if( from->len < len )
-    error("Not enough space for %lu bytes\n", len);
+    error("Not enough space for %lu bytes\n",
+	  DO_NOT_WARN((unsigned long)len));
   res = (char *)from->str;
   from->str += len;
   from->len -= len;
@@ -322,7 +323,8 @@ packbitsdecode(struct buffer src,
     }
   }
   if(dst.len)
-    fprintf(stderr, "%ld bytes left to write! (should be 0)\n", dst.len);
+    fprintf(stderr, "%ld bytes left to write! (should be 0)\n",
+	    DO_NOT_WARN((long)dst.len));
   return src;
 }
 
diff --git a/src/modules/Image/encodings/ras.c b/src/modules/Image/encodings/ras.c
index 04df3be4dd..16de5c701e 100644
--- a/src/modules/Image/encodings/ras.c
+++ b/src/modules/Image/encodings/ras.c
@@ -1,9 +1,9 @@
-/* $Id: ras.c,v 1.9 2000/08/08 11:11:16 grubba Exp $ */
+/* $Id: ras.c,v 1.10 2000/08/11 18:37:32 grubba Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: ras.c,v 1.9 2000/08/08 11:11:16 grubba Exp $
+**!	$Id: ras.c,v 1.10 2000/08/11 18:37:32 grubba Exp $
 **! submodule RAS
 **!
 **!	This submodule keep the RAS encode/decode capabilities
@@ -14,7 +14,7 @@
 #include "global.h"
 
 #include "stralloc.h"
-RCSID("$Id: ras.c,v 1.9 2000/08/08 11:11:16 grubba Exp $");
+RCSID("$Id: ras.c,v 1.10 2000/08/11 18:37:32 grubba Exp $");
 #include "pike_macros.h"
 #include "object.h"
 #include "constants.h"
@@ -453,7 +453,7 @@ static void image_ras_encode(INT32 args)
 
   if(ct) {
     struct pike_string *cts;
-    int i, n = image_colortable_size(ct);
+    ptrdiff_t i, n = image_colortable_size(ct);
     unsigned char *tmp;
     rs.ras_depth = 8;
     rs.ras_maptype = RMT_EQUAL_RGB;
diff --git a/src/modules/Image/encodings/x.c b/src/modules/Image/encodings/x.c
index e430a55c8c..782ff76f71 100644
--- a/src/modules/Image/encodings/x.c
+++ b/src/modules/Image/encodings/x.c
@@ -1,9 +1,9 @@
-/* $Id: x.c,v 1.29 2000/08/04 10:48:14 grubba Exp $ */
+/* $Id: x.c,v 1.30 2000/08/11 18:21:29 grubba Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: x.c,v 1.29 2000/08/04 10:48:14 grubba Exp $
+**!	$Id: x.c,v 1.30 2000/08/11 18:21:29 grubba Exp $
 **! submodule X
 **!
 **!	This submodule handles encoding and decoding of
@@ -29,7 +29,7 @@
 #include <winsock.h>
 #endif
 
-RCSID("$Id: x.c,v 1.29 2000/08/04 10:48:14 grubba Exp $");
+RCSID("$Id: x.c,v 1.30 2000/08/11 18:21:29 grubba Exp $");
 #include "pike_macros.h"
 #include "object.h"
 #include "constants.h"
@@ -271,12 +271,12 @@ static void image_x_encode_truecolor(INT32 args)
    }
    else
    {
-      INT32 rfshift,gfshift,bfshift,rzshift,gzshift,bzshift;
-      INT32 bpshift,blinemod,bit;
+      ptrdiff_t rfshift,gfshift,bfshift,rzshift,gzshift,bzshift;
+      ptrdiff_t bpshift,blinemod,bit;
 
-      rfshift=rshift-(sizeof(COLORTYPE)*8-rbits);
-      gfshift=gshift-(sizeof(COLORTYPE)*8-gbits);
-      bfshift=bshift-(sizeof(COLORTYPE)*8-bbits);
+      rfshift = rshift-(sizeof(COLORTYPE)*8-rbits);
+      gfshift = gshift-(sizeof(COLORTYPE)*8-gbits);
+      bfshift = bshift-(sizeof(COLORTYPE)*8-bbits);
       if (rfshift<0) rzshift=-rfshift,rfshift=0; else rzshift=0;
       if (gfshift<0) gzshift=-gfshift,gfshift=0; else gzshift=0;
       if (bfshift<0) bzshift=-bfshift,bfshift=0; else bzshift=0;
diff --git a/src/modules/Image/font.c b/src/modules/Image/font.c
index 3e5dd63e99..10d938add0 100644
--- a/src/modules/Image/font.c
+++ b/src/modules/Image/font.c
@@ -1,4 +1,4 @@
-/* $Id: font.c,v 1.61 2000/08/10 09:51:53 per Exp $ */
+/* $Id: font.c,v 1.62 2000/08/11 18:42:54 grubba 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.61 2000/08/10 09:51:53 per Exp $
+**!	$Id: font.c,v 1.62 2000/08/11 18:42:54 grubba Exp $
 **! class Font
 **!
 **! note
@@ -204,8 +204,8 @@ struct font
 #endif
    void *mem;         /* pointer to mmaped/malloced memory */
    unsigned long chars;       /* number of characters */
-  float xspacing_scale; /* Fraction of spacing to use */
-  float yspacing_scale; /* Fraction of spacing to use */
+  double xspacing_scale; /* Fraction of spacing to use */
+  double yspacing_scale; /* Fraction of spacing to use */
   enum {
     J_LEFT,
     J_RIGHT,
@@ -253,7 +253,7 @@ static void exit_font_struct(struct object *obj)
 static INLINE int char_space(struct font *this, INT32 c)
 {
   if(c==0x20)
-    return (int)((double)(this->height*this->xspacing_scale)/4.5);
+    return DOUBLE_TO_INT((double)(this->height*this->xspacing_scale)/4.5);
   else if(c==0x20+128)
     return (this->height*this->xspacing_scale)/18;
   return this->charinfo[c].spacing*this->xspacing_scale;
@@ -266,7 +266,7 @@ static INLINE int char_width(struct font *this, INT32 c)
 }  
 
 #ifndef HAVE_MMAP
-static INLINE int my_read(int from, void *t, int towrite)
+static INLINE int my_read(int from, void *t, size_t towrite)
 {
   int res;
   while((res = fd_read(from, t, towrite)) < 0)
@@ -310,11 +310,12 @@ static INLINE void write_char(struct _char *ci,
       for (x=(INT32)ci->width; x>0; x--)
       {
 	 int r,c;
-	 if((c=255-*p)) 
+	 if((c=255-*p)) {
 	   if ((r=pos->r+c)>255)
 	     pos->r=pos->g=pos->b=255;
 	   else
 	     pos->r=pos->g=pos->b=r;
+	 }
 	 pos++;
 	 p++;
       }
@@ -473,8 +474,8 @@ loading_default:
 
 		  for (i=0; i<THIS->chars; i++)
 		  {
-		     if (i*sizeof(INT32)<(unsigned long)size
-			 && ntohl(fh->o[i])<(unsigned long)size
+		     if (i*sizeof(INT32)<(size_t)size
+			 && ntohl(fh->o[i])<(size_t)size
 			 && ! ( ntohl(fh->o[i]) % 4) ) /* must be aligned */
 		     {
 			ch=(struct char_head*)
@@ -561,7 +562,7 @@ void font_write(INT32 args)
    p_wchar0 *to_write0;
    p_wchar1 *to_write1;
    p_wchar2 *to_write2;
-   int to_write_len;
+   ptrdiff_t to_write_len;
    INT32 c;
    struct font *this = (*(struct font **)(Pike_fp->current_storage));
    if (!this)
@@ -639,7 +640,9 @@ void font_write(INT32 args)
    img = ((struct image*)o->storage);
    img->xsize = maxwidth2;
    if(args>1)
-     img->ysize = this->height+((double)this->height*(double)(args-1)*(double)this->yspacing_scale)+1;
+     img->ysize = DOUBLE_TO_INT(this->height+
+				((double)this->height*(double)(args-1)*
+				 (double)this->yspacing_scale)+1);
    else
      img->ysize = this->height;
    img->rgb.r=img->rgb.g=img->rgb.b=255;
@@ -775,7 +778,7 @@ void font_text_extents(INT32 args)
      p_wchar0 *to_write0;
      p_wchar1 *to_write1;
      p_wchar2 *to_write2;
-     int to_write_len;
+     ptrdiff_t to_write_len;
      if (sp[j-args].type!=T_STRING)
 	bad_arg_error("font->write",sp-args,args,0,"",sp-args,
 		"Bad arguments to font->write()\n");
diff --git a/src/modules/Image/matrix.c b/src/modules/Image/matrix.c
index 828767d7c8..51b739f57e 100644
--- a/src/modules/Image/matrix.c
+++ b/src/modules/Image/matrix.c
@@ -1,9 +1,9 @@
-/* $Id: matrix.c,v 1.27 2000/08/09 11:23:40 grubba Exp $ */
+/* $Id: matrix.c,v 1.28 2000/08/11 18:44:04 grubba Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: matrix.c,v 1.27 2000/08/09 11:23:40 grubba Exp $
+**!	$Id: matrix.c,v 1.28 2000/08/11 18:44:04 grubba Exp $
 **! class Image
 */
 
@@ -206,7 +206,7 @@ CHRONO("scale begin");
 			   source->xsize, (1.0-decimals(yn)),dx);
 	 if ((yd = DOUBLE_TO_INT(yn+dy) - DOUBLE_TO_INT(yn))>1)
             while (--yd)
-   	       scale_add_line(new, (INT32)(yn+yd), newx, source->img, y,
+   	       scale_add_line(new, DOUBLE_TO_INT(yn+yd), newx, source->img, y,
 			      source->xsize, 1.0, dx);
 	 if (decimals(yn+dy))
 	    scale_add_line(new, DOUBLE_TO_INT(yn+dy), newx, source->img, y,
@@ -1015,8 +1015,8 @@ void img_rotate(INT32 args,int xpn)
 
    dest2.img=d0.img=NULL;
 
-   if (angle<-135) angle-=360*(int)((angle-225)/360);
-   else if (angle>225) angle-=360*(int)((angle+135)/360);
+   if (angle<-135) angle-=360*DOUBLE_TO_INT((angle-225)/360);
+   else if (angle>225) angle-=360*DOUBLE_TO_INT((angle+135)/360);
    if (angle<-45)
    {
       img_ccw(THIS,&dest2);
diff --git a/src/modules/Image/pattern.c b/src/modules/Image/pattern.c
index 800b495cbc..71d13b1205 100644
--- a/src/modules/Image/pattern.c
+++ b/src/modules/Image/pattern.c
@@ -1,9 +1,9 @@
-/* $Id: pattern.c,v 1.21 2000/08/10 16:47:00 grubba Exp $ */
+/* $Id: pattern.c,v 1.22 2000/08/11 18:49:46 grubba Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: pattern.c,v 1.21 2000/08/10 16:47:00 grubba Exp $
+**!	$Id: pattern.c,v 1.22 2000/08/11 18:49:46 grubba Exp $
 **! class Image
 */
 
@@ -289,9 +289,10 @@ static void init_colorrange(rgb_group *cr,struct svalue *s,char *where)
    *vp=v[0]+1+1.0/(COLORRANGE_LEVELS-1);
    lrgb=*rgbp=rgb[0]; /* back to original color */
 
-   for (k=1,i=v[0]*(COLORRANGE_LEVELS-1); k<=s->u.array->size/2; k++)
+   for (k=1,i=DOUBLE_TO_INT(v[0]*(COLORRANGE_LEVELS-1));
+	k<=s->u.array->size/2; k++)
    {
-      n=v[k]*COLORRANGE_LEVELS;
+      n = DOUBLE_TO_INT(v[k]*COLORRANGE_LEVELS);
 
       if (n>i)
       {
@@ -303,9 +304,9 @@ static void init_colorrange(rgb_group *cr,struct svalue *s,char *where)
 
 	 for (b=0;i<n && i<COLORRANGE_LEVELS;i++,b++)
 	 {
-	    cr[i&(COLORRANGE_LEVELS-1)].r=(unsigned char)(lrgb.r+fr*b);
-	    cr[i&(COLORRANGE_LEVELS-1)].g=(unsigned char)(lrgb.g+fg*b);
-	    cr[i&(COLORRANGE_LEVELS-1)].b=(unsigned char)(lrgb.b+fb*b);
+	    cr[i&(COLORRANGE_LEVELS-1)].r = DOUBLE_TO_COLORTYPE(lrgb.r+fr*b);
+	    cr[i&(COLORRANGE_LEVELS-1)].g = DOUBLE_TO_COLORTYPE(lrgb.g+fg*b);
+	    cr[i&(COLORRANGE_LEVELS-1)].b = DOUBLE_TO_COLORTYPE(lrgb.b+fb*b);
 	 }
       }
       lrgb=rgb[k];
@@ -331,7 +332,7 @@ static void init_colorrange(rgb_group *cr,struct svalue *s,char *where)
    ( (args>n) \
       ? ( (sp[n-args].type==T_INT) ? sp[n-args].u.integer \
 	  : ( (sp[n-args].type==T_FLOAT) ? DOUBLE_TO_INT(sp[n-args].u.float_number) \
-	      : ( error("illegal argument(s) to %s\n", where), 0.0 ) ) ) \
+	      : ( error("illegal argument(s) to %s\n", where), 0 ) ) ) \
       : def )
 
 /*
-- 
GitLab