/* */
/* */
/* */
-/* (C) 1998-2011, Ullrich von Bassewitz */
+/* (C) 1998-2012, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
#include <string.h>
#include <ctype.h>
#include <errno.h>
-#include <sys/types.h> /* EMX needs this */
-#include <sys/stat.h>
/* common */
#include "alignment.h"
#include "bitops.h"
#include "cddefs.h"
#include "coll.h"
+#include "filestat.h"
#include "gentype.h"
#include "intstack.h"
#include "scopedefs.h"
#include "incpath.h"
#include "instr.h"
#include "listing.h"
-#include "macpack.h"
#include "macro.h"
#include "nexttok.h"
#include "objcode.h"
/* Parse arguments */
while (1) {
- if (GetCPU() == CPU_65816) {
- EmitWord (GenWordExpr (Expression ()));
- } else {
+ ExprNode* Expr = Expression ();
+ if (GetCPU () == CPU_65816 || ForceRange) {
/* Do a range check */
- EmitWord (Expression ());
- }
+ Expr = GenWordExpr (Expr);
+ }
+ EmitWord (Expr);
if (CurTok.Tok != TOK_COMMA) {
break;
} else {
EmitStrBuf (&CurTok.SVal);
NextTok ();
} else {
- EmitByte (Expression ());
+ EmitByte (BoundedExpr (Expression, 1));
}
if (CurTok.Tok != TOK_COMMA) {
break;
/* Do smart handling of dangling comma */
if (CurTok.Tok == TOK_SEP) {
Error ("Unexpected end of line");
- break;
+ break;
}
}
}
/* Read the index as numerical value */
Index = ConstExpression ();
- if (Index < 0 || Index > 255) {
+ if (Index <= 0 || Index > 255) {
/* Value out of range */
ErrorSkip ("Range error");
return;
/* Parse arguments */
while (1) {
- EmitWord (GenSwapExpr (Expression ()));
+ EmitWord (GenSwapExpr (BoundedExpr (Expression, 2)));
if (CurTok.Tok != TOK_COMMA) {
break;
} else {
/* Define dwords */
{
while (1) {
- EmitDWord (Expression ());
+ EmitDWord (BoundedExpr (Expression, 4));
if (CurTok.Tok != TOK_COMMA) {
break;
} else {
/* Parse arguments */
while (1) {
- EmitFarAddr (Expression ());
+ EmitFarAddr (BoundedExpr (Expression, 3));
if (CurTok.Tok != TOK_COMMA) {
break;
} else {
* here.
*/
SB_Terminate (&Name);
- if (stat (SB_GetConstBuf (&Name), &StatBuf) != 0) {
+ if (FileStat (SB_GetConstBuf (&Name), &StatBuf) != 0) {
Fatal ("Cannot stat input file `%m%p': %s", &Name, strerror (errno));
}
static void DoMacPack (void)
/* Insert a macro package */
{
- int Package;
-
/* We expect an identifier */
if (CurTok.Tok != TOK_IDENT) {
ErrorSkip ("Identifier expected");
- return;
- }
-
- /* Search for the macro package name */
- LocaseSVal ();
- Package = MacPackFind (&CurTok.SVal);
- if (Package < 0) {
- /* Not found */
- ErrorSkip ("Invalid macro package");
- return;
- }
-
- /* Insert the package. If this fails, skip the remainder of the line to
- * avoid additional error messages.
- */
- if (MacPackInsert (Package) == 0) {
- SkipUntilSep ();
+ } else {
+ SB_AppendStr (&CurTok.SVal, ".mac");
+ SB_Terminate (&CurTok.SVal);
+ if (NewInputFile (SB_GetConstBuf (&CurTok.SVal)) == 0) {
+ /* Error opening the file, skip remainder of line */
+ SkipUntilSep ();
+ }
}
}
/* Parse arguments */
while (1) {
- EmitWord (Expression ());
+ EmitWord (BoundedExpr (Expression, 2));
if (CurTok.Tok != TOK_COMMA) {
break;
} else {
/* Control commands flags */
enum {
- ccNone = 0x0000, /* No special flags */
- ccKeepToken = 0x0001 /* Do not skip the current token */
+ ccNone = 0x0000, /* No special flags */
+ ccKeepToken = 0x0001 /* Do not skip the current token */
};
/* Control command table */
typedef struct CtrlDesc CtrlDesc;
struct CtrlDesc {
- unsigned Flags; /* Flags for this directive */
+ unsigned Flags; /* Flags for this directive */
void (*Handler) (void); /* Command handler */
};