remote TABs in doc/ and test/
This commit is contained in:
@@ -12,38 +12,38 @@ void print(void);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 15; i++)
|
||||
up[i] = down[i] = 1;
|
||||
for (i = 0; i < 8; i++)
|
||||
rows[i] = 1;
|
||||
queens(0);
|
||||
return 0;
|
||||
int i;
|
||||
for (i = 0; i < 15; i++)
|
||||
up[i] = down[i] = 1;
|
||||
for (i = 0; i < 8; i++)
|
||||
rows[i] = 1;
|
||||
queens(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void queens(int c)
|
||||
{
|
||||
int r;
|
||||
int r;
|
||||
|
||||
for (r = 0; r < 8; r++)
|
||||
if (rows[r] && up[r-c+7] && down[r+c]) {
|
||||
rows[r] = up[r-c+7] = down[r+c] = 0;
|
||||
x[c] = r;
|
||||
if (c == 7)
|
||||
print();
|
||||
else
|
||||
queens(c + 1);
|
||||
rows[r] = up[r-c+7] = down[r+c] = 1;
|
||||
}
|
||||
for (r = 0; r < 8; r++)
|
||||
if (rows[r] && up[r-c+7] && down[r+c]) {
|
||||
rows[r] = up[r-c+7] = down[r+c] = 0;
|
||||
x[c] = r;
|
||||
if (c == 7)
|
||||
print();
|
||||
else
|
||||
queens(c + 1);
|
||||
rows[r] = up[r-c+7] = down[r+c] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void print(void)
|
||||
{
|
||||
int k;
|
||||
int k;
|
||||
|
||||
for (k = 0; k < 8; k++) {
|
||||
printf("%c", x[k]+'1');
|
||||
if(k<7) printf(" ");
|
||||
}
|
||||
printf("\n");
|
||||
for (k = 0; k < 8; k++) {
|
||||
printf("%c", x[k]+'1');
|
||||
if(k<7) printf(" ");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
@@ -14,49 +14,49 @@ int g(int x[][4],int *y[]);
|
||||
int x[3][4], *y[3];
|
||||
|
||||
main() {
|
||||
int z[3][4];
|
||||
int i, j, *p;
|
||||
int z[3][4];
|
||||
int i, j, *p;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (j = 0; j < 4; j++)
|
||||
x[i][j] = 1000*i + j;
|
||||
y[i] = x[i];
|
||||
}
|
||||
f();
|
||||
for (i = 0; i < 3; i++) {
|
||||
y[i] = p = &z[i][0];
|
||||
for (j = 0; j < 4; j++)
|
||||
p[j] = x[i][j];
|
||||
}
|
||||
g(z, y);
|
||||
|
||||
return 0;
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (j = 0; j < 4; j++)
|
||||
x[i][j] = 1000*i + j;
|
||||
y[i] = x[i];
|
||||
}
|
||||
f();
|
||||
for (i = 0; i < 3; i++) {
|
||||
y[i] = p = &z[i][0];
|
||||
for (j = 0; j < 4; j++)
|
||||
p[j] = x[i][j];
|
||||
}
|
||||
g(z, y);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
f() {
|
||||
int i, j;
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
for (j = 0; j < 4; j++)
|
||||
printf(" %d", x[i][j]);
|
||||
printf("\n");
|
||||
for (i = 0; i < 3; i++)
|
||||
for (j = 0; j < 4; j++)
|
||||
printf(" %d", y[i][j]);
|
||||
printf("\n");
|
||||
for (i = 0; i < 3; i++)
|
||||
for (j = 0; j < 4; j++)
|
||||
printf(" %d", x[i][j]);
|
||||
printf("\n");
|
||||
for (i = 0; i < 3; i++)
|
||||
for (j = 0; j < 4; j++)
|
||||
printf(" %d", y[i][j]);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
g(x, y)
|
||||
int x[][4], *y[];
|
||||
{
|
||||
int i, j;
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
for (j = 0; j < 4; j++)
|
||||
printf(" %d", x[i][j]);
|
||||
printf("\n");
|
||||
for (i = 0; i < 3; i++)
|
||||
for (j = 0; j < 4; j++)
|
||||
printf(" %d", y[i][j]);
|
||||
printf("\n");
|
||||
for (i = 0; i < 3; i++)
|
||||
for (j = 0; j < 4; j++)
|
||||
printf(" %d", x[i][j]);
|
||||
printf("\n");
|
||||
for (i = 0; i < 3; i++)
|
||||
for (j = 0; j < 4; j++)
|
||||
printf(" %d", y[i][j]);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
@@ -9,17 +9,17 @@
|
||||
|
||||
typedef signed int TypA[3];
|
||||
typedef struct TypB {
|
||||
TypA Data[2];
|
||||
TypA Data[2];
|
||||
} sTypB;
|
||||
sTypB Bs[10];
|
||||
TypA * APtr;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
Bs[7].Data[1][2]=11;
|
||||
APtr=&(Bs[7].Data[1]);
|
||||
printf("Hallo Welt! %i = %i \n",Bs[7].Data[1][2], (*APtr)[2] );
|
||||
return 0;
|
||||
Bs[7].Data[1][2]=11;
|
||||
APtr=&(Bs[7].Data[1]);
|
||||
printf("Hallo Welt! %i = %i \n",Bs[7].Data[1][2], (*APtr)[2] );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -17,26 +17,26 @@ typedef RecordType *RecordPtr;
|
||||
|
||||
void Proc3(RecordPtr *PtrParOut)
|
||||
{
|
||||
/* whatever */
|
||||
/* whatever */
|
||||
}
|
||||
|
||||
void Proc1(RecordPtr PtrParIn)
|
||||
{
|
||||
#define NextRecord (*(PtrParIn->PtrComp))
|
||||
Proc3((RecordPtr *)NextRecord.PtrComp);
|
||||
Proc3(&NextRecord.PtrComp);
|
||||
Proc3(&PtrParIn->PtrComp->PtrComp);
|
||||
Proc3((RecordPtr *)NextRecord.PtrComp);
|
||||
Proc3(&NextRecord.PtrComp);
|
||||
Proc3(&PtrParIn->PtrComp->PtrComp);
|
||||
|
||||
#ifdef CAST_STRUCT_PTR
|
||||
Proc3((RecordPtr *) PtrParIn->PtrComp->PtrComp);
|
||||
Proc3((RecordPtr *) (*(PtrParIn->PtrComp)).PtrComp);
|
||||
Proc3((RecordPtr *) NextRecord.PtrComp);
|
||||
Proc3((RecordPtr *) PtrParIn->PtrComp->PtrComp);
|
||||
Proc3((RecordPtr *) (*(PtrParIn->PtrComp)).PtrComp);
|
||||
Proc3((RecordPtr *) NextRecord.PtrComp);
|
||||
#else
|
||||
Proc3(PtrParIn->PtrComp->PtrComp);
|
||||
Proc3((*(PtrParIn->PtrComp)).PtrComp);
|
||||
Proc3(NextRecord.PtrComp);
|
||||
Proc3(PtrParIn->PtrComp->PtrComp);
|
||||
Proc3((*(PtrParIn->PtrComp)).PtrComp);
|
||||
Proc3(NextRecord.PtrComp);
|
||||
#endif
|
||||
|
||||
|
||||
#undef NextRecord
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ with compiler option -O but does _not_ show up with -Oi.
|
||||
|
||||
unsigned htons(unsigned val)
|
||||
{
|
||||
return (((unsigned) (val)) << 8) | (((unsigned) (val)) >> 8);
|
||||
return (((unsigned) (val)) << 8) | (((unsigned) (val)) >> 8);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
||||
@@ -25,7 +25,7 @@ int foo=0,bar=2;
|
||||
int main(void)
|
||||
{
|
||||
while(foo<bar)
|
||||
label: ++foo;
|
||||
label: ++foo;
|
||||
|
||||
printf("foo: %d bar: %d\n",foo,bar);
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@ int argc;
|
||||
char *argv[];
|
||||
#endif
|
||||
{
|
||||
int i, c, nc;
|
||||
int i, c, nc;
|
||||
#ifndef NO_FLOATS
|
||||
float cutoff, atof();
|
||||
float cutoff, atof();
|
||||
#else
|
||||
signed cutoff;
|
||||
#endif
|
||||
@@ -45,22 +45,22 @@ char *argv[];
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (argc <= 1)
|
||||
if (argc <= 1)
|
||||
#ifndef NO_FLOATS
|
||||
cutoff = 0.0;
|
||||
cutoff = 0.0;
|
||||
#else
|
||||
cutoff = 0;
|
||||
#endif
|
||||
else
|
||||
else
|
||||
#ifndef NO_FLOATS
|
||||
cutoff = atof(argv[1])/100;
|
||||
cutoff = atof(argv[1])/100;
|
||||
#else
|
||||
cutoff = atoi(argv[1])/100;
|
||||
#endif
|
||||
for (i = 0; i < 0x100; )
|
||||
for (i = 0; i < 0x100; )
|
||||
{
|
||||
#ifndef NO_FLOATS
|
||||
f[i++] = 0.0;
|
||||
f[i++] = 0.0;
|
||||
#else
|
||||
f[i++] = 0;
|
||||
#endif
|
||||
@@ -87,13 +87,13 @@ char *argv[];
|
||||
printf("a-z char:freq\n\n");
|
||||
|
||||
/* first round ... lowercase characters */
|
||||
for (i = 0; i < 0x100; ++i)
|
||||
for (i = 0; i < 0x100; ++i)
|
||||
{
|
||||
if ((f[i]) && ((f[i]/nc) >= cutoff))
|
||||
if ((f[i]) && ((f[i]/nc) >= cutoff))
|
||||
{
|
||||
if ((i >= 'a') && (i <= 'z'))
|
||||
if ((i >= 'a') && (i <= 'z'))
|
||||
{
|
||||
printf("%c", i);
|
||||
printf("%c", i);
|
||||
#ifndef NO_FLOATS
|
||||
printf(":%.1f\n", 100*f[i]/nc);
|
||||
#else
|
||||
@@ -101,19 +101,19 @@ char *argv[];
|
||||
#endif
|
||||
f[i]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("A-Z char:freq\n\n");
|
||||
|
||||
/* second round ... uppercase characters */
|
||||
for (i = 0; i < 0x100; ++i)
|
||||
for (i = 0; i < 0x100; ++i)
|
||||
{
|
||||
if ((f[i]) && ((f[i]/nc) >= cutoff))
|
||||
if ((f[i]) && ((f[i]/nc) >= cutoff))
|
||||
{
|
||||
if ((i >= 'A') && (i <= 'Z'))
|
||||
if ((i >= 'A') && (i <= 'Z'))
|
||||
{
|
||||
printf("%c", i);
|
||||
printf("%c", i);
|
||||
#ifndef NO_FLOATS
|
||||
printf(":%.1f\n", 100*f[i]/nc);
|
||||
#else
|
||||
@@ -121,19 +121,19 @@ char *argv[];
|
||||
#endif
|
||||
f[i]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("0-9 char:freq\n\n");
|
||||
|
||||
/* third round ... numbers */
|
||||
for (i = 0; i < 0x100; ++i)
|
||||
for (i = 0; i < 0x100; ++i)
|
||||
{
|
||||
if ((f[i]) && ((f[i]/nc) >= cutoff))
|
||||
if ((f[i]) && ((f[i]/nc) >= cutoff))
|
||||
{
|
||||
if ((i >= '0') && (i <= '9'))
|
||||
if ((i >= '0') && (i <= '9'))
|
||||
{
|
||||
printf("%c", i);
|
||||
printf("%c", i);
|
||||
#ifndef NO_FLOATS
|
||||
printf(":%.1f\n", 100*f[i]/nc);
|
||||
#else
|
||||
@@ -141,19 +141,19 @@ char *argv[];
|
||||
#endif
|
||||
f[i]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("isprint char:freq\n\n");
|
||||
|
||||
/* second last round ... remaining printable characters */
|
||||
for (i = 0; i < 0x100; ++i)
|
||||
for (i = 0; i < 0x100; ++i)
|
||||
{
|
||||
if ((f[i]) && ((f[i]/nc) >= cutoff))
|
||||
if ((f[i]) && ((f[i]/nc) >= cutoff))
|
||||
{
|
||||
if(isprint(i))
|
||||
if(isprint(i))
|
||||
{
|
||||
printf("%c", i);
|
||||
printf("%c", i);
|
||||
#ifndef NO_FLOATS
|
||||
printf(":%.1f\n", 100*f[i]/nc);
|
||||
#else
|
||||
@@ -161,30 +161,30 @@ char *argv[];
|
||||
#endif
|
||||
f[i]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("rest char:freq\n\n");
|
||||
|
||||
/* last round ... remaining non printable characters */
|
||||
for (i = 0; i < 0x100; ++i)
|
||||
for (i = 0; i < 0x100; ++i)
|
||||
{
|
||||
if ((f[i]) && ((f[i]/nc) >= cutoff))
|
||||
if ((f[i]) && ((f[i]/nc) >= cutoff))
|
||||
{
|
||||
if(i=='\n')
|
||||
{
|
||||
printf("newline");
|
||||
printf("newline");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%03o", i);
|
||||
printf("%03o", i);
|
||||
}
|
||||
#ifndef NO_FLOATS
|
||||
printf(":%.1f\n", 100*f[i]/nc);
|
||||
#else
|
||||
printf(":%d\n", 100*f[i]/nc);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(in);
|
||||
return 0;
|
||||
|
||||
@@ -14,23 +14,23 @@ void backslash(unsigned char c)
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 'b':
|
||||
c = '\b';
|
||||
case 'f':
|
||||
c = '\f';
|
||||
case 'n':
|
||||
c = '\n';
|
||||
case 'r':
|
||||
c = '\r';
|
||||
case 't':
|
||||
c = '\t';
|
||||
case 'v':
|
||||
case 'b':
|
||||
c = '\b';
|
||||
case 'f':
|
||||
c = '\f';
|
||||
case 'n':
|
||||
c = '\n';
|
||||
case 'r':
|
||||
c = '\r';
|
||||
case 't':
|
||||
c = '\t';
|
||||
case 'v':
|
||||
#ifndef NO_BACKSLASH_V
|
||||
c = '\v';
|
||||
#else
|
||||
c = 0x0b;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if(!isprint(c))
|
||||
{
|
||||
@@ -54,7 +54,7 @@ void testbackslash(void)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
testbackslash();
|
||||
testbackslash();
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -12,82 +12,82 @@
|
||||
/* this kind of line-continuation for strings doesnt work properly for cc65 */
|
||||
|
||||
const unsigned char characters[]={
|
||||
/*0123456789abcdef0123456789abcdef*/
|
||||
/* iso646-us control-characters */
|
||||
" " /* 00-1f */
|
||||
/* iso646-us printable characters */
|
||||
" !\"#$%&'()*+,-./" /* 20-2f !"#$%&'()*+,-./ */
|
||||
"0123456789" /* 30-39 0123456789 */
|
||||
":;<=>?@" /* 3a-40 :;<=>?@ */
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" /* 41-5a A-Z */
|
||||
"[\\]^_`" /* 5b-60 [\]^_` */
|
||||
"abcdefghijklmnopqrstuvwxyz" /* 61-7a a-z */
|
||||
"{|}~ " /* 7b-7f {|}~ */
|
||||
/* iso8859-15 extended characters */
|
||||
/*0123456789abcdef0123456789abcdef*/
|
||||
/* iso646-us control-characters */
|
||||
" " /* 00-1f */
|
||||
/* iso646-us printable characters */
|
||||
" !\"#$%&'()*+,-./" /* 20-2f !"#$%&'()*+,-./ */
|
||||
"0123456789" /* 30-39 0123456789 */
|
||||
":;<=>?@" /* 3a-40 :;<=>?@ */
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" /* 41-5a A-Z */
|
||||
"[\\]^_`" /* 5b-60 [\]^_` */
|
||||
"abcdefghijklmnopqrstuvwxyz" /* 61-7a a-z */
|
||||
"{|}~ " /* 7b-7f {|}~ */
|
||||
/* iso8859-15 extended characters */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
const unsigned char characters[]={
|
||||
/*0123456789abcdef0123456789abcdef*/
|
||||
/* iso646-us control-characters */
|
||||
/* 00-1f */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
/* iso646-us printable characters */
|
||||
/* 20-2f !"#$%&'()*+,-./ */
|
||||
' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/',
|
||||
/* 30-39 0123456789 */
|
||||
'0','1','2','3','4','5','6','7','8','9',
|
||||
/* 3a-40 :;<=>?@ */
|
||||
':',';','<','=','>','?','@',
|
||||
/* 41-5a A-Z */
|
||||
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
|
||||
/* 5b-60 [\]^_` */
|
||||
'[','\\',']','^','_','`',
|
||||
/* 61-7a a-z */
|
||||
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
|
||||
/* 7b-7f {|}~ */
|
||||
'{','|','}','~',' '
|
||||
/* iso8859-15 extended characters */
|
||||
/*0123456789abcdef0123456789abcdef*/
|
||||
/* iso646-us control-characters */
|
||||
/* 00-1f */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
/* iso646-us printable characters */
|
||||
/* 20-2f !"#$%&'()*+,-./ */
|
||||
' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/',
|
||||
/* 30-39 0123456789 */
|
||||
'0','1','2','3','4','5','6','7','8','9',
|
||||
/* 3a-40 :;<=>?@ */
|
||||
':',';','<','=','>','?','@',
|
||||
/* 41-5a A-Z */
|
||||
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
|
||||
/* 5b-60 [\]^_` */
|
||||
'[','\\',']','^','_','`',
|
||||
/* 61-7a a-z */
|
||||
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
|
||||
/* 7b-7f {|}~ */
|
||||
'{','|','}','~',' '
|
||||
/* iso8859-15 extended characters */
|
||||
};
|
||||
|
||||
void printchars(unsigned char a,unsigned char b){
|
||||
for(b++;a!=b;a++)
|
||||
for(b++;a!=b;a++)
|
||||
/* printf("%02x ",a); */
|
||||
/* printf("%02x ",characters[a]); */
|
||||
printf("%c",characters[a]);
|
||||
printf("\n");
|
||||
printf("%c",characters[a]);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
printf("characters:\n\n");
|
||||
printchars(0x61,0x7a);
|
||||
printchars(0x41,0x5a);
|
||||
printf("numbers:\n\n");
|
||||
printchars(0x30,0x39);
|
||||
printf("other:\n\n");
|
||||
printchars(0x20,0x2f);
|
||||
/*printchars(0x3a,0x40);*/
|
||||
printchars(0x3a,0x3f);
|
||||
/*printchars(0x5b,0x60);*/
|
||||
/*printchars(0x7b,0x7f);*/
|
||||
printf("\n\n");
|
||||
printf("slash: '%c'\n",'/');
|
||||
printf("backslash: '%c'\n",'\\');
|
||||
printf("curly braces open: '%c'\n",'{');
|
||||
printf("curly braces close: '%c'\n",'}');
|
||||
printf("square braces open: '%c'\n",'[');
|
||||
printf("square braces close: '%c'\n",']');
|
||||
printf("underscore: '%c'\n",'_');
|
||||
printf("tilde: '%c'\n",'~');
|
||||
printf("pipe: '%c'\n",'|');
|
||||
printf("apostroph: '%c'\n",'\'');
|
||||
printf("single quote '%c'\n",'`');
|
||||
printf("xor '%c'\n",'^');
|
||||
printf("at '%c'\n",'@');
|
||||
printf("characters:\n\n");
|
||||
printchars(0x61,0x7a);
|
||||
printchars(0x41,0x5a);
|
||||
printf("numbers:\n\n");
|
||||
printchars(0x30,0x39);
|
||||
printf("other:\n\n");
|
||||
printchars(0x20,0x2f);
|
||||
/*printchars(0x3a,0x40);*/
|
||||
printchars(0x3a,0x3f);
|
||||
/*printchars(0x5b,0x60);*/
|
||||
/*printchars(0x7b,0x7f);*/
|
||||
printf("\n\n");
|
||||
printf("slash: '%c'\n",'/');
|
||||
printf("backslash: '%c'\n",'\\');
|
||||
printf("curly braces open: '%c'\n",'{');
|
||||
printf("curly braces close: '%c'\n",'}');
|
||||
printf("square braces open: '%c'\n",'[');
|
||||
printf("square braces close: '%c'\n",']');
|
||||
printf("underscore: '%c'\n",'_');
|
||||
printf("tilde: '%c'\n",'~');
|
||||
printf("pipe: '%c'\n",'|');
|
||||
printf("apostroph: '%c'\n",'\'');
|
||||
printf("single quote '%c'\n",'`');
|
||||
printf("xor '%c'\n",'^');
|
||||
printf("at '%c'\n",'@');
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,31 +8,31 @@
|
||||
|
||||
void printc(signed char a,signed char b){
|
||||
signed char x=a/b,y=a%b,z=a*b;
|
||||
printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z);
|
||||
printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z);
|
||||
}
|
||||
void prints(short a,short b){
|
||||
short x=a/b,y=a%b,z=a*b;
|
||||
printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z);
|
||||
printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z);
|
||||
}
|
||||
void printl(long a,long b){
|
||||
long x=a/b,y=a%b,z=a*b;
|
||||
printf("%3ld,%3ld is %3ld,%3ld,%3ld\n",a,b,x,y,z);
|
||||
printf("%3ld,%3ld is %3ld,%3ld,%3ld\n",a,b,x,y,z);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
printl( 3,-2);
|
||||
printl(-3,-2);
|
||||
printl(-3, 2);
|
||||
printl( 3, 2);
|
||||
printf("-\n");
|
||||
prints( 3,-2);
|
||||
prints(-3,-2);
|
||||
prints(-3, 2);
|
||||
prints( 3, 2);
|
||||
printf("-\n");
|
||||
printc( 3,-2);
|
||||
printc(-3,-2);
|
||||
printc(-3, 2);
|
||||
printc( 3, 2);
|
||||
return 0;
|
||||
printl( 3,-2);
|
||||
printl(-3,-2);
|
||||
printl(-3, 2);
|
||||
printl( 3, 2);
|
||||
printf("-\n");
|
||||
prints( 3,-2);
|
||||
prints(-3,-2);
|
||||
prints(-3, 2);
|
||||
prints( 3, 2);
|
||||
printf("-\n");
|
||||
printc( 3,-2);
|
||||
printc(-3,-2);
|
||||
printc(-3, 2);
|
||||
printc( 3, 2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
*******************************************************************************
|
||||
* Bug reports, patches, comments, suggestions should be sent to:
|
||||
*
|
||||
* Ben Smith, Rick Grehan or Tom Yager
|
||||
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
|
||||
* Ben Smith, Rick Grehan or Tom Yager
|
||||
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
|
||||
*
|
||||
*******************************************************************************
|
||||
* Modification Log:
|
||||
@@ -38,53 +38,53 @@ void mov(unsigned char n,unsigned char f,unsigned char t)
|
||||
{
|
||||
char o;
|
||||
|
||||
if(n == 1)
|
||||
{
|
||||
num[f]--;
|
||||
num[t]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
o = (6-(f+t));
|
||||
mov(n-1,f,o);
|
||||
mov(1,f,t);
|
||||
mov(n-1,o,t);
|
||||
}
|
||||
if(n == 1)
|
||||
{
|
||||
num[f]--;
|
||||
num[t]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
o = (6-(f+t));
|
||||
mov(n-1,f,o);
|
||||
mov(1,f,t);
|
||||
mov(n-1,o,t);
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("%2d: %2d %2d %2d %2d\n",
|
||||
(int)iter,(int)num[0],(int)num[1],(int)num[2],(int)num[3]);
|
||||
#endif
|
||||
#ifdef VERBOSE
|
||||
printf("%2d: %2d %2d %2d %2d\n",
|
||||
(int)iter,(int)num[0],(int)num[1],(int)num[2],(int)num[3]);
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc,char **argv)
|
||||
{
|
||||
#ifdef USECMDLINE
|
||||
if (argc < 2) {
|
||||
printf("Usage: %s [duration] [disks]\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(argc > 1) duration = atoi(argv[1]);
|
||||
if(argc > 2) disk = atoi(argv[2]);
|
||||
}
|
||||
#endif
|
||||
#ifdef USECMDLINE
|
||||
if (argc < 2) {
|
||||
printf("Usage: %s [duration] [disks]\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(argc > 1) duration = atoi(argv[1]);
|
||||
if(argc > 2) disk = atoi(argv[2]);
|
||||
}
|
||||
#endif
|
||||
|
||||
printf("towers of hanoi\ndisks: %d\n\n",disk);
|
||||
printf("towers of hanoi\ndisks: %d\n\n",disk);
|
||||
|
||||
num[1] = disk;
|
||||
num[1] = disk;
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("%2d: %2d %2d %2d %2d\n",
|
||||
(int)iter,(int)num[0],(int)num[1],(int)num[2],(int)num[3]);
|
||||
#endif
|
||||
#ifdef VERBOSE
|
||||
printf("%2d: %2d %2d %2d %2d\n",
|
||||
(int)iter,(int)num[0],(int)num[1],(int)num[2],(int)num[3]);
|
||||
#endif
|
||||
|
||||
while(num[3]<disk)
|
||||
{
|
||||
mov(disk,1,3);
|
||||
++iter;
|
||||
}
|
||||
while(num[3]<disk)
|
||||
{
|
||||
mov(disk,1,3);
|
||||
++iter;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -13,39 +13,39 @@ int main(void)
|
||||
}
|
||||
|
||||
memchar() {
|
||||
char x, *p;
|
||||
char x, *p;
|
||||
|
||||
&x, &p;
|
||||
x = *p++;
|
||||
x = *++p;
|
||||
x = *p--;
|
||||
x = *--p;
|
||||
&x, &p;
|
||||
x = *p++;
|
||||
x = *++p;
|
||||
x = *p--;
|
||||
x = *--p;
|
||||
}
|
||||
|
||||
memint() {
|
||||
int x, *p;
|
||||
int x, *p;
|
||||
|
||||
&x, &p;
|
||||
x = *p++;
|
||||
x = *++p;
|
||||
x = *p--;
|
||||
x = *--p;
|
||||
&x, &p;
|
||||
x = *p++;
|
||||
x = *++p;
|
||||
x = *p--;
|
||||
x = *--p;
|
||||
}
|
||||
|
||||
regchar() {
|
||||
register char x, *p;
|
||||
register char x, *p;
|
||||
|
||||
x = *p++;
|
||||
x = *++p;
|
||||
x = *p--;
|
||||
x = *--p;
|
||||
x = *p++;
|
||||
x = *++p;
|
||||
x = *p--;
|
||||
x = *--p;
|
||||
}
|
||||
|
||||
regint() {
|
||||
register int x, *p;
|
||||
register int x, *p;
|
||||
|
||||
x = *p++;
|
||||
x = *++p;
|
||||
x = *p--;
|
||||
x = *--p;
|
||||
x = *p++;
|
||||
x = *++p;
|
||||
x = *p--;
|
||||
x = *--p;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ h();
|
||||
/*
|
||||
Word words[] = {
|
||||
1, 2, 3,"if",
|
||||
{ { 4, 5 }, { 'f', 'o', 'r' } },
|
||||
{ { 4, 5 }, { 'f', 'o', 'r' } },
|
||||
6, 7, 8, {"else"},
|
||||
{ { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', },
|
||||
{ 0 },
|
||||
@@ -35,7 +35,7 @@ Word words[] = {
|
||||
|
||||
Word words[] = {
|
||||
{{1, 2, 3},"if"},
|
||||
{ { 4, 5 }, { 'f', 'o', 'r' } },
|
||||
{ { 4, 5 }, { 'f', 'o', 'r' } },
|
||||
{{6, 7, 8}, "else"},
|
||||
{ { 9, 10, 11}, {'w', 'h', 'i', 'l', 'e', }},
|
||||
{{ 0 }},
|
||||
@@ -47,24 +47,24 @@ int *y[] = { x[0], x[1], x[2], 0 };
|
||||
|
||||
main()
|
||||
{
|
||||
int i, j;
|
||||
int i, j;
|
||||
|
||||
for (i = 0; y[i]; i++) {
|
||||
for (j = 0; y[i][j]; j++)
|
||||
printf(" %d", y[i][j]);
|
||||
printf("\n");
|
||||
}
|
||||
f();
|
||||
g(wordlist);
|
||||
return 0;
|
||||
for (i = 0; y[i]; i++) {
|
||||
for (j = 0; y[i][j]; j++)
|
||||
printf(" %d", y[i][j]);
|
||||
printf("\n");
|
||||
}
|
||||
f();
|
||||
g(wordlist);
|
||||
return 0;
|
||||
}
|
||||
|
||||
f() {
|
||||
static char *keywords[] = {"if", "for", "else", "while", 0, };
|
||||
char **p;
|
||||
static char *keywords[] = {"if", "for", "else", "while", 0, };
|
||||
char **p;
|
||||
|
||||
for (p = keywords; *p; p++)
|
||||
printf("%s\n", *p);
|
||||
for (p = keywords; *p; p++)
|
||||
printf("%s\n", *p);
|
||||
}
|
||||
|
||||
#ifdef NO_OLD_FUNC_DECL
|
||||
@@ -74,22 +74,22 @@ g(p)
|
||||
Word *p;
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for ( ; p->codes[0]; p++) {
|
||||
for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++)
|
||||
printf("%d ", p->codes[i]);
|
||||
printf("%s\n", p->name);
|
||||
}
|
||||
h();
|
||||
for ( ; p->codes[0]; p++) {
|
||||
for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++)
|
||||
printf("%d ", p->codes[i]);
|
||||
printf("%s\n", p->name);
|
||||
}
|
||||
h();
|
||||
}
|
||||
|
||||
h()
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(words)/sizeof(Word); i++)
|
||||
printf("%d %d %d %s\n", words[i].codes[0],
|
||||
words[i].codes[1], words[i].codes[2],
|
||||
&words[i].name[0]);
|
||||
for (i = 0; i < sizeof(words)/sizeof(Word); i++)
|
||||
printf("%d %d %d %s\n", words[i].codes[0],
|
||||
words[i].codes[1], words[i].codes[2],
|
||||
&words[i].name[0]);
|
||||
}
|
||||
|
||||
@@ -14,17 +14,17 @@ unsigned long a=3;
|
||||
|
||||
unsigned long _func(unsigned long x,unsigned long y)
|
||||
{
|
||||
printf("x:%ld y:%ld\n",x,y);
|
||||
return 0;
|
||||
printf("x:%ld y:%ld\n",x,y);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define func(x,y) _func(x,y)
|
||||
#define func(x,y) _func(x,y)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
fs= func( (fd/a) , func(2,0x0082c90f) );
|
||||
printf("fs:%ld\n",fs);
|
||||
fs=_func( (fd/a) , _func(2,0x0082c90f) );
|
||||
printf("fs:%ld\n",fs);
|
||||
return 0;
|
||||
fs= func( (fd/a) , func(2,0x0082c90f) );
|
||||
printf("fs:%ld\n",fs);
|
||||
fs=_func( (fd/a) , _func(2,0x0082c90f) );
|
||||
printf("fs:%ld\n",fs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
3448
test/ref/paranoia.c
3448
test/ref/paranoia.c
File diff suppressed because it is too large
Load Diff
@@ -16,15 +16,15 @@ char i1[];
|
||||
void test1(void) {
|
||||
int a;
|
||||
|
||||
a=sizeof(i1[0]);
|
||||
printf("%04x - ",a);
|
||||
if(sizeof(i1[0])==sizeof(char)) {
|
||||
/* gcc gives size of element */
|
||||
printf("sizeof(i1[0]) gives size of element\n");
|
||||
}
|
||||
if(sizeof(i1[0])==sizeof(char*)) {
|
||||
printf("sizeof(i1[0]) gives size of pointer to element\n");
|
||||
}
|
||||
a=sizeof(i1[0]);
|
||||
printf("%04x - ",a);
|
||||
if(sizeof(i1[0])==sizeof(char)) {
|
||||
/* gcc gives size of element */
|
||||
printf("sizeof(i1[0]) gives size of element\n");
|
||||
}
|
||||
if(sizeof(i1[0])==sizeof(char*)) {
|
||||
printf("sizeof(i1[0]) gives size of pointer to element\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -40,14 +40,14 @@ char *t4={"abcde"};
|
||||
void test2(void) {
|
||||
char c1,c2,c3,c4;
|
||||
int i,e=0;
|
||||
for(i=0;i<5;i++){
|
||||
c1=t1[i];c2=t2[i];c3=t3[i];c4=t4[i];
|
||||
/* printf("%02x %02x %02x %02x\n",c1,c2,c3,c4); */
|
||||
printf("%c %c %c %c\n",c1,c2,c3,c4);
|
||||
if(!((c1==c2)&(c1==c3)&(c1==c4))) e=1;
|
||||
}
|
||||
if(e) printf("test2 failed.\n");
|
||||
else printf("test2 ok.\n");
|
||||
for(i=0;i<5;i++){
|
||||
c1=t1[i];c2=t2[i];c3=t3[i];c4=t4[i];
|
||||
/* printf("%02x %02x %02x %02x\n",c1,c2,c3,c4); */
|
||||
printf("%c %c %c %c\n",c1,c2,c3,c4);
|
||||
if(!((c1==c2)&(c1==c3)&(c1==c4))) e=1;
|
||||
}
|
||||
if(e) printf("test2 failed.\n");
|
||||
else printf("test2 ok.\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -74,7 +74,7 @@ A3 a3[] = {
|
||||
#endif
|
||||
|
||||
void test3a(A3 *list, int number){
|
||||
printf("%s %d\n",list->name,number);
|
||||
printf("%s %d\n",list->name,number);
|
||||
}
|
||||
|
||||
static void test31(void)
|
||||
@@ -103,10 +103,10 @@ static void test30(void)
|
||||
*/
|
||||
|
||||
int main(void) {
|
||||
test1();
|
||||
test2();
|
||||
test30();
|
||||
test31();
|
||||
/* test32(); */
|
||||
return 0;
|
||||
test1();
|
||||
test2();
|
||||
test30();
|
||||
test31();
|
||||
/* test32(); */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -14,62 +14,62 @@ int *xx;
|
||||
exchange(int *x,int *y) {
|
||||
int t;
|
||||
|
||||
printf("exchange(%d,%d)\n", x - xx, y - xx);
|
||||
t = *x; *x = *y; *y = t;
|
||||
printf("exchange(%d,%d)\n", x - xx, y - xx);
|
||||
t = *x; *x = *y; *y = t;
|
||||
}
|
||||
|
||||
/* partition - partition a[i..j] */
|
||||
int partition(int a[], int i, int j) {
|
||||
int v, k;
|
||||
|
||||
j++;
|
||||
k = i;
|
||||
v = a[k];
|
||||
while (i < j) {
|
||||
i++; while (a[i] < v) i++;
|
||||
j--; while (a[j] > v) j--;
|
||||
if (i < j) exchange(&a[i], &a[j]);
|
||||
}
|
||||
exchange(&a[k], &a[j]);
|
||||
return j;
|
||||
j++;
|
||||
k = i;
|
||||
v = a[k];
|
||||
while (i < j) {
|
||||
i++; while (a[i] < v) i++;
|
||||
j--; while (a[j] > v) j--;
|
||||
if (i < j) exchange(&a[i], &a[j]);
|
||||
}
|
||||
exchange(&a[k], &a[j]);
|
||||
return j;
|
||||
}
|
||||
|
||||
/* quick - quicksort a[lb..ub] */
|
||||
void quick(int a[], int lb, int ub) {
|
||||
int k;
|
||||
|
||||
if (lb >= ub)
|
||||
return;
|
||||
k = partition(a, lb, ub);
|
||||
quick(a, lb, k - 1);
|
||||
quick(a, k + 1, ub);
|
||||
if (lb >= ub)
|
||||
return;
|
||||
k = partition(a, lb, ub);
|
||||
quick(a, lb, k - 1);
|
||||
quick(a, k + 1, ub);
|
||||
}
|
||||
|
||||
/* sort - sort a[0..n-1] into increasing order */
|
||||
sort(int a[], int n) {
|
||||
quick(xx = a, 0, --n);
|
||||
quick(xx = a, 0, --n);
|
||||
}
|
||||
|
||||
/* putd - output decimal number */
|
||||
void putd(int n) {
|
||||
if (n < 0) {
|
||||
putchar('-');
|
||||
n = -n;
|
||||
}
|
||||
if (n/10)
|
||||
putd(n/10);
|
||||
putchar(n%10 + '0');
|
||||
if (n < 0) {
|
||||
putchar('-');
|
||||
n = -n;
|
||||
}
|
||||
if (n/10)
|
||||
putd(n/10);
|
||||
putchar(n%10 + '0');
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
int i;
|
||||
int i;
|
||||
|
||||
sort(in, (sizeof in)/(sizeof in[0]));
|
||||
for (i = 0; i < (sizeof in)/(sizeof in[0]); i++) {
|
||||
putd(in[i]);
|
||||
putchar('\n');
|
||||
}
|
||||
sort(in, (sizeof in)/(sizeof in[0]));
|
||||
for (i = 0; i < (sizeof in)/(sizeof in[0]); i++) {
|
||||
putd(in[i]);
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,6 @@ int j, k, m, n;
|
||||
#endif
|
||||
|
||||
f5(){
|
||||
x=A[k*m]*A[j*m]+B[k*n]*B[j*n];
|
||||
x=A[k*m]*B[j*n]-B[k*n]*A[j*m];
|
||||
x=A[k*m]*A[j*m]+B[k*n]*B[j*n];
|
||||
x=A[k*m]*B[j*n]-B[k*n]*A[j*m];
|
||||
}
|
||||
|
||||
@@ -10,15 +10,15 @@
|
||||
#ifndef NO_FUNCS_TAKE_STRUCTS
|
||||
struct node
|
||||
{
|
||||
int a[4];
|
||||
int a[4];
|
||||
} x =
|
||||
{
|
||||
#ifdef NO_SLOPPY_STRUCT_INIT
|
||||
{
|
||||
{
|
||||
#endif
|
||||
1,2,3,4
|
||||
1,2,3,4
|
||||
#ifdef NO_SLOPPY_STRUCT_INIT
|
||||
}
|
||||
}
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
@@ -27,68 +27,68 @@ print(char *fmt, ...);
|
||||
|
||||
main()
|
||||
{
|
||||
print("test 1\n");
|
||||
print("test %s\n", "2");
|
||||
print("test %d%c", 3, '\n');
|
||||
print("%s%s %w%c", "te", "st", 4, '\n');
|
||||
print("test 1\n");
|
||||
print("test %s\n", "2");
|
||||
print("test %d%c", 3, '\n');
|
||||
print("%s%s %w%c", "te", "st", 4, '\n');
|
||||
#ifdef NO_FLOATS
|
||||
print("%s%s %f%c", "te", "st", (signed long) 5, '\n');
|
||||
#else
|
||||
print("%s%s %f%c", "te", "st", 5.0, '\n');
|
||||
print("%s%s %f%c", "te", "st", (signed long) 5, '\n');
|
||||
#else
|
||||
print("%s%s %f%c", "te", "st", 5.0, '\n');
|
||||
#endif
|
||||
#ifndef NO_FUNCS_TAKE_STRUCTS
|
||||
#ifndef NO_FUNCS_TAKE_STRUCTS
|
||||
print("%b %b %b %b %b %b\n", x, x, x, x, x, x);
|
||||
#endif
|
||||
return 0;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
print(char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
for (; *fmt; fmt++)
|
||||
{
|
||||
if (*fmt == '%')
|
||||
switch (*++fmt) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
for (; *fmt; fmt++)
|
||||
{
|
||||
if (*fmt == '%')
|
||||
switch (*++fmt) {
|
||||
case 'b': {
|
||||
#ifdef NO_FUNCS_TAKE_STRUCTS
|
||||
printf("(1 2 3 4)");
|
||||
#else
|
||||
struct node x =
|
||||
va_arg(
|
||||
ap,
|
||||
struct node
|
||||
);
|
||||
printf("(%d %d %d %d)", x.a[0], x.a[1], x.a[2], x.a[3]);
|
||||
#endif
|
||||
#ifdef NO_FUNCS_TAKE_STRUCTS
|
||||
printf("(1 2 3 4)");
|
||||
#else
|
||||
struct node x =
|
||||
va_arg(
|
||||
ap,
|
||||
struct node
|
||||
);
|
||||
printf("(%d %d %d %d)", x.a[0], x.a[1], x.a[2], x.a[3]);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case 'c':
|
||||
/* printf("%c", va_arg(ap, char)); */
|
||||
printf("%c", va_arg(ap, int));
|
||||
break;
|
||||
case 'd':
|
||||
printf("%d", va_arg(ap, int));
|
||||
break;
|
||||
case 'w':
|
||||
/* printf("%x", va_arg(ap, short)); */
|
||||
printf("%x", va_arg(ap, int));
|
||||
break;
|
||||
case 's':
|
||||
printf("%s", va_arg(ap, char *));
|
||||
break;
|
||||
case 'f':
|
||||
#ifdef NO_FLOATS
|
||||
printf("%ld.000000", va_arg(ap, signed long));
|
||||
#else
|
||||
printf("%f", va_arg(ap, double));
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
printf("%c", *fmt);
|
||||
break;
|
||||
}
|
||||
else
|
||||
printf("%c", *fmt);
|
||||
}
|
||||
va_end(ap);
|
||||
case 'c':
|
||||
/* printf("%c", va_arg(ap, char)); */
|
||||
printf("%c", va_arg(ap, int));
|
||||
break;
|
||||
case 'd':
|
||||
printf("%d", va_arg(ap, int));
|
||||
break;
|
||||
case 'w':
|
||||
/* printf("%x", va_arg(ap, short)); */
|
||||
printf("%x", va_arg(ap, int));
|
||||
break;
|
||||
case 's':
|
||||
printf("%s", va_arg(ap, char *));
|
||||
break;
|
||||
case 'f':
|
||||
#ifdef NO_FLOATS
|
||||
printf("%ld.000000", va_arg(ap, signed long));
|
||||
#else
|
||||
printf("%f", va_arg(ap, double));
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
printf("%c", *fmt);
|
||||
break;
|
||||
}
|
||||
else
|
||||
printf("%c", *fmt);
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ FILE *outfile=NULL;
|
||||
#else
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
@@ -34,18 +34,18 @@ FILE *outfile=NULL;
|
||||
|
||||
struct Xdirent
|
||||
{
|
||||
char d_name[XNAME_MAX+1];
|
||||
unsigned short d_off;
|
||||
unsigned short d_reclen;
|
||||
unsigned char d_type;
|
||||
unsigned char d_namlen;
|
||||
char d_name[XNAME_MAX+1];
|
||||
unsigned short d_off;
|
||||
unsigned short d_reclen;
|
||||
unsigned char d_type;
|
||||
unsigned char d_namlen;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char fd;
|
||||
unsigned short off;
|
||||
char name[XNAME_MAX+1];
|
||||
unsigned char fd;
|
||||
unsigned short off;
|
||||
char name[XNAME_MAX+1];
|
||||
} XDIR;
|
||||
|
||||
unsigned char b1[4];
|
||||
@@ -61,51 +61,51 @@ static struct Xdirent entry;
|
||||
unsigned char fd;
|
||||
static unsigned char ch;
|
||||
|
||||
entry.d_off=dir->off;
|
||||
entry.d_off=dir->off;
|
||||
|
||||
/* basic line-link / file-length */
|
||||
memcpy(buffer,b1,4);
|
||||
|
||||
dir->off=dir->off+4;
|
||||
entry.d_reclen=254*(buffer[2]+(buffer[3]<<8));
|
||||
/* basic line-link / file-length */
|
||||
memcpy(buffer,b1,4);
|
||||
|
||||
dir->off=dir->off+4;
|
||||
entry.d_reclen=254*(buffer[2]+(buffer[3]<<8));
|
||||
|
||||
/* read file entry */
|
||||
memcpy(buffer,b2,0x10);
|
||||
|
||||
dir->off=dir->off+i;
|
||||
/* read file entry */
|
||||
memcpy(buffer,b2,0x10);
|
||||
|
||||
dir->off=dir->off+i;
|
||||
|
||||
printf("Xreaddir: '%s'\n",buffer);
|
||||
|
||||
/* skip until either quote (file) or b (blocks free => end) */
|
||||
i=0;ii=0;
|
||||
while(i==0){
|
||||
temp=buffer[ii];ii++;
|
||||
if(ii>16){
|
||||
/* something went wrong...this shouldnt happen! */
|
||||
return(NULL);
|
||||
}
|
||||
else if(temp=='\"') i++;
|
||||
else if(temp=='b') {
|
||||
/* "blocks free" */
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
printf("Xreaddir: '%s'\n",buffer);
|
||||
printf("Xreaddir: '%s'\n",buffer);
|
||||
|
||||
/* skip until either quote (file) or b (blocks free => end) */
|
||||
i=0;ii=0;
|
||||
while(i==0){
|
||||
temp=buffer[ii];ii++;
|
||||
if(ii>16){
|
||||
/* something went wrong...this shouldnt happen! */
|
||||
return(NULL);
|
||||
}
|
||||
else if(temp=='\"') i++;
|
||||
else if(temp=='b') {
|
||||
/* "blocks free" */
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
printf("Xreaddir: '%s'\n",buffer);
|
||||
|
||||
/* process file entry */
|
||||
/* process file entry */
|
||||
|
||||
i=0; temp=buffer[ii];ii++;
|
||||
while(temp!='\"'){
|
||||
entry.d_name[i]=temp;
|
||||
i++;
|
||||
temp=buffer[ii];ii++;
|
||||
}
|
||||
entry.d_name[i]=0;
|
||||
entry.d_namlen=i;
|
||||
i=0; temp=buffer[ii];ii++;
|
||||
while(temp!='\"'){
|
||||
entry.d_name[i]=temp;
|
||||
i++;
|
||||
temp=buffer[ii];ii++;
|
||||
}
|
||||
entry.d_name[i]=0;
|
||||
entry.d_namlen=i;
|
||||
|
||||
/* set type flag */
|
||||
/* set type flag */
|
||||
|
||||
return(&entry);
|
||||
return(&entry);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
@@ -113,16 +113,16 @@ int main(void)
|
||||
char mydirname[XNAME_MAX+1]=".";
|
||||
XDIR mydir;
|
||||
struct Xdirent *mydirent;
|
||||
|
||||
|
||||
printf("start\n");
|
||||
|
||||
if((mydirent=Xreaddir(&mydir))==NULL)
|
||||
{
|
||||
printf("NULL\n");
|
||||
printf("NULL\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("=%s\n",mydirent->d_name);
|
||||
printf("=%s\n",mydirent->d_name);
|
||||
}
|
||||
printf("done\n");
|
||||
|
||||
|
||||
@@ -74,8 +74,8 @@ void makepoint(point *p,int x, int y) {
|
||||
/* make a rectangle from two points */
|
||||
void makerect(rect *d,point p1, point p2) {
|
||||
rect r;
|
||||
r.pt1 = p1;
|
||||
r.pt2 = p2;
|
||||
r.pt1 = p1;
|
||||
r.pt2 = p2;
|
||||
|
||||
canonrect(d,r);
|
||||
}
|
||||
@@ -97,53 +97,53 @@ odd(struct odd y) {
|
||||
|
||||
/* add two points */
|
||||
point addpoint(point p1, point p2) {
|
||||
p1.x += p2.x;
|
||||
p1.y += p2.y;
|
||||
return p1;
|
||||
p1.x += p2.x;
|
||||
p1.y += p2.y;
|
||||
return p1;
|
||||
}
|
||||
/* canonicalize rectangle coordinates */
|
||||
rect canonrect(rect r) {
|
||||
rect temp;
|
||||
rect temp;
|
||||
|
||||
temp.pt1.x = min(r.pt1.x, r.pt2.x);
|
||||
temp.pt1.y = min(r.pt1.y, r.pt2.y);
|
||||
temp.pt2.x = max(r.pt1.x, r.pt2.x);
|
||||
temp.pt2.y = max(r.pt1.y, r.pt2.y);
|
||||
return temp;
|
||||
temp.pt1.x = min(r.pt1.x, r.pt2.x);
|
||||
temp.pt1.y = min(r.pt1.y, r.pt2.y);
|
||||
temp.pt2.x = max(r.pt1.x, r.pt2.x);
|
||||
temp.pt2.y = max(r.pt1.y, r.pt2.y);
|
||||
return temp;
|
||||
}
|
||||
/* make a point from x and y components */
|
||||
point makepoint(int x, int y) {
|
||||
point p;
|
||||
point p;
|
||||
|
||||
p.x = x;
|
||||
p.y = y;
|
||||
return p;
|
||||
p.x = x;
|
||||
p.y = y;
|
||||
return p;
|
||||
}
|
||||
|
||||
/* make a rectangle from two points */
|
||||
rect makerect(point p1, point p2) {
|
||||
rect r;
|
||||
rect r;
|
||||
|
||||
r.pt1 = p1;
|
||||
r.pt2 = p2;
|
||||
return canonrect(r);
|
||||
r.pt1 = p1;
|
||||
r.pt2 = p2;
|
||||
return canonrect(r);
|
||||
}
|
||||
|
||||
struct odd {char a[3]; } y =
|
||||
{
|
||||
#ifdef NO_SLOPPY_STRUCT_INIT
|
||||
{
|
||||
{
|
||||
#endif
|
||||
'a', 'b', 0
|
||||
'a', 'b', 0
|
||||
#ifdef NO_SLOPPY_STRUCT_INIT
|
||||
}
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
odd(struct odd y)
|
||||
{
|
||||
struct odd x
|
||||
= y;
|
||||
struct odd x
|
||||
= y;
|
||||
printf("%s\n\r", x.a);
|
||||
}
|
||||
|
||||
@@ -157,8 +157,8 @@ int ptinrect(point *p, rect *r) {
|
||||
}
|
||||
#else
|
||||
int ptinrect(point p, rect r) {
|
||||
return p.x >= r.pt1.x && p.x < r.pt2.x
|
||||
&& p.y >= r.pt1.y && p.y < r.pt2.y;
|
||||
return p.x >= r.pt1.x && p.x < r.pt2.x
|
||||
&& p.y >= r.pt1.y && p.y < r.pt2.y;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -212,9 +212,9 @@ point pts[] = { -1, -1, 1, 1, 20, 300, 500, 400 };
|
||||
#else
|
||||
if (ptinrect(x, screen) == 0)
|
||||
#endif
|
||||
{
|
||||
{
|
||||
printf("not ");
|
||||
}
|
||||
}
|
||||
printf("within (%d,%d; %d,%d)\n\r", screen.pt1.x, screen.pt1.y,
|
||||
screen.pt2.x, screen.pt2.y);
|
||||
}
|
||||
@@ -240,24 +240,24 @@ point pts[] = { -1, -1, 1, 1, 20, 300, 500, 400 };
|
||||
#endif
|
||||
|
||||
rect screen =
|
||||
makerect(
|
||||
addpoint(maxpt, makepoint(-10, -10)),
|
||||
addpoint(origin, makepoint(10, 10))
|
||||
);
|
||||
makerect(
|
||||
addpoint(maxpt, makepoint(-10, -10)),
|
||||
addpoint(origin, makepoint(10, 10))
|
||||
);
|
||||
|
||||
test1();
|
||||
|
||||
for (i = 0; i < sizeof pts/sizeof pts[0]; i++) {
|
||||
printf("(%d,%d) is ", pts[i].x,
|
||||
(x = makepoint(pts[i].x, pts[i].y)).y);
|
||||
if (ptinrect(x, screen) == 0)
|
||||
printf("not ");
|
||||
test1();
|
||||
|
||||
for (i = 0; i < sizeof pts/sizeof pts[0]; i++) {
|
||||
printf("(%d,%d) is ", pts[i].x,
|
||||
(x = makepoint(pts[i].x, pts[i].y)).y);
|
||||
if (ptinrect(x, screen) == 0)
|
||||
printf("not ");
|
||||
printf("within (%d,%d; %d,%d)\n\r", screen.pt1.x, screen.pt1.y,
|
||||
screen.pt2.x, screen.pt2.y);
|
||||
}
|
||||
odd(y);
|
||||
screen.pt2.x, screen.pt2.y);
|
||||
}
|
||||
odd(y);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* FUNCS_RETURN_STRUCTS */
|
||||
|
||||
@@ -18,9 +18,9 @@ limit();
|
||||
|
||||
big(
|
||||
# ifdef ASSUME_32BIT_UNSIGNED
|
||||
unsigned
|
||||
unsigned
|
||||
# else
|
||||
unsigned long
|
||||
unsigned long
|
||||
# endif
|
||||
x);
|
||||
|
||||
@@ -28,28 +28,28 @@ x);
|
||||
|
||||
main()
|
||||
{
|
||||
testbackslash();
|
||||
f();
|
||||
g();
|
||||
h();
|
||||
testbig(); /* ! broken long int compare (?) */
|
||||
limit(); /* ! broken long int compare (?) */
|
||||
testbackslash();
|
||||
f();
|
||||
g();
|
||||
h();
|
||||
testbig(); /* ! broken long int compare (?) */
|
||||
limit(); /* ! broken long int compare (?) */
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
testbig()
|
||||
{
|
||||
#ifdef ASSUME_32BIT_INT
|
||||
int i;
|
||||
#else
|
||||
signed long i;
|
||||
#endif
|
||||
/* 2341234 2341234 2341234 */
|
||||
for (i = 0x1000000; i&0x7000000; i += 0x1000000) {
|
||||
/* printf("i = 0x%lx\n", i); */
|
||||
big(i);
|
||||
}
|
||||
#ifdef ASSUME_32BIT_INT
|
||||
int i;
|
||||
#else
|
||||
signed long i;
|
||||
#endif
|
||||
/* 2341234 2341234 2341234 */
|
||||
for (i = 0x1000000; i&0x7000000; i += 0x1000000) {
|
||||
/* printf("i = 0x%lx\n", i); */
|
||||
big(i);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NO_LOCAL_STRING_INIT
|
||||
@@ -69,93 +69,93 @@ testbackslash()
|
||||
#else
|
||||
for (s = "bfnrtvx"; *s; s++) {
|
||||
#endif
|
||||
printf("%c = %c\n", *s, backslash(*s));
|
||||
printf("%c = %c\n", *s, backslash(*s));
|
||||
}
|
||||
}
|
||||
|
||||
backslash(c)
|
||||
{
|
||||
switch (c)
|
||||
switch (c)
|
||||
{
|
||||
case 'b':
|
||||
return 'b';
|
||||
case 'f':
|
||||
return 'f';
|
||||
case 'n':
|
||||
return 'n';
|
||||
case 'r':
|
||||
return 'r';
|
||||
case 't':
|
||||
return 't';
|
||||
case 'v':
|
||||
case 'b':
|
||||
return 'b';
|
||||
case 'f':
|
||||
return 'f';
|
||||
case 'n':
|
||||
return 'n';
|
||||
case 'r':
|
||||
return 'r';
|
||||
case 't':
|
||||
return 't';
|
||||
case 'v':
|
||||
return 'v';
|
||||
}
|
||||
}
|
||||
|
||||
return 'x';
|
||||
return 'x';
|
||||
}
|
||||
|
||||
f() {
|
||||
int i, x = 0, y;
|
||||
int i, x = 0, y;
|
||||
|
||||
printf("f:\n");
|
||||
for (i = 0; i <= 20; i++) {
|
||||
y = i;
|
||||
switch (i) {
|
||||
case 1: x = i; break;
|
||||
case 2: x = i; break;
|
||||
case 7: x = i; break;
|
||||
case 8: x = i; break;
|
||||
case 9: x = i; break;
|
||||
case 16: x = i; break;
|
||||
case 17: x = i; break;
|
||||
case 18: x = i; break;
|
||||
case 19: x = i; break;
|
||||
case 20: x = i; break;
|
||||
}
|
||||
printf("x = %d\n", x);
|
||||
}
|
||||
printf("f:\n");
|
||||
for (i = 0; i <= 20; i++) {
|
||||
y = i;
|
||||
switch (i) {
|
||||
case 1: x = i; break;
|
||||
case 2: x = i; break;
|
||||
case 7: x = i; break;
|
||||
case 8: x = i; break;
|
||||
case 9: x = i; break;
|
||||
case 16: x = i; break;
|
||||
case 17: x = i; break;
|
||||
case 18: x = i; break;
|
||||
case 19: x = i; break;
|
||||
case 20: x = i; break;
|
||||
}
|
||||
printf("x = %d\n", x);
|
||||
}
|
||||
}
|
||||
|
||||
g() {
|
||||
int i;
|
||||
int i;
|
||||
|
||||
printf("g:\n");
|
||||
for (i = 1; i <= 10; i++)
|
||||
switch (i) {
|
||||
case 1: case 2: printf("1 %d\n", i); break;
|
||||
case 3: case 4: case 5: printf("2 %d\n", i); break;
|
||||
case 6: case 7: case 8: printf("3 %d\n", i);
|
||||
default:
|
||||
printf("d %d\n", i); break;
|
||||
case 1001: case 1002: case 1003: case 1004:
|
||||
printf("5 %d\n", i); break;
|
||||
case 3001: case 3002: case 3003: case 3004:
|
||||
printf("6 %d\n", i); break;
|
||||
}
|
||||
printf("g:\n");
|
||||
for (i = 1; i <= 10; i++)
|
||||
switch (i) {
|
||||
case 1: case 2: printf("1 %d\n", i); break;
|
||||
case 3: case 4: case 5: printf("2 %d\n", i); break;
|
||||
case 6: case 7: case 8: printf("3 %d\n", i);
|
||||
default:
|
||||
printf("d %d\n", i); break;
|
||||
case 1001: case 1002: case 1003: case 1004:
|
||||
printf("5 %d\n", i); break;
|
||||
case 3001: case 3002: case 3003: case 3004:
|
||||
printf("6 %d\n", i); break;
|
||||
}
|
||||
}
|
||||
|
||||
h()
|
||||
{
|
||||
int i, n=0;
|
||||
int i, n=0;
|
||||
|
||||
printf("h:\n");
|
||||
for (i = 1; i <= 500; i++)
|
||||
switch (i) {
|
||||
default: n++; continue;
|
||||
case 128: printf("i = %d\n", i); break;
|
||||
case 16: printf("i = %d\n", i); break;
|
||||
case 8: printf("i = %d\n", i); break;
|
||||
case 120: printf("i = %d\n", i); break;
|
||||
case 280: printf("i = %d\n", i); break;
|
||||
case 264: printf("i = %d\n", i); break;
|
||||
case 248: printf("i = %d\n", i); break;
|
||||
case 272: printf("i = %d\n", i); break;
|
||||
case 304: printf("i = %d\n", i); break;
|
||||
case 296: printf("i = %d\n", i); break;
|
||||
case 288: printf("i = %d\n", i); break;
|
||||
case 312: printf("i = %d\n", i); break;
|
||||
}
|
||||
printf("%d defaults\n", n);
|
||||
printf("h:\n");
|
||||
for (i = 1; i <= 500; i++)
|
||||
switch (i) {
|
||||
default: n++; continue;
|
||||
case 128: printf("i = %d\n", i); break;
|
||||
case 16: printf("i = %d\n", i); break;
|
||||
case 8: printf("i = %d\n", i); break;
|
||||
case 120: printf("i = %d\n", i); break;
|
||||
case 280: printf("i = %d\n", i); break;
|
||||
case 264: printf("i = %d\n", i); break;
|
||||
case 248: printf("i = %d\n", i); break;
|
||||
case 272: printf("i = %d\n", i); break;
|
||||
case 304: printf("i = %d\n", i); break;
|
||||
case 296: printf("i = %d\n", i); break;
|
||||
case 288: printf("i = %d\n", i); break;
|
||||
case 312: printf("i = %d\n", i); break;
|
||||
}
|
||||
printf("%d defaults\n", n);
|
||||
}
|
||||
|
||||
#ifdef NO_OLD_FUNC_DECL
|
||||
@@ -165,9 +165,9 @@ h()
|
||||
#endif
|
||||
|
||||
# ifdef ASSUME_32BIT_UNSIGNED
|
||||
unsigned
|
||||
unsigned
|
||||
# else
|
||||
unsigned long
|
||||
unsigned long
|
||||
# endif
|
||||
|
||||
#ifdef NO_OLD_FUNC_DECL
|
||||
@@ -176,42 +176,42 @@ h()
|
||||
x; {
|
||||
#endif
|
||||
|
||||
/* printf("x = 0x%x\n", x); */
|
||||
/* printf("x = 0x%x\n", x); */
|
||||
|
||||
switch(x&0x6000000){
|
||||
case -1:
|
||||
case -2:
|
||||
case 0x0000000:
|
||||
printf("x = 0x%lx\n", x); break;
|
||||
case 0x2000000:
|
||||
printf("x = 0x%lx\n", x); break;
|
||||
case 0x4000000:
|
||||
printf("x = 0x%lx\n", x); break;
|
||||
default:
|
||||
printf("x = 0x%lx (default)\n", x); break;
|
||||
}
|
||||
switch(x&0x6000000){
|
||||
case -1:
|
||||
case -2:
|
||||
case 0x0000000:
|
||||
printf("x = 0x%lx\n", x); break;
|
||||
case 0x2000000:
|
||||
printf("x = 0x%lx\n", x); break;
|
||||
case 0x4000000:
|
||||
printf("x = 0x%lx\n", x); break;
|
||||
default:
|
||||
printf("x = 0x%lx (default)\n", x); break;
|
||||
}
|
||||
}
|
||||
|
||||
limit() {
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = INT_MIN; i <= INT_MIN+5; i++)
|
||||
/* for (i = INT_MIN; i < INT_MIN+6; i++) */
|
||||
switch (i) {
|
||||
case INT_MIN: printf("0\n"); break;
|
||||
case INT_MIN+1: printf("1\n"); break;
|
||||
case INT_MIN+2: printf("2\n"); break;
|
||||
case INT_MIN+3: printf("3\n"); break;
|
||||
case INT_MIN+4: printf("4\n"); break;
|
||||
default: printf("5\n"); break;
|
||||
}
|
||||
for (i = INT_MAX; i >= INT_MAX-5; i--)
|
||||
switch (i) {
|
||||
case INT_MAX: printf("0\n"); break;
|
||||
case INT_MAX-1: printf("1\n"); break;
|
||||
case INT_MAX-2: printf("2\n"); break;
|
||||
case INT_MAX-3: printf("3\n"); break;
|
||||
case INT_MAX-4: printf("4\n"); break;
|
||||
default: printf("5\n"); break;
|
||||
}
|
||||
for (i = INT_MIN; i <= INT_MIN+5; i++)
|
||||
/* for (i = INT_MIN; i < INT_MIN+6; i++) */
|
||||
switch (i) {
|
||||
case INT_MIN: printf("0\n"); break;
|
||||
case INT_MIN+1: printf("1\n"); break;
|
||||
case INT_MIN+2: printf("2\n"); break;
|
||||
case INT_MIN+3: printf("3\n"); break;
|
||||
case INT_MIN+4: printf("4\n"); break;
|
||||
default: printf("5\n"); break;
|
||||
}
|
||||
for (i = INT_MAX; i >= INT_MAX-5; i--)
|
||||
switch (i) {
|
||||
case INT_MAX: printf("0\n"); break;
|
||||
case INT_MAX-1: printf("1\n"); break;
|
||||
case INT_MAX-2: printf("2\n"); break;
|
||||
case INT_MAX-3: printf("3\n"); break;
|
||||
case INT_MAX-4: printf("4\n"); break;
|
||||
default: printf("5\n"); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,31 +9,31 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void testlimits(int i) {
|
||||
printf("%d:",i);
|
||||
printf("%d:",i);
|
||||
|
||||
switch(i) {
|
||||
case -1: /* works */
|
||||
/* case 0xffff: */ /* 'range error' (-1) */
|
||||
switch(i) {
|
||||
case -1: /* works */
|
||||
/* case 0xffff: */ /* 'range error' (-1) */
|
||||
|
||||
printf("-1\n");
|
||||
break;
|
||||
/* max int */
|
||||
printf("-1\n");
|
||||
break;
|
||||
/* max int */
|
||||
|
||||
/* case 0x7fff: */ /* works */
|
||||
case 32767: /* works */
|
||||
/* case 32768: */ /* 'range error' (correct for that one!) */
|
||||
/* case 0x7fff: */ /* works */
|
||||
case 32767: /* works */
|
||||
/* case 32768: */ /* 'range error' (correct for that one!) */
|
||||
|
||||
printf("max\n");
|
||||
break;
|
||||
/* min int */
|
||||
printf("max\n");
|
||||
break;
|
||||
/* min int */
|
||||
|
||||
case -32768: /* 'warning. constant is long' */
|
||||
/* case 0x8000: */ /* 'range error' */
|
||||
/* case -32769: */ /* 'range error' (correct for that one!) */
|
||||
printf("min\n");
|
||||
break;
|
||||
}
|
||||
printf("\n");
|
||||
case -32768: /* 'warning. constant is long' */
|
||||
/* case 0x8000: */ /* 'range error' */
|
||||
/* case -32769: */ /* 'range error' (correct for that one!) */
|
||||
printf("min\n");
|
||||
break;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void testdefault1(unsigned char i) {
|
||||
@@ -45,9 +45,9 @@ signed char k;
|
||||
#else
|
||||
char k;
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
#ifdef UNSIGNED_CHARS
|
||||
signed char k;
|
||||
#else
|
||||
@@ -56,89 +56,89 @@ char k;
|
||||
|
||||
#endif
|
||||
|
||||
for(;i<254;) {
|
||||
k = i;
|
||||
printf(">%d\n",i);i++;
|
||||
switch(k) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
case 6:
|
||||
break;
|
||||
case 7:
|
||||
break;
|
||||
case 8:
|
||||
break;
|
||||
case 9:
|
||||
break;
|
||||
case 10:
|
||||
break;
|
||||
case 11:
|
||||
break;
|
||||
case 12:
|
||||
break;
|
||||
case 13:
|
||||
break;
|
||||
case 14:
|
||||
break;
|
||||
case 15:
|
||||
break;
|
||||
case 17:
|
||||
break;
|
||||
/* triggers bug ? */
|
||||
/* gcc warning: case label value exceeds maximum value for type */
|
||||
/* cc65 error: range error */
|
||||
for(;i<254;) {
|
||||
k = i;
|
||||
printf(">%d\n",i);i++;
|
||||
switch(k) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
case 6:
|
||||
break;
|
||||
case 7:
|
||||
break;
|
||||
case 8:
|
||||
break;
|
||||
case 9:
|
||||
break;
|
||||
case 10:
|
||||
break;
|
||||
case 11:
|
||||
break;
|
||||
case 12:
|
||||
break;
|
||||
case 13:
|
||||
break;
|
||||
case 14:
|
||||
break;
|
||||
case 15:
|
||||
break;
|
||||
case 17:
|
||||
break;
|
||||
/* triggers bug ? */
|
||||
/* gcc warning: case label value exceeds maximum value for type */
|
||||
/* cc65 error: range error */
|
||||
|
||||
/*
|
||||
case 170:
|
||||
break;
|
||||
*/
|
||||
case 18:
|
||||
break;
|
||||
case 19:
|
||||
break;
|
||||
case 20:
|
||||
break;
|
||||
case 21:
|
||||
break;
|
||||
case 22:
|
||||
break;
|
||||
case 23:
|
||||
break;
|
||||
case 24:
|
||||
switch(k) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 100:
|
||||
break;
|
||||
default:
|
||||
printf(">>>default\n");
|
||||
/* triggers bug if this break; is missing? */
|
||||
/* break; */
|
||||
}
|
||||
}
|
||||
/*
|
||||
case 170:
|
||||
break;
|
||||
*/
|
||||
case 18:
|
||||
break;
|
||||
case 19:
|
||||
break;
|
||||
case 20:
|
||||
break;
|
||||
case 21:
|
||||
break;
|
||||
case 22:
|
||||
break;
|
||||
case 23:
|
||||
break;
|
||||
case 24:
|
||||
switch(k) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 100:
|
||||
break;
|
||||
default:
|
||||
printf(">>>default\n");
|
||||
/* triggers bug if this break; is missing? */
|
||||
/* break; */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void testdefault2(unsigned char i) {
|
||||
@@ -150,9 +150,9 @@ char k;
|
||||
#else
|
||||
unsigned char k;
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
#ifdef UNSIGNED_CHARS
|
||||
char k;
|
||||
#else
|
||||
@@ -161,102 +161,102 @@ unsigned char k;
|
||||
|
||||
#endif
|
||||
|
||||
for(;i<254;) {
|
||||
k = i;
|
||||
printf(">%d\n",i);i++;
|
||||
switch(k) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
case 6:
|
||||
break;
|
||||
case 7:
|
||||
break;
|
||||
case 8:
|
||||
break;
|
||||
case 9:
|
||||
break;
|
||||
case 10:
|
||||
break;
|
||||
case 11:
|
||||
break;
|
||||
case 12:
|
||||
break;
|
||||
case 13:
|
||||
break;
|
||||
case 14:
|
||||
break;
|
||||
case 15:
|
||||
break;
|
||||
case 17:
|
||||
break;
|
||||
/* triggers bug ? */
|
||||
for(;i<254;) {
|
||||
k = i;
|
||||
printf(">%d\n",i);i++;
|
||||
switch(k) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
case 6:
|
||||
break;
|
||||
case 7:
|
||||
break;
|
||||
case 8:
|
||||
break;
|
||||
case 9:
|
||||
break;
|
||||
case 10:
|
||||
break;
|
||||
case 11:
|
||||
break;
|
||||
case 12:
|
||||
break;
|
||||
case 13:
|
||||
break;
|
||||
case 14:
|
||||
break;
|
||||
case 15:
|
||||
break;
|
||||
case 17:
|
||||
break;
|
||||
/* triggers bug ? */
|
||||
|
||||
case 170:
|
||||
break;
|
||||
|
||||
case 18:
|
||||
break;
|
||||
case 19:
|
||||
break;
|
||||
case 20:
|
||||
break;
|
||||
case 21:
|
||||
break;
|
||||
case 22:
|
||||
break;
|
||||
case 23:
|
||||
break;
|
||||
case 24:
|
||||
switch(k) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 100:
|
||||
break;
|
||||
default:
|
||||
printf(">>>default\n");
|
||||
/* triggers bug if this break; is missing? */
|
||||
/* break; */
|
||||
}
|
||||
}
|
||||
case 170:
|
||||
break;
|
||||
|
||||
case 18:
|
||||
break;
|
||||
case 19:
|
||||
break;
|
||||
case 20:
|
||||
break;
|
||||
case 21:
|
||||
break;
|
||||
case 22:
|
||||
break;
|
||||
case 23:
|
||||
break;
|
||||
case 24:
|
||||
switch(k) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 100:
|
||||
break;
|
||||
default:
|
||||
printf(">>>default\n");
|
||||
/* triggers bug if this break; is missing? */
|
||||
/* break; */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
testlimits(32767);
|
||||
testlimits(-32768);
|
||||
testlimits(-1);
|
||||
|
||||
testdefault1(1);
|
||||
testdefault1(2);
|
||||
testdefault1(3);
|
||||
testdefault1(4);
|
||||
|
||||
testdefault2(1);
|
||||
testdefault2(2);
|
||||
testdefault2(3);
|
||||
testdefault2(4);
|
||||
testlimits(32767);
|
||||
testlimits(-32768);
|
||||
testlimits(-1);
|
||||
|
||||
testdefault1(1);
|
||||
testdefault1(2);
|
||||
testdefault1(3);
|
||||
testdefault1(4);
|
||||
|
||||
testdefault2(1);
|
||||
testdefault2(2);
|
||||
testdefault2(3);
|
||||
testdefault2(4);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ static char string[0x100];
|
||||
va_start(ap,format);
|
||||
|
||||
vsprintf(string,format,ap);
|
||||
printf("fd:%d,format:%s,string:%s\n",fd,format,string);
|
||||
printf("fd:%d,format:%s,string:%s\n",fd,format,string);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
102
test/ref/wf1.c
102
test/ref/wf1.c
@@ -16,12 +16,12 @@ FILE *in;
|
||||
|
||||
struct node
|
||||
{
|
||||
int count; /* frequency count */
|
||||
struct node *left; /* left subtree */
|
||||
struct node *right; /* right subtree */
|
||||
char *word; /* word itself */
|
||||
int count; /* frequency count */
|
||||
struct node *left; /* left subtree */
|
||||
struct node *right; /* right subtree */
|
||||
char *word; /* word itself */
|
||||
} words[MAXWORDS];
|
||||
int next; /* index of next free entry in words */
|
||||
int next; /* index of next free entry in words */
|
||||
|
||||
/*struct node *lookup();*/
|
||||
|
||||
@@ -38,14 +38,14 @@ struct node *lookup(char *word, struct node **p);
|
||||
|
||||
int isletter(char c);
|
||||
|
||||
/* err - print error message s and die */
|
||||
/* err - print error message s and die */
|
||||
#ifndef NO_OLD_FUNC_DECL
|
||||
err(s) char *s; {
|
||||
#else
|
||||
int err(char *s) {
|
||||
#endif
|
||||
printf("? %s\n", s);
|
||||
exit(1);
|
||||
printf("? %s\n", s);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* getword - get next input word into buf, return 0 on EOF */
|
||||
@@ -55,25 +55,25 @@ int getword(buf) char *buf;
|
||||
int getword(char *buf)
|
||||
#endif
|
||||
{
|
||||
char *s;
|
||||
int c;
|
||||
char *s;
|
||||
int c;
|
||||
|
||||
while (((c = getchar()) != -1) && (isletter(c) == 0))
|
||||
;
|
||||
;
|
||||
for (s = buf; (c = isletter(c)); c = getchar())
|
||||
*s++ = c;
|
||||
*s = 0;
|
||||
if (s > buf)
|
||||
return 1;
|
||||
return 0;
|
||||
*s++ = c;
|
||||
*s = 0;
|
||||
if (s > buf)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* isletter - return folded version of c if it is a letter, 0 otherwise */
|
||||
int isletter(char c)
|
||||
{
|
||||
if ((c >= 'A') && (c <= 'Z')) c += 'a' - 'A';
|
||||
if ((c >= 'a') && (c <= 'z')) return c;
|
||||
return 0;
|
||||
if ((c >= 'A') && (c <= 'Z')) c += 'a' - 'A';
|
||||
if ((c >= 'a') && (c <= 'z')) return c;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* lookup - lookup word in tree; install if necessary */
|
||||
@@ -84,27 +84,27 @@ char *word; struct node **p;
|
||||
struct node *lookup(char *word, struct node **p)
|
||||
#endif
|
||||
{
|
||||
int cond;
|
||||
/* char *malloc(); */
|
||||
int cond;
|
||||
/* char *malloc(); */
|
||||
|
||||
if (*p) {
|
||||
cond = strcmp(word, (*p)->word);
|
||||
if (cond < 0)
|
||||
return lookup(word, &(*p)->left);
|
||||
else if (cond > 0)
|
||||
return lookup(word, &(*p)->right);
|
||||
else
|
||||
return *p;
|
||||
}
|
||||
if (next >= MAXWORDS)
|
||||
err("out of node storage");
|
||||
words[next].count = 0;
|
||||
words[next].left = words[next].right = 0;
|
||||
words[next].word = malloc(strlen(word) + 1);
|
||||
if (words[next].word == 0)
|
||||
err("out of word storage");
|
||||
strcpy(words[next].word, word);
|
||||
return *p = &words[next++];
|
||||
if (*p) {
|
||||
cond = strcmp(word, (*p)->word);
|
||||
if (cond < 0)
|
||||
return lookup(word, &(*p)->left);
|
||||
else if (cond > 0)
|
||||
return lookup(word, &(*p)->right);
|
||||
else
|
||||
return *p;
|
||||
}
|
||||
if (next >= MAXWORDS)
|
||||
err("out of node storage");
|
||||
words[next].count = 0;
|
||||
words[next].left = words[next].right = 0;
|
||||
words[next].word = malloc(strlen(word) + 1);
|
||||
if (words[next].word == 0)
|
||||
err("out of word storage");
|
||||
strcpy(words[next].word, word);
|
||||
return *p = &words[next++];
|
||||
}
|
||||
|
||||
/* tprint - print tree */
|
||||
@@ -113,28 +113,28 @@ void tprint(tree) struct node *tree; {
|
||||
#else
|
||||
void tprint(struct node *tree) {
|
||||
#endif
|
||||
if (tree) {
|
||||
tprint(tree->left);
|
||||
printf("%d:%s\n", tree->count, tree->word);
|
||||
tprint(tree->right);
|
||||
}
|
||||
if (tree) {
|
||||
tprint(tree->left);
|
||||
printf("%d:%s\n", tree->count, tree->word);
|
||||
tprint(tree->right);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct node *root;
|
||||
char word[20];
|
||||
struct node *root;
|
||||
char word[20];
|
||||
|
||||
in = fopen("wf1.in","rb");
|
||||
if (in == NULL) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
root = 0;
|
||||
next = 0;
|
||||
while (getword(word))
|
||||
lookup(word, &root)->count++;
|
||||
tprint(root);
|
||||
root = 0;
|
||||
next = 0;
|
||||
while (getword(word))
|
||||
lookup(word, &root)->count++;
|
||||
tprint(root);
|
||||
|
||||
fclose(in);
|
||||
return 0;
|
||||
|
||||
1052
test/ref/yacc.c
1052
test/ref/yacc.c
File diff suppressed because it is too large
Load Diff
222
test/ref/yacc2.c
222
test/ref/yacc2.c
@@ -10,105 +10,105 @@
|
||||
# define YYTYPE char
|
||||
struct yywork
|
||||
{
|
||||
YYTYPE verify, advance;
|
||||
YYTYPE verify, advance;
|
||||
} yycrank[] =
|
||||
{
|
||||
{0,0}, {0,0}, {1,3}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {1,4}, {1,3},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {1,3}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {1,4}, {1,3},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
|
||||
{0,0}, {1,5}, {5,7}, {5,7},
|
||||
{5,7}, {5,7}, {5,7}, {5,7},
|
||||
{5,7}, {5,7}, {5,7}, {5,7},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {1,5}, {5,7}, {5,7},
|
||||
{5,7}, {5,7}, {5,7}, {5,7},
|
||||
{5,7}, {5,7}, {5,7}, {5,7},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
/* 0x40 */
|
||||
{0,0}, {0,0}, {1,6}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {1,6}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {0,0}, {0,0}, {0,0},
|
||||
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {0,0}, {0,0},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {0,0}, {0,0},
|
||||
|
||||
{0,0}, {0,0}, {6,8}, {0,0},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{0,0}, {0,0}, {6,8}, {0,0},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
/* 0x80 */
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {0,0}, {0,0},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {0,0}, {0,0},
|
||||
|
||||
#ifdef CHARSETHACK
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0},
|
||||
|
||||
/* 0xc0 */
|
||||
{0,0}, {0,0}, {1,6}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {1,6}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {6,8}, {6,8}, {6,8},
|
||||
{6,8}, {0,0}, {0,0}, {0,0},
|
||||
#endif
|
||||
{0,0}
|
||||
{0,0}
|
||||
};
|
||||
|
||||
struct yywork *yytop = yycrank+255;
|
||||
|
||||
int yyvstop[] =
|
||||
{
|
||||
0,4,0,3,4,0,2,4,0,1,4,0,2,0,1,0,0
|
||||
0,4,0,3,4,0,2,4,0,1,4,0,2,0,1,0,0
|
||||
};
|
||||
|
||||
struct yysvf
|
||||
{
|
||||
struct yywork *yystoff;
|
||||
struct yysvf *yyother;
|
||||
int *yystops;
|
||||
struct yywork *yystoff;
|
||||
struct yysvf *yyother;
|
||||
int *yystops;
|
||||
};
|
||||
|
||||
struct yysvf yysvec[] =
|
||||
{
|
||||
{0, 0, 0},
|
||||
{yycrank+-1, 0, 0},
|
||||
{yycrank+0, yysvec+1, 0},
|
||||
{yycrank+0, 0, yyvstop+1},
|
||||
{yycrank+0, 0, yyvstop+3},
|
||||
{yycrank+2, 0, yyvstop+6},
|
||||
{yycrank+19, 0, yyvstop+9},
|
||||
{yycrank+0, yysvec+5, yyvstop+12},
|
||||
{yycrank+0, yysvec+6, yyvstop+14},
|
||||
{0, 0, 0}
|
||||
{0, 0, 0},
|
||||
{yycrank+-1, 0, 0},
|
||||
{yycrank+0, yysvec+1, 0},
|
||||
{yycrank+0, 0, yyvstop+1},
|
||||
{yycrank+0, 0, yyvstop+3},
|
||||
{yycrank+2, 0, yyvstop+6},
|
||||
{yycrank+19, 0, yyvstop+9},
|
||||
{yycrank+0, yysvec+5, yyvstop+12},
|
||||
{yycrank+0, yysvec+6, yyvstop+14},
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
#if 0
|
||||
@@ -116,7 +116,7 @@ struct yysvf yysvec[] =
|
||||
// *yylastch++ = yych = input();
|
||||
void subtest1(void)
|
||||
{
|
||||
*yylastch++ = yych = input();
|
||||
*yylastch++ = yych = input();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -125,26 +125,26 @@ static int bog=1234;
|
||||
#if 0
|
||||
void bogus(void)
|
||||
{
|
||||
bog*=0x1234;
|
||||
bog*=0x1234;
|
||||
}
|
||||
#else
|
||||
#define bogus() bog+=0x1234
|
||||
#define bogus() bog+=0x1234
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
// yyt = yyt + yych;
|
||||
void subtest2(void)
|
||||
{
|
||||
register struct yywork *yyt;
|
||||
int yych;
|
||||
register struct yywork *yyt;
|
||||
int yych;
|
||||
|
||||
yyt=yycrank;
|
||||
yych=10;
|
||||
yyt=yycrank;
|
||||
yych=10;
|
||||
|
||||
bogus();
|
||||
yyt = yyt + yych;
|
||||
bogus();
|
||||
yyt = yyt + yych;
|
||||
|
||||
printf("yyt: %d %d\n",yyt->verify,yyt->advance);
|
||||
printf("yyt: %d %d\n",yyt->verify,yyt->advance);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -152,21 +152,21 @@ void subtest2(void)
|
||||
// if(yyt <= yytop && yyt->verify+yysvec == yystate)
|
||||
void subtest3(void)
|
||||
{
|
||||
register struct yywork *yyt;
|
||||
register struct yysvf *yystate;
|
||||
register struct yywork *yyt;
|
||||
register struct yysvf *yystate;
|
||||
|
||||
yyt=yycrank;
|
||||
yystate=yysvec;
|
||||
|
||||
bogus();
|
||||
if(yyt <= yytop && yyt->verify+yysvec == yystate)
|
||||
{
|
||||
printf("if ok %d %d\n",yyt->verify,yyt->advance);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("if not ok %d %d\n",yyt->verify,yyt->advance);
|
||||
}
|
||||
yyt=yycrank;
|
||||
yystate=yysvec;
|
||||
|
||||
bogus();
|
||||
if(yyt <= yytop && yyt->verify+yysvec == yystate)
|
||||
{
|
||||
printf("if ok %d %d\n",yyt->verify,yyt->advance);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("if not ok %d %d\n",yyt->verify,yyt->advance);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -179,19 +179,19 @@ short yyr2[]=
|
||||
// yyps -= yyr2[yyn];
|
||||
void subtest4(void)
|
||||
{
|
||||
register short *yyps, yyn;
|
||||
register short *yyps, yyn;
|
||||
|
||||
yyps=0x8004;
|
||||
yyn=0;
|
||||
yyps=0x8004;
|
||||
yyn=0;
|
||||
|
||||
while(yyn<14)
|
||||
{
|
||||
bogus();
|
||||
yyps -= yyr2[yyn];
|
||||
while(yyn<14)
|
||||
{
|
||||
bogus();
|
||||
yyps -= yyr2[yyn];
|
||||
|
||||
yyn++;
|
||||
}
|
||||
printf("yyps: %04x\n",yyps);
|
||||
yyn++;
|
||||
}
|
||||
printf("yyps: %04x\n",yyps);
|
||||
}
|
||||
|
||||
#if 1
|
||||
@@ -199,21 +199,21 @@ void subtest4(void)
|
||||
int yylookret=10;
|
||||
yylook()
|
||||
{
|
||||
yylookret--;
|
||||
return yylookret;
|
||||
yylookret--;
|
||||
return yylookret;
|
||||
}
|
||||
|
||||
// while((nstr = yylook()) >= 0)
|
||||
void subtest5(void)
|
||||
{
|
||||
int nstr;
|
||||
int nstr;
|
||||
|
||||
bogus();
|
||||
while((nstr = yylook()) >= 0)
|
||||
{
|
||||
printf("nstr: %04x\n",nstr);
|
||||
bogus();
|
||||
}
|
||||
bogus();
|
||||
while((nstr = yylook()) >= 0)
|
||||
{
|
||||
printf("nstr: %04x\n",nstr);
|
||||
bogus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user