]> git.imager.perl.org - imager.git/commitdiff
- eliminate unused variables and static functions
authorTony Cook <tony@develop=help.com>
Mon, 24 Jan 2005 13:18:48 +0000 (13:18 +0000)
committerTony Cook <tony@develop=help.com>
Mon, 24 Jan 2005 13:18:48 +0000 (13:18 +0000)
- simplify some XS code by adding another typemap entry

27 files changed:
Changes
Imager.xs
bmp.c
draw.c
draw.h
fills.c
filters.c
font.c
freetyp2.c
gif.c
io.c
iolayer.c
jpeg.c
map.c
maskimg.c
palimg.c
png.c
pnm.c
polygon.c
quant.c
raw.c
rgb.c
rotate.c
tags.c
tga.c
tiff.c
typemap

diff --git a/Changes b/Changes
index ba55555ceaedcced69644a17df74ea8b7e4770f5..c5160da91361ca813b422547ad47b6e26c8a79ba 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1009,6 +1009,8 @@ Revision history for Perl extension Imager.
 - explicitly document there are no PNG specific tags.
 - more examples in Imager::Draw
 - minor cleanup of Imager::Fill
+- eliminate unused variables and static functions
+- simplify some XS code by adding another typemap entry
 
 =================================================================
 
index 2827069097b578c8c24b06c8ad7ac96919fc294e..c374f94de7bd571160781c40d5eb54622718f1c3 100644 (file)
--- a/Imager.xs
+++ b/Imager.xs
@@ -18,6 +18,7 @@ typedef io_glue* Imager__IO;
 typedef i_color* Imager__Color;
 typedef i_fcolor* Imager__Color__Float;
 typedef i_img*   Imager__ImgRaw;
+typedef int undef_neg_int;
 
 #ifdef HAVE_LIBTT
 typedef TT_Fonthandle* Imager__Font__TT;
@@ -558,6 +559,7 @@ static struct value_name orddith_names[] =
   { "custom", od_custom, },
 };
 
