found a small error with Purify
authorceriel <none@none>
Mon, 18 Jan 1993 15:30:54 +0000 (15:30 +0000)
committerceriel <none@none>
Mon, 18 Jan 1993 15:30:54 +0000 (15:30 +0000)
modules/src/input/inp_pkg.body
modules/src/input/inp_pkg.spec

index 8ba2c29..336679c 100644 (file)
@@ -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
        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
@@ -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;
index 52567c6..0aea9f7 100644 (file)
 #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();