(no message)
[unix-history] / usr / src / usr.bin / ul / ul.c
index 5a0790c..826993d 100644 (file)
@@ -1,4 +1,7 @@
-/*     @(#)vcrt.c      3.13    */
+#ifndef lint
+static char sccsid[] = "@(#)ul.c       4.5 (Berkeley) %G%";
+#endif
+
 #include <stdio.h>
 
 #define        IESC    '\033'
 #include <stdio.h>
 
 #define        IESC    '\033'
@@ -185,6 +188,7 @@ FILE *f;
 
        case '\n':
                flushln();
 
        case '\n':
                flushln();
+               continue;
 
        default:
                if (c < ' ')    /* non printing */
 
        default:
                if (c < ' ')    /* non printing */
@@ -195,14 +199,19 @@ FILE *f;
                } else if (obuf[col].c_char == '_') {
                        obuf[col].c_char = c;
                        obuf[col].c_mode |= UNDERL|mode;
                } else if (obuf[col].c_char == '_') {
                        obuf[col].c_char = c;
                        obuf[col].c_mode |= UNDERL|mode;
-               } else
+               } else if (obuf[col].c_char == c)
                        obuf[col].c_mode |= BOLD|mode;
                        obuf[col].c_mode |= BOLD|mode;
+               else {
+                       obuf[col].c_mode = c;
+                       obuf[col].c_mode = mode;
+               }
                col++;
                if (col > maxcol)
                        maxcol = col;
                continue;
        }
                col++;
                if (col > maxcol)
                        maxcol = col;
                continue;
        }
-       flushln();
+       if (maxcol)
+               flushln();
 }
 
 flushln()
 }
 
 flushln()
@@ -424,6 +433,9 @@ setmode(newmode)
 int newmode;
 {
        if (!iflag)
 int newmode;
 {
        if (!iflag)
+       {
+               if (curmode != NORMAL && newmode != NORMAL)
+                       setmode(NORMAL);
                switch (newmode) {
                case NORMAL:
                        switch(curmode) {
                switch (newmode) {
                case NORMAL:
                        switch(curmode) {
@@ -466,6 +478,7 @@ int newmode;
                        puts(ENTER_STANDOUT);
                        break;
                }
                        puts(ENTER_STANDOUT);
                        break;
                }
+       }
        curmode = newmode;
 }
 /*     @(#)getopt.c    3.2     */
        curmode = newmode;
 }
 /*     @(#)getopt.c    3.2     */