asthetic mods
[unix-history] / usr / src / old / more / more.c
index b686a18..d4eb516 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)more.c      4.7 (Berkeley) 82/12/14";
+static char *sccsid = "@(#)more.c      4.11 (Berkeley) 83/03/17";
 
 /*
 ** more.c - General purpose tty output filter and file perusal program
 
 /*
 ** more.c - General purpose tty output filter and file perusal program
@@ -263,23 +263,39 @@ char *argv[];
 argscan(s)
 char *s;
 {
 argscan(s)
 char *s;
 {
-           for (dlines = 0; *s != '\0'; s++)
-               if (isdigit(*s))
-                   dlines = dlines*10 + *s - '0';
-               else if (*s == 'd')
-                   dum_opt = 1;
-               else if (*s == 'l')
-                   stop_opt = 0;
-               else if (*s == 'f')
-                   fold_opt = 0;
-               else if (*s == 'p')
-                   noscroll++;
-               else if (*s == 'c')
-                   clreol++;
-               else if (*s == 's')
-                   ssp_opt = 1;
-               else if (*s == 'u')
-                   ul_opt = 0;
+       for (dlines = 0; *s != '\0'; s++)
+       {
+               switch (*s)
+               {
+                 case '0': case '1': case '2':
+                 case '3': case '4': case '5':
+                 case '6': case '7': case '8':
+                 case '9':
+                       dlines = dlines*10 + *s - '0';
+                       break;
+                 case 'd':
+                       dum_opt = 1;
+                       break;
+                 case 'l':
+                       stop_opt = 0;
+                       break;
+                 case 'f':
+                       fold_opt = 0;
+                       break;
+                 case 'p':
+                       noscroll++;
+                       break;
+                 case 'c':
+                       clreol++;
+                       break;
+                 case 's':
+                       ssp_opt = 1;
+                       break;
+                 case 'u':
+                       ul_opt = 0;
+                       break;
+               }
+       }
 }
 
 
 }
 
 
@@ -415,7 +431,7 @@ register int num_lines;
            return;
        if (hard && promptlen > 0)
                erase (0);
            return;
        if (hard && promptlen > 0)
                erase (0);
-       if (noscroll && num_lines == dlines)
+       if (noscroll && num_lines >= dlines)
        { 
            if (clreol)
                home();
        { 
            if (clreol)
                home();
@@ -550,16 +566,16 @@ int n;
 char *str;
 {
     sptr = str;
 char *str;
 {
     sptr = str;
-    sprintf (n);
+    Sprintf (n);
     *sptr = '\0';
 }
 
     *sptr = '\0';
 }
 
-sprintf (n)
+Sprintf (n)
 {
     int a;
 
     if (a = n/10)
 {
     int a;
 
     if (a = n/10)
-       sprintf (a);
+       Sprintf (a);
     *sptr++ = n % 10 + '0';
 }
 
     *sptr++ = n % 10 + '0';
 }
 
@@ -1306,10 +1322,11 @@ initterm ()
     char       clearbuf[100];
     char       *clearptr, *padstr;
     int                ldisc;
     char       clearbuf[100];
     char       *clearptr, *padstr;
     int                ldisc;
+    char       *term;
 
     setbuf(stdout, obuf);
     if (!(no_tty = gtty(1, &otty))) {
 
     setbuf(stdout, obuf);
     if (!(no_tty = gtty(1, &otty))) {
-       if (tgetent(buf, getenv("TERM")) <= 0) {
+       if ((term = getenv("TERM")) && tgetent(buf, term) <= 0) {
            dumb++; ul_opt = 0;
        }
        else {
            dumb++; ul_opt = 0;
        }
        else {
@@ -1351,7 +1368,7 @@ initterm ()
            if (padstr = tgetstr("pc", &clearptr))
                PC = *padstr;
            Home = tgetstr("ho",&clearptr);
            if (padstr = tgetstr("pc", &clearptr))
                PC = *padstr;
            Home = tgetstr("ho",&clearptr);
-           if (*Home == '\0')
+           if (Home == 0 && *Home == '\0')
            {
                if ((cursorm = tgetstr("cm", &clearptr)) != NULL) {
                    strcpy(cursorhome, tgoto(cursorm, 0, 0));
            {
                if ((cursorm = tgetstr("cm", &clearptr)) != NULL) {
                    strcpy(cursorhome, tgoto(cursorm, 0, 0));