=/^G show total bytes now; document may not always work
[unix-history] / usr / src / usr.bin / deroff / deroff.c
index f9d0c3b..ae13342 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)deroff.c   4.4     (Berkeley)      83/04/29";
+static char sccsid[] = "@(#)deroff.c   4.7     (Berkeley)      88/04/24";
 #endif not lint
 
 #include <stdio.h>
 #endif not lint
 
 #include <stdio.h>
@@ -288,9 +288,9 @@ char *s, *p;
 }
 
 /*ARGSUSED*/
 }
 
 /*ARGSUSED*/
-textline(str, const)
+textline(str, constant)
        char    *str;
        char    *str;
-       int     const;
+       int     constant;
 {
        if (wordflag) {
                msputwords(0);
 {
        if (wordflag) {
                msputwords(0);
@@ -314,9 +314,9 @@ work()
        }
 }
 
        }
 }
 
-regline(pfunc, const)
+regline(pfunc, constant)
        int     (*pfunc)();
        int     (*pfunc)();
-       int     const;
+       int     constant;
 {
        line[0] = c;
        lp = line;
 {
        line[0] = c;
        lp = line;
@@ -342,7 +342,7 @@ regline(pfunc, const)
        *lp = '\0';
 
        if(line[0] != '\0')
        *lp = '\0';
 
        if(line[0] != '\0')
-               (*pfunc)(line, const);
+               (*pfunc)(line, constant);
 }
 
 macro()
 }
 
 macro()
@@ -659,9 +659,9 @@ struct      mactab  manmactab[];
 /*
  *     Put out a macro line, using ms and mm conventions.
  */
 /*
  *     Put out a macro line, using ms and mm conventions.
  */
-msputmac(s, const)
+msputmac(s, constant)
        register char *s;
        register char *s;
-       int     const;
+       int     constant;
 {
        register char *t;
        register found;
 {
        register char *t;
        register found;
@@ -679,7 +679,7 @@ msputmac(s, const)
                for(t = s ; *t!=' ' && *t!='\t' && *t!='\0' ; ++t)
                        ;
                if(*s == '\"')s++;
                for(t = s ; *t!=' ' && *t!='\t' && *t!='\0' ; ++t)
                        ;
                if(*s == '\"')s++;
-               if(t>s+const && chars[ s[0] ]==LETTER && chars[ s[1] ]==LETTER){
+               if(t>s+constant && chars[ s[0] ]==LETTER && chars[ s[1] ]==LETTER){
                        while(s < t)
                                if(*s == '\"')s++;
                                else
                        while(s < t)
                                if(*s == '\"')s++;
                                else
@@ -719,19 +719,12 @@ msputwords(macline)
                for(p = p1 ; (i=chars[*p]) != SPECIAL ; ++p)
                        if(i == LETTER) ++nlet;
 
                for(p = p1 ; (i=chars[*p]) != SPECIAL ; ++p)
                        if(i == LETTER) ++nlet;
 
-               if (   (macline && nlet > 1)
-                   || (!macline && nlet > 2 
-                                && chars[p1[0]] == LETTER
-                                && chars[p1[1]] == LETTER) )
-               {
+               if (nlet > 1 && chars[p1[0]] == LETTER) {
                        /*
                         *      delete trailing ampersands and apostrophes
                         */
                        /*
                         *      delete trailing ampersands and apostrophes
                         */
-                       while(  (p[-1]=='\'')
-                            || (p[-1]=='&')
-                            || (chars[p[-1]] == PUNCT) ){
+                       while( (i=chars[p[-1]]) == PUNCT || i == APOS )
                                --p;
                                --p;
-                       }
                        while(p1 < p)
                                putchar(*p1++);
                        putchar('\n');
                        while(p1 < p)
                                putchar(*p1++);
                        putchar('\n');
@@ -746,9 +739,9 @@ msputwords(macline)
 #define SKIPBLANK(cp)  while(*cp == ' ' || *cp == '\t') { cp++; }
 #define SKIPNONBLANK(cp) while(*cp !=' ' && *cp !='\cp' && *cp !='\0') { cp++; }
 
 #define SKIPBLANK(cp)  while(*cp == ' ' || *cp == '\t') { cp++; }
 #define SKIPNONBLANK(cp) while(*cp !=' ' && *cp !='\cp' && *cp !='\0') { cp++; }
 
-meputmac(cp, const)
+meputmac(cp, constant)
        reg     char    *cp;
        reg     char    *cp;
-               int     const;
+               int     constant;
 {
        reg     char    *np;
                int     found;
 {
        reg     char    *np;
                int     found;
@@ -807,10 +800,10 @@ meputmac(cp, const)
                /*
                 *      Determine if the argument merits being printed
                 *
                /*
                 *      Determine if the argument merits being printed
                 *
-                *      const is the cut off point below which something
+                *      constant is the cut off point below which something
                 *      is not a word.
                 */
                 *      is not a word.
                 */
-               if (   ( (np - cp) > const)
+               if (   ( (np - cp) > constant)
                    && (    inquote
                         || (chars[cp[0]] == LETTER)) ){
                        for (cp = cp; cp < np; cp++){
                    && (    inquote
                         || (chars[cp[0]] == LETTER)) ){
                        for (cp = cp; cp < np; cp++){
@@ -929,6 +922,11 @@ domacro()
 }
 PS()
 {
 }
 PS()
 {
+       for (C; c == ' ' || c == '\t'; C);
+       if (c == '<') {         /* ".PS < file" -- don't expect a .PE */
+               SKIP;
+               return(0);
+       }
        if (!msflag) {
                inpic();
        } else {
        if (!msflag) {
                inpic();
        } else {