#include "cpu.h"
#include "error.h"
#include "global.h"
-#include "io.h"
#include "litpool.h"
#include "optimize.h"
#include "util.h"
#include "function.h"
#include "global.h"
#include "incpath.h"
-#include "io.h"
#include "litpool.h"
#include "macrotab.h"
#include "pragma.h"
int comma;
SymEntry* Entry;
- kill ();
NextToken (); /* "prime" the pump */
NextToken ();
while (curtok != TOK_CEOF) {
#include "global.h"
#include "input.h"
-#include "io.h"
#include "scanner.h"
#include "stmt.h"
#include "error.h"
#include "funcdesc.h"
#include "function.h"
#include "global.h"
-#include "io.h"
#include "litpool.h"
#include "macrotab.h"
#include "preproc.h"
#include "error.h"
#include "global.h"
#include "incpath.h"
-#include "io.h"
#include "input.h"
+/* Input line stuff */
+static char LineBuf [LINESIZE];
+char* line = LineBuf;
+char* lptr = LineBuf;
+
/* Maximum count of nested includes */
#define MAX_INC_NESTING 16
/*****************************************************************************/
-/* struct IFile */
+/* struct IFile */
/*****************************************************************************/
/* Check for the maximum include nesting */
if (IFileCount > MAX_INC_NESTING) {
PPError (ERR_INCLUDE_NESTING);
- return;
+ return;
}
/* Search for the file */
int Done;
/* Setup the line */
- kill ();
+ ClearLine ();
/* If there is no file open, bail out */
if (Input == 0) {
while (fgets (line + Len, LINESIZE - Len, Input->F) == 0) {
- /* eof */
- kill ();
+ /* Assume EOF */
+ ClearLine ();
/* Leave the current file */
CloseIncludeFile ();
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.
*/
if (Len > 0 && line[Len-1] == '\\') {
line[Len-1] = '\n'; /* Replace by newline */
- } else {
- Done = 1;
- }
+ } else {
+ Done = 1;
+ }
}
/* Got a line */
+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;
}
}
+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);
+}
+
+
+
+/*****************************************************************************/
+/* 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 */
/*****************************************************************************/
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 */
+++ /dev/null
-
-/* 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';
-}
-
-
-
+++ /dev/null
-/*
- * 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
-
-
-
+#include <stdio.h>
+
+
+
/*****************************************************************************/
/* Data */
/*****************************************************************************/
ident.o \
incpath.o \
input.o \
- io.o \
litpool.o \
locals.o \
loop.o \
ident.obj \
incpath.obj \
input.obj \
- io.obj \
litpool.obj \
locals.obj \
loop.obj \
#include <stdarg.h>
+#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "cpu.h"
#include "error.h"
#include "global.h"
-#include "io.h"
#include "optimize.h"
#include "global.h"
#include "error.h"
-#include "io.h"
#include "litpool.h"
#include "symtab.h"
#include "preproc.h"
#include "ident.h"
#include "incpath.h"
#include "input.h"
-#include "io.h"
#include "macrotab.h"
#include "scanner.h"
#include "util.h"
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;
if (M->ArgCount >= 0) {
/* Function like macro */
if (MacroCall (M) == 0) {
- kill ();
+ ClearLine ();
}
} else {
/* Just copy the replacement text */
}
if (*lptr != ')') {
PPError (ERR_RPAREN_EXPECTED);
- kill ();
+ ClearLine ();
return;
}
gch ();
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 ();
}
}
/* clear rest of line */
- kill ();
+ ClearLine ();
}
}
if (!issym (sname)) {
PPError (ERR_CPP_DIRECTIVE_EXPECTED);
- kill ();
+ ClearLine ();
} else {
switch (searchtok (sname, pre_toks)) {
/* Not allowed in strict ANSI mode */
if (ANSI) {
PPError (ERR_CPP_DIRECTIVE_EXPECTED);
- kill ();
+ ClearLine ();
}
break;
default:
PPError (ERR_CPP_DIRECTIVE_EXPECTED);
- kill ();
+ ClearLine ();
}
}
#include "global.h"
#include "ident.h"
#include "input.h"
-#include "io.h"
#include "litpool.h"
#include "preproc.h"
#include "symtab.h"
#include "error.h"
#include "funcdesc.h"
#include "global.h"
-#include "io.h"
#include "symentry.h"
#include "symtab.h"