File gocr-0.41-pgm.patch of Package gocr

--- src/pnm.c	2006-08-23 00:33:58.000000000 +0200
+++ src/pnm.c.new	2006-09-01 01:15:48.000000000 +0200
@@ -280,7 +280,7 @@
   pic=(unsigned char *)malloc( nx*ny );
   if(pic==NULL)F0("memory failed");			// no memory
   /* this is a slow but short routine for P1 to P6 formats */
-  if( c2=='5' && c2=='2' ) /* slow PGM-RAW/ASC read pixelwise */
+  if( c2=='5' || c2=='2' ) /* slow PGM-RAW/ASC read pixelwise */
     for (i=0;i<nx*ny;i++) {
      if (c2=='5') { if(bps!=(int)fread(buf,1,bps,f1))F0("read"); }
      else for (j=0;j<3;j++) fread_num(buf+j*bps, bps, f1);
@@ -292,9 +292,9 @@
       if (c2=='6') { if (3*bps!=(int)fread(buf,1,3*bps,f1)) F0("read"); }
       else for (j=0;j<3;j++) fread_num(buf+j*bps, bps, f1);
       pic[i]
-          = ((PPM_RED_WEIGHT   * buf[  bps-1] + 511)>>10)
-          + ((PPM_GREEN_WEIGHT * buf[2*bps-1] + 511)>>10)
-          + ((PPM_BLUE_WEIGHT  * buf[3*bps-1] + 511)>>10);
+          = ((PPM_RED_WEIGHT   * (unsigned char)buf[  bps-1] + 511)>>10)
+          + ((PPM_GREEN_WEIGHT * (unsigned char)buf[2*bps-1] + 511)>>10)
+          + ((PPM_BLUE_WEIGHT  * (unsigned char)buf[3*bps-1] + 511)>>10);
       /* normalized to 0..255 */
     }
   }
openSUSE Build Service is sponsored by