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

Diff for /mandoc/roff.c between version 1.175 and 1.177

version 1.175, 2012/11/19 17:57:23 version 1.177, 2013/06/27 09:49:47
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010, 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2010, 2011, 2012, 2013 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 393  roffnode_push(struct roff *r, enum rofft tok, const ch
Line 393  roffnode_push(struct roff *r, enum rofft tok, const ch
 static void  static void
 roff_free1(struct roff *r)  roff_free1(struct roff *r)
 {  {
         struct tbl_node *t;          struct tbl_node *tbl;
         struct eqn_node *e;          struct eqn_node *e;
         int              i;          int              i;
   
         while (NULL != (t = r->first_tbl)) {          while (NULL != (tbl = r->first_tbl)) {
                 r->first_tbl = t->next;                  r->first_tbl = tbl->next;
                 tbl_free(t);                  tbl_free(tbl);
         }          }
   
         r->first_tbl = r->last_tbl = r->tbl = NULL;          r->first_tbl = r->last_tbl = r->tbl = NULL;
Line 1028  roff_cond_sub(ROFF_ARGS)
Line 1028  roff_cond_sub(ROFF_ARGS)
   
         rr = r->last->rule;          rr = r->last->rule;
         roffnode_cleanscope(r);          roffnode_cleanscope(r);
           t = roff_parse(r, *bufp, &pos);
   
         /*          /*
          * If the macro is unknown, first check if it contains a closing           * Fully handle known macros when they are structurally
          * delimiter `\}'.  If it does, close out our scope and return           * required or when the conditional evaluated to true.
          * the currently-scoped rule (ignore or continue).  Else, drop  
          * into the currently-scoped rule.  
          */           */
   
         if (ROFF_MAX == (t = roff_parse(r, *bufp, &pos))) {          if ((ROFF_MAX != t) &&
                 ep = &(*bufp)[pos];              (ROFF_ccond == t || ROFFRULE_ALLOW == rr ||
                 for ( ; NULL != (ep = strchr(ep, '\\')); ep++) {               ROFFMAC_STRUCT & roffs[t].flags)) {
                         ep++;                  assert(roffs[t].proc);
                         if ('}' != *ep)                  return((*roffs[t].proc)(r, t, bufp, szp,
                                 continue;                                          ln, ppos, pos, offs));
           }
   
                         /*          /* Always check for the closing delimiter `\}'. */
                          * Make the \} go away.  
                          * This is a little haphazard, as it's not quite  
                          * clear how nroff does this.  
                          * If we're at the end of line, then just chop  
                          * off the \} and resize the buffer.  
                          * If we aren't, then conver it to spaces.  
                          */  
   
                         if ('\0' == *(ep + 1)) {          ep = &(*bufp)[pos];
                                 *--ep = '\0';          while (NULL != (ep = strchr(ep, '\\'))) {
                                 *szp -= 2;                  if ('}' != *(++ep))
                         } else                          continue;
                                 *(ep - 1) = *ep = ' ';  
   
                         roff_ccond(r, ROFF_ccond, bufp, szp,                  /*
                                         ln, pos, pos + 2, offs);                   * If we're at the end of line, then just chop
                         break;                   * off the \} and resize the buffer.
                 }                   * If we aren't, then convert it to spaces.
                 return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT);                   */
         }  
   
         /*                  if ('\0' == *(ep + 1)) {
          * A denied conditional must evaluate its children if and only                          *--ep = '\0';
          * if they're either structurally required (such as loops and                          *szp -= 2;
          * conditionals) or a closing macro.                  } else
          */                          *(ep - 1) = *ep = ' ';
   
         if (ROFFRULE_DENY == rr)                  roff_ccond(r, ROFF_ccond, bufp, szp,
                 if ( ! (ROFFMAC_STRUCT & roffs[t].flags))                                  ln, pos, pos + 2, offs);
                         if (ROFF_ccond != t)                  break;
                                 return(ROFF_IGN);          }
           return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT);
         assert(roffs[t].proc);  
         return((*roffs[t].proc)(r, t, bufp, szp,  
                                 ln, ppos, pos, offs));  
 }  }
   
 /* ARGSUSED */  /* ARGSUSED */
Line 1413  roff_EN(ROFF_ARGS)
Line 1401  roff_EN(ROFF_ARGS)
 static enum rofferr  static enum rofferr
 roff_TS(ROFF_ARGS)  roff_TS(ROFF_ARGS)
 {  {
         struct tbl_node *t;          struct tbl_node *tbl;
   
         if (r->tbl) {          if (r->tbl) {
                 mandoc_msg(MANDOCERR_SCOPEBROKEN, r->parse, ln, ppos, NULL);                  mandoc_msg(MANDOCERR_SCOPEBROKEN, r->parse, ln, ppos, NULL);
                 tbl_end(&r->tbl);                  tbl_end(&r->tbl);
         }          }
   
         t = tbl_alloc(ppos, ln, r->parse);          tbl = tbl_alloc(ppos, ln, r->parse);
   
         if (r->last_tbl)          if (r->last_tbl)
                 r->last_tbl->next = t;                  r->last_tbl->next = tbl;
         else          else
                 r->first_tbl = r->last_tbl = t;                  r->first_tbl = r->last_tbl = tbl;
   
         r->tbl = r->last_tbl = t;          r->tbl = r->last_tbl = tbl;
         return(ROFF_IGN);          return(ROFF_IGN);
 }  }
   

Legend:
Removed from v.1.175  
changed lines
  Added in v.1.177

CVSweb