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

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

version 1.23, 2009/01/05 17:57:08 version 1.24, 2009/01/06 15:49:44
Line 35  static int   rewind_expblock(struct mdoc *, int, int, 
Line 35  static int   rewind_expblock(struct mdoc *, 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       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  static int
   lookup(struct mdoc *mdoc, int from, const char *p)
   {
   
           if ( ! (MDOC_PARSED & mdoc_macros[from].flags))
                   return(MDOC_MAX);
           return(mdoc_find(mdoc, p));
   }
   
   
   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 292  macro_close_explicit(MACRO_PROT_ARGS)
Line 303  macro_close_explicit(MACRO_PROT_ARGS)
                 if (ARGS_EOLN == c)                  if (ARGS_EOLN == c)
                         break;                          break;
   
                 if (MDOC_MAX != (c = mdoc_find(mdoc, p))) {                  if (MDOC_MAX != (c = lookup(mdoc, tok, p))) {
                         if ( ! flushed) {                          if ( ! flushed) {
                                 if ( ! rewind_expblock(mdoc, ppos, tok, tt))                                  if ( ! rewind_expblock(mdoc, ppos, tok, tt))
                                         return(0);                                          return(0);
Line 383  macro_text(MACRO_PROT_ARGS)
Line 394  macro_text(MACRO_PROT_ARGS)
                 if (ARGS_PUNCT == c)                  if (ARGS_PUNCT == c)
                         break;                          break;
   
                 if (MDOC_MAX != (c = mdoc_find(mdoc, p))) {                  if (MDOC_MAX != (c = lookup(mdoc, tok, p))) {
                         if ( ! rewind_elem(mdoc, ppos, tok)) {                          if ( ! rewind_elem(mdoc, ppos, tok)) {
                                 mdoc_argv_free(argc, argv);                                  mdoc_argv_free(argc, argv);
                                 return(0);                                  return(0);
Line 426  macro_text(MACRO_PROT_ARGS)
Line 437  macro_text(MACRO_PROT_ARGS)
 int  int
 macro_scoped(MACRO_PROT_ARGS)  macro_scoped(MACRO_PROT_ARGS)
 {  {
         int               c, lastarg, argc;          int               c, lastarg, argc, j;
         struct mdoc_arg   argv[MDOC_LINEARG_MAX];          struct mdoc_arg   argv[MDOC_LINEARG_MAX];
           char             *p;
   
         assert ( ! (MDOC_CALLABLE & mdoc_macros[tok].flags));          assert ( ! (MDOC_CALLABLE & mdoc_macros[tok].flags));
   
Line 458  macro_scoped(MACRO_PROT_ARGS)
Line 470  macro_scoped(MACRO_PROT_ARGS)
   
         mdoc_argv_free(argc, argv);          mdoc_argv_free(argc, argv);
   
         /* XXX - Assumes header isn't parsed! */          if (0 == buf[*pos]) {
                   mdoc_body_alloc(mdoc, ppos, tok);
         if (0 != buf[*pos]) {  
                 mdoc_head_alloc(mdoc, ppos, tok);  
                 mdoc->next = MDOC_NEXT_CHILD;                  mdoc->next = MDOC_NEXT_CHILD;
                   return(1);
           }
   
                 mdoc_word_alloc(mdoc, lastarg, &buf[*pos]);          mdoc_head_alloc(mdoc, ppos, tok);
                 mdoc->next = MDOC_NEXT_SIBLING;          mdoc->next = MDOC_NEXT_CHILD;
   
                 if ( ! rewind_head(mdoc, ppos, tok))          for (j = 0; j < MDOC_LINEARG_MAX; j++) {
                   lastarg = *pos;
                   c = mdoc_args(mdoc, tok, pos, buf, ARGS_DELIM, &p);
   
                   if (ARGS_ERROR == c)
                         return(0);                          return(0);
                   if (ARGS_PUNCT == c)
                           break;
                   if (ARGS_EOLN == c)
                           break;
   
                   if (MDOC_MAX == (c = lookup(mdoc, tok, p))) {
                           mdoc_word_alloc(mdoc, lastarg, p);
                           mdoc->next = MDOC_NEXT_SIBLING;
                           continue;
                   }
   
                 while (buf[*pos])                  if ( ! mdoc_macro(mdoc, c, lastarg, pos, buf))
                         (*pos)++;                          return(0);
                   break;
         }          }
   
           if (j == MDOC_LINEARG_MAX)
                   return(mdoc_err(mdoc, tok, lastarg, ERR_ARGS_MANY));
   
           if ( ! rewind_head(mdoc, ppos, tok))
                   return(0);
           if (1 == ppos && ! append_delims(mdoc, tok, pos, buf))
                   return(0);
   
         mdoc_body_alloc(mdoc, ppos, tok);          mdoc_body_alloc(mdoc, ppos, tok);
         mdoc->next = MDOC_NEXT_CHILD;          mdoc->next = MDOC_NEXT_CHILD;
   
Line 516  macro_scoped_line(MACRO_PROT_ARGS)
Line 551  macro_scoped_line(MACRO_PROT_ARGS)
                 if (ARGS_EOLN == c)                  if (ARGS_EOLN == c)
                         break;                          break;
   
                 if (MDOC_MAX == (c = mdoc_find(mdoc, p))) {                  if (MDOC_MAX == (c = lookup(mdoc, tok, p))) {
                         mdoc_word_alloc(mdoc, lastarg, p);                          mdoc_word_alloc(mdoc, lastarg, p);
                         mdoc->next = MDOC_NEXT_SIBLING;                          mdoc->next = MDOC_NEXT_SIBLING;
                         continue;                          continue;
Line 591  macro_constant_scoped(MACRO_PROT_ARGS)
Line 626  macro_constant_scoped(MACRO_PROT_ARGS)
                 if (ARGS_EOLN == c)                  if (ARGS_EOLN == c)
                         break;                          break;
   
                 if (MDOC_MAX != (c = mdoc_find(mdoc, p))) {                  if (MDOC_MAX != (c = lookup(mdoc, tok, p))) {
                         if ( ! flushed) {                          if ( ! flushed) {
                                 if ( ! rewind_head(mdoc, ppos, tok))                                  if ( ! rewind_head(mdoc, ppos, tok))
                                         return(0);                                          return(0);
Line 641  macro_constant_scoped(MACRO_PROT_ARGS)
Line 676  macro_constant_scoped(MACRO_PROT_ARGS)
 int  int
 macro_constant_delimited(MACRO_PROT_ARGS)  macro_constant_delimited(MACRO_PROT_ARGS)
 {  {
         int               lastarg, flushed, j, c, maxargs;          int               lastarg, flushed, j, c, maxargs, argc;
           struct mdoc_arg   argv[MDOC_LINEARG_MAX];
         char             *p;          char             *p;
   
         lastarg = ppos;          lastarg = ppos;
Line 653  macro_constant_delimited(MACRO_PROT_ARGS)
Line 689  macro_constant_delimited(MACRO_PROT_ARGS)
         case (MDOC_Ns):          case (MDOC_Ns):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Ux):          case (MDOC_Ux):
                   /* FALLTHROUGH */
           case (MDOC_St):
                 maxargs = 0;                  maxargs = 0;
                 break;                  break;
         default:          default:
Line 660  macro_constant_delimited(MACRO_PROT_ARGS)
Line 698  macro_constant_delimited(MACRO_PROT_ARGS)
                 break;                  break;
         }          }
   
         mdoc_elem_alloc(mdoc, lastarg, tok, 0, NULL);          for (argc = 0; argc < MDOC_LINEARG_MAX; argc++) {
                   lastarg = *pos;
                   c = mdoc_argv(mdoc, tok, &argv[argc], pos, buf);
                   if (ARGV_EOLN == c || ARGV_WORD == c)
                           break;
                   else if (ARGV_ARG == c)
                           continue;
                   mdoc_argv_free(argc, argv);
                   return(0);
           }
   
           if ( ! mdoc_valid_pre(mdoc, tok, ppos, argc, argv)) {
                   mdoc_argv_free(argc, argv);
                   return(0);
           }
   
           mdoc_elem_alloc(mdoc, lastarg, tok, argc, argv);
         mdoc->next = MDOC_NEXT_CHILD;          mdoc->next = MDOC_NEXT_CHILD;
   
           mdoc_argv_free(argc, argv);
   
         for (j = 0; j < MDOC_LINEARG_MAX; j++) {          for (j = 0; j < MDOC_LINEARG_MAX; j++) {
                 lastarg = *pos;                  lastarg = *pos;
   
Line 680  macro_constant_delimited(MACRO_PROT_ARGS)
Line 736  macro_constant_delimited(MACRO_PROT_ARGS)
                 if (ARGS_EOLN == c)                  if (ARGS_EOLN == c)
                         break;                          break;
   
                 if (MDOC_MAX != (c = mdoc_find(mdoc, p))) {                  if (MDOC_MAX != (c = lookup(mdoc, tok, p))) {
                         if ( ! flushed && ! rewind_elem(mdoc, ppos, tok))                          if ( ! flushed && ! rewind_elem(mdoc, ppos, tok))
                                 return(0);                                  return(0);
                         flushed = 1;                          flushed = 1;
Line 721  macro_constant(MACRO_PROT_ARGS)
Line 777  macro_constant(MACRO_PROT_ARGS)
         int              c, lastarg, argc, sz, fl;          int              c, lastarg, argc, sz, fl;
         struct mdoc_arg  argv[MDOC_LINEARG_MAX];          struct mdoc_arg  argv[MDOC_LINEARG_MAX];
         char            *p;          char            *p;
   
           /*assert( ! (MDOC_PARSED & mdoc_macros[tok].flags));*/
           /*FIXME*/
   
         fl = 0;          fl = 0;
         if (MDOC_QUOTABLE & mdoc_macros[tok].flags)          if (MDOC_QUOTABLE & mdoc_macros[tok].flags)

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

CVSweb