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

Diff for /mandoc/eqn.c between version 1.77 and 1.81

version 1.77, 2017/07/14 18:18:26 version 1.81, 2018/12/13 05:23:38
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2014, 2015, 2017, 2018 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 30 
Line 30 
 #include "mandoc_aux.h"  #include "mandoc_aux.h"
 #include "mandoc.h"  #include "mandoc.h"
 #include "roff.h"  #include "roff.h"
   #include "eqn.h"
 #include "libmandoc.h"  #include "libmandoc.h"
 #include "libroff.h"  #include "eqn_parse.h"
   
 #define EQN_NEST_MAX     128 /* maximum nesting of defines */  #define EQN_NEST_MAX     128 /* maximum nesting of defines */
 #define STRNEQ(p1, sz1, p2, sz2) \  #define STRNEQ(p1, sz1, p2, sz2) \
Line 284  enum parse_mode {
Line 285  enum parse_mode {
         MODE_TOK          MODE_TOK
 };  };
   
   struct  eqn_def {
           char             *key;
           size_t            keysz;
           char             *val;
           size_t            valsz;
   };
   
 static  struct eqn_box  *eqn_box_alloc(struct eqn_node *, struct eqn_box *);  static  struct eqn_box  *eqn_box_alloc(struct eqn_node *, struct eqn_box *);
 static  struct eqn_box  *eqn_box_makebinary(struct eqn_node *,  static  struct eqn_box  *eqn_box_makebinary(struct eqn_node *,
                                 struct eqn_box *);                                  struct eqn_box *);
Line 468  eqn_next(struct eqn_node *ep, enum parse_mode mode)
Line 476  eqn_next(struct eqn_node *ep, enum parse_mode mode)
 void  void
 eqn_box_free(struct eqn_box *bp)  eqn_box_free(struct eqn_box *bp)
 {  {
           if (bp == NULL)
                   return;
   
         if (bp->first)          if (bp->first)
                 eqn_box_free(bp->first);                  eqn_box_free(bp->first);
Line 482  eqn_box_free(struct eqn_box *bp)
Line 492  eqn_box_free(struct eqn_box *bp)
         free(bp);          free(bp);
 }  }
   
   struct eqn_box *
   eqn_box_new(void)
   {
           struct eqn_box  *bp;
   
           bp = mandoc_calloc(1, sizeof(*bp));
           bp->expectargs = UINT_MAX;
           return bp;
   }
   
 /*  /*
  * Allocate a box as the last child of the parent node.   * Allocate a box as the last child of the parent node.
  */   */
Line 490  eqn_box_alloc(struct eqn_node *ep, struct eqn_box *par
Line 510  eqn_box_alloc(struct eqn_node *ep, struct eqn_box *par
 {  {
         struct eqn_box  *bp;          struct eqn_box  *bp;
   
         bp = mandoc_calloc(1, sizeof(struct eqn_box));          bp = eqn_box_new();
         bp->parent = parent;          bp->parent = parent;
         bp->parent->args++;          bp->parent->args++;
         bp->expectargs = UINT_MAX;  
         bp->font = bp->parent->font;          bp->font = bp->parent->font;
         bp->size = ep->gsize;          bp->size = ep->gsize;
   
Line 717  next_tok:
Line 736  next_tok:
                         parent->bottom = mandoc_strdup("\\[ul]");                          parent->bottom = mandoc_strdup("\\[ul]");
                         break;                          break;
                 case EQN_TOK_BAR:                  case EQN_TOK_BAR:
                         parent->top = mandoc_strdup("\\[rl]");                          parent->top = mandoc_strdup("\\[rn]");
                         break;                          break;
                 case EQN_TOK_DOT:                  case EQN_TOK_DOT:
                         parent->top = mandoc_strdup("\\[a.]");                          parent->top = mandoc_strdup("\\[a.]");
Line 1091  void
Line 1110  void
 eqn_free(struct eqn_node *p)  eqn_free(struct eqn_node *p)
 {  {
         int              i;          int              i;
   
           if (p == NULL)
                   return;
   
         for (i = 0; i < (int)p->defsz; i++) {          for (i = 0; i < (int)p->defsz; i++) {
                 free(p->defs[i].key);                  free(p->defs[i].key);

Legend:
Removed from v.1.77  
changed lines
  Added in v.1.81

CVSweb