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

Diff for /mandoc/term.c between version 1.6 and 1.9

version 1.6, 2009/02/21 21:00:06 version 1.9, 2009/02/22 19:23:48
Line 24 
Line 24 
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
   
   #ifdef __linux__
   #include <time.h>
   #endif
   
 #include "term.h"  #include "term.h"
   
 enum    termstyle {  enum    termstyle {
Line 46  static void    pescape(struct termp *, 
Line 50  static void    pescape(struct termp *, 
 static  void              chara(struct termp *, char);  static  void              chara(struct termp *, char);
 static  void              style(struct termp *, enum termstyle);  static  void              style(struct termp *, enum termstyle);
   
   #ifdef __linux__
   extern  size_t            strlcat(char *, const char *, size_t);
   extern  size_t            strlcpy(char *, const char *, size_t);
   #endif
   
 void  void
 flushln(struct termp *p)  flushln(struct termp *p)
Line 74  flushln(struct termp *p)
Line 82  flushln(struct termp *p)
                 for (j = 0; j < p->offset; j++)                  for (j = 0; j < p->offset; j++)
                         putchar(' ');                          putchar(' ');
   
           /*
            * If we're literal, print out verbatim.
            */
           if (p->flags & TERMP_LITERAL) {
                   /* FIXME: count non-printing chars. */
                   for (i = 0; i < p->col; i++)
                           putchar(p->buf[i]);
                   putchar('\n');
                   p->col = 0;
                   return;
           }
   
         for (i = 0; i < p->col; i++) {          for (i = 0; i < p->col; i++) {
                 /*                  /*
                  * Count up visible word characters.  Control sequences                   * Count up visible word characters.  Control sequences
Line 259  pword(struct termp *p, const char *word, size_t len)
Line 279  pword(struct termp *p, const char *word, size_t len)
 {  {
         size_t           i;          size_t           i;
   
         assert(len > 0);          /*assert(len > 0);*/ /* Can be, if literal. */
   
         if ( ! (p->flags & TERMP_NOSPACE))          if ( ! (p->flags & TERMP_NOSPACE) &&
                           ! (p->flags & TERMP_LITERAL))
                 chara(p, ' ');                  chara(p, ' ');
   
         p->flags &= ~TERMP_NOSPACE;          p->flags &= ~TERMP_NOSPACE;
Line 290  word(struct termp *p, const char *word)
Line 311  word(struct termp *p, const char *word)
 {  {
         size_t           i, j, len;          size_t           i, j, len;
   
         if (mdoc_isdelim(word))          if (p->flags & TERMP_LITERAL) {
                 p->flags |= TERMP_NOSPACE;                  pword(p, word, strlen(word));
                   return;
           }
   
         len = strlen(word);          len = strlen(word);
         assert(len > 0);          assert(len > 0);
   
           if (mdoc_isdelim(word)) {
                   if ( ! (p->flags & TERMP_IGNDELIM))
                           p->flags |= TERMP_NOSPACE;
                   p->flags &= ~TERMP_IGNDELIM;
           }
   
         /* LINTED */          /* LINTED */
         for (j = i = 0; i < len; i++) {          for (j = i = 0; i < len; i++) {
                 if ( ! isspace(word[i])) {                  if ( ! isspace(word[i])) {
Line 363  termprint_footer(struct termp *p, const struct mdoc_me
Line 392  termprint_footer(struct termp *p, const struct mdoc_me
                 err(1, "malloc");                  err(1, "malloc");
   
         tm = localtime(&meta->date);          tm = localtime(&meta->date);
   
   #ifdef __linux__
           if (0 == strftime(buf, p->rmargin, "%B %d, %Y", tm))
   #else
         if (NULL == strftime(buf, p->rmargin, "%B %d, %Y", tm))          if (NULL == strftime(buf, p->rmargin, "%B %d, %Y", tm))
   #endif
                 err(1, "strftime");                  err(1, "strftime");
   
         osz = strlcpy(os, meta->os, p->rmargin);          osz = strlcpy(os, meta->os, p->rmargin);

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

CVSweb