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

Diff for /mandoc/Attic/macro.c between version 1.28 and 1.32

version 1.28, 2009/01/08 14:55:59 version 1.32, 2009/01/12 12:52:21
Line 37  static int   rewind_body(struct mdoc *, int);
Line 37  static int   rewind_body(struct mdoc *, int);
 static  int       rewind_last(struct mdoc *, struct mdoc_node *);  static  int       rewind_last(struct mdoc *, struct mdoc_node *);
 static  int       append_delims(struct mdoc *,  static  int       append_delims(struct mdoc *,
                         int, int, int *, char *);                          int, int, int *, char *);
 static  int       lookup(struct mdoc *, int, const char *);  static  int       lookup(struct mdoc *, int, int, int, const char *);
   
   
 static int  static int
 lookup(struct mdoc *mdoc, int from, const char *p)  lookup(struct mdoc *mdoc, int line, int pos, int from, const char *p)
 {  {
           int              res;
   
         if ( ! (MDOC_PARSED & mdoc_macros[from].flags))          res = mdoc_find(mdoc, p);
                 return(MDOC_MAX);          if (MDOC_PARSED & mdoc_macros[from].flags)
         return(mdoc_find(mdoc, p));                  return(res);
           if (MDOC_MAX == res)
                   return(res);
   
           if ( ! mdoc_pwarn(mdoc, line, pos, WARN_SYNTAX_MACLIKE))
                   return(-1);
           return(MDOC_MAX);
 }  }
   
   
Line 55  rewind_last(struct mdoc *mdoc, struct mdoc_node *to)
Line 62  rewind_last(struct mdoc *mdoc, struct mdoc_node *to)
 {  {
   
         assert(to);          assert(to);
         while (mdoc->last != to) {          mdoc->next = MDOC_NEXT_SIBLING;
           if (mdoc->last == to) {
                 if ( ! mdoc_valid_post(mdoc))                  if ( ! mdoc_valid_post(mdoc))
                         return(0);                          return(0);
                 if ( ! mdoc_action_post(mdoc))                  if ( ! mdoc_action_post(mdoc))
                         return(0);                          return(0);
                   return(1);
           }
   
           do {
                 mdoc->last = mdoc->last->parent;                  mdoc->last = mdoc->last->parent;
                 assert(mdoc->last);                  assert(mdoc->last);
         }                  if ( ! mdoc_valid_post(mdoc))
                           return(0);
                   if ( ! mdoc_action_post(mdoc))
                           return(0);
           } while (mdoc->last != to);
   
         mdoc->next = MDOC_NEXT_SIBLING;          return(1);
         if ( ! mdoc_valid_post(mdoc))  
                 return(0);  
         return(mdoc_action_post(mdoc));  
 }  }
   
   
Line 80  rewind_elem(struct mdoc *mdoc, int tok)
Line 93  rewind_elem(struct mdoc *mdoc, int tok)
         if (MDOC_ELEM != n->type)          if (MDOC_ELEM != n->type)
                 n = n->parent;                  n = n->parent;
         assert(MDOC_ELEM == n->type);          assert(MDOC_ELEM == n->type);
         assert(tok == n->data.elem.tok);          assert(tok == n->tok);
   
         return(rewind_last(mdoc, n));          return(rewind_last(mdoc, n));
 }  }
Line 98  rewind_body(struct mdoc *mdoc, int tok)
Line 111  rewind_body(struct mdoc *mdoc, int tok)
         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 (tok == (t = n->data.head.tok))                  if (tok == (t = n->tok))
                         break;                          break;
                 if ( ! (MDOC_EXPLICIT & mdoc_macros[t].flags))                  if ( ! (MDOC_EXPLICIT & mdoc_macros[t].flags))
                         continue;                          continue;