+#if 0
 static int
 hv_fetch_bool(HV *hv, char *name, int def) {
   SV **sv;
@@ -581,6 +583,7 @@ hv_fetch_int(HV *hv, char *name, int def) {
   else
     return def;
 }
+#endif
 
 /* look through the hash for quantization options */
 static void handle_quant_opts(i_quantize *quant, HV *hv)
@@ -845,7 +848,6 @@ load_fount_segs(AV *asegs, int *count) {
   */
   int i, j;
   AV *aseg;
-  SV *sv;
   i_fountain_seg *segs;
   double work[3];
   int worki[2];
@@ -1961,7 +1963,7 @@ i_tt_cp(handle,im,xb,yb,channel,points,str_sv,len_ignored,smooth,utf8)
                 RETVAL
 
 
-undef_int
+void
 i_tt_bbox(handle,point,str_sv,len_ignored, utf8)
   Imager::Font::TT     handle
             float     point
@@ -2619,8 +2621,6 @@ void
 i_readgif_callback(...)
           PROTOTYPE: &
             PREINIT:
-               char*    data;
-               int     length;
                int*    colour_table;
                int     colours, q, w;
              i_img*    rimg;
@@ -3332,11 +3332,6 @@ DSO_call(handle,func_index,hv)
 
 
 
-# this is mostly for testing...
-# this function results in 'RETVAL' : unreferenced local variable
-# in VC++, and might be subtley wrong
-# the most obvious change may result in a double free so I'm leaving it
-# for now
 SV *
 i_get_pixel(im, x, y)
        Imager::ImgRaw im
@@ -3347,13 +3342,15 @@ i_get_pixel(im, x, y)
       CODE:
        color = (i_color *)mymalloc(sizeof(i_color));
        if (i_gpix(im, x, y, color) == 0) {
-          ST(0) = sv_newmortal();
-          sv_setref_pv(ST(0), "Imager::Color", (void *)color);
+          RETVAL = NEWSV(0, 0);
+          sv_setref_pv(RETVAL, "Imager::Color", (void *)color);
         }
         else {
           myfree(color);
-          ST(0) = &PL_sv_undef;
+          RETVAL = &PL_sv_undef;
         }
+      OUTPUT:
+        RETVAL
         
 
 int
@@ -3475,14 +3472,16 @@ i_addcolors(im, ...)
         index = i_addcolors(im, colors, items-1);
         myfree(colors);
         if (index == 0) {
-          ST(0) = sv_2mortal(newSVpv("0 but true", 0));
+          RETVAL = newSVpv("0 but true", 0);
         }
         else if (index == -1) {
-          ST(0) = &PL_sv_undef;
+          RETVAL = &PL_sv_undef;
         }
         else {
-          ST(0) = sv_2mortal(newSViv(index));
+          RETVAL = newSViv(index);
         }
+      OUTPUT:
+        RETVAL
 
 undef_int 
 i_setcolors(im, index, ...)
@@ -3540,33 +3539,13 @@ i_getcolors(im, index, ...)
         myfree(colors);
 
 
-SV *
+undef_neg_int
 i_colorcount(im)
         Imager::ImgRaw im
-      PREINIT:
-        int count;
-      CODE:
-        count = i_colorcount(im);
-        if (count >= 0) {
-          ST(0) = sv_2mortal(newSViv(count));
-        }
-        else {
-          ST(0) = &PL_sv_undef;
-        }
 
-SV *
+undef_neg_int
 i_maxcolors(im)
         Imager::ImgRaw im
-      PREINIT:
-        int count;
-      CODE:
-        count = i_maxcolors(im);
-        if (count >= 0) {
-          ST(0) = sv_2mortal(newSViv(count));
-        }
-        else {
-          ST(0) = &PL_sv_undef;
-        }
 
 SV *
 i_findcolor(im, color)
@@ -3576,11 +3555,13 @@ i_findcolor(im, color)
         i_palidx index;
       CODE:
         if (i_findcolor(im, color, &index)) {
-          ST(0) = sv_2mortal(newSViv(index));
+          RETVAL = newSViv(index);
         }
         else {
-          ST(0) = &PL_sv_undef;
+          RETVAL = &PL_sv_undef;
         }
+      OUTPUT:
+        RETVAL
 
 int
 i_img_bits(im)
@@ -3777,14 +3758,16 @@ i_gpixf(im, x, y)
       CODE:
        color = (i_fcolor *)mymalloc(sizeof(i_fcolor));
        if (i_gpixf(im, x, y, color) == 0) {
-          ST(0) = sv_newmortal();
-          sv_setref_pv(ST(0), "Imager::Color::Float", (void *)color);
+          RETVAL = NEWSV(0,0);
+          sv_setref_pv(RETVAL, "Imager::Color::Float", (void *)color);
         }
         else {
           myfree(color);
-          ST(0) = &PL_sv_undef;
+          RETVAL = &PL_sv_undef;
         }
-        
+      OUTPUT:
+        RETVAL
+
 void
 i_glin(im, l, r, y)
         Imager::ImgRaw im
@@ -3897,12 +3880,14 @@ i_tags_find(im, name, start)
       CODE:
         if (i_tags_find(&im->tags, name, start, &entry)) {
           if (entry == 0)
-            ST(0) = sv_2mortal(newSVpv("0 but true", 0));
+            RETVAL = newSVpv("0 but true", 0);
           else
-            ST(0) = sv_2mortal(newSViv(entry));
+            RETVAL = newSViv(entry);
         } else {
-          ST(0) = &PL_sv_undef;
+          RETVAL = &PL_sv_undef;
         }
+      OUTPUT:
+        RETVAL
 
 SV *
 i_tags_findn(im, code, start)
@@ -3914,12 +3899,15 @@ i_tags_findn(im, code, start)
       CODE:
         if (i_tags_findn(&im->tags, code, start, &entry)) {
           if (entry == 0)
-            ST(0) = sv_2mortal(newSVpv("0 but true", 0));
+            RETVAL = newSVpv("0 but true", 0);
           else
-            ST(0) = sv_2mortal(newSViv(entry));
+            RETVAL = newSViv(entry);
         }
-        else
-          ST(0) = &PL_sv_undef;
+        else {
+          RETVAL = &PL_sv_undef;
+        }
+      OUTPUT:
+        RETVAL
 
 int
 i_tags_delete(im, entry)
diff --git a/bmp.c b/bmp.c
index 35ec116a79dbfb673a816ba73a2a31ce2790332f..b78d55337bdfd9c0b76d5fd11d4a38436ebd7531 100644 (file)
--- a/bmp.c
+++ b/bmp.c
@@ -516,7 +516,7 @@ static int
 write_8bit_data(io_glue *ig, i_img *im) {
   i_palidx *line;
   int line_size = im->xsize;
-  int x, y;
+  int y;
 
   /* round up to nearest multiple of four */
   line_size = (line_size + 3) / 4 * 4;
@@ -558,7 +558,7 @@ static int
 write_24bit_data(io_glue *ig, i_img *im) {
   int *chans;
   unsigned char *samples;
-  int x, y;
+  int y;
   int line_size = 3 * im->xsize;
   
   line_size = (line_size + 3) / 4 * 4;
@@ -632,7 +632,7 @@ read_1bit_bmp(io_glue *ig, int xsize, int ysize, int clr_used,
   i_palidx *line, *p;
   unsigned char *packed;
   int line_size = (xsize + 7)/8;
-  int byte, bit;
+  int bit;
   unsigned char *in;
   long base_offset;
 
@@ -826,7 +826,6 @@ read_4bit_bmp(io_glue *ig, int xsize, int ysize, int clr_used,
   }
   else if (compression == BI_RLE4) {
     int read_size;
-    int want_high;
     int count;
 
     i_tags_add(&im->tags, "bmp_compression_name", 0, "BI_RLE4", -1, 0);
@@ -921,9 +920,8 @@ read_8bit_bmp(io_glue *ig, int xsize, int ysize, int clr_used,
               int compression, long offbits) {
   i_img *im;
   int x, y, lasty, yinc;
-  i_palidx *line, *p;
+  i_palidx *line;
   int line_size = xsize;
-  unsigned char *in;
   long base_offset;
 
   line_size = (line_size+3) / 4 * 4;
@@ -992,7 +990,6 @@ read_8bit_bmp(io_glue *ig, int xsize, int ysize, int clr_used,
   }
   else if (compression == BI_RLE8) {
     int read_size;
-    int want_high;
     int count;
     unsigned char packed[2];
 
@@ -1093,7 +1090,6 @@ read_direct_bmp(io_glue *ig, int xsize, int ysize, int bit_count,
   i_img *im;
   int x, y, lasty, yinc;
   i_color *line, *p;
-  unsigned char *in;
   int pix_size = bit_count / 8;
   int line_size = xsize * pix_size;
   struct bm_masks masks;
diff --git a/draw.c b/draw.c
index 8f1a2090a069547126b9baac676d403edabb9293..05d69c80ce51c64dab09bf58232651139d3f1a38 100644 (file)
--- a/draw.c
+++ b/draw.c
@@ -247,7 +247,6 @@ make_minmax_list(i_mmarray *dot, float x, float y, float radius) {
   polar_to_plane(x, y, angle, radius, &sx, &sy);
   
   for(angle = 0.0; angle<361; angle +=astep) {
-    float alpha;
     lx = sx; ly = sy;
     polar_to_plane(x, y, angle, radius, &cx, &cy);
     sx = cx; sy = cy;
@@ -315,7 +314,7 @@ i_circle_aa(i_img *im, float x, float y, float rad, i_color *val) {
   make_minmax_list(&dot, x, y, rad);
 
   for(ly = 0; ly<im->ysize; ly++) {
-    int ix, cy, cnt = 0, minx = INT_MAX, maxx = INT_MIN;
+    int ix, cy, minx = INT_MAX, maxx = INT_MIN;
 
     /* Find the left/rightmost set subpixels */
     for(cy = 0; cy<16; cy++) {
@@ -443,7 +442,6 @@ i_line(i_img *im, int x1, int y1, int x2, int y2, i_color *val, int endp) {
   int x, y;
   int dx, dy;
   int p;
-  unsigned char *cp;
 
   dx = x2 - x1;
   dy = y2 - y1;
@@ -632,7 +630,6 @@ i_line_aa(i_img *im, int x1, int y1, int x2, int y2, i_color *val, int endp) {
   int x, y;
   int dx, dy;
   int p;
-  unsigned char *cp;
 
   dx = x2 - x1;
   dy = y2 - y1;
diff --git a/draw.h b/draw.h
index ef0eeed4cdea5044ea9a6fe975d91ab453160c21..2fb33a9594a76a77cf3780fa01ac8cc6971e6986 100644 (file)
--- a/draw.h
+++ b/draw.h
@@ -17,7 +17,6 @@ void i_mmarray_add(i_mmarray *ar,int x,int y);
 int i_mmarray_gmin(i_mmarray *ar,int y);
 int i_mmarray_getm(i_mmarray *ar,int y);
 void i_mmarray_render(i_img *im,i_mmarray *ar,i_color *val);
-static void i_arcdraw(int x1, int y1, int x2, int y2, i_mmarray *ar);
 void i_mmarray_info(i_mmarray *ar);
 void i_arc(i_img *im,int x,int y,float rad,float d1,float d2,i_color *val);
 void i_box(i_img *im,int x0,int y0,int x1,int y1,i_color *val);
diff --git a/fills.c b/fills.c
index 9d54639bd4ee5378f0241c8703df6d38c2f6d6ad..ed2a205c36aea4eb7fdb5d28c59417335a9e1d54 100644 (file)
--- a/fills.c
+++ b/fills.c
@@ -726,7 +726,6 @@ static void fill_image(i_fill_t *fill, int x, int y, int width, int channels,
                        i_color *data) {
   struct i_fill_image_t *f = (struct i_fill_image_t *)fill;
   int i = 0;
-  i_color c;
   i_color *out = data;
   
   if (f->has_matrix) {
@@ -824,7 +823,6 @@ static void fill_imagef(i_fill_t *fill, int x, int y, int width, int channels,
                        i_fcolor *data) {
   struct i_fill_image_t *f = (struct i_fill_image_t *)fill;
   int i = 0;
-  i_fcolor c;
   
   if (f->has_matrix) {
     /* the hard way */
@@ -1050,7 +1048,6 @@ static void combine_mult(i_color *out, i_color *in, int channels, int count) {
   int ch;
 
   while (count--) {
-    i_color c = *in;
     double mult[MAXCHANNELS];
     mult[3] = in->channel[3];
     for (ch = 0; ch < (channels); ++ch) { 
@@ -1079,8 +1076,6 @@ static void combine_multf(i_fcolor *out, i_fcolor *in, int channels, int count)
 }
 
 static void combine_dissolve(i_color *out, i_color *in, int channels, int count) {
-  int ch;
-
   while (count--) {
     if (in->channel[3] > rand() * (255.0 / RAND_MAX))
       COMBINE(*out, *in, channels);
@@ -1090,8 +1085,6 @@ static void combine_dissolve(i_color *out, i_color *in, int channels, int count)
 }
 
 static void combine_dissolvef(i_fcolor *out, i_fcolor *in, int channels, int count) {
-  int ch;
-
   while (count--) {
     if (in->channel[3] > rand() * (1.0 / RAND_MAX))
       COMBINEF(*out, *in, channels);
index e7d58e3aab240eb4508ae610392e856d8ae9e19e..b02e7a322289485dbbe1871a7207a683ec22ca69 100644 (file)
--- a/filters.c
+++ b/filters.c
@@ -1216,7 +1216,6 @@ i_diff_image(i_img *im1, i_img *im2, int mindiff) {
   i_img *out;
   int outchans, diffchans;
   int xsize, ysize;
-  i_img temp;
 
   i_clear_error();
   if (im1->channels != im2->channels) {
diff --git a/font.c b/font.c
index 685991e3c7a203bec0d03ee9f314e3f8d5b3a450..7b5d0931f3a5bc9fe149fdc73b2ebc2dd9156c6b 100644 (file)
--- a/font.c
+++ b/font.c
@@ -488,7 +488,6 @@ i_t1_has_chars(int font_num, const char *text, int len, int utf8,
 
   while (len) {
     unsigned long c;
-    int index;
     if (utf8) {
       c = i_utf8_advance(&text, &len);
       if (c == ~0UL) {
@@ -1247,7 +1246,6 @@ int
 i_tt_has_chars(TT_Fonthandle *handle, char const *text, int len, int utf8,
                char *out) {
   int count = 0;
-  int inst;
   mm_log((1, "i_tt_has_chars(handle %p, text %p, len %d, utf8 %d)\n", 
           handle, text, len, utf8));
 
@@ -1381,7 +1379,6 @@ i_tt_render_all_glyphs( TT_Fonthandle *handle, int inst, TT_Raster_Map *bit,
                         TT_Raster_Map *small_bit, int cords[6], 
                         char const* txt, int len, int smooth, int utf8 ) {
   unsigned long j;
-  int i;
   TT_F26Dot6 x,y;
   
   mm_log((1,"i_tt_render_all_glyphs( handle 0x%X, inst %d, bit 0x%X, small_bit 0x%X, txt '%.*s', len %d, smooth %d, utf8 %d)\n",
index f2cb6fca586508b3de7b8b179dc6b294697858ea..bdcf63d293da342d7cbc55e127a02f7a4c24efbd 100644 (file)
@@ -126,8 +126,6 @@ i_ft2_new(char *name, int index) {
   FT_Error error;
   FT2_Fonthandle *result;
   FT_Face face;
-  double matrix[6] = { 1, 0, 0,
-                       0, 1, 0 };
   int i, j;
   FT_Encoding encoding;
   int score;
@@ -428,7 +426,6 @@ too much hard work.
 void ft2_transform_box(FT2_Fonthandle *handle, int bbox[4]) {
   double work[8];
   double *matrix = handle->matrix;
-  int i;
   
   work[0] = matrix[0] * bbox[0] + matrix[1] * bbox[1];
   work[1] = matrix[3] * bbox[0] + matrix[4] * bbox[1];
@@ -490,13 +487,11 @@ i_ft2_bbox_r(FT2_Fonthandle *handle, double cheight, double cwidth,
   int ascent = 0, descent = 0;
   int glyph_ascent, glyph_descent;
   FT_Glyph_Metrics *gm;
-  int start = 0;
   int work[4];
   int bounds[4];
   double x = 0, y = 0;
   int i;
   FT_GlyphSlot slot;
-  int advx, advy;
   int loadFlags = FT_LOAD_DEFAULT;
 
   if (vlayout)
diff --git a/gif.c b/gif.c
index db79f6bdae81fedfa3649714ecd0d1057410bcce..6d6255afed87f0db8b98cbf304e4f1d2e4b51e62 100644 (file)
--- a/gif.c
+++ b/gif.c
@@ -495,7 +495,7 @@ standard.
 
 i_img **i_readgif_multi_low(GifFileType *GifFile, int *count) {
   i_img *img;
-  int i, j, Size, Width, Height, ExtCode, Count, x;
+  int i, j, Size, Width, Height, ExtCode, Count;
   int ImageNum = 0, BackGround = 0, ColorMapSize = 0;
   ColorMapObject *ColorMap;
  
@@ -1386,9 +1386,8 @@ static int
 has_common_palette(i_img **imgs, int count, i_quantize *quant, 
                    int want_trans) {
   int size = quant->mc_count;
-  int i, j;
+  int i;
   int imgn;
-  int x, y;
   char used[256];
 
   /* we try to build a common palette here, if we can manage that, then
@@ -1498,7 +1497,6 @@ i_writegif_low(i_quantize *quant, GifFileType *gf, i_img **imgs, int count) {
   i_color *orig_colors = quant->mc_colors;
   i_color *glob_colors = NULL;
   int glob_color_count;
-  int glob_map_size;
   int glob_want_trans;
   int glob_paletted; /* the global map was made from the image palettes */
   int colors_paletted;
diff --git a/io.c b/io.c
index 9c705fae31c591fcaca6119be0373e8399d55946..5624361f163340a120e94e1d117ac98e72dc470a 100644 (file)
--- a/io.c
+++ b/io.c
@@ -115,12 +115,6 @@ mymalloc_file_line(size_t size, char* file, int line) {
   return buf;
 }
 
-
-
-
-
-
-
 void*
 myrealloc_file_line(void *ptr, size_t newsize, char* file, int line) {
   char *buf;
@@ -155,9 +149,6 @@ myrealloc_file_line(void *ptr, size_t newsize, char* file, int line) {
   return buf;
 }
 
-
-
-
 static
 void
 bndcheck(int idx) {
@@ -229,6 +220,11 @@ void*
 mymalloc(int size) {
   void *buf;
 
+  if (size < 0) {
+    fprintf(stderr, "Attempt to allocate size %d\n", size);
+    exit(3);
+  }
+
   if ( (buf = malloc(size)) == NULL ) {
     mm_log((1, "mymalloc: unable to malloc %d\n", size));
     fprintf(stderr,"Unable to malloc %d.\n", size); exit(3);
index 7b16142ba7b1191c5fe12477e47fb75005c4bdca..18f3b782e83a4906530d7f4a051775b2026eccec 100644 (file)
--- a/iolayer.c
+++ b/iolayer.c
@@ -218,7 +218,6 @@ static
 ssize_t 
 buffer_read(io_glue *ig, void *buf, size_t count) {
   io_ex_buffer *ieb = ig->exdata;
-  char        *cbuf = buf;
 
   IOL_DEB( printf("buffer_read: fd = %d, ier->cpos = %ld, buf = %p, count = %d\n", fd, (long) ier->cpos, buf, count) );
 
diff --git a/jpeg.c b/jpeg.c
index 394c6245535cdbc5be4444aede6318b6578babdd..8437575fc3e2567a8b59051a256eac42ec108319 100644 (file)
--- a/jpeg.c
+++ b/jpeg.c
@@ -399,7 +399,6 @@ i_readjpeg_wiol(io_glue *data, int length, char** iptc_itext, int *itlength) {
 
 undef_int
 i_writejpeg_wiol(i_img *im, io_glue *ig, int qfactor) {
-  struct stat stbuf;
   JSAMPLE *image_buffer;
   int quality;
 
diff --git a/map.c b/map.c
index 7acd64af6ae2c394e617fa4bbaffde1d96cb340f..0e9c47db2dfd920f39de68311dee8382d98bda39 100644 (file)
--- a/map.c
+++ b/map.c
@@ -38,7 +38,7 @@ void
 i_map(i_img *im, unsigned char (*maps)[256], unsigned int mask) {
   i_color *vals;
   int x, y;
-  int mapno, i, ch;
+  int i, ch;
   int minset = -1, maxset;
 
   mm_log((1,"i_map(im %p, maps %p, chmask %u)\n", im, maps, mask));
index bc31c8af560c7e1f433b03393e957220cf2ce224..aa8f5efbae6277ca14f557ce093ac0ec4d67313f 100644 (file)
--- a/maskimg.c
+++ b/maskimg.c
@@ -230,7 +230,6 @@ Internal function.
 */
 static int i_plin_masked(i_img *im, int l, int r, int y, i_color *vals) {
   i_img_mask_ext *ext = MASKEXT(im);
-  int result;
 
   if (y >= 0 && y < im->ysize && l < im->xsize && l >= 0) {
     if (r > im->xsize)
index 870c7a0f8f018bfbee36f7e8ce2fc28a595146a8..b655963eb161894e68e480f15777635848c603a1 100644 (file)
--- a/palimg.c
+++ b/palimg.c
@@ -170,8 +170,6 @@ The conversion cannot be done for virtual images.
 */
 int i_img_to_rgb_inplace(i_img *im) {
   i_img temp;
-  i_color *pal;
-  int palsize;
 
   if (im->virtual)
     return 0;
@@ -341,7 +339,7 @@ RGB.
 =cut
 */
 static int i_plin_p(i_img *im, int l, int r, int y, i_color *vals) {
-  int ch, count, i;
+  int count, i;
   i_palidx *data;
   i_palidx which;
   if (y >=0 && y < im->ysize && l < im->xsize && l >= 0) {
diff --git a/png.c b/png.c
index 03900270895ebe293eaf348bcaa004ff39d4efc7..728593759facd606e97c9a22113d8bf703cc4529 100644 (file)
--- a/png.c
+++ b/png.c
@@ -72,8 +72,6 @@ i_writepng_wiol(i_img *im, io_glue *ig) {
   volatile int cspace,channels;
   double xres, yres;
   int aspect_only, have_res;
-  double offx, offy;
-  char offunit[20] = "pixel";
 
   io_glue_commit_types(ig);
   mm_log((1,"i_writepng(im %p ,ig %p)\n", im, ig));
diff --git a/pnm.c b/pnm.c
index 148b887ba7df4731f8bdd543a2050fe5234ab64a..4d27604b4943e0fc5ec2bcdb804f25358dab3e6b 100644 (file)
--- a/pnm.c
+++ b/pnm.c
@@ -425,7 +425,6 @@ undef_int
 i_writeppm_wiol(i_img *im, io_glue *ig) {
   char header[255];
   int rc;
-  writep write_func;
 
   mm_log((1,"i_writeppm(im %p, ig %p)\n", im, ig));
   i_clear_error();
@@ -450,8 +449,6 @@ i_writeppm_wiol(i_img *im, io_glue *ig) {
       unsigned char *data = mymalloc(3 * im->xsize);
       if (data != NULL) {
         int y = 0;
-        int x, ch;
-        unsigned char *p;
         static int rgb_chan[3] = { 0, 1, 2 };
 
         rc = 0;
@@ -489,9 +486,7 @@ i_writeppm_wiol(i_img *im, io_glue *ig) {
       unsigned char *data = mymalloc(im->xsize);
       if (data != NULL) {
         int y = 0;
-        int x, ch;
         int chan = 0;
-        unsigned char *p;
 
         rc = 0;
         while (y < im->ysize && rc >= 0) {
index 9e53bb2e738eb085cd1638a85debd1cf28fe8ce2..5a81de51f3158b61b81edd12a7c39b6ae4f2cb0c 100644 (file)
--- a/polygon.c
+++ b/polygon.c
@@ -123,13 +123,14 @@ point_set_new(double *x, double *y, int l) {
   return pset;
 }
 
+#if 0
 static
 void
 p_line_dump(p_line *l) {
   printf("%d (%d,%d)->(%d,%d) [%d-%d,%d-%d]\n", l->n, l->x1, l->y1, l->x2, l->y2, 
         l->minx, l->maxx, l->miny, l->maxy);
 }
-
+#endif
 
 static
 void
@@ -179,6 +180,7 @@ lines_in_interval(p_line *lset, int l, p_slice *tllist, pcord minc, pcord maxc)
   return count;
 }
 
+#if 0
 static
 int
 lines_in_interval_old(p_line *lset, int l, p_slice *tllist, pcord cc) {
@@ -198,6 +200,7 @@ lines_in_interval_old(p_line *lset, int l, p_slice *tllist, pcord cc) {
   }
   return count;
 }
+#endif
 
 /* marks the up variable for all lines in a slice */
 
@@ -302,8 +305,6 @@ pixel_coverage(p_line *line, pcord minx, pcord maxx, pcord  miny, pcord maxy) {
   double lycross, rycross;
   int l, r;
 
-  double xs, ys;
-  
   if (!line->updown) {
     l = r = 0;
   } else {
@@ -364,7 +365,6 @@ render_slice_scanline(ss_scanline *ss, int y, p_line *l, p_line *r) {
   int thin;            /* boolean for thin/thick segment */
   int startpix;                /* temporary variable for "start of this interval" */
   int stoppix;         /* temporary variable for "end of this interval" */
-  int step2end;                /* temporary variable to mark where step2 ends */
 
   /* Find the y bounds of scanline_slice */
 
@@ -406,7 +406,7 @@ render_slice_scanline(ss_scanline *ss, int y, p_line *l, p_line *r) {
 }
 
 
-
+#if 0
 static
 void
 render_slice_scanline_old(ss_scanline *ss, int y, p_line *l, p_line *r) {
@@ -418,7 +418,6 @@ render_slice_scanline_old(ss_scanline *ss, int y, p_line *l, p_line *r) {
   int thin;            /* boolean for thin/thick segment */
   int startpix;                /* temporary variable for "start of this interval" */
   int stoppix;         /* temporary variable for "end of this interval" */
-  int step2end;                /* temporary variable to mark where step2 ends */
 
   /* Find the y bounds of scanline_slice */
 
@@ -497,11 +496,7 @@ render_slice_scanline_old(ss_scanline *ss, int y, p_line *l, p_line *r) {
   
   ss->line[cpix] += (16.0)*(maxy-miny) - pixel_coverage(r, cpix*16, cpix*16+16, miny, maxy);
 }
-
-
-
-
-
+#endif
 
 /* Antialiasing polygon algorithm 
    specs:
@@ -537,7 +532,6 @@ static void
 i_poly_aa_low(i_img *im, int l, double *x, double *y, void *ctx, scanline_flusher flusher) {
   int i ,k;                    /* Index variables */
   int clc;                     /* Lines inside current interval */
-  pcord miny ,maxy;            /* Min and max values of the current slice in the subcord system */
   pcord tempy;
   int cscl;                    /* Current scanline */
 
@@ -581,7 +575,6 @@ i_poly_aa_low(i_img *im, int l, double *x, double *y, void *ctx, scanline_flushe
   for(i=0; i<l-1; i++) {
     int startscan = i_max( coarse(pset[i].y), 0);
     int stopscan = i_min( coarse(pset[i+1].y+15), im->ysize);
-    pcord cc = (pset[i].y + pset[i+1].y)/2;
 
     if (pset[i].y == pset[i+1].y) {
       POLY_DEB( printf("current slice thickness = 0 => skipping\n") );
@@ -602,8 +595,6 @@ i_poly_aa_low(i_img *im, int l, double *x, double *y, void *ctx, scanline_flushe
     POLY_DEB( printf("Interval contains %d lines\n", clc) );
 
     for(k=0; k<clc; k++) {
-      int lno = tllist[k].n;
-      p_line *ln = lset+lno;
       POLY_DEB(
               printf("%d:  line #%2d: (%2d, %2d)->(%2d, %2d) (%2d/%2d, %2d/%2d) -> (%2d/%2d, %2d/%2d) alignment=%s\n",
                      k, lno, ln->x1, ln->y1, ln->x2, ln->y2, 
@@ -660,7 +651,6 @@ struct poly_cfill_state {
 static void
 scanline_flush_cfill(i_img *im, ss_scanline *ss, int y, void *ctx) {
   int x, ch, tv;
-  i_color t;
   int pos;
   int left, right;
   struct poly_cfill_state *state = (struct poly_cfill_state *)ctx;
diff --git a/quant.c b/quant.c
index 8615d05eb2ea19ff1e108522e33ef98464f0d89f..51524cd59b66113ff56662baf81b371df708a98d 100644 (file)
--- a/quant.c
+++ b/quant.c
@@ -66,9 +66,6 @@ quant_makemap(i_quantize *quant, i_img **imgs, int count) {
   }
 }
 
-#ifdef HAVE_LIBGIF
-static void translate_giflib(i_quantize *, i_img *, i_palidx *);
-#endif
 static void translate_closest(i_quantize *, i_img *, i_palidx *);
 static void translate_errdiff(i_quantize *, i_img *, i_palidx *);
 static void translate_addi(i_quantize *, i_img *, i_palidx *);
@@ -179,9 +176,11 @@ frand(void) {
   return rand()/(RAND_MAX+1.0);
 }
 
+#ifdef NOTEF
 static
 int
 eucl_d(cvec* cv,i_color *cl) { return PWR2(cv->r-cl->channel[0])+PWR2(cv->g-cl->channel[1])+PWR2(cv->b-cl->channel[2]); }
+#endif
 
 static
 int
@@ -747,7 +746,7 @@ static int distcomp(void const *a, void const *b) {
    welcome.
  */
 static void hbsetup(i_quantize *quant, hashbox *hb) {
-  long *dists, mind, maxd, cd;
+  long *dists, mind, maxd;
   int cr, cb, cg, hbnum, i;
   i_color cenc;
 #ifdef HB_SORT
@@ -1157,8 +1156,6 @@ translate_errdiff(i_quantize *quant, i_img *img, i_palidx *out) {
   int errw;
   int difftotal;
   int x, y, dx, dy;
-  int minr, maxr, ming, maxg, minb, maxb, cr, cg, cb;
-  i_color find;
   int bst_idx;
   CF_VARS;
 
diff --git a/raw.c b/raw.c
index 90eb487b77a5b6fb92c8c427fb72f758332d30e0..214bc21e4c044bc0edb9a1497f9d70cb71efbc55 100644 (file)
--- a/raw.c
+++ b/raw.c
@@ -119,8 +119,6 @@ i_writeraw_wiol(i_img* im, io_glue *ig) {
       return(0);
     }
   } else {
-    int y;
-    
     if (im->type == i_direct_type) {
       /* just save it as 8-bits, maybe support saving higher bit count
          raw images later */
diff --git a/rgb.c b/rgb.c
index ae886169b17e735cc7555142da32b510ed0fbc1f..7559a06ceea83fef81192134219d35d1255b2d84 100644 (file)
--- a/rgb.c
+++ b/rgb.c
@@ -169,18 +169,15 @@ Returns NULL on error.
 i_img *
 i_readrgb_wiol(io_glue *ig, int length) {
   i_img *img;
-  int x, y, c,i;
+  int y, c,i;
   int width, height, channels;
   unsigned long maxlen;
 
   int savemask;
   
-  char *idstring = NULL;
-
   rgb_header header;
   unsigned char headbuf[512];
   unsigned char *databuf;
-  unsigned char *reorderbuf;
   unsigned long *starttab, *lengthtab;
   i_color *linebuf = NULL;
   i_mempool mp;
index 207d2d693b04e0b90059a336a24f89da061054b3..ebdfda462d76580a2fb48ed12c39f068d27de514 100644 (file)
--- a/rotate.c
+++ b/rotate.c
@@ -185,7 +185,6 @@ i_img *i_matrix_transform_bg(i_img *src, int xsize, int ysize, double *matrix,
   int ch;
   int i, j;
   double sx, sy, sz;
-  double out[3];
 
   if (src->type == i_direct_type) {
     if (src->bits == i_8_bits) {
diff --git a/tags.c b/tags.c
index 3e5049730ce5a4a917dc613b704a96df99e2cad3..de2815aef501a32ab743b9b88f4d42d5cc0be611 100644 (file)
--- a/tags.c
+++ b/tags.c
@@ -317,29 +317,6 @@ int i_tags_get_int(i_img_tags *tags, char const *name, int code, int *value) {
 }
 
 static int parse_long(char *data, char **end, long *out) {
-#if 0
-  /* I wrote this without thinking about strtol */
-  long x = 0;
-  int neg = *data == '-';
-
-  if (neg)
-    ++data;
-  if (!isdigit(*data))
-    return 0;
-  while (isdigit(*data)) {
-    /* this check doesn't guarantee we don't overflow, but it helps */
-    if (x > LONG_MAX / 10)
-      return 0; 
-    x = x * 10 + *data - '0';
-    ++data;
-  }
-  if (neg)
-    x = -x;
-
-  *end = data;
-
-  return 1;
-#else
   long result;
   int savederr = errno;
   char *myend;
@@ -348,14 +325,15 @@ static int parse_long(char *data, char **end, long *out) {
   result = strtol(data, &myend, 10);
   if ((result == LONG_MIN || result == LONG_MAX) && errno == ERANGE
       || myend == data) {
+    errno = savederr;
     return 0;
   }
 
+  errno = savederr;
   *out = result;
   *end = myend;
 
   return 1;
-#endif
 }
 
 /* parse a comma-separated list of integers
diff --git a/tga.c b/tga.c
index edcef272fd7b085fbe030124aa257f7ab5e4e77f..36ef7dc72ad43954f0ac4da876299b3d0e22cf3c 100644 (file)
--- a/tga.c
+++ b/tga.c
@@ -464,7 +464,7 @@ destination is compressed.
 static
 int
 tga_dest_write(tga_dest *s, unsigned char *buf, size_t pixels) {
-  int cp = 0, j, k;
+  int cp = 0, j;
 
   if (!s->compressed) {
     if (s->ig->writecb(s->ig, buf, pixels*s->bytepp) != pixels*s->bytepp) return 0;
@@ -598,7 +598,7 @@ Returns NULL on error.
 i_img *
 i_readtga_wiol(io_glue *ig, int length) {
   i_img* img = NULL;
-  int x, y, i;
+  int x, y;
   int width, height, channels;
   int mapped;
   char *idstring = NULL;
@@ -607,7 +607,6 @@ i_readtga_wiol(io_glue *ig, int length) {
   tga_header header;
   unsigned char headbuf[18];
   unsigned char *databuf;
-  unsigned char *reorderbuf;
 
   i_color *linebuf = NULL;
   i_clear_error();
@@ -696,7 +695,6 @@ i_readtga_wiol(io_glue *ig, int length) {
   
   mapped = 1;
   switch (header.datatypecode) {
-    int tbpp;
   case 2:  /* Uncompressed, rgb images          */
   case 10: /* Compressed,   rgb images          */
     mapped = 0;
@@ -785,7 +783,6 @@ Writes an image in targa format.  Returns 0 on error.
 
 undef_int
 i_writetga_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idstring, size_t idlen) {
-  static int rgb_chan[] = { 2, 1, 0, 3 };
   tga_header header;
   tga_dest dest;
   unsigned char headbuf[18];
@@ -836,7 +833,6 @@ i_writetga_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idst
 
   io_glue_commit_types(ig);
   
-  header.idlength;
   header.idlength = idlen;
   header.colourmaptype   = mapped ? 1 : 0;
   header.datatypecode    = mapped ? 1 : img->channels == 1 ? 3 : 2;
@@ -875,8 +871,6 @@ i_writetga_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idst
   mm_log((1, "dest.bytepp = %d\n", dest.bytepp));
 
   if (img->type == i_palette_type) {
-    int i;
-    int bytepp = bpp_to_bytes(bitspp);
     if (!tga_palette_write(ig, img, bitspp, i_colorcount(img))) return 0;
     
     if (!img->virtual && !dest.compressed) {
diff --git a/tiff.c b/tiff.c
index 9ab8dec36a01500076a047cf1181021a7e1d753c..692b00818a504647419265df63a53f08f5ace2ea 100644 (file)
--- a/tiff.c
+++ b/tiff.c
@@ -31,7 +31,6 @@ Some of these functions are internal.
 =cut
 */
 
-
 #define byteswap_macro(x) \
      ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) |     \
       (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24))
@@ -527,7 +526,6 @@ i_writetiff_low_faxable(TIFF *tif, i_img *im, int fine) {
   uint32 y;
   int rc;
   uint32 x;
-  int luma_mask;
   uint32 rowsperstrip;
   float vres = fine ? 196 : 98;
   int luma_chan;
@@ -639,7 +637,7 @@ i_writetiff_low(TIFF *tif, i_img *im) {
   tsize_t linebytes;
   int ch, ci, rc;
   uint32 x;
-  int got_xres, got_yres, got_aspectonly, aspect_only, resunit;
+  int got_xres, got_yres, aspect_only, resunit;
   double xres, yres;
   uint16 bitspersample = 8;
   uint16 samplesperpixel;
@@ -704,7 +702,6 @@ i_writetiff_low(TIFF *tif, i_img *im) {
     i_color c;
     int count = i_colorcount(im);
     int size;
-    int bits;
     int ch, i;
     
     samplesperpixel = 1;
@@ -1005,7 +1002,6 @@ Stores an image in the iolayer object.
 undef_int
 i_writetiff_wiol(i_img *img, io_glue *ig) {
   TIFF* tif;
-  int i;
 
   io_glue_commit_types(ig);
   i_clear_error();
@@ -1060,7 +1056,6 @@ point.
 undef_int
 i_writetiff_wiol_faxable(i_img *im, io_glue *ig, int fine) {
   TIFF* tif;
-  int i;
 
   io_glue_commit_types(ig);
   i_clear_error();
diff --git a/typemap b/typemap
index abcf4de9233f0550d5bc5a7ed6709d1d021970bb..1312b02e520f39d2b649b8be204d2503bbf35abe 100644 (file)
--- a/typemap
+++ b/typemap
@@ -10,6 +10,7 @@ const char *          T_PV
 float                  T_FLOAT
 float*                 T_ARRAY
 undef_int              T_IV_U
+undef_neg_int           T_IV_NEGU
 HASH                   T_HVREF
 utf8_str               T_UTF8_STR
 #############################################################################
@@ -30,5 +31,8 @@ OUTPUT
 T_IV_U
        if ($var == 0) $arg=&PL_sv_undef;
        else sv_setiv($arg, (IV)$var);
+T_IV_NEGU
+       if ($var < 0) $arg=&PL_sv_undef;
+       else sv_setiv($arg, (IV)$var);
 T_PTR_NULL
        sv_setiv($arg, (IV)$var);