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

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

version 1.176, 2013/05/31 22:08:09 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 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 */

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

CVSweb