[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.5 and 1.6

version 1.5, 2000/03/22 15:38:23 version 1.6, 2001/07/12 05:17:27
Line 50 
Line 50 
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
   #include <unistd.h>
   #include <stdlib.h>
   #include <curses.h>
   #include <term.h>
   
 #define IESC    '\033'  #define IESC    '\033'
 #define SO      '\016'  #define SO      '\016'
Line 83 
Line 87 
 int     upln;  int     upln;
 int     iflag;  int     iflag;
   
 int     outchar();  int     outchar(int);
 #define PRINT(s)        if (s == NULL) /* void */; else tputs(s, 1, outchar)  void    initcap(void);
   void    initbuf(void);
   void    mfilter(FILE *);
   void    reverse(void);
   void    fwd(void);
   void    flushln(void);
   void    msetmode(int);
   void    outc(int);
   void    overstrike(void);
   void    iattr(void);
   
   #define PRINT(s) \
           do { \
                   if (s) \
                           tputs(s, 1, outchar); \
           } while (0)
   
   int
 main(argc, argv)  main(argc, argv)
         int argc;          int argc;
         char **argv;          char **argv;
Line 138 
Line 158 
                         must_overstrike = 1;                          must_overstrike = 1;
         initbuf();          initbuf();
         if (optind == argc)          if (optind == argc)
                 filter(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) {
Line 146 
Line 166 
                         exit(1);                          exit(1);
                 }                  }
   
                 filter(f);                  mfilter(f);
                 fclose(f);                  fclose(f);
         }          }
         exit(0);          exit(0);
 }  }
   
 filter(f)  void
   mfilter(f)
         FILE *f;          FILE *f;
 {  {
         register c;          int c;
   
         while ((c = getc(f)) != EOF && col < MAXBUF) switch(c) {          while ((c = getc(f)) != EOF && col < MAXBUF) switch(c) {
   
Line 265 
Line 286 
                 flushln();                  flushln();
 }  }
   
   void
 flushln()  flushln()
 {  {
         register lastmode;          int lastmode, i;
         register i;  
         int hadmodes = 0;          int hadmodes = 0;
   
         lastmode = NORMAL;          lastmode = NORMAL;
         for (i=0; i<maxcol; i++) {          for (i=0; i<maxcol; i++) {
                 if (obuf[i].c_mode != lastmode) {                  if (obuf[i].c_mode != lastmode) {
                         hadmodes++;                          hadmodes++;
                         setmode(obuf[i].c_mode);                          msetmode(obuf[i].c_mode);
                         lastmode = obuf[i].c_mode;                          lastmode = obuf[i].c_mode;
                 }                  }
                 if (obuf[i].c_char == '\0') {                  if (obuf[i].c_char == '\0') {
Line 287 
Line 308 
                         outc(obuf[i].c_char);                          outc(obuf[i].c_char);
         }          }
         if (lastmode != NORMAL) {          if (lastmode != NORMAL) {
                 setmode(0);                  msetmode(0);
         }          }
         if (must_overstrike && hadmodes)          if (must_overstrike && hadmodes)
                 overstrike();                  overstrike();
Line 304 
Line 325 
  * For terminals that can overstrike, overstrike underlines and bolds.   * For terminals that can overstrike, overstrike underlines and bolds.
  * We don't do anything with halfline ups and downs, or Greek.   * We don't do anything with halfline ups and downs, or Greek.
  */   */
   void
 overstrike()  overstrike()
 {  {
         register int i;          register int i;
Line 341 
Line 363 
         }          }
 }  }
   
   void
 iattr()  iattr()
 {  {
         register int i;          register int i;
Line 364 
Line 387 
         putchar('\n');          putchar('\n');
 }  }
   
   void
 initbuf()  initbuf()
 {  {
   
Line 373 
Line 397 
         mode &= ALTSET;          mode &= ALTSET;
 }  }
   
   void
 fwd()  fwd()
 {  {
         register oldcol, oldmax;          int oldcol, oldmax;
   
         oldcol = col;          oldcol = col;
         oldmax = maxcol;          oldmax = maxcol;
Line 384 
Line 409 
         maxcol = oldmax;          maxcol = oldmax;
 }  }
   
   void
 reverse()  reverse()
 {  {
         upln++;          upln++;
Line 393 
Line 419 
         upln++;          upln++;
 }  }
   
   void
 initcap()  initcap()
 {  {
         static char tcapbuf[512];          static char tcapbuf[512];
Line 446 
Line 473 
         must_use_uc = (UNDER_CHAR && !ENTER_UNDERLINE);          must_use_uc = (UNDER_CHAR && !ENTER_UNDERLINE);
 }  }
   
   int
 outchar(c)  outchar(c)
         int c;          int c;
 {  {
         putchar(c & 0177);          putchar(c & 0177);
           return (0);
 }  }
   
 static int curmode = 0;  static int curmode = 0;
   
   void
 outc(c)  outc(c)
         int c;          int c;
 {  {
Line 464 
Line 494 
         }          }
 }  }
   
 setmode(newmode)  void
   msetmode(newmode)
         int newmode;          int newmode;
 {  {
         if (!iflag) {          if (!iflag) {
                 if (curmode != NORMAL && newmode != NORMAL)                  if (curmode != NORMAL && newmode != NORMAL)
                         setmode(NORMAL);                          msetmode(NORMAL);
                 switch (newmode) {                  switch (newmode) {
                 case NORMAL:                  case NORMAL:
                         switch(curmode) {                          switch(curmode) {

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6