Line 122  rewind_head(struct mdoc *mdoc, int tok)
Line 135  rewind_head(struct mdoc *mdoc, int tok)
         for (n = mdoc->last; n; n = n->parent) {          for (n = mdoc->last; n; n = n->parent) {
                 if (MDOC_HEAD != n->type)                  if (MDOC_HEAD != n->type)
                         continue;                          continue;
                 if (tok == (t = n->data.head.tok))                  if (tok == (t = n->tok))
                         break;                          break;
                 if ( ! (MDOC_EXPLICIT & mdoc_macros[t].flags))                  if ( ! (MDOC_EXPLICIT & mdoc_macros[t].flags))
                         continue;                          continue;
Line 140  rewind_expblock(struct mdoc *mdoc, int tok)
Line 153  rewind_expblock(struct mdoc *mdoc, int tok)
         struct mdoc_node *n;          struct mdoc_node *n;
         int               t;          int               t;
   
         assert(mdoc->last);          n = mdoc->last ? mdoc->last->parent : NULL;
   
         /* LINTED */          /* LINTED */
         for (n = mdoc->last; n; n = n->parent) {          for ( ; n; n = n->parent) {
                 if (MDOC_BLOCK != n->type)                  if (MDOC_BLOCK != n->type)
                         continue;                          continue;
                 if (tok == (t = n->data.block.tok))                  if (tok == (t = n->tok))
                         break;                          break;
                 if (MDOC_NESTED & mdoc_macros[t].flags)                  if (MDOC_NESTED & mdoc_macros[t].flags)
                         continue;                          continue;
Line 170  rewind_impblock(struct mdoc *mdoc, int tok)
Line 183  rewind_impblock(struct mdoc *mdoc, int tok)
         for ( ; n; n = n->parent) {          for ( ; n; n = n->parent) {
                 if (MDOC_BLOCK != n->type)                  if (MDOC_BLOCK != n->type)
                         continue;                          continue;
                 if (tok == (t = n->data.block.tok))                  if (tok == (t = n->tok))
                         break;                          break;
                 if ( ! (MDOC_EXPLICIT & mdoc_macros[t].flags))                  if ( ! (MDOC_EXPLICIT & mdoc_macros[t].flags))
                         continue;                          continue;
                 if (MDOC_NESTED & mdoc_macros[t].flags)                  if (MDOC_NESTED & mdoc_macros[tok].flags)
                         return(1);                          return(1);
                 return(mdoc_verr(mdoc, n, ERR_SCOPE_BREAK));                  return(mdoc_verr(mdoc, n, ERR_SCOPE_BREAK));
         }          }
Line 280  macro_close_explicit(MACRO_PROT_ARGS)
Line 293  macro_close_explicit(MACRO_PROT_ARGS)
         }          }
   
         if ( ! (MDOC_CALLABLE & mdoc_macros[tok].flags)) {          if ( ! (MDOC_CALLABLE & mdoc_macros[tok].flags)) {
                 if (buf[*pos])                  if (0 == buf[*pos])
                         return(rewind_expblock(mdoc, tt));                          return(rewind_expblock(mdoc, tt));
                 return(mdoc_perr(mdoc, line, ppos, ERR_ARGS_EQ0));                  return(mdoc_perr(mdoc, line, ppos, ERR_ARGS_EQ0));
         }          }
Line 314  macro_close_explicit(MACRO_PROT_ARGS)
Line 327  macro_close_explicit(MACRO_PROT_ARGS)
                 if (ARGS_EOLN == c)                  if (ARGS_EOLN == c)
                         break;                          break;
   
                 if (MDOC_MAX != (c = lookup(mdoc, tok, p))) {                  if (-1 == (c = lookup(mdoc, line, lastarg, tok, p)))
                           return(0);
                   else if (MDOC_MAX != c) {
                         if ( ! flushed) {                          if ( ! flushed) {
                                 if ( ! rewind_expblock(mdoc, tt))                                  if ( ! rewind_expblock(mdoc, tt))
                                         return(0);                                          return(0);
Line 323  macro_close_explicit(MACRO_PROT_ARGS)
Line 338  macro_close_explicit(MACRO_PROT_ARGS)
                         if ( ! mdoc_macro(mdoc, c, line, lastarg, pos, buf))                          if ( ! mdoc_macro(mdoc, c, line, lastarg, pos, buf))
                                 return(0);                                  return(0);
                         break;                          break;
                 }                  }
   
                 if ( ! mdoc_word_alloc(mdoc, line, lastarg, p))                  if ( ! mdoc_word_alloc(mdoc, line, lastarg, p))
                         return(0);                          return(0);
Line 416  macro_text(MACRO_PROT_ARGS)
Line 431  macro_text(MACRO_PROT_ARGS)
                 if (ARGS_PUNCT == c)                  if (ARGS_PUNCT == c)
                         break;                          break;
   
                 if (MDOC_MAX != (c = lookup(mdoc, tok, p))) {                  if (-1 == (c = lookup(mdoc, line, la, tok, p)))
                           return(0);
                   else if (MDOC_MAX != c) {
                         if ( ! rewind_elem(mdoc, tok)) {                          if ( ! rewind_elem(mdoc, tok)) {
                                 mdoc_argv_free(argc, argv);                                  mdoc_argv_free(argc, argv);
                                 return(0);                                  return(0);
Line 523  macro_scoped(MACRO_PROT_ARGS)
Line 540  macro_scoped(MACRO_PROT_ARGS)
                 if (ARGS_EOLN == c)                  if (ARGS_EOLN == c)
                         break;                          break;
   
                 if (MDOC_MAX == (c = lookup(mdoc, tok, p))) {                  if (-1 == (c = lookup(mdoc, line, lastarg, tok, p)))
                           return(0);
                   else if (MDOC_MAX == c) {
                         if ( ! mdoc_word_alloc(mdoc, line, lastarg, p))                          if ( ! mdoc_word_alloc(mdoc, line, lastarg, p))
                                 return(0);                                  return(0);
                         mdoc->next = MDOC_NEXT_SIBLING;                          mdoc->next = MDOC_NEXT_SIBLING;
                         continue;                          continue;
                 }                  }
   
                 if ( ! mdoc_macro(mdoc, c, line, lastarg, pos, buf))                  if ( ! mdoc_macro(mdoc, c, line, lastarg, pos, buf))
                         return(0);                          return(0);
Line 583  macro_scoped_line(MACRO_PROT_ARGS)
Line 602  macro_scoped_line(MACRO_PROT_ARGS)
                 if (ARGS_EOLN == c)                  if (ARGS_EOLN == c)
                         break;                          break;
   
                 if (MDOC_MAX == (c = lookup(mdoc, tok, p))) {                  if (-1 == (c = lookup(mdoc, line, lastarg, tok, p)))
                           return(0);
                   else if (MDOC_MAX == c) {
                         if ( ! mdoc_word_alloc(mdoc, line, lastarg, p))                          if ( ! mdoc_word_alloc(mdoc, line, lastarg, p))
                                 return(0);                                  return(0);
                         mdoc->next = MDOC_NEXT_SIBLING;                          mdoc->next = MDOC_NEXT_SIBLING;
                         continue;                          continue;
                 }                  }
   
                 if ( ! mdoc_macro(mdoc, c, line, lastarg, pos, buf))                  if ( ! mdoc_macro(mdoc, c, line, lastarg, pos, buf))
                         return(0);                          return(0);
Line 667  macro_constant_scoped(MACRO_PROT_ARGS)
Line 688  macro_constant_scoped(MACRO_PROT_ARGS)
                 if (ARGS_EOLN == c)                  if (ARGS_EOLN == c)
                         break;                          break;
   
                 if (MDOC_MAX != (c = lookup(mdoc, tok, p))) {                  if (-1 == (c = lookup(mdoc, line, lastarg, tok, p)))
                           return(0);
                   else if (MDOC_MAX != c) {
                         if ( ! flushed) {                          if ( ! flushed) {
                                 if ( ! rewind_head(mdoc, tok))                                  if ( ! rewind_head(mdoc, tok))
                                         return(0);                                          return(0);
Line 779  macro_constant_delimited(MACRO_PROT_ARGS)
Line 802  macro_constant_delimited(MACRO_PROT_ARGS)
                 if (ARGS_EOLN == c)                  if (ARGS_EOLN == c)
                         break;                          break;
   
                 if (MDOC_MAX != (c = lookup(mdoc, tok, p))) {                  if (-1 == (c = lookup(mdoc, line, lastarg, tok, p)))
                           return(0);
                   else if (MDOC_MAX != c) {
                         if ( ! flushed && ! rewind_elem(mdoc, tok))                          if ( ! flushed && ! rewind_elem(mdoc, tok))
                                 return(0);                                  return(0);
                         flushed = 1;                          flushed = 1;

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.32

CVSweb