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

Diff for /mandoc/term.c between version 1.157 and 1.164

version 1.157, 2010/07/02 10:50:50 version 1.164, 2010/07/25 22:56:47
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
    * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 33 
Line 34 
 #include "term.h"  #include "term.h"
 #include "main.h"  #include "main.h"
   
 static  void              spec(struct termp *, const char *, size_t);  static  void              spec(struct termp *, enum roffdeco,
                                   const char *, size_t);
 static  void              res(struct termp *, const char *, size_t);  static  void              res(struct termp *, const char *, size_t);
 static  void              buffera(struct termp *, const char *, size_t);  static  void              buffera(struct termp *, const char *, size_t);
 static  void              bufferc(struct termp *, char);  static  void              bufferc(struct termp *, char);
Line 240  term_flushln(struct termp *p)
Line 242  term_flushln(struct termp *p)
                         if ('\t' == p->buf[i])                          if ('\t' == p->buf[i])
                                 break;                                  break;
                         if (' ' == p->buf[i]) {                          if (' ' == p->buf[i]) {
                                 while (' ' == p->buf[i]) {                                  j = i;
                                         vbl += (*p->width)(p, p->buf[i]);                                  while (' ' == p->buf[i])
                                         i++;                                          i++;
                                 }                                  vbl += (i - j) * (*p->width)(p, ' ');
                                 break;                                  break;
                         }                          }
                         if (ASCII_NBRSP == p->buf[i]) {                          if (ASCII_NBRSP == p->buf[i]) {
Line 359  term_vspace(struct termp *p)
Line 361  term_vspace(struct termp *p)
   
   
 static void  static void
 spec(struct termp *p, const char *word, size_t len)  spec(struct termp *p, enum roffdeco d, const char *word, size_t len)
 {  {
         const char      *rhs;          const char      *rhs;
         size_t           sz;          size_t           sz;
   
         rhs = chars_a2ascii(p->symtab, word, len, &sz);          rhs = chars_spec2str(p->symtab, word, len, &sz);
         if (rhs)          if (rhs)
                 encode(p, rhs, sz);                  encode(p, rhs, sz);
           else if (DECO_SSPECIAL == d)
                   encode(p, word, len);
 }  }
   
   
Line 376  res(struct termp *p, const char *word, size_t len)
Line 380  res(struct termp *p, const char *word, size_t len)
         const char      *rhs;          const char      *rhs;
         size_t           sz;          size_t           sz;
   
         rhs = chars_a2res(p->symtab, word, len, &sz);          rhs = chars_res2str(p->symtab, word, len, &sz);
         if (rhs)          if (rhs)
                 encode(p, rhs, sz);                  encode(p, rhs, sz);
 }  }
Line 502  term_word(struct termp *p, const char *word)
Line 506  term_word(struct termp *p, const char *word)
   
         p->flags &= ~TERMP_SENTENCE;          p->flags &= ~TERMP_SENTENCE;
   
         /* FIXME: use strcspn. */  
   
         while (*word) {          while (*word) {
                 if ('\\' != *word) {                  if ((ssz = strcspn(word, "\\")) > 0)
                         encode(p, word, 1);                          encode(p, word, ssz);
                         word++;  
                   word += ssz;
                   if ('\\' != *word)
                         continue;                          continue;
                 }  
   
                 seq = ++word;                  seq = ++word;
                 sz = a2roffdeco(&deco, &seq, &ssz);                  sz = a2roffdeco(&deco, &seq, &ssz);
Line 519  term_word(struct termp *p, const char *word)
Line 522  term_word(struct termp *p, const char *word)
                         res(p, seq, ssz);                          res(p, seq, ssz);
                         break;                          break;
                 case (DECO_SPECIAL):                  case (DECO_SPECIAL):
                         spec(p, seq, ssz);                          /* FALLTHROUGH */
                   case (DECO_SSPECIAL):
                           spec(p, deco, seq, ssz);
                         break;                          break;
                 case (DECO_BOLD):                  case (DECO_BOLD):
                         term_fontrepl(p, TERMFONT_BOLD);                          term_fontrepl(p, TERMFONT_BOLD);
Line 546  term_word(struct termp *p, const char *word)
Line 551  term_word(struct termp *p, const char *word)
          * Note that we don't process the pipe: the parser sees it as           * Note that we don't process the pipe: the parser sees it as
          * punctuation, but we don't in terms of typography.           * punctuation, but we don't in terms of typography.
          */           */
         if (sv[0] && 0 == sv[1])          if (sv[0] && '\0' == sv[1])
                 switch (sv[0]) {                  switch (sv[0]) {
                 case('('):                  case('('):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */

Legend:
Removed from v.1.157  
changed lines
  Added in v.1.164

CVSweb