diff --git a/modules/src/input/inp_pkg.body b/modules/src/input/inp_pkg.body index 8ba2c29de..336679c69 100644 --- a/modules/src/input/inp_pkg.body +++ b/modules/src/input/inp_pkg.body @@ -1,13 +1,10 @@ /* 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 @@ -37,7 +34,12 @@ INP_NPUSHBACK: the number of characters pushback */ -#include +#if __STDC__ +#include +#else +extern char *malloc(); +#endif + #include #ifndef INP_NPUSHBACK @@ -362,6 +364,7 @@ loadbuf() 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; @@ -385,6 +388,7 @@ loadbuf() 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; diff --git a/modules/src/input/inp_pkg.spec b/modules/src/input/inp_pkg.spec index 52567c6a2..0aea9f72f 100644 --- a/modules/src/input/inp_pkg.spec +++ b/modules/src/input/inp_pkg.spec @@ -22,14 +22,22 @@ #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; @@ -41,10 +49,8 @@ extern int loadbuf(); 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 @@ -52,4 +58,3 @@ extern int InsertFile(); whose length is indicated by "length". It returns 1 if it succeeds, 0 if it fails. */ -extern int InsertText();