[BACK]Return to term.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/term.c between version 1.97 and 1.99

version 1.97, 2009/07/28 10:15:12 version 1.99, 2009/09/16 09:41:24
Line 24 
Line 24 
 #include "man.h"  #include "man.h"
 #include "mdoc.h"  #include "mdoc.h"
   
 extern  int               man_run(struct termp *,  extern  void              man_run(struct termp *,
                                 const struct man *);                                  const struct man *);
 extern  int               mdoc_run(struct termp *,  extern  void              mdoc_run(struct termp *,
                                 const struct mdoc *);                                  const struct mdoc *);
   
 static  struct termp     *term_alloc(enum termenc);  static  struct termp     *term_alloc(enum termenc);
Line 51  ascii_alloc(void)
Line 51  ascii_alloc(void)
 }  }
   
   
 int  void
 terminal_man(void *arg, const struct man *man)  terminal_man(void *arg, const struct man *man)
 {  {
         struct termp    *p;          struct termp    *p;
Line 60  terminal_man(void *arg, const struct man *man)
Line 60  terminal_man(void *arg, const struct man *man)
         if (NULL == p->symtab)          if (NULL == p->symtab)
                 p->symtab = term_ascii2htab();                  p->symtab = term_ascii2htab();
   
         return(man_run(p, man));          man_run(p, man);
 }  }
   
   
 int  void
 terminal_mdoc(void *arg, const struct mdoc *mdoc)  terminal_mdoc(void *arg, const struct mdoc *mdoc)
 {  {
         struct termp    *p;          struct termp    *p;
Line 73  terminal_mdoc(void *arg, const struct mdoc *mdoc)
Line 73  terminal_mdoc(void *arg, const struct mdoc *mdoc)
         if (NULL == p->symtab)          if (NULL == p->symtab)
                 p->symtab = term_ascii2htab();                  p->symtab = term_ascii2htab();
   
         return(mdoc_run(p, mdoc));          mdoc_run(p, mdoc);
 }  }
   
   
Line 104  term_alloc(enum termenc enc)
Line 104  term_alloc(enum termenc enc)
         struct termp *p;          struct termp *p;
   
         if (NULL == (p = malloc(sizeof(struct termp))))          if (NULL == (p = malloc(sizeof(struct termp))))
                 err(1, "malloc");                  return(NULL);
         bzero(p, sizeof(struct termp));          bzero(p, sizeof(struct termp));
         p->maxrmargin = 78;          p->maxrmargin = 78;
         p->enc = enc;          p->enc = enc;
Line 492  do_escaped(struct termp *p, const char **word)
Line 492  do_escaped(struct termp *p, const char **word)
   
                 switch (*wp) {                  switch (*wp) {
                 case ('B'):                  case ('B'):
                         p->flags |= TERMP_BOLD;                          p->bold++;
                         break;                          break;
                 case ('I'):                  case ('I'):
                         p->flags |= TERMP_UNDER;                          p->under++;
                         break;                          break;
                 case ('P'):                  case ('P'):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case ('R'):                  case ('R'):
                         p->flags &= ~TERMP_STYLE;                          p->bold = p->under = 0;
                         break;                          break;
                 default:                  default:
                         break;                          break;
Line 579  buffer(struct termp *p, char c)
Line 579  buffer(struct termp *p, char c)
                 s = p->maxcols * 2;                  s = p->maxcols * 2;
                 p->buf = realloc(p->buf, s);                  p->buf = realloc(p->buf, s);
                 if (NULL == p->buf)                  if (NULL == p->buf)
                         err(1, "realloc");                          err(1, "realloc"); /* FIXME: shouldn't be here! */
                 p->maxcols = s;                  p->maxcols = s;
         }          }
         p->buf[(int)(p->col)++] = c;          p->buf[(int)(p->col)++] = c;
Line 590  static void
Line 590  static void
 encode(struct termp *p, char c)  encode(struct termp *p, char c)
 {  {
   
         if (' ' != c && TERMP_STYLE & p->flags) {          if (' ' != c) {
                 if (TERMP_BOLD & p->flags) {                  if (p->bold) {
                         buffer(p, c);                          buffer(p, c);
                         buffer(p, 8);                          buffer(p, 8);
                 }                  }
                 if (TERMP_UNDER & p->flags) {                  if (p->under) {
                         buffer(p, '_');                          buffer(p, '_');
                         buffer(p, 8);                          buffer(p, 8);
                 }                  }

Legend:
Removed from v.1.97  
changed lines
  Added in v.1.99

CVSweb