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

Diff for /mandoc/Attic/macro.c between version 1.24 and 1.25

version 1.24, 2009/01/06 15:49:44 version 1.25, 2009/01/07 15:53:00
Line 34  static int   rewind_impblock(struct mdoc *, int, int);
Line 34  static int   rewind_impblock(struct mdoc *, int, int);
 static  int       rewind_expblock(struct mdoc *, int, int, int);  static  int       rewind_expblock(struct mdoc *, int, int, int);
 static  int       rewind_head(struct mdoc *, int, int);  static  int       rewind_head(struct mdoc *, int, int);
 static  int       rewind_body(struct mdoc *, int, int, int);  static  int       rewind_body(struct mdoc *, int, int, int);
   static  int       rewind_last(struct mdoc *, int, struct mdoc_node *);
 static  int       append_delims(struct mdoc *, int, int *, char *);  static  int       append_delims(struct mdoc *, int, int *, char *);
 static  int       lookup(struct mdoc *, int, const char *);  static  int       lookup(struct mdoc *, int, const char *);
   
Line 49  lookup(struct mdoc *mdoc, int from, const char *p)
Line 50  lookup(struct mdoc *mdoc, int from, const char *p)
   
   
 static int  static int
   rewind_last(struct mdoc *mdoc, int ppos, struct mdoc_node *to)
   {
   
           assert(to);
           while (mdoc->last != to) {
                   if ( ! mdoc_valid_post(mdoc, ppos))
                           return(0);
                   if ( ! mdoc_action(mdoc, ppos))
                           return(0);
                   mdoc->last = mdoc->last->parent;
                   assert(mdoc->last);
           }
           mdoc->next = MDOC_NEXT_SIBLING;
           if ( ! mdoc_valid_post(mdoc, ppos))
                   return(0);
           return(mdoc_action(mdoc, ppos));
   }
   
   
   static int
 rewind_elem(struct mdoc *mdoc, int ppos, int tok)  rewind_elem(struct mdoc *mdoc, int ppos, int tok)
 {  {
         struct mdoc_node *n;          struct mdoc_node *n;
Line 59  rewind_elem(struct mdoc *mdoc, int ppos, int tok)
Line 80  rewind_elem(struct mdoc *mdoc, int ppos, int tok)
         assert(MDOC_ELEM == n->type);          assert(MDOC_ELEM == n->type);
         assert(tok == n->data.elem.tok);          assert(tok == n->data.elem.tok);
   
         mdoc->last = n;          return(rewind_last(mdoc, ppos, n));
         mdoc->next = MDOC_NEXT_SIBLING;  
         if ( ! mdoc_valid_post(mdoc, tok, ppos))  
                 return(0);  
         return(mdoc_action(mdoc, tok, ppos));  
 }  }
   
   
Line 71  static int
Line 88  static int
 rewind_body(struct mdoc *mdoc, int ppos, int tok, int tt)  rewind_body(struct mdoc *mdoc, int ppos, int tok, int tt)
 {  {
         struct mdoc_node *n;          struct mdoc_node *n;
           int               t;
   
         /* LINTED */          /* LINTED */
         for (n = mdoc->last; n; n = n->parent) {          for (n = mdoc->last; n; n = n->parent) {
                 if (MDOC_BODY != n->type)                  if (MDOC_BODY != n->type)
                         continue;                          continue;
                 if (tt == n->data.head.tok)                  if (tt == (t = n->data.head.tok))
                         break;                          break;
                 if ( ! (MDOC_EXPLICIT & mdoc_macros[tt].flags))                  if ( ! (MDOC_EXPLICIT & mdoc_macros[t].flags))
                         continue;                          continue;
                 return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_BREAK));                  return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_BREAK));
         }          }
   
         mdoc->last = n ? n : mdoc->last;          assert(n);
         mdoc->next = MDOC_NEXT_SIBLING;          return(rewind_last(mdoc, ppos, n));
         /* XXX - no validation, we do this only for blocks/elements. */  
         return(1);  
 }  }
   
   
