[BACK]Return to ul.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ul

Diff for /src/usr.bin/ul/ul.c between version 1.12 and 1.13

version 1.12, 2004/03/13 22:11:56 version 1.13, 2004/07/06 14:37:59
Line 43 
Line 43 
 static const char rcsid[] = "$OpenBSD$";  static const char rcsid[] = "$OpenBSD$";
 #endif /* not lint */  #endif /* not lint */
   
   #include <curses.h>
   #include <err.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  
 #include <unistd.h>  
 #include <stdlib.h>  #include <stdlib.h>
 #include <curses.h>  #include <string.h>
 #include <term.h>  #include <term.h>
   #include <unistd.h>
   
 #define IESC    '\033'  #define IESC    '\033'
 #define SO      '\016'  #define SO      '\016'
Line 127 
Line 128 
   
                 default:                  default:
                         fprintf(stderr,                          fprintf(stderr,
                                 "usage: %s [ -i ] [ -tTerm ] file...\n",                                  "usage: %s [-i] [-t terminal] file...\n",
                                 argv[0]);                                  argv[0]);
                         exit(1);                          exit(1);
                 }                  }
Line 138 
Line 139 
                 break;                  break;
   
         default:          default:
                 fprintf(stderr,"trouble reading termcap");                  warnx("trouble reading termcap");
                 /* fall through to ... */                  /* FALLTHROUGH */
   
         case 0:          case 0:
                 /* No such terminal type - assume dumb */                  /* No such terminal type - assume dumb */
Line 156 
Line 157 
                 mfilter(stdin);                  mfilter(stdin);
         else for (; optind<argc; optind++) {          else for (; optind<argc; optind++) {
                 f = fopen(argv[optind],"r");                  f = fopen(argv[optind],"r");
                 if (f == NULL) {                  if (f == NULL)
                         perror(argv[optind]);                          err(1, "%s", argv[optind]);
                         exit(1);  
                 }  
   
                 mfilter(f);                  mfilter(f);
                 fclose(f);                  fclose(f);
Line 231 
Line 230 
                         continue;                          continue;
   
                 default:                  default:
                         fprintf(stderr,                          errx(1, "0%o: unknown escape sequence", c);
                                 "Unknown escape sequence in input: %o, %o\n",                          /* NOTREACHED */
                                 IESC, c);  
                         exit(1);  
                 }                  }
                 continue;                  continue;
   
Line 243 
Line 240 
                         obuf[col].c_mode |= UNDERL | mode;                          obuf[col].c_mode |= UNDERL | mode;
                 else                  else
                         obuf[col].c_char = '_';                          obuf[col].c_char = '_';
                   /* FALLTHROUGH */
         case ' ':          case ' ':
                 col++;                  col++;
                 if (col > maxcol)                  if (col > maxcol)
Line 323 
Line 321 
 overstrike(void)  overstrike(void)
 {  {
         int i;          int i;
         char lbuf[256];          char *buf, *cp;
         char *cp = lbuf;  
         int hadbold=0;          int hadbold=0;
   
           if ((buf = malloc(maxcol + 1)) == NULL)
                   err(1, NULL);
           cp = buf;
   
         /* Set up overstrike buffer */          /* Set up overstrike buffer */
         for (i=0; i<maxcol; i++)          for (i=0; i<maxcol; i++)
                 switch (obuf[i].c_mode) {                  switch (obuf[i].c_mode) {
Line 343 
Line 344 
                         break;                          break;
                 }                  }
         putchar('\r');          putchar('\r');
         for (*cp=' '; *cp==' '; cp--)          while (cp > buf && *(cp - 1) == ' ')
                 *cp = '\0';                  cp--;
         for (cp=lbuf; *cp; cp++)          *cp = '\0';
           for (cp = buf; *cp != '\0'; cp++)
                 putchar(*cp);                  putchar(*cp);
         if (hadbold) {          if (hadbold) {
                 putchar('\r');                  putchar('\r');
                 for (cp=lbuf; *cp; cp++)                  for (cp = buf; *cp != '\0'; cp++)
                         putchar(*cp=='_' ? ' ' : *cp);                          putchar(*cp=='_' ? ' ' : *cp);
                 putchar('\r');                  putchar('\r');
                 for (cp=lbuf; *cp; cp++)                  for (cp = buf; *cp != '\0'; cp++)
                         putchar(*cp=='_' ? ' ' : *cp);                          putchar(*cp=='_' ? ' ' : *cp);
         }          }
           free(buf);
 }  }
   
 void  void
 iattr(void)  iattr(void)
 {  {
         int i;          int i;
         char lbuf[256];          char *buf, *cp;
         char *cp = lbuf;  
   
           if ((buf = malloc(maxcol + 1)) == NULL)
                   err(1, NULL);
           cp = buf;
   
         for (i=0; i<maxcol; i++)          for (i=0; i<maxcol; i++)
                 switch (obuf[i].c_mode) {                  switch (obuf[i].c_mode) {
                 case NORMAL:    *cp++ = ' '; break;                  case NORMAL:    *cp++ = ' '; break;
Line 374 
Line 380 
                 case BOLD:      *cp++ = '!'; break;                  case BOLD:      *cp++ = '!'; break;
                 default:        *cp++ = 'X'; break;                  default:        *cp++ = 'X'; break;
                 }                  }
         for (*cp=' '; *cp==' '; cp--)          while (cp > buf && *(cp - 1) == ' ')
                 *cp = '\0';                  cp--;
         for (cp=lbuf; *cp; cp++)          *cp = '\0';
           for (cp = buf; *cp != '\0'; cp++)
                 putchar(*cp);                  putchar(*cp);
           free(buf);
         putchar('\n');          putchar('\n');
 }  }
   

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13