Fix line endings (CRLF -> LF) on all affected files.
This commit is contained in:
@@ -1,38 +1,38 @@
|
||||
/*
|
||||
!!DESCRIPTION!! div/mod test
|
||||
!!ORIGIN!!
|
||||
!!LICENCE!! public domain
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
/*
|
||||
!!DESCRIPTION!! div/mod test
|
||||
!!ORIGIN!!
|
||||
!!LICENCE!! public domain
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
190
test/ref/init.c
190
test/ref/init.c
@@ -1,95 +1,95 @@
|
||||
/*
|
||||
!!DESCRIPTION!! variable initialization
|
||||
!!ORIGIN!! LCC 4.1 Testsuite
|
||||
!!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
/* todo: add back conditional stuff here ! */
|
||||
|
||||
typedef struct { int codes[3]; char name[6]; } Word;
|
||||
|
||||
#ifdef NO_IMPLICIT_FUNC_PROTOTYPES
|
||||
|
||||
#ifdef NO_OLD_FUNC_DECL
|
||||
f();
|
||||
void g(Word *p);
|
||||
h();
|
||||
#else
|
||||
f();
|
||||
g();
|
||||
h();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
Word words[] = {
|
||||
1, 2, 3,"if",
|
||||
{ { 4, 5 }, { 'f', 'o', 'r' } },
|
||||
6, 7, 8, {"else"},
|
||||
{ { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', },
|
||||
{ 0 },
|
||||
}, *wordlist = words;
|
||||
*/
|
||||
|
||||
Word words[] = {
|
||||
{{1, 2, 3},"if"},
|
||||
{ { 4, 5 }, { 'f', 'o', 'r' } },
|
||||
{{6, 7, 8}, "else"},
|
||||
{ { 9, 10, 11}, {'w', 'h', 'i', 'l', 'e', }},
|
||||
{{ 0 }},
|
||||
}, *wordlist = words;
|
||||
|
||||
/*int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };*/
|
||||
int x[][5] = { {1, 2, 3, 4, 0 }, { 5, 6 }, { 7 } };
|
||||
int *y[] = { x[0], x[1], x[2], 0 };
|
||||
|
||||
main()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
f() {
|
||||
static char *keywords[] = {"if", "for", "else", "while", 0, };
|
||||
char **p;
|
||||
|
||||
for (p = keywords; *p; p++)
|
||||
printf("%s\n", *p);
|
||||
}
|
||||
|
||||
#ifdef NO_OLD_FUNC_DECL
|
||||
void g(Word *p)
|
||||
#else
|
||||
g(p)
|
||||
Word *p;
|
||||
#endif
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
h()
|
||||
{
|
||||
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]);
|
||||
}
|
||||
/*
|
||||
!!DESCRIPTION!! variable initialization
|
||||
!!ORIGIN!! LCC 4.1 Testsuite
|
||||
!!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
/* todo: add back conditional stuff here ! */
|
||||
|
||||
typedef struct { int codes[3]; char name[6]; } Word;
|
||||
|
||||
#ifdef NO_IMPLICIT_FUNC_PROTOTYPES
|
||||
|
||||
#ifdef NO_OLD_FUNC_DECL
|
||||
f();
|
||||
void g(Word *p);
|
||||
h();
|
||||
#else
|
||||
f();
|
||||
g();
|
||||
h();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
Word words[] = {
|
||||
1, 2, 3,"if",
|
||||
{ { 4, 5 }, { 'f', 'o', 'r' } },
|
||||
6, 7, 8, {"else"},
|
||||
{ { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', },
|
||||
{ 0 },
|
||||
}, *wordlist = words;
|
||||
*/
|
||||
|
||||
Word words[] = {
|
||||
{{1, 2, 3},"if"},
|
||||
{ { 4, 5 }, { 'f', 'o', 'r' } },
|
||||
{{6, 7, 8}, "else"},
|
||||
{ { 9, 10, 11}, {'w', 'h', 'i', 'l', 'e', }},
|
||||
{{ 0 }},
|
||||
}, *wordlist = words;
|
||||
|
||||
/*int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };*/
|
||||
int x[][5] = { {1, 2, 3, 4, 0 }, { 5, 6 }, { 7 } };
|
||||
int *y[] = { x[0], x[1], x[2], 0 };
|
||||
|
||||
main()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
f() {
|
||||
static char *keywords[] = {"if", "for", "else", "while", 0, };
|
||||
char **p;
|
||||
|
||||
for (p = keywords; *p; p++)
|
||||
printf("%s\n", *p);
|
||||
}
|
||||
|
||||
#ifdef NO_OLD_FUNC_DECL
|
||||
void g(Word *p)
|
||||
#else
|
||||
g(p)
|
||||
Word *p;
|
||||
#endif
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
h()
|
||||
{
|
||||
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]);
|
||||
}
|
||||
|
||||
@@ -1,112 +1,112 @@
|
||||
/*
|
||||
!!DESCRIPTION!! pointer test
|
||||
!!ORIGIN!!
|
||||
!!LICENCE!! public domain
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
check behaviour on incompletely declared arrays
|
||||
*/
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
check behaviour on string init
|
||||
*/
|
||||
|
||||
char t1[]="abcde";
|
||||
char t2[]={"abcde"};
|
||||
|
||||
char *t3="abcde";
|
||||
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");
|
||||
}
|
||||
|
||||
/*
|
||||
check behaviour on extern-declarations inside functions
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
void *func;
|
||||
} A3;
|
||||
|
||||
#ifdef NO_SLOPPY_STRUCT_INIT
|
||||
A3 a3[] = {
|
||||
{ "test3", (void*) NULL },
|
||||
{ "test3", (void*) NULL },
|
||||
};
|
||||
#else
|
||||
/*gcc warning: missing braces around initializer (near initialization for `a3[0]')
|
||||
this type of struct-initialization seems to be kinda common */
|
||||
A3 a3[] = {
|
||||
"test3", (void*) NULL ,
|
||||
"test3", (void*) NULL ,
|
||||
};
|
||||
#endif
|
||||
|
||||
void test3a(A3 *list, int number){
|
||||
printf("%s %d\n",list->name,number);
|
||||
}
|
||||
|
||||
static void test31(void)
|
||||
{
|
||||
extern A3 a3[];
|
||||
test3a(a3, -1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* this variation compiles and works with cc65, but gives an error with gcc :=P */
|
||||
static void test32(void)
|
||||
{
|
||||
extern A3 *a3;
|
||||
test3a(a3, -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void test30(void)
|
||||
{
|
||||
test3a(a3, -1);
|
||||
}
|
||||
|
||||
/*
|
||||
todo: add test on function pointers in the form of (*func)(arg) ...
|
||||
cc65 seems to have problems here aswell ;/
|
||||
*/
|
||||
|
||||
int main(void) {
|
||||
test1();
|
||||
test2();
|
||||
test30();
|
||||
test31();
|
||||
/* test32(); */
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
!!DESCRIPTION!! pointer test
|
||||
!!ORIGIN!!
|
||||
!!LICENCE!! public domain
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
check behaviour on incompletely declared arrays
|
||||
*/
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
check behaviour on string init
|
||||
*/
|
||||
|
||||
char t1[]="abcde";
|
||||
char t2[]={"abcde"};
|
||||
|
||||
char *t3="abcde";
|
||||
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");
|
||||
}
|
||||
|
||||
/*
|
||||
check behaviour on extern-declarations inside functions
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
void *func;
|
||||
} A3;
|
||||
|
||||
#ifdef NO_SLOPPY_STRUCT_INIT
|
||||
A3 a3[] = {
|
||||
{ "test3", (void*) NULL },
|
||||
{ "test3", (void*) NULL },
|
||||
};
|
||||
#else
|
||||
/*gcc warning: missing braces around initializer (near initialization for `a3[0]')
|
||||
this type of struct-initialization seems to be kinda common */
|
||||
A3 a3[] = {
|
||||
"test3", (void*) NULL ,
|
||||
"test3", (void*) NULL ,
|
||||
};
|
||||
#endif
|
||||
|
||||
void test3a(A3 *list, int number){
|
||||
printf("%s %d\n",list->name,number);
|
||||
}
|
||||
|
||||
static void test31(void)
|
||||
{
|
||||
extern A3 a3[];
|
||||
test3a(a3, -1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* this variation compiles and works with cc65, but gives an error with gcc :=P */
|
||||
static void test32(void)
|
||||
{
|
||||
extern A3 *a3;
|
||||
test3a(a3, -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void test30(void)
|
||||
{
|
||||
test3a(a3, -1);
|
||||
}
|
||||
|
||||
/*
|
||||
todo: add test on function pointers in the form of (*func)(arg) ...
|
||||
cc65 seems to have problems here aswell ;/
|
||||
*/
|
||||
|
||||
int main(void) {
|
||||
test1();
|
||||
test2();
|
||||
test30();
|
||||
test31();
|
||||
/* test32(); */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,262 +1,262 @@
|
||||
/*
|
||||
!!DESCRIPTION!! switch test
|
||||
!!ORIGIN!!
|
||||
!!LICENCE!! public domain
|
||||
*/
|
||||
|
||||
/*#define STANDALONE*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
!!DESCRIPTION!! switch test
|
||||
!!ORIGIN!!
|
||||
!!LICENCE!! public domain
|
||||
*/
|
||||
|
||||
/*#define STANDALONE*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void testlimits(int i) {
|
||||
printf("%d:",i);
|
||||
|
||||
printf("%d:",i);
|
||||
|
||||
switch(i) {
|
||||
case -1: /* works */
|
||||
/* case 0xffff: */ /* 'range error' (-1) */
|
||||
|
||||
printf("-1\n");
|
||||
break;
|
||||
/* max int */
|
||||
|
||||
/* case 0x7fff: */ /* works */
|
||||
case 32767: /* works */
|
||||
/* case 32768: */ /* 'range error' (correct for that one!) */
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
void testdefault1(unsigned char i) {
|
||||
/* we want a signed char */
|
||||
#ifdef REFCC
|
||||
|
||||
#ifdef REFCC_UNSIGNED_CHARS
|
||||
signed char k;
|
||||
#else
|
||||
char k;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef UNSIGNED_CHARS
|
||||
signed char k;
|
||||
#else
|
||||
char k;
|
||||
#endif
|
||||
|
||||
#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 */
|
||||
|
||||
/*
|
||||
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) {
|
||||
/* we want a unsigned char */
|
||||
#ifdef REFCC
|
||||
|
||||
#ifdef REFCC_UNSIGNED_CHARS
|
||||
char k;
|
||||
#else
|
||||
unsigned char k;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef UNSIGNED_CHARS
|
||||
char k;
|
||||
#else
|
||||
unsigned char k;
|
||||
#endif
|
||||
|
||||
#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 ? */
|
||||
|
||||
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 -1: /* works */
|
||||
/* case 0xffff: */ /* 'range error' (-1) */
|
||||
|
||||
printf("-1\n");
|
||||
break;
|
||||
/* max int */
|
||||
|
||||
/* case 0x7fff: */ /* works */
|
||||
case 32767: /* works */
|
||||
/* case 32768: */ /* 'range error' (correct for that one!) */
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
void testdefault1(unsigned char i) {
|
||||
/* we want a signed char */
|
||||
#ifdef REFCC
|
||||
|
||||
#ifdef REFCC_UNSIGNED_CHARS
|
||||
signed char k;
|
||||
#else
|
||||
char k;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef UNSIGNED_CHARS
|
||||
signed char k;
|
||||
#else
|
||||
char k;
|
||||
#endif
|
||||
|
||||
#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 */
|
||||
|
||||
/*
|
||||
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) {
|
||||
/* we want a unsigned char */
|
||||
#ifdef REFCC
|
||||
|
||||
#ifdef REFCC_UNSIGNED_CHARS
|
||||
char k;
|
||||
#else
|
||||
unsigned char k;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef UNSIGNED_CHARS
|
||||
char k;
|
||||
#else
|
||||
unsigned char k;
|
||||
#endif
|
||||
|
||||
#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 ? */
|
||||
|
||||
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);
|
||||
|
||||
return 0;
|
||||
}
|
||||
testlimits(32767);
|
||||
testlimits(-32768);
|
||||
testlimits(-1);
|
||||
|
||||
testdefault1(1);
|
||||
testdefault1(2);
|
||||
testdefault1(3);
|
||||
testdefault1(4);
|
||||
|
||||
testdefault2(1);
|
||||
testdefault2(2);
|
||||
testdefault2(3);
|
||||
testdefault2(4);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,105 +1,105 @@
|
||||
/*
|
||||
!!DESCRIPTION!! varargs test
|
||||
!!ORIGIN!!
|
||||
!!LICENCE!! public domain
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void chk0(char *format,...);
|
||||
void chk1(int fd,char *format,...);
|
||||
|
||||
#if 0
|
||||
// old workaround for broken varargs
|
||||
|
||||
void chk0(char *format,...){
|
||||
__asm__ ("pha"); // save argument size
|
||||
{
|
||||
//va_list ap;
|
||||
char *ap;
|
||||
char *_format;
|
||||
static char string[0x100];
|
||||
|
||||
// va_start(ap,format);
|
||||
__asm__ ("pla"); // restore argument size
|
||||
__asm__ ("ldx #$00"); // clear hibyte of AX
|
||||
ap=__AX__;
|
||||
ap+=(char*)&format;
|
||||
// get value of format
|
||||
ap-=2;
|
||||
_format=*((char**)ap);
|
||||
|
||||
// vsprintf(string,format,ap);
|
||||
vsprintf(&string[0],_format,ap);
|
||||
printf("format:%s,string:%s\n",_format,string);
|
||||
// va_end(ap);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void chk1(int fd,char *format,...){
|
||||
__asm__ ("pha"); // save argument size
|
||||
{
|
||||
//va_list ap;
|
||||
char *ap;
|
||||
char *_format;
|
||||
int _fd;
|
||||
static char string[0x100];
|
||||
|
||||
// va_start(ap,format);
|
||||
__asm__ ("pla"); // restore argument size
|
||||
__asm__ ("ldx #$00"); // clear hibyte of AX
|
||||
ap=__AX__;
|
||||
ap+=(char*)&format;
|
||||
// get value of fd
|
||||
ap-=2;
|
||||
_fd=*((int*)ap);
|
||||
// get value of format
|
||||
ap-=2;
|
||||
_format=*((char**)ap);
|
||||
|
||||
// vsprintf(string,format,ap);
|
||||
vsprintf(&string[0],_format,ap);
|
||||
printf("fd:%d,format:%s,string:%s\n",_fd,_format,string);
|
||||
// va_end(ap);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void chk0(char *format,...){
|
||||
va_list ap;
|
||||
static char string[0x100];
|
||||
va_start(ap,format);
|
||||
vsprintf(string,format,ap);
|
||||
printf("format:%s,string:%s\n",format,string);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void chk1(int fd,char *format,...){
|
||||
va_list ap;
|
||||
static char string[0x100];
|
||||
|
||||
va_start(ap,format);
|
||||
|
||||
vsprintf(string,format,ap);
|
||||
printf("fd:%d,format:%s,string:%s\n",fd,format,string);
|
||||
va_end(ap);
|
||||
!!DESCRIPTION!! varargs test
|
||||
!!ORIGIN!!
|
||||
!!LICENCE!! public domain
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void chk0(char *format,...);
|
||||
void chk1(int fd,char *format,...);
|
||||
|
||||
#if 0
|
||||
// old workaround for broken varargs
|
||||
|
||||
void chk0(char *format,...){
|
||||
__asm__ ("pha"); // save argument size
|
||||
{
|
||||
//va_list ap;
|
||||
char *ap;
|
||||
char *_format;
|
||||
static char string[0x100];
|
||||
|
||||
// va_start(ap,format);
|
||||
__asm__ ("pla"); // restore argument size
|
||||
__asm__ ("ldx #$00"); // clear hibyte of AX
|
||||
ap=__AX__;
|
||||
ap+=(char*)&format;
|
||||
// get value of format
|
||||
ap-=2;
|
||||
_format=*((char**)ap);
|
||||
|
||||
// vsprintf(string,format,ap);
|
||||
vsprintf(&string[0],_format,ap);
|
||||
printf("format:%s,string:%s\n",_format,string);
|
||||
// va_end(ap);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc,char **argv) {
|
||||
printf("varargs test\n");
|
||||
|
||||
printf("\nchk0/0:\n");chk0("chk0 %s","arg0");
|
||||
printf("\nchk0/1:\n");chk0("chk0 %s %s","arg0","arg1");
|
||||
printf("\nchk0/2:\n");chk0("chk0 %s %s %s","arg0","arg1","arg2");
|
||||
|
||||
printf("\nchk1/0:\n");chk1(0xfd,"chk1 %s","arg0");
|
||||
printf("\nchk1/1:\n");chk1(0xfd,"chk1 %s %s","arg0","arg1");
|
||||
printf("\nchk1/2:\n");chk1(0xfd,"chk1 %s %s %s","arg0","arg1","arg2");
|
||||
|
||||
void chk1(int fd,char *format,...){
|
||||
__asm__ ("pha"); // save argument size
|
||||
{
|
||||
//va_list ap;
|
||||
char *ap;
|
||||
char *_format;
|
||||
int _fd;
|
||||
static char string[0x100];
|
||||
|
||||
// va_start(ap,format);
|
||||
__asm__ ("pla"); // restore argument size
|
||||
__asm__ ("ldx #$00"); // clear hibyte of AX
|
||||
ap=__AX__;
|
||||
ap+=(char*)&format;
|
||||
// get value of fd
|
||||
ap-=2;
|
||||
_fd=*((int*)ap);
|
||||
// get value of format
|
||||
ap-=2;
|
||||
_format=*((char**)ap);
|
||||
|
||||
// vsprintf(string,format,ap);
|
||||
vsprintf(&string[0],_format,ap);
|
||||
printf("fd:%d,format:%s,string:%s\n",_fd,_format,string);
|
||||
// va_end(ap);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void chk0(char *format,...){
|
||||
va_list ap;
|
||||
static char string[0x100];
|
||||
va_start(ap,format);
|
||||
vsprintf(string,format,ap);
|
||||
printf("format:%s,string:%s\n",format,string);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void chk1(int fd,char *format,...){
|
||||
va_list ap;
|
||||
static char string[0x100];
|
||||
|
||||
va_start(ap,format);
|
||||
|
||||
vsprintf(string,format,ap);
|
||||
printf("fd:%d,format:%s,string:%s\n",fd,format,string);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
int main(int argc,char **argv) {
|
||||
printf("varargs test\n");
|
||||
|
||||
printf("\nchk0/0:\n");chk0("chk0 %s","arg0");
|
||||
printf("\nchk0/1:\n");chk0("chk0 %s %s","arg0","arg1");
|
||||
printf("\nchk0/2:\n");chk0("chk0 %s %s %s","arg0","arg1","arg2");
|
||||
|
||||
printf("\nchk1/0:\n");chk1(0xfd,"chk1 %s","arg0");
|
||||
printf("\nchk1/1:\n");chk1(0xfd,"chk1 %s %s","arg0","arg1");
|
||||
printf("\nchk1/2:\n");chk1(0xfd,"chk1 %s %s %s","arg0","arg1","arg2");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user