Line 107  rewind_head(struct mdoc *mdoc, int ppos, int tok)
Line 123  rewind_head(struct mdoc *mdoc, int ppos, int tok)
                 return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_BREAK));                  return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_BREAK));
         }          }
   
         mdoc->last = n ? n : mdoc->last;          assert(n);
         mdoc->next = MDOC_NEXT_SIBLING;          return(rewind_last(mdoc, ppos, n));
         /* XXX - no validation, we do this only for blocks/elements. */  
         return(1);  
 }  }
   
   
Line 133  rewind_expblock(struct mdoc *mdoc, int ppos, int tok, 
Line 147  rewind_expblock(struct mdoc *mdoc, int ppos, int tok, 
                 return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_BREAK));                  return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_BREAK));
         }          }
   
         if (NULL == (mdoc->last = n))          if (NULL == n)
                 return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_NOCTX));                  return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_NOCTX));
           return(rewind_last(mdoc, ppos, n));
         mdoc->next = MDOC_NEXT_SIBLING;  
         if ( ! mdoc_valid_post(mdoc, tok, ppos))  
                 return(0);  
         return(mdoc_action(mdoc, tok, ppos));  
 }  }
   
   
Line 166  rewind_impblock(struct mdoc *mdoc, int ppos, int tok)
Line 176  rewind_impblock(struct mdoc *mdoc, int ppos, int tok)
   
         if (NULL == n)          if (NULL == n)
                 return(1);                  return(1);
           return(rewind_last(mdoc, ppos, n));
         mdoc->next = MDOC_NEXT_SIBLING;  
         mdoc->last = n;  
         if ( ! mdoc_valid_post(mdoc, tok, ppos))  
                 return(0);  
         return(mdoc_action(mdoc, tok, ppos));  
 }  }
   
   
Line 471  macro_scoped(MACRO_PROT_ARGS)
Line 476  macro_scoped(MACRO_PROT_ARGS)
         mdoc_argv_free(argc, argv);          mdoc_argv_free(argc, argv);
   
         if (0 == buf[*pos]) {          if (0 == buf[*pos]) {
                   mdoc_head_alloc(mdoc, ppos, tok);
                   if ( ! rewind_head(mdoc, ppos, tok))
                           return(0);
                 mdoc_body_alloc(mdoc, ppos, tok);                  mdoc_body_alloc(mdoc, ppos, tok);
                 mdoc->next = MDOC_NEXT_CHILD;                  mdoc->next = MDOC_NEXT_CHILD;
                 return(1);                  return(1);
Line 600  macro_constant_scoped(MACRO_PROT_ARGS)
Line 608  macro_constant_scoped(MACRO_PROT_ARGS)
         mdoc->next = MDOC_NEXT_CHILD;          mdoc->next = MDOC_NEXT_CHILD;
   
         if (0 == maxargs) {          if (0 == maxargs) {
                   mdoc_head_alloc(mdoc, ppos, tok);
                   if ( ! rewind_head(mdoc, ppos, tok))
                           return(0);
                 mdoc_body_alloc(mdoc, ppos, tok);                  mdoc_body_alloc(mdoc, ppos, tok);
                 flushed = 1;                  flushed = 1;
         } else          } else
Line 834  macro_obsolete(MACRO_PROT_ARGS)
Line 845  macro_obsolete(MACRO_PROT_ARGS)
 {  {
   
         return(mdoc_warn(mdoc, tok, ppos, WARN_IGN_OBSOLETE));          return(mdoc_warn(mdoc, tok, ppos, WARN_IGN_OBSOLETE));
   }
   
   
   int
   macro_end(struct mdoc *mdoc)
   {
   
           assert(mdoc->first);
           assert(mdoc->last);
           return(rewind_last(mdoc, -1, mdoc->first));
 }  }

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

CVSweb