mirror of
https://github.com/cc65/cc65.git
synced 2025-01-12 17:30:50 +00:00
Remove io.*, some cleanup
git-svn-id: svn://svn.cc65.org/cc65/trunk@87 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
a66cf46549
commit
c31008c78a
@ -45,7 +45,6 @@
|
||||
#include "cpu.h"
|
||||
#include "error.h"
|
||||
#include "global.h"
|
||||
#include "io.h"
|
||||
#include "litpool.h"
|
||||
#include "optimize.h"
|
||||
#include "util.h"
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include "function.h"
|
||||
#include "global.h"
|
||||
#include "incpath.h"
|
||||
#include "io.h"
|
||||
#include "litpool.h"
|
||||
#include "macrotab.h"
|
||||
#include "pragma.h"
|
||||
@ -66,7 +65,6 @@ static void Parse (void)
|
||||
int comma;
|
||||
SymEntry* Entry;
|
||||
|
||||
kill ();
|
||||
NextToken (); /* "prime" the pump */
|
||||
NextToken ();
|
||||
while (curtok != TOK_CEOF) {
|
||||
|
@ -39,7 +39,6 @@
|
||||
|
||||
#include "global.h"
|
||||
#include "input.h"
|
||||
#include "io.h"
|
||||
#include "scanner.h"
|
||||
#include "stmt.h"
|
||||
#include "error.h"
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "funcdesc.h"
|
||||
#include "function.h"
|
||||
#include "global.h"
|
||||
#include "io.h"
|
||||
#include "litpool.h"
|
||||
#include "macrotab.h"
|
||||
#include "preproc.h"
|
||||
|
@ -44,7 +44,6 @@
|
||||
#include "error.h"
|
||||
#include "global.h"
|
||||
#include "incpath.h"
|
||||
#include "io.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 */
|
||||
#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 */
|
||||
if (IFileCount > MAX_INC_NESTING) {
|
||||
PPError (ERR_INCLUDE_NESTING);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Search for the file */
|
||||
@ -196,7 +200,7 @@ int NextLine (void)
|
||||
int Done;
|
||||
|
||||
/* Setup the line */
|
||||
kill ();
|
||||
ClearLine ();
|
||||
|
||||
/* If there is no file open, bail out */
|
||||
if (Input == 0) {
|
||||
@ -210,8 +214,8 @@ int NextLine (void)
|
||||
|
||||
while (fgets (line + Len, LINESIZE - Len, Input->F) == 0) {
|
||||
|
||||
/* eof */
|
||||
kill ();
|
||||
/* Assume EOF */
|
||||
ClearLine ();
|
||||
|
||||
/* Leave the current file */
|
||||
CloseIncludeFile ();
|
||||
@ -232,7 +236,7 @@ int NextLine (void)
|
||||
while (Len > 0 && line [Len-1] == '\n') {
|
||||
--Len;
|
||||
}
|
||||
line [Len] = '\0';
|
||||
line [Len] = '\0';
|
||||
|
||||
/* Output the source line in the generated assembler file
|
||||
* if requested.
|
||||
@ -246,9 +250,9 @@ int NextLine (void)
|
||||
*/
|
||||
if (Len > 0 && line[Len-1] == '\\') {
|
||||
line[Len-1] = '\n'; /* Replace by newline */
|
||||
} else {
|
||||
Done = 1;
|
||||
}
|
||||
} else {
|
||||
Done = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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)
|
||||
/* Return the name of the current input file */
|
||||
{
|
||||
if (Input == 0) {
|
||||
return "(outside file scope)";
|
||||
return "(outside file scope)";
|
||||
} 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 */
|
||||
/*****************************************************************************/
|
||||
@ -53,12 +69,30 @@ void OpenIncludeFile (const char* Name, unsigned DirSpec);
|
||||
int NextLine (void);
|
||||
/* 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);
|
||||
/* Return the name of the current input file */
|
||||
|
||||
unsigned GetCurrentLine (void);
|
||||
/* 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 */
|
||||
|
@ -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 */
|
||||
/*****************************************************************************/
|
||||
|
@ -29,7 +29,6 @@ OBJS = anonname.o \
|
||||
ident.o \
|
||||
incpath.o \
|
||||
input.o \
|
||||
io.o \
|
||||
litpool.o \
|
||||
locals.o \
|
||||
loop.o \
|
||||
|
@ -83,7 +83,6 @@ OBJS = anonname.obj \
|
||||
ident.obj \
|
||||
incpath.obj \
|
||||
input.obj \
|
||||
io.obj \
|
||||
litpool.obj \
|
||||
locals.obj \
|
||||
loop.obj \
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
@ -45,7 +46,6 @@
|
||||
#include "cpu.h"
|
||||
#include "error.h"
|
||||
#include "global.h"
|
||||
#include "io.h"
|
||||
#include "optimize.h"
|
||||
|
||||
|
||||
|
@ -38,7 +38,6 @@
|
||||
|
||||
#include "global.h"
|
||||
#include "error.h"
|
||||
#include "io.h"
|
||||
#include "litpool.h"
|
||||
#include "symtab.h"
|
||||
#include "preproc.h"
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "ident.h"
|
||||
#include "incpath.h"
|
||||
#include "input.h"
|
||||
#include "io.h"
|
||||
#include "macrotab.h"
|
||||
#include "scanner.h"
|
||||
#include "util.h"
|
||||
@ -154,11 +153,11 @@ static char* CopyQuotedString (int Quote, char* Target)
|
||||
|
||||
|
||||
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) {
|
||||
PPError (ERR_IDENT_EXPECTED);
|
||||
kill ();
|
||||
ClearLine ();
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
@ -319,7 +318,7 @@ static void ExpandMacro (Macro* M)
|
||||
if (M->ArgCount >= 0) {
|
||||
/* Function like macro */
|
||||
if (MacroCall (M) == 0) {
|
||||
kill ();
|
||||
ClearLine ();
|
||||
}
|
||||
} else {
|
||||
/* Just copy the replacement text */
|
||||
@ -371,7 +370,7 @@ static void addmac (void)
|
||||
}
|
||||
if (*lptr != ')') {
|
||||
PPError (ERR_RPAREN_EXPECTED);
|
||||
kill ();
|
||||
ClearLine ();
|
||||
return;
|
||||
}
|
||||
gch ();
|
||||
@ -677,8 +676,10 @@ static void doinclude (void)
|
||||
xfree (Name);
|
||||
|
||||
Done:
|
||||
/* clear rest of line so next read will come from new file (if open) */
|
||||
kill ();
|
||||
/* Clear the remaining line so the next input will come from the new
|
||||
* file (if open)
|
||||
*/
|
||||
ClearLine ();
|
||||
}
|
||||
|
||||
|
||||
@ -694,7 +695,7 @@ static void doerror (void)
|
||||
}
|
||||
|
||||
/* clear rest of line */
|
||||
kill ();
|
||||
ClearLine ();
|
||||
}
|
||||
|
||||
|
||||
@ -771,7 +772,7 @@ void preprocess (void)
|
||||
}
|
||||
if (!issym (sname)) {
|
||||
PPError (ERR_CPP_DIRECTIVE_EXPECTED);
|
||||
kill ();
|
||||
ClearLine ();
|
||||
} else {
|
||||
switch (searchtok (sname, pre_toks)) {
|
||||
|
||||
@ -828,7 +829,7 @@ void preprocess (void)
|
||||
/* Not allowed in strict ANSI mode */
|
||||
if (ANSI) {
|
||||
PPError (ERR_CPP_DIRECTIVE_EXPECTED);
|
||||
kill ();
|
||||
ClearLine ();
|
||||
}
|
||||
break;
|
||||
|
||||
@ -849,7 +850,7 @@ void preprocess (void)
|
||||
|
||||
default:
|
||||
PPError (ERR_CPP_DIRECTIVE_EXPECTED);
|
||||
kill ();
|
||||
ClearLine ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "global.h"
|
||||
#include "ident.h"
|
||||
#include "input.h"
|
||||
#include "io.h"
|
||||
#include "litpool.h"
|
||||
#include "preproc.h"
|
||||
#include "symtab.h"
|
||||
|
@ -50,7 +50,6 @@
|
||||
#include "error.h"
|
||||
#include "funcdesc.h"
|
||||
#include "global.h"
|
||||
#include "io.h"
|
||||
#include "symentry.h"
|
||||
#include "symtab.h"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user