Remove io.*, some cleanup
git-svn-id: svn://svn.cc65.org/cc65/trunk@87 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -45,7 +45,6 @@
|
|||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "io.h"
|
|
||||||
#include "litpool.h"
|
#include "litpool.h"
|
||||||
#include "optimize.h"
|
#include "optimize.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|||||||
@@ -45,7 +45,6 @@
|
|||||||
#include "function.h"
|
#include "function.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "incpath.h"
|
#include "incpath.h"
|
||||||
#include "io.h"
|
|
||||||
#include "litpool.h"
|
#include "litpool.h"
|
||||||
#include "macrotab.h"
|
#include "macrotab.h"
|
||||||
#include "pragma.h"
|
#include "pragma.h"
|
||||||
@@ -66,7 +65,6 @@ static void Parse (void)
|
|||||||
int comma;
|
int comma;
|
||||||
SymEntry* Entry;
|
SymEntry* Entry;
|
||||||
|
|
||||||
kill ();
|
|
||||||
NextToken (); /* "prime" the pump */
|
NextToken (); /* "prime" the pump */
|
||||||
NextToken ();
|
NextToken ();
|
||||||
while (curtok != TOK_CEOF) {
|
while (curtok != TOK_CEOF) {
|
||||||
|
|||||||
@@ -39,7 +39,6 @@
|
|||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "io.h"
|
|
||||||
#include "scanner.h"
|
#include "scanner.h"
|
||||||
#include "stmt.h"
|
#include "stmt.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include "funcdesc.h"
|
#include "funcdesc.h"
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "io.h"
|
|
||||||
#include "litpool.h"
|
#include "litpool.h"
|
||||||
#include "macrotab.h"
|
#include "macrotab.h"
|
||||||
#include "preproc.h"
|
#include "preproc.h"
|
||||||
|
|||||||
@@ -44,7 +44,6 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "incpath.h"
|
#include "incpath.h"
|
||||||
#include "io.h"
|
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -55,6 +54,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Input line stuff */
|
||||||
|
static char LineBuf [LINESIZE];
|
||||||
|
char* line = LineBuf;
|
||||||
|
char* lptr = LineBuf;
|
||||||
|
|
||||||
/* Maximum count of nested includes */
|
/* Maximum count of nested includes */
|
||||||
#define MAX_INC_NESTING 16
|
#define MAX_INC_NESTING 16
|
||||||
|
|
||||||
@@ -78,7 +82,7 @@ static IFile* Input = 0; /* Single linked list of active files */
|
|||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* struct IFile */
|
/* struct IFile */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
@@ -142,7 +146,7 @@ void OpenIncludeFile (const char* Name, unsigned DirSpec)
|
|||||||
/* Check for the maximum include nesting */
|
/* Check for the maximum include nesting */
|
||||||
if (IFileCount > MAX_INC_NESTING) {
|
if (IFileCount > MAX_INC_NESTING) {
|
||||||
PPError (ERR_INCLUDE_NESTING);
|
PPError (ERR_INCLUDE_NESTING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search for the file */
|
/* Search for the file */
|
||||||
@@ -196,7 +200,7 @@ int NextLine (void)
|
|||||||
int Done;
|
int Done;
|
||||||
|
|
||||||
/* Setup the line */
|
/* Setup the line */
|
||||||
kill ();
|
ClearLine ();
|
||||||
|
|
||||||
/* If there is no file open, bail out */
|
/* If there is no file open, bail out */
|
||||||
if (Input == 0) {
|
if (Input == 0) {
|
||||||
@@ -210,8 +214,8 @@ int NextLine (void)
|
|||||||
|
|
||||||
while (fgets (line + Len, LINESIZE - Len, Input->F) == 0) {
|
while (fgets (line + Len, LINESIZE - Len, Input->F) == 0) {
|
||||||
|
|
||||||
/* eof */
|
/* Assume EOF */
|
||||||
kill ();
|
ClearLine ();
|
||||||
|
|
||||||
/* Leave the current file */
|
/* Leave the current file */
|
||||||
CloseIncludeFile ();
|
CloseIncludeFile ();
|
||||||
@@ -232,7 +236,7 @@ int NextLine (void)
|
|||||||
while (Len > 0 && line [Len-1] == '\n') {
|
while (Len > 0 && line [Len-1] == '\n') {
|
||||||
--Len;
|
--Len;
|
||||||
}
|
}
|
||||||
line [Len] = '\0';
|
line [Len] = '\0';
|
||||||
|
|
||||||
/* Output the source line in the generated assembler file
|
/* Output the source line in the generated assembler file
|
||||||
* if requested.
|
* if requested.
|
||||||
@@ -246,9 +250,9 @@ int NextLine (void)
|
|||||||
*/
|
*/
|
||||||
if (Len > 0 && line[Len-1] == '\\') {
|
if (Len > 0 && line[Len-1] == '\\') {
|
||||||
line[Len-1] = '\n'; /* Replace by newline */
|
line[Len-1] = '\n'; /* Replace by newline */
|
||||||
} else {
|
} else {
|
||||||
Done = 1;
|
Done = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Got a line */
|
/* Got a line */
|
||||||
@@ -257,13 +261,22 @@ int NextLine (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ClearLine (void)
|
||||||
|
/* Clear the current input line */
|
||||||
|
{
|
||||||
|
line [0] = '\0';
|
||||||
|
lptr = line;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char* GetCurrentFile (void)
|
const char* GetCurrentFile (void)
|
||||||
/* Return the name of the current input file */
|
/* Return the name of the current input file */
|
||||||
{
|
{
|
||||||
if (Input == 0) {
|
if (Input == 0) {
|
||||||
return "(outside file scope)";
|
return "(outside file scope)";
|
||||||
} else {
|
} else {
|
||||||
return Input->Name;
|
return Input->Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,3 +290,39 @@ unsigned GetCurrentLine (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int nch (void)
|
||||||
|
/* Get the next char in input stream (the one behind the current one) */
|
||||||
|
{
|
||||||
|
if (*lptr == '\0') {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return lptr[1] & 0xFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int cgch (void)
|
||||||
|
/* Get the current character in the input stream and advance line
|
||||||
|
* pointer (unless already at end of line).
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
if (*lptr == '\0') {
|
||||||
|
return (0);
|
||||||
|
} else {
|
||||||
|
return (*lptr++ & 0xFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int gch (void)
|
||||||
|
/* Get the current character in the input stream and advance line
|
||||||
|
* pointer (no end of line check is performed).
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
return (*lptr++ & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,22 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* data */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Maximum length of an input line and the corresponding char array */
|
||||||
|
#define LINEMAX 4095
|
||||||
|
#define LINESIZE LINEMAX+1
|
||||||
|
|
||||||
|
/* Input line stuff */
|
||||||
|
extern char* line;
|
||||||
|
extern char* lptr;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Code */
|
/* Code */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -53,12 +69,30 @@ void OpenIncludeFile (const char* Name, unsigned DirSpec);
|
|||||||
int NextLine (void);
|
int NextLine (void);
|
||||||
/* Get a line from the current input. Returns 0 on end of file. */
|
/* Get a line from the current input. Returns 0 on end of file. */
|
||||||
|
|
||||||
|
void ClearLine (void);
|
||||||
|
/* Clear the current input line */
|
||||||
|
|
||||||
const char* GetCurrentFile (void);
|
const char* GetCurrentFile (void);
|
||||||
/* Return the name of the current input file */
|
/* Return the name of the current input file */
|
||||||
|
|
||||||
unsigned GetCurrentLine (void);
|
unsigned GetCurrentLine (void);
|
||||||
/* Return the line number in the current input file */
|
/* Return the line number in the current input file */
|
||||||
|
|
||||||
|
int nch (void);
|
||||||
|
/* Get the next char in input stream (the one behind the current one) */
|
||||||
|
|
||||||
|
int cgch (void);
|
||||||
|
/* Get the current character in the input stream and advance line
|
||||||
|
* pointer (unless already at end of line).
|
||||||
|
*/
|
||||||
|
|
||||||
|
int gch (void);
|
||||||
|
/* Get the current character in the input stream and advance line
|
||||||
|
* pointer (no end of line check is performed).
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of input.h */
|
/* End of input.h */
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
|
|
||||||
/* C I/O functions */
|
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
#include "io.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* data */
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Input line stuff */
|
|
||||||
char linebuf [LINESIZE];
|
|
||||||
char* line = linebuf;
|
|
||||||
char* lptr = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* code */
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int nch (void)
|
|
||||||
/* Get the next char in input stream (the one behind the current one) */
|
|
||||||
{
|
|
||||||
if (*lptr == '\0') {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return lptr[1] & 0xFF;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cgch (void)
|
|
||||||
/* Get the current character in the input stream and advance line
|
|
||||||
* pointer (unless already at end of line).
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
if (*lptr == '\0') {
|
|
||||||
return (0);
|
|
||||||
} else {
|
|
||||||
return (*lptr++ & 0xFF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int gch (void)
|
|
||||||
/* Get the current character in the input stream and advance line
|
|
||||||
* pointer (no end of line check is performed).
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
return (*lptr++ & 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void kill (void)
|
|
||||||
/* Reset input line pointer, clear input line */
|
|
||||||
{
|
|
||||||
lptr = line;
|
|
||||||
*lptr = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
* io.h
|
|
||||||
*
|
|
||||||
* Ullrich von Bassewitz, 19.06.1998
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef IO_H
|
|
||||||
#define IO_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* data */
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Maximum length of an input line and the corresponding char array */
|
|
||||||
#define LINEMAX 4095
|
|
||||||
#define LINESIZE LINEMAX+1
|
|
||||||
|
|
||||||
/* Maximum number of nested input files */
|
|
||||||
#define MAXFILES 16
|
|
||||||
|
|
||||||
/* Input line stuff */
|
|
||||||
extern char linebuf [LINESIZE];
|
|
||||||
extern char* line;
|
|
||||||
extern char* lptr;
|
|
||||||
|
|
||||||
/* File table entry */
|
|
||||||
struct filent {
|
|
||||||
FILE* f_iocb;
|
|
||||||
char* f_name;
|
|
||||||
int f_ln;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* code */
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void kill (void);
|
|
||||||
/* Reset input line pointer, clear input line */
|
|
||||||
|
|
||||||
int nch (void);
|
|
||||||
/* Get the next char in input stream (the one behind the current one) */
|
|
||||||
|
|
||||||
int cgch (void);
|
|
||||||
/* Get the current character in the input stream and advance line
|
|
||||||
* pointer (unless already at end of line).
|
|
||||||
*/
|
|
||||||
|
|
||||||
int gch (void);
|
|
||||||
/* Get the current character in the input stream and advance line
|
|
||||||
* pointer (no end of line check is performed).
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of io.h */
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -38,6 +38,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Data */
|
/* Data */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ OBJS = anonname.o \
|
|||||||
ident.o \
|
ident.o \
|
||||||
incpath.o \
|
incpath.o \
|
||||||
input.o \
|
input.o \
|
||||||
io.o \
|
|
||||||
litpool.o \
|
litpool.o \
|
||||||
locals.o \
|
locals.o \
|
||||||
loop.o \
|
loop.o \
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ OBJS = anonname.obj \
|
|||||||
ident.obj \
|
ident.obj \
|
||||||
incpath.obj \
|
incpath.obj \
|
||||||
input.obj \
|
input.obj \
|
||||||
io.obj \
|
|
||||||
litpool.obj \
|
litpool.obj \
|
||||||
locals.obj \
|
locals.obj \
|
||||||
loop.obj \
|
loop.obj \
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
@@ -45,7 +46,6 @@
|
|||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "io.h"
|
|
||||||
#include "optimize.h"
|
#include "optimize.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,6 @@
|
|||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "io.h"
|
|
||||||
#include "litpool.h"
|
#include "litpool.h"
|
||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
#include "preproc.h"
|
#include "preproc.h"
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
#include "ident.h"
|
#include "ident.h"
|
||||||
#include "incpath.h"
|
#include "incpath.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "io.h"
|
|
||||||
#include "macrotab.h"
|
#include "macrotab.h"
|
||||||
#include "scanner.h"
|
#include "scanner.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@@ -154,11 +153,11 @@ static char* CopyQuotedString (int Quote, char* Target)
|
|||||||
|
|
||||||
|
|
||||||
static int macname (char *sname)
|
static int macname (char *sname)
|
||||||
/* Get macro symbol name. If error, print message and kill line. */
|
/* Get macro symbol name. If error, print message and clear line. */
|
||||||
{
|
{
|
||||||
if (issym (sname) == 0) {
|
if (issym (sname) == 0) {
|
||||||
PPError (ERR_IDENT_EXPECTED);
|
PPError (ERR_IDENT_EXPECTED);
|
||||||
kill ();
|
ClearLine ();
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
@@ -319,7 +318,7 @@ static void ExpandMacro (Macro* M)
|
|||||||
if (M->ArgCount >= 0) {
|
if (M->ArgCount >= 0) {
|
||||||
/* Function like macro */
|
/* Function like macro */
|
||||||
if (MacroCall (M) == 0) {
|
if (MacroCall (M) == 0) {
|
||||||
kill ();
|
ClearLine ();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Just copy the replacement text */
|
/* Just copy the replacement text */
|
||||||
@@ -371,7 +370,7 @@ static void addmac (void)
|
|||||||
}
|
}
|
||||||
if (*lptr != ')') {
|
if (*lptr != ')') {
|
||||||
PPError (ERR_RPAREN_EXPECTED);
|
PPError (ERR_RPAREN_EXPECTED);
|
||||||
kill ();
|
ClearLine ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gch ();
|
gch ();
|
||||||
@@ -677,8 +676,10 @@ static void doinclude (void)
|
|||||||
xfree (Name);
|
xfree (Name);
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
/* clear rest of line so next read will come from new file (if open) */
|
/* Clear the remaining line so the next input will come from the new
|
||||||
kill ();
|
* file (if open)
|
||||||
|
*/
|
||||||
|
ClearLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -694,7 +695,7 @@ static void doerror (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* clear rest of line */
|
/* clear rest of line */
|
||||||
kill ();
|
ClearLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -771,7 +772,7 @@ void preprocess (void)
|
|||||||
}
|
}
|
||||||
if (!issym (sname)) {
|
if (!issym (sname)) {
|
||||||
PPError (ERR_CPP_DIRECTIVE_EXPECTED);
|
PPError (ERR_CPP_DIRECTIVE_EXPECTED);
|
||||||
kill ();
|
ClearLine ();
|
||||||
} else {
|
} else {
|
||||||
switch (searchtok (sname, pre_toks)) {
|
switch (searchtok (sname, pre_toks)) {
|
||||||
|
|
||||||
@@ -828,7 +829,7 @@ void preprocess (void)
|
|||||||
/* Not allowed in strict ANSI mode */
|
/* Not allowed in strict ANSI mode */
|
||||||
if (ANSI) {
|
if (ANSI) {
|
||||||
PPError (ERR_CPP_DIRECTIVE_EXPECTED);
|
PPError (ERR_CPP_DIRECTIVE_EXPECTED);
|
||||||
kill ();
|
ClearLine ();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -849,7 +850,7 @@ void preprocess (void)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
PPError (ERR_CPP_DIRECTIVE_EXPECTED);
|
PPError (ERR_CPP_DIRECTIVE_EXPECTED);
|
||||||
kill ();
|
ClearLine ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "ident.h"
|
#include "ident.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "io.h"
|
|
||||||
#include "litpool.h"
|
#include "litpool.h"
|
||||||
#include "preproc.h"
|
#include "preproc.h"
|
||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
|
|||||||
@@ -50,7 +50,6 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "funcdesc.h"
|
#include "funcdesc.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "io.h"
|
|
||||||
#include "symentry.h"
|
#include "symentry.h"
|
||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user