Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms.

This commit is contained in:
rsc 2006-04-01 19:24:03 +00:00
parent 226d80b821
commit cbeb0b26e4
492 changed files with 3218 additions and 3167 deletions

View file

@ -22,7 +22,7 @@ closest(int Y, int Cb, int Cr)
g = Y-c2*Cb-c3*Cr;
b = Y+c4*Cb;
//print("YCbCr: %d %d %d, RGB: %g %g %g\n", Y, Cb, Cr, r, g, b);
/*print("YCbCr: %d %d %d, RGB: %g %g %g\n", Y, Cb, Cr, r, g, b); */
min = 1000000.;
v = 1000;
@ -32,23 +32,23 @@ closest(int Y, int Cb, int Cr)
G = (rgb >> 8) & 0xFF;
B = (rgb >> 0) & 0xFF;
diff = (R-r)*(R-r) + (G-g)*(G-g) + (B-b)*(B-b);
// y1 = 0.5870*G + 0.114*B + 0.299*R;
// cb1 = (B-y1)/1.772;
// cr1 = (R-y1)/1.402;
/* y1 = 0.5870*G + 0.114*B + 0.299*R; */
/* cb1 = (B-y1)/1.772; */
/* cr1 = (R-y1)/1.402; */
if(diff < min){
// if(Y==0 && y1!=0)
// continue;
// if(Y==256-16 && y1<256-16)
// continue;
// if(Cb==0 && cb1!=0)
// continue;
// if(Cb==256-16 && cb1<256-16)
// continue;
// if(Cr==0 && cr1!=0)
// continue;
// if(Cr==256-16 && cr1<256-16)
// continue;
//print("%d %d %d\n", R, G, B);
/* if(Y==0 && y1!=0) */
/* continue; */
/* if(Y==256-16 && y1<256-16) */
/* continue; */
/* if(Cb==0 && cb1!=0) */
/* continue; */
/* if(Cb==256-16 && cb1<256-16) */
/* continue; */
/* if(Cr==0 && cr1!=0) */
/* continue; */
/* if(Cr==256-16 && cr1<256-16) */
/* continue; */
/*print("%d %d %d\n", R, G, B); */
min = diff;
v = i;
}

View file

