/* INPUT AND BUFFER HANDLING MODULE */
/*
- [input.X inp_pkg.spec input.h]
Input buffering module: this module contains the routines that
offers an input buffering mechanism to the user.
This module exports the following objects:
- input.h : an include-file, which must be included when using
- this module
InsertFile() : suspend input from current buffer and obtain the
next input characters from the specified file
InsertText() : suspend input from current buffer and take the
INP_NPUSHBACK: the number of characters pushback
*/
-#include <alloc.h>
+#if __STDC__
+#include <stdlib.h>
+#else
+extern char *malloc();
+#endif
+
#include <system.h>
#ifndef INP_NPUSHBACK
register char *de = bh->bh_text;
register int i = INP_NPUSHBACK - 1;
+ if (i >= bh->bh_size) i = bh->bh_size - 1;
while (i-- > 0) {
/* make sure PushBack will work */
*--de = *--so;
register char *de = &buf[INP_NPUSHBACK - 1];
register int i = INP_NPUSHBACK - 1;
+ if (i >= bh->bh_size) i = bh->bh_size - 1;
for (;i > 0; i--) {
/* make sure PushBack will work */
*--de = *--so;
#define PushBack() (--_ipp)
#define ChPushBack(ch) (*--_ipp = (ch))
-/* EOF may be defined as -1 in most programs but the character -1 may
- be expanded to the int -1 which causes troubles at the indexing in
- the class or boolean arrays.
+/* EOI may be defined as -1 in most programs but the character -1 may
+ be expanded to the int -1 which causes troubles with indexing.
*/
#define EOI (0200)
extern char *_ipp;
+
+#if __STDC__
+int loadbuf(void);
+int InsertFile(char *, char **, char **);
+int InsertText(char *, int);
+#else
extern int loadbuf();
+extern int InsertFile();
+extern int InsertText();
+#endif
/* int InsertFile(filename, table, result)
char *filename;
will be looked for in the directories, mentioned in the null-terminated
list indicated by "table". It returns 1 if it succeeds, 0 if it fails.
"result" will contain the full path if InsertFile returns 1.
-*/
-extern int InsertFile();
-/* int InsertText(text, length)
+ int InsertText(text, length)
char *text;
int length;
This funtion suspends input from the current input stream. The next
whose length is indicated by "length".
It returns 1 if it succeeds, 0 if it fails.
*/
-extern int InsertText();