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

Diff for /mandoc/eqn.c between version 1.41 and 1.47

version 1.41, 2014/04/20 19:40:13 version 1.47, 2014/09/28 14:05:11
Line 14 
Line 14 
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
 #ifdef HAVE_CONFIG_H  
 #include "config.h"  #include "config.h"
 #endif  
   
   #include <sys/types.h>
   
 #include <assert.h>  #include <assert.h>
 #include <limits.h>  #include <limits.h>
 #include <stdio.h>  #include <stdio.h>
Line 195  static const struct eqnstr eqnfonts[EQNFONT__MAX] = {
Line 195  static const struct eqnstr eqnfonts[EQNFONT__MAX] = {
 };  };
   
 static  const struct eqnstr eqnposs[EQNPOS__MAX] = {  static  const struct eqnstr eqnposs[EQNPOS__MAX] = {
         { "", 0 }, /* EQNPOS_NONE */          { NULL, 0 }, /* EQNPOS_NONE */
         { "over", 4 }, /* EQNPOS_OVER */          { "over", 4 }, /* EQNPOS_OVER */
         { "sup", 3 }, /* EQNPOS_SUP */          { "sup", 3 }, /* EQNPOS_SUP */
           { NULL, 0 }, /* EQNPOS_SUPSUB */
         { "sub", 3 }, /* EQNPOS_SUB */          { "sub", 3 }, /* EQNPOS_SUB */
         { "to", 2 }, /* EQNPOS_TO */          { "to", 2 }, /* EQNPOS_TO */
         { "from", 4 }, /* EQNPOS_FROM */          { "from", 4 }, /* EQNPOS_FROM */
           { NULL, 0 }, /* EQNPOS_FROMTO */
 };  };
   
 static  const struct eqnstr eqnpiles[EQNPILE__MAX] = {  static  const struct eqnstr eqnpiles[EQNPILE__MAX] = {
Line 300  eqn_read(struct eqn_node **epp, int ln,
Line 302  eqn_read(struct eqn_node **epp, int ln,
                         p++;                          p++;
                 if ('\0' == *p)                  if ('\0' == *p)
                         return(er);                          return(er);
                 mandoc_msg(MANDOCERR_ARGSLOST, ep->parse, ln, pos, NULL);                  mandoc_vmsg(MANDOCERR_ARG_SKIP, ep->parse,
                       ln, pos, "EN %s", p);
                 return(er);                  return(er);
         }          }
   
Line 568  eqn_box(struct eqn_node *ep, struct eqn_box *last)
Line 571  eqn_box(struct eqn_node *ep, struct eqn_box *last)
                 return(EQN_OK);                  return(EQN_OK);
         }          }
   
           /*
            * Positional elements (e.g., over, sub, sup, ...).
            */
         for (i = 0; i < (int)EQNPOS__MAX; i++) {          for (i = 0; i < (int)EQNPOS__MAX; i++) {
                 if ( ! EQNSTREQ(&eqnposs[i], start, sz))                  /* Some elements don't have names (are virtual). */
                   if (NULL == eqnposs[i].name)
                         continue;                          continue;
                   else if ( ! EQNSTREQ(&eqnposs[i], start, sz))
                           continue;
                 if (NULL == last->last) {                  if (NULL == last->last) {
                         EQN_MSG(MANDOCERR_EQNSYNT, ep);                          EQN_MSG(MANDOCERR_EQNSYNT, ep);
                         return(EQN_ERR);                          return(EQN_ERR);
                 }                  }
                 last->last->pos = (enum eqn_post)i;                  /*
                    * If we encounter x sub y sup z, then according to the
                    * eqn manual, we regard this as x subsup y z.
                    */
                   if (EQNPOS_SUP == i &&
                           NULL != last->last->prev &&
                           EQNPOS_SUB == last->last->prev->pos)
                           last->last->prev->pos = EQNPOS_SUBSUP;
                   else if (EQNPOS_TO == i &&
                           NULL != last->last->prev &&
                           EQNPOS_FROM == last->last->prev->pos)
                           last->last->prev->pos = EQNPOS_FROMTO;
                   else
                           last->last->pos = (enum eqn_post)i;
   
                 if (EQN_EOF == (c = eqn_box(ep, last))) {                  if (EQN_EOF == (c = eqn_box(ep, last))) {
                         EQN_MSG(MANDOCERR_EQNEOF, ep);                          EQN_MSG(MANDOCERR_EQNEOF, ep);
                         return(EQN_ERR);                          return(EQN_ERR);
Line 664  eqn_box_alloc(struct eqn_node *ep, struct eqn_box *par
Line 687  eqn_box_alloc(struct eqn_node *ep, struct eqn_box *par
         bp->parent = parent;          bp->parent = parent;
         bp->size = ep->gsize;          bp->size = ep->gsize;
   
         if (NULL == parent->first)          if (NULL != parent->first) {
                 parent->first = bp;  
         else  
                 parent->last->next = bp;                  parent->last->next = bp;
                   bp->prev = parent->last;
           } else
                   parent->first = bp;
   
         parent->last = bp;          parent->last = bp;
         return(bp);          return(bp);
Line 767  again:
Line 791  again:
                         ep->cur++;                          ep->cur++;
         } else {          } else {
                 if (q)                  if (q)
                         EQN_MSG(MANDOCERR_BADQUOTE, ep);                          EQN_MSG(MANDOCERR_ARG_QUOTE, ep);
                 next = strchr(start, '\0');                  next = strchr(start, '\0');
                 *sz = (size_t)(next - start);                  *sz = (size_t)(next - start);
                 ep->cur += *sz;                  ep->cur += *sz;
Line 864  eqn_do_define(struct eqn_node *ep)
Line 888  eqn_do_define(struct eqn_node *ep)
   
                 if (i == (int)ep->defsz) {                  if (i == (int)ep->defsz) {
                         ep->defsz++;                          ep->defsz++;
                         ep->defs = mandoc_realloc(ep->defs,                          ep->defs = mandoc_reallocarray(ep->defs,
                             ep->defsz * sizeof(struct eqn_def));                              ep->defsz, sizeof(struct eqn_def));
                         ep->defs[i].key = ep->defs[i].val = NULL;                          ep->defs[i].key = ep->defs[i].val = NULL;
                 }                  }
   

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.47

CVSweb