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

Diff for /mandoc/mdoc.c between version 1.193 and 1.201

version 1.193, 2011/07/27 12:41:02 version 1.201, 2012/07/18 11:11:12
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) 2010 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2010, 2012 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 160  mdoc_alloc1(struct mdoc *mdoc)
Line 160  mdoc_alloc1(struct mdoc *mdoc)
         mdoc->last = mandoc_calloc(1, sizeof(struct mdoc_node));          mdoc->last = mandoc_calloc(1, sizeof(struct mdoc_node));
         mdoc->first = mdoc->last;          mdoc->first = mdoc->last;
         mdoc->last->type = MDOC_ROOT;          mdoc->last->type = MDOC_ROOT;
           mdoc->last->tok = MDOC_MAX;
         mdoc->next = MDOC_NEXT_CHILD;          mdoc->next = MDOC_NEXT_CHILD;
 }  }
   
Line 196  mdoc_free(struct mdoc *mdoc)
Line 197  mdoc_free(struct mdoc *mdoc)
  * Allocate volatile and non-volatile parse resources.   * Allocate volatile and non-volatile parse resources.
  */   */
 struct mdoc *  struct mdoc *
 mdoc_alloc(struct roff *roff, struct mparse *parse)  mdoc_alloc(struct roff *roff, struct mparse *parse, char *defos)
 {  {
         struct mdoc     *p;          struct mdoc     *p;
   
         p = mandoc_calloc(1, sizeof(struct mdoc));          p = mandoc_calloc(1, sizeof(struct mdoc));
   
         p->parse = parse;          p->parse = parse;
           p->defos = defos;
         p->roff = roff;          p->roff = roff;
   
         mdoc_hash_init();          mdoc_hash_init();
Line 300  mdoc_parseln(struct mdoc *m, int ln, char *buf, int of
Line 302  mdoc_parseln(struct mdoc *m, int ln, char *buf, int of
                         m->flags &= ~MDOC_SYNOPSIS;                          m->flags &= ~MDOC_SYNOPSIS;
         }          }
   
         return(mandoc_getcontrol(buf, &offs) ?          return(roff_getcontrol(m->roff, buf, &offs) ?
                         mdoc_pmacro(m, ln, buf, offs) :                          mdoc_pmacro(m, ln, buf, offs) :
                         mdoc_ptext(m, ln, buf, offs));                          mdoc_ptext(m, ln, buf, offs));
 }  }
Line 568  int
Line 570  int
 mdoc_word_alloc(struct mdoc *m, int line, int pos, const char *p)  mdoc_word_alloc(struct mdoc *m, int line, int pos, const char *p)
 {  {
         struct mdoc_node *n;          struct mdoc_node *n;
         size_t            sv, len;  
   
         len = strlen(p);  
   
         n = node_alloc(m, line, pos, MDOC_MAX, MDOC_TEXT);          n = node_alloc(m, line, pos, MDOC_MAX, MDOC_TEXT);
         n->string = mandoc_malloc(len + 1);          n->string = roff_strdup(m->roff, p);
         sv = strlcpy(n->string, p, len + 1);  
   
         /* Prohibit truncation. */  
         assert(sv < len + 1);  
   
         if ( ! node_append(m, n))          if ( ! node_append(m, n))
                 return(0);                  return(0);
   
Line 653  mdoc_node_delete(struct mdoc *m, struct mdoc_node *p)
Line 648  mdoc_node_delete(struct mdoc *m, struct mdoc_node *p)
         mdoc_node_free(p);          mdoc_node_free(p);
 }  }
   
   int
   mdoc_node_relink(struct mdoc *m, struct mdoc_node *p)
   {
   
           mdoc_node_unlink(m, p);
           return(node_append(m, p));
   }
   
 #if 0  #if 0
 /*  /*
  * Pre-treat a text line.   * Pre-treat a text line.
Line 806  mdoc_ptext(struct mdoc *m, int line, char *buf, int of
Line 809  mdoc_ptext(struct mdoc *m, int line, char *buf, int of
                         return(0);                          return(0);
   
                 m->next = MDOC_NEXT_SIBLING;                  m->next = MDOC_NEXT_SIBLING;
                 return(1);  
                   return(mdoc_valid_post(m));
         }          }
   
         if ( ! mdoc_word_alloc(m, line, offs, buf+offs))          if ( ! mdoc_word_alloc(m, line, offs, buf+offs))
Line 986  mdoc_isdelim(const char *p)
Line 990  mdoc_isdelim(const char *p)
   
         if (0 == strcmp(p + 1, "."))          if (0 == strcmp(p + 1, "."))
                 return(DELIM_CLOSE);                  return(DELIM_CLOSE);
         if (0 == strcmp(p + 1, "*(Ba"))          if (0 == strcmp(p + 1, "fR|\\fP"))
                 return(DELIM_MIDDLE);                  return(DELIM_MIDDLE);
   
         return(DELIM_NONE);          return(DELIM_NONE);

Legend:
Removed from v.1.193  
changed lines
  Added in v.1.201

CVSweb