@ -269,14 +269,14 @@ enum
Mexit,
Up= 1,
Down= 0,
Down= 0
};
char *menu3str[] = {
"write image",
"write mask",
"exit",
0,
0
};
Menu menu3 = {
@ -409,7 +409,7 @@ mousemoved(void)
enum
{
BORDER= 1,
BORDER= 1
};
void

View file

@ -39,7 +39,7 @@ enum
enum{ /* PNG flags */
II_GAMMA = 1 << 0,
II_COMMENT = 1 << 1,
II_COMMENT = 1 << 1
};
typedef struct ImageInfo {

View file

@ -113,7 +113,7 @@ char *sofName[16] = {
"c is otherwise used",
"Sequential DCT - differential arithmetic coding",
"Progressive DCT - differential arithmetic coding",
"Lossless - differential arithmetic coding",
"Lossless - differential arithmetic coding"
};
void get_sof (int kind) {
@ -272,10 +272,10 @@ main (int argc, char *argv[]) {
if (infile == NULL)
quit ("can't open %s\n", fname);
Start:
// if (get1() != 0xff || get1() != 0xd8)
// quit ("not JFIF");
// printf ("SOI\n");
// get_app (0xe0);
/* if (get1() != 0xff || get1() != 0xd8) */
/* quit ("not JFIF"); */
/* printf ("SOI\n"); */
/* get_app (0xe0); */
for (;;) {
c = get1();
if (c != 0xff)

View file

@ -1192,7 +1192,7 @@ enum {
c1 = 2871, /* 1.402 * 2048 */
c2 = 705, /* 0.34414 * 2048 */
c3 = 1463, /* 0.71414 * 2048 */
c4 = 3629, /* 1.772 * 2048 */
c4 = 3629 /* 1.772 * 2048 */
};
static

View file

@ -16,31 +16,31 @@ enum{ IDATSIZE=1000000,
FilterAvg = 3, /* new[x][y] = buf[x][y] + (new[x-1][y]+new[x][y-1])/2 */
FilterPaeth= 4, /* new[x][y] = buf[x][y] + paeth(new[x-1][y],new[x][y-1],new[x-1][y-1]) */
FilterLast = 5,
PropertyBit = 1<<5,
PropertyBit = 1<<5
};
typedef struct ZlibW{
uchar *chan[4]; // Rawimage channels
uchar *scan; // new scanline
uchar *pscan; // previous scanline
int scanl; // scan len
int scanp; // scan pos
int nchan; // number of input chans
int npix; // pixels read so far
int chanl; // number of bytes allocated to chan[x]
uchar *chan[4]; /* Rawimage channels */
uchar *scan; /* new scanline */
uchar *pscan; /* previous scanline */
int scanl; /* scan len */
int scanp; /* scan pos */
int nchan; /* number of input chans */
int npix; /* pixels read so far */
int chanl; /* number of bytes allocated to chan[x] */
int scanpix;
int bpp; // bits per sample
int bpp; /* bits per sample */
int palsize;
int row; // current scanline number
int row; /* current scanline number */
uchar palette[3*256];
} ZlibW;
typedef struct ZlibR{
Biobuf *bi;
uchar *buf;
uchar *b; // next byte to decompress
uchar *e; // past end of buf
uchar *b; /* next byte to decompress */
uchar *e; /* past end of buf */
ZlibW *w;
} ZlibR;

View file

@ -155,7 +155,7 @@ static Pix pix[] = {
{ '5', 0, Bgetc, 1, CY, 0, 0 }, /* raw portable greymap */
{ '3', 0, Bgetint, 3, CRGB, 0, 0 }, /* portable pixmap */
{ '6', 0, Bgetc, 3, CRGB, 0, 0 }, /* raw portable pixmap */
{ 0 },
{ 0 }
};
Rawimage*

View file

@ -76,19 +76,19 @@ Breadyuv(Biobuf *bp, int colourspace)
}
switch (sz) {
case 720 * PAL * 2: // 625 x 8bit
case 720 * PAL * 2: /* 625 x 8bit */
bits = 8;
lines = PAL;
break;
case 720 * NTSC * 2: // 525 x 8bit
case 720 * NTSC * 2: /* 525 x 8bit */
bits = 8;
lines = NTSC;
break;
case 720 * PAL * 2 + (720 * PAL / 2) : // 625 x 10bit
case 720 * PAL * 2 + (720 * PAL / 2) : /* 625 x 10bit */
bits = 10;
lines = PAL;
break;
case 720 * NTSC * 2 + (720 * NTSC / 2) : // 525 x 10bit
case 720 * NTSC * 2 + (720 * NTSC / 2) : /* 525 x 10bit */
bits = 10;
lines = NTSC;
break;
@ -97,8 +97,8 @@ Breadyuv(Biobuf *bp, int colourspace)
goto Error;
}
// print("bits=%d pixels=%d lines=%d\n", bits, 720, lines);
//
/* print("bits=%d pixels=%d lines=%d\n", bits, 720, lines); */
/* */
a->nchans = 3;
a->chandesc = CRGB;
a->chanlen = 720 * lines;

View file

@ -21,7 +21,7 @@ closest(int Y, int Cb, int Cr)
g = Y-c2*Cb-c3*Cr;
b = Y+c4*Cb;
//print("YCbCr: %d %d %d, RGB: %g %g %g\n", Y, Cb, Cr, r, g, b);
/*print("YCbCr: %d %d %d, RGB: %g %g %g\n", Y, Cb, Cr, r, g, b); */
min = 1000000.;
v = 1000;
@ -35,19 +35,19 @@ closest(int Y, int Cb, int Cr)
cb1 = (B-y1)/1.772;
cr1 = (R-y1)/1.402;
if(diff < min){
// if(Y==0 && y1!=0)
// continue;
/* if(Y==0 && y1!=0) */
/* continue; */
if(Y==256-16 && y1<256-16)
continue;
// if(Cb==0 && cb1!=0)
// continue;
/* if(Cb==0 && cb1!=0) */
/* continue; */
if(Cb==256-16 && cb1<256-16)
continue;
// if(Cr==0 && cr1!=0)
// continue;
/* if(Cr==0 && cr1!=0) */
/* continue; */
if(Cr==256-16 && cr1<256-16)
continue;
//print("%d %d %d\n", R, G, B);
/*print("%d %d %d\n", R, G, B); */
min = diff;
v = i;
}
@ -66,8 +66,8 @@ main(int argc, char *argv[])
int y, cb, cr;
uchar close[16*16*16];
//print("%d\n", closest(atoi(argv[1]), atoi(argv[2]), atoi(argv[3])));
//exits("X");
/*print("%d\n", closest(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]))); */
/*exits("X"); */
/* ycbcrmap */
print("uint ycbcrmap[256] = {\n");

View file

@ -7,7 +7,7 @@ enum
{
FileHdrLen= 6,
IconDescrLen= 16,
IconHdrLen= 40,
IconHdrLen= 40
};
typedef struct Icon Icon;

View file

@ -8,7 +8,7 @@ enum {
c1 = 2871, /* 1.402 * 2048 */
c2 = 705, /* 0.34414 * 2048 */
c3 = 1463, /* 0.71414 * 2048 */
c4 = 3629, /* 1.772 * 2048 */
c4 = 3629 /* 1.772 * 2048 */
};
Rawimage*

View file

@ -8,7 +8,7 @@
enum
{
Nhash = 4001,
Nbuf = 300,
Nbuf = 300
};
typedef struct Entry Entry;

View file

@ -1,7 +1,7 @@
// based on PNG 1.2 specification, July 1999 (see also rfc2083)
// Alpha is not supported yet because of lack of industry acceptance and
// because Plan9 Image uses premultiplied alpha, so png can't be lossless.
// Only 24bit color supported, because 8bit may as well use GIF.
/* based on PNG 1.2 specification, July 1999 (see also rfc2083) */
/* Alpha is not supported yet because of lack of industry acceptance and */
/* because Plan9 Image uses premultiplied alpha, so png can't be lossless. */
/* Only 24bit color supported, because 8bit may as well use GIF. */
#include <u.h>
#include <libc.h>
@ -13,22 +13,22 @@
#include "imagefile.h"
enum{ IDATSIZE = 20000,
FilterNone = 0,
FilterNone = 0
};
typedef struct ZlibR{
uchar *data;
int width;
int nrow, ncol;
int row, col; // next pixel to send
int row, col; /* next pixel to send */
int pixwid;
} ZlibR;
typedef struct ZlibW{
Biobuf *bo;
uchar *buf;
uchar *b; // next place to write
uchar *e; // past end of buf
uchar *b; /* next place to write */
uchar *e; /* past end of buf */
} ZlibW;
static ulong *crctab;
@ -68,11 +68,11 @@ zread(void *va, void *buf, int n)
int nrow = z->nrow;
int ncol = z->ncol;
uchar *b = buf, *e = b+n, *img;
int pixels; // number of pixels in row that can be sent now
int pixels; /* number of pixels in row that can be sent now */
int i, a, pixwid;
pixwid = z->pixwid;
while(b+pixwid <= e){ // loop over image rows
while(b+pixwid <= e){ /* loop over image rows */
if(z->row >= nrow)
break;
if(z->col==0)
@ -129,7 +129,7 @@ zwrite(void *va, void *buf, int n)
uchar *b = buf, *e = b+n;
int m;
while(b < e){ // loop over IDAT chunks
while(b < e){ /* loop over IDAT chunks */
m = z->e - z->b;
if(m > e - b)
m = e - b;
@ -190,15 +190,15 @@ memwritepng(Biobuf *bo, Memimage *r, ImageInfo *II)
deflateinit();
Bwrite(bo, PNGmagic, sizeof PNGmagic);
// IHDR chunk
/* IHDR chunk */
h = buf;
put4(h, ncol); h += 4;
put4(h, nrow); h += 4;
*h++ = 8; // bit depth = 24 bit per pixel
*h++ = rgb->chan==BGR24 ? 2 : 6; // color type = rgb
*h++ = 0; // compression method = deflate
*h++ = 0; // filter method
*h++ = 0; // interlace method = no interlace
*h++ = 8; /* bit depth = 24 bit per pixel */
*h++ = rgb->chan==BGR24 ? 2 : 6; /* color type = rgb */
*h++ = 0; /* compression method = deflate */
*h++ = 0; /* filter method */
*h++ = 0; /* interlace method = no interlace */
chunk(bo, "IHDR", buf, h-buf);
tm = gmtime(time(0));
@ -220,12 +220,12 @@ memwritepng(Biobuf *bo, Memimage *r, ImageInfo *II)
if(II->fields_set & II_COMMENT){
strncpy((char*)buf, "Comment", sizeof buf);
n = strlen((char*)buf)+1; // leave null between Comment and text
n = strlen((char*)buf)+1; /* leave null between Comment and text */
strncpy((char*)(buf+n), II->comment, sizeof buf - n);
chunk(bo, "tEXt", buf, n+strlen((char*)buf+n));
}
// image chunks
/* image chunks */
zr.nrow = nrow;
zr.ncol = ncol;
zr.width = rgb->width * sizeof(ulong);