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

Diff for /mandoc/man.c between version 1.122 and 1.128

version 1.122, 2013/12/31 23:23:10 version 1.128, 2014/03/30 19:47:48
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
    * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
    * Copyright (c) 2011 Joerg Sonnenberger <joerg@netbsd.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 21 
Line 23 
 #include <sys/types.h>  #include <sys/types.h>
   
 #include <assert.h>  #include <assert.h>
   #include <ctype.h>
 #include <stdarg.h>  #include <stdarg.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <stdio.h>  #include <stdio.h>
Line 28 
Line 31 
   
 #include "man.h"  #include "man.h"
 #include "mandoc.h"  #include "mandoc.h"
   #include "mandoc_aux.h"
 #include "libman.h"  #include "libman.h"
 #include "libmandoc.h"  #include "libmandoc.h"
   
Line 41  const char *const __man_macronames[MAN_MAX] = {   
Line 45  const char *const __man_macronames[MAN_MAX] = {   
         "fi",           "RE",           "RS",           "DT",          "fi",           "RE",           "RS",           "DT",
         "UC",           "PD",           "AT",           "in",          "UC",           "PD",           "AT",           "in",
         "ft",           "OP",           "EX",           "EE",          "ft",           "OP",           "EX",           "EE",
         "UR",           "UE"          "UR",           "UE",           "ll"
         };          };
   
 const   char * const *man_macronames = __man_macronames;  const   char * const *man_macronames = __man_macronames;
Line 97  man_free(struct man *man)
Line 101  man_free(struct man *man)
   
   
 struct man *  struct man *
 man_alloc(struct roff *roff, struct mparse *parse)  man_alloc(struct roff *roff, struct mparse *parse, int quick)
 {  {
         struct man      *p;          struct man      *p;
   
Line 105  man_alloc(struct roff *roff, struct mparse *parse)
Line 109  man_alloc(struct roff *roff, struct mparse *parse)
   
         man_hash_init();          man_hash_init();
         p->parse = parse;          p->parse = parse;
           p->quick = quick;
         p->roff = roff;          p->roff = roff;
   
         man_alloc1(p);          man_alloc1(p);
Line 604  man_pmacro(struct man *man, int ln, char *buf, int off
Line 609  man_pmacro(struct man *man, int ln, char *buf, int off
         if ( ! (*man_macros[tok].fp)(man, tok, ln, ppos, &offs, buf))          if ( ! (*man_macros[tok].fp)(man, tok, ln, ppos, &offs, buf))
                 goto err;                  goto err;
   
           /* In quick mode (for mandocdb), abort after the NAME section. */
   
           if (man->quick && MAN_SH == tok &&
               strcmp(man->last->prev->child->string, "NAME"))
                   return(2);
   
         /*          /*
          * We weren't in a block-line scope when entering the           * We weren't in a block-line scope when entering the
          * above-parsed macro, so return.           * above-parsed macro, so return.
Line 695  man_mparse(const struct man *man)
Line 706  man_mparse(const struct man *man)
   
         assert(man && man->parse);          assert(man && man->parse);
         return(man->parse);          return(man->parse);
   }
   
   void
   man_deroff(char **dest, const struct man_node *n)
   {
           char    *cp;
           size_t   sz;
   
           if (MAN_TEXT != n->type) {
                   for (n = n->child; n; n = n->next)
                           man_deroff(dest, n);
                   return;
           }
   
           /* Skip leading whitespace and escape sequences. */
   
           cp = n->string;
           while ('\0' != *cp) {
                   if ('\\' == *cp) {
                           cp++;
                           mandoc_escape((const char **)&cp, NULL, NULL);
                   } else if (isspace((unsigned char)*cp))
                           cp++;
                   else
                           break;
           }
   
           /* Skip trailing whitespace. */
   
           for (sz = strlen(cp); sz; sz--)
                   if (0 == isspace((unsigned char)cp[sz-1]))
                           break;
   
           /* Skip empty strings. */
   
           if (0 == sz)
                   return;
   
           if (NULL == *dest) {
                   *dest = mandoc_strndup(cp, sz);
                   return;
           }
   
           mandoc_asprintf(&cp, "%s %*s", *dest, (int)sz, cp);
           free(*dest);
           *dest = cp;
 }  }

Legend:
Removed from v.1.122  
changed lines
  Added in v.1.128

CVSweb