killbss routine smarter now; does not overwrite all BSS; did not work
authorceriel <none@none>
Fri, 2 Dec 1988 15:39:59 +0000 (15:39 +0000)
committerceriel <none@none>
Fri, 2 Dec 1988 15:39:59 +0000 (15:39 +0000)
as it should, because systemcall interface also uses the fact that BSS = 0

lang/m2/libm2/XXTermcap.c
lang/m2/libm2/halt.c
lang/m2/libm2/init.c
lang/m2/libm2/stackprio.c

index be7e4bd..46ff28c 100644 (file)
 #define ISSPACE(c)     ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n')
 #define ISDIGIT(x)     ((x) >= '0' && (x) <= '9')
 
-short  ospeed;         /* output speed */
-char   PC;             /* padding character */
-char   *BC;            /* back cursor movement */
-char   *UP;            /* up cursor movement */
+short  ospeed = 0;             /* output speed */
+char   PC = 0;                 /* padding character */
+char   *BC = 0;                /* back cursor movement */
+char   *UP = 0;                /* up cursor movement */
 
-static char    *capab;         /* the capability itself */
+static char    *capab = 0;             /* the capability itself */
 static int     check_for_tc();
 static int     match_name();
 
@@ -181,8 +181,10 @@ char       *name;
                else file = "/etc/termcap";
        } else
                file = "/etc/termcap";
-       if ((fp = open(file, 0)) < 0)
+       if ((fp = open(file, 0)) < 0) {
+               capab = 0;
                return(-1); 
+       }
        while (fgets(buf, 1024, fp) != NULL) {
                if (buf[0] == '#') continue;
                while (*(cp = &buf[strlen(buf) - 2]) == '\\')
@@ -191,9 +193,14 @@ char       *name;
                if (match_name(buf, name)) {
                        strcpy(bp, buf);
                        close(fp);
-                       return(check_for_tc());
+                       if(check_for_tc() == 0) {
+                               capab = 0;
+                               return 0;
+                       }
+                       return 1;
                }
        }
+       capab = 0;
        close(fp);
        return(0);
 }
@@ -236,7 +243,9 @@ check_for_tc()
                        return(0);      /* no : in termcap entry */
        if (p[1] != 't' || p[2] != 'c')
                return(1);
-       if (count > 16) return(0);      /* recursion in tc= definitions */
+       if (count > 16) {
+               return(0);      /* recursion in tc= definitions */
+       }
        count++;
        strcpy(terminalname, &p[4]);
        q = terminalname;
@@ -264,9 +273,9 @@ char        *id;
        char    *cp;
        int     ret;
 
-       if ((cp = capab) == NULL || id == NULL)
+       if ((cp = capab) == NULL || id == NULL || *cp == 0)
                return(-1);
-       while (*++cp != ':')
+       while (*++cp && *cp != ':')
                ;
        while (*cp) {
                cp++;
@@ -298,9 +307,9 @@ char        *id;
 {
        char    *cp;
 
-       if ((cp = capab) == NULL || id == NULL)
+       if ((cp = capab) == NULL || id == NULL || *cp == 0)
                return(-1);
-       while (*++cp != ':')
+       while (*++cp && *cp != ':')
                ;
        while (*cp) {
                cp++;
@@ -328,7 +337,7 @@ char        **area;
        char    *ret;
        int     i;
 
-       if ((cp = capab) == NULL || id == NULL)
+       if ((cp = capab) == NULL || id == NULL || *cp == 0)
                return(NULL);
        while (*++cp != ':')
                ;
index e32e890..01eeef3 100644 (file)
@@ -10,7 +10,7 @@
 */
 #define MAXPROCS 16
 
-static int callindex;
+static int callindex = 0;
 static int (*proclist[MAXPROCS])();
 
 _cleanup()
index 37b3231..be90690 100644 (file)
@@ -31,10 +31,30 @@ init()
        sigtrp(M2_UNIXSIG, SIGALRM);
        sigtrp(M2_UNIXSIG, SIGTERM);
 }
+#if em22 || em24 || em44
+killbss()
+{
+}
+#else
+
+static int blablabla;          /*      We cannot use end, because then also
+                                       bss allocated for the systemcall lib
+                                       would be overwritten. Lets hope that
+                                       this helps ...
+                               */
+
+killbss()
+{
+       extern char *edata;
+       register char *p = (char *) &edata;
+
+       while (p < (char *) &blablabla) *p++ = 0x66;
+}
+#endif
 
 extern int catch();
 
 int (*handler)() = catch;
-char **argv, **environ;
-int argc, StackSize;
-char *CurrentProcess, MainProcess, StackBase, MainLB;
+char **argv = 0, **environ = 0;
+int argc = 0, StackSize = 0;
+char *CurrentProcess = 0, MainProcess = 0, StackBase = 0, MainLB = 0;
index a320440..ecd3fee 100644 (file)
@@ -9,7 +9,7 @@
   Version:     $Header$
 */
 
-static unsigned prio;
+static unsigned prio = 0;
 
 stackprio(n)
        unsigned n;