mirror of
https://github.com/cc65/cc65.git
synced 2025-01-14 16:33:00 +00:00
Fixed geos portion of Makefile
git-svn-id: svn://svn.cc65.org/cc65/trunk@780 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
49376daf0d
commit
5e14218975
@ -111,7 +111,13 @@ cbm610lib:
|
|||||||
# GEOS on the C64/128
|
# GEOS on the C64/128
|
||||||
|
|
||||||
geoslib:
|
geoslib:
|
||||||
for i in geos common runtime; do \
|
CC=$(CC) \
|
||||||
|
AS=../$(AS) \
|
||||||
|
AR=../$(AR) \
|
||||||
|
CFLAGS="-Osir -g -t geos -I../../include" \
|
||||||
|
AFLAGS="-t geos" \
|
||||||
|
$(MAKE) -C geos || exit 1
|
||||||
|
for i in common runtime; do \
|
||||||
CC=$(CC) \
|
CC=$(CC) \
|
||||||
AS=$(AS) \
|
AS=$(AS) \
|
||||||
AR=$(AR) \
|
AR=$(AR) \
|
||||||
|
@ -36,9 +36,19 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static struct indesc* D; /* Copy of function argument */
|
||||||
|
static va_list ap; /* Copy of function argument */
|
||||||
static jmp_buf JumpBuf; /* Label that is used in case of EOF */
|
static jmp_buf JumpBuf; /* Label that is used in case of EOF */
|
||||||
static char C; /* Character from input */
|
static char C; /* Character from input */
|
||||||
static unsigned Width; /* Maximum field width */
|
static unsigned Width; /* Maximum field width */
|
||||||
|
static long IntVal; /* Converted int value */
|
||||||
|
static unsigned Conversions; /* Number of conversions */
|
||||||
|
|
||||||
|
/* Flags */
|
||||||
|
static unsigned char Positive; /* Flag for positive value */
|
||||||
|
static unsigned char NoAssign; /* Supppress assigment */
|
||||||
|
static unsigned char IsShort; /* Short type */
|
||||||
|
static unsigned char IsLong; /* Long type */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -54,39 +64,39 @@ static unsigned Width; /* Maximum field width */
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ReadChar (struct indesc* d)
|
static void ReadChar (void)
|
||||||
/* Get an input character, count characters */
|
/* Get an input character, count characters */
|
||||||
{
|
{
|
||||||
C = d->fin (d);
|
C = D->fin (D);
|
||||||
++d->ccount;
|
++D->ccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void SkipWhite (struct indesc* d)
|
static void SkipWhite (void)
|
||||||
/* Skip white space in the input and return the first non white character */
|
/* Skip white space in the input and return the first non white character */
|
||||||
{
|
{
|
||||||
while (isspace (C)) {
|
while (isspace (C)) {
|
||||||
ReadChar (d);
|
ReadChar ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned char ReadSign (struct indesc* d)
|
static void ReadSign (void)
|
||||||
/* Read an optional sign and skip it. Return 1 if the value is positive,
|
/* Read an optional sign and skip it. Store 1 in Positive if the value is
|
||||||
* return 0 otherwise.
|
* positive, store 0 otherwise.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
switch (C) {
|
switch (C) {
|
||||||
case '-':
|
case '-':
|
||||||
ReadChar (d);
|
ReadChar ();
|
||||||
return 0;
|
Positive = 0;
|
||||||
case '+':
|
case '+':
|
||||||
ReadChar (d);
|
ReadChar ();
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
default:
|
default:
|
||||||
return 1;
|
Positive = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,51 +115,71 @@ static unsigned char HexVal (char C)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned long ReadInt (struct indesc* d, unsigned char Base)
|
static void ReadInt (unsigned char Base)
|
||||||
/* Read an integer */
|
/* Read an integer and store it into IntVal */
|
||||||
{
|
{
|
||||||
unsigned long V = 0;
|
|
||||||
|
|
||||||
/* Value must start with a digit */
|
/* Value must start with a digit */
|
||||||
if (!isdigit (C)) {
|
if (!isdigit (C)) {
|
||||||
longjmp (JumpBuf, RC_NOCONV);
|
longjmp (JumpBuf, RC_NOCONV);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the value */
|
/* Read the value */
|
||||||
|
IntVal = 0;
|
||||||
while (isxdigit (C) && Width-- > 0) {
|
while (isxdigit (C) && Width-- > 0) {
|
||||||
printf ("ReadInt: '%c'\n", C);
|
printf ("ReadInt: '%c'\n", C);
|
||||||
V = V * Base + HexVal (C);
|
IntVal = IntVal * Base + HexVal (C);
|
||||||
ReadChar (d);
|
ReadChar ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the read value */
|
/* One more conversion */
|
||||||
return V;
|
++Conversions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int _scanf (struct indesc* d, const char* format, va_list ap)
|
static void AssignInt (void)
|
||||||
|
/* Assign the integer value in Val to the next argument. The function makes
|
||||||
|
* several non portable assumptions to reduce code size:
|
||||||
|
* - int and unsigned types have the same representation
|
||||||
|
* - short and int have the same representation.
|
||||||
|
* - all pointer types have the same representation.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
if (!NoAssign) {
|
||||||
|
/* Get the next argument pointer */
|
||||||
|
void* P = va_arg (ap, void*);
|
||||||
|
|
||||||
|
/* Assign to the converted value */
|
||||||
|
if (IsLong) {
|
||||||
|
*(long*)P = IntVal;
|
||||||
|
} else {
|
||||||
|
*(int*)P = (int) IntVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _scanf (struct indesc* D_, const char* format, va_list ap_)
|
||||||
/* This is the routine used to do the actual work. It is called from several
|
/* This is the routine used to do the actual work. It is called from several
|
||||||
* types of wrappers to implement the actual ISO xxscanf functions.
|
* types of wrappers to implement the actual ISO xxscanf functions.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
unsigned Conversions; /* Number of conversions */
|
|
||||||
|
|
||||||
char F; /* Character from format string */
|
char F; /* Character from format string */
|
||||||
unsigned char NoAssign; /* Supppress assigment */
|
|
||||||
unsigned char IsShort; /* Short type */
|
|
||||||
unsigned char IsLong; /* Long type */
|
|
||||||
unsigned char Positive; /* Flag for positive value */
|
|
||||||
unsigned char Result; /* setjmp result */
|
unsigned char Result; /* setjmp result */
|
||||||
|
char* S;
|
||||||
|
unsigned char Base; /* Integer base in %i */
|
||||||
|
|
||||||
/* Variables that hold intermediate values */
|
/* Place copies of the arguments into global variables. This is not very
|
||||||
void* P;
|
* nice, but on a 6502 platform it gives better code, since the values
|
||||||
long L;
|
* do not have to be passed as parameters.
|
||||||
|
*/
|
||||||
|
D = D_;
|
||||||
|
ap = ap_;
|
||||||
|
|
||||||
/* Initialize variables */
|
/* Initialize variables */
|
||||||
Conversions = 0;
|
Conversions = 0;
|
||||||
d->ccount = 0;
|
D->ccount = 0;
|
||||||
|
|
||||||
/* Set up the jump label. The get() routine will use this label when EOF
|
/* Set up the jump label. The get() routine will use this label when EOF
|
||||||
* is reached.
|
* is reached.
|
||||||
@ -160,7 +190,7 @@ int _scanf (struct indesc* d, const char* format, va_list ap)
|
|||||||
|
|
||||||
Again:
|
Again:
|
||||||
/* Get the next input character */
|
/* Get the next input character */
|
||||||
ReadChar (d);
|
ReadChar ();
|
||||||
|
|
||||||
/* Walk over the format string */
|
/* Walk over the format string */
|
||||||
while (F = *format++) {
|
while (F = *format++) {
|
||||||
@ -180,7 +210,7 @@ Again:
|
|||||||
* any amount of whitespace including none(!). So this
|
* any amount of whitespace including none(!). So this
|
||||||
* match will never fail.
|
* match will never fail.
|
||||||
*/
|
*/
|
||||||
SkipWhite (d);
|
SkipWhite ();
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else if (F != C) {
|
} else if (F != C) {
|
||||||
@ -239,76 +269,60 @@ FlagsDone:
|
|||||||
IsLong = 1;
|
IsLong = 1;
|
||||||
case 'd':
|
case 'd':
|
||||||
/* Optionally signed decimal integer */
|
/* Optionally signed decimal integer */
|
||||||
SkipWhite (d);
|
SkipWhite ();
|
||||||
Positive = ReadSign (d);
|
ReadSign ();
|
||||||
L = ReadInt (d, 10);
|
ReadInt (10);
|
||||||
if (!Positive) {
|
if (!Positive) {
|
||||||
L = -L;
|
IntVal = -IntVal;
|
||||||
}
|
|
||||||
if (!NoAssign) {
|
|
||||||
/* All pointers have the same size, so save some
|
|
||||||
* code here.
|
|
||||||
*/
|
|
||||||
P = va_arg (ap, void*);
|
|
||||||
if (IsLong) {
|
|
||||||
*(long*)P = L;
|
|
||||||
} else {
|
|
||||||
*(int*)P = (int) L;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
AssignInt ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
/* Optionally signed integer with a base */
|
/* Optionally signed integer with a base */
|
||||||
|
SkipWhite ();
|
||||||
|
ReadSign ();
|
||||||
|
if (C == '0') {
|
||||||
|
ReadChar ();
|
||||||
|
switch (C) {
|
||||||
|
case 'x':
|
||||||
|
case 'X':
|
||||||
|
Base = 16;
|
||||||
|
ReadChar();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Base = 8;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Base = 10;
|
||||||
|
}
|
||||||
|
ReadInt (Base);
|
||||||
|
if (!Positive) {
|
||||||
|
IntVal = -IntVal;
|
||||||
|
}
|
||||||
|
AssignInt ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
/* Unsigned octal integer */
|
/* Unsigned octal integer */
|
||||||
L = ReadInt (d, 8);
|
SkipWhite ();
|
||||||
if (!NoAssign) {
|
ReadInt (8);
|
||||||
/* All pointers have the same size, so save some
|
AssignInt ();
|
||||||
* code here.
|
|
||||||
*/
|
|
||||||
P = va_arg (ap, void*);
|
|
||||||
if (IsLong) {
|
|
||||||
*(long*)P = L;
|
|
||||||
} else {
|
|
||||||
*(int*)P = (int) L;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
/* Unsigned decimal integer */
|
/* Unsigned decimal integer */
|
||||||
L = ReadInt (d, 10);
|
SkipWhite ();
|
||||||
if (!NoAssign) {
|
ReadInt (10);
|
||||||
/* All pointers have the same size, so save some
|
AssignInt ();
|
||||||
* code here.
|
|
||||||
*/
|
|
||||||
P = va_arg (ap, void*);
|
|
||||||
if (IsLong) {
|
|
||||||
*(long*)P = L;
|
|
||||||
} else {
|
|
||||||
*(int*)P = (int) L;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
case 'X':
|
case 'X':
|
||||||
/* Unsigned hexadecimal integer */
|
/* Unsigned hexadecimal integer */
|
||||||
L = ReadInt (d, 16);
|
SkipWhite ();
|
||||||
if (!NoAssign) {
|
ReadInt (16);
|
||||||
/* All pointers have the same size, so save some
|
AssignInt ();
|
||||||
* code here.
|
|
||||||
*/
|
|
||||||
P = va_arg (ap, void*);
|
|
||||||
if (IsLong) {
|
|
||||||
*(long*)P = L;
|
|
||||||
} else {
|
|
||||||
*(int*)P = (int) L;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'E':
|
case 'E':
|
||||||
@ -320,6 +334,14 @@ FlagsDone:
|
|||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
/* Whitespace terminated string */
|
/* Whitespace terminated string */
|
||||||
|
SkipWhite ();
|
||||||
|
S = NoAssign? 0 : va_arg (ap, char*);
|
||||||
|
while (C && !isspace (C) && Width--) {
|
||||||
|
if (S) {
|
||||||
|
*S++ = C;
|
||||||
|
}
|
||||||
|
ReadChar ();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
@ -336,6 +358,9 @@ FlagsDone:
|
|||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
/* Store characters consumed so far */
|
/* Store characters consumed so far */
|
||||||
|
IntVal = D->ccount;
|
||||||
|
IsLong = 0;
|
||||||
|
AssignInt ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -354,7 +379,7 @@ FlagsDone:
|
|||||||
} else if (Result == RC_EOF) {
|
} else if (Result == RC_EOF) {
|
||||||
|
|
||||||
/* Jump via JumpBuf means EOF on input */
|
/* Jump via JumpBuf means EOF on input */
|
||||||
if (d->ccount == 0) {
|
if (D->ccount == 0) {
|
||||||
/* Special case: error */
|
/* Special case: error */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user