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

Diff for /mandoc/mdoc_macro.c between version 1.22 and 1.27

version 1.22, 2009/07/19 08:28:48 version 1.27, 2009/07/25 16:03:03
Line 71  const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
Line 71  const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
         { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ad */          { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ad */
         { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* An */          { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* An */
         { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ar */          { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ar */
         { in_line_eoln, MDOC_CALLABLE }, /* Cd */          { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Cd */
         { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Cm */          { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Cm */
         { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Dv */          { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Dv */
         { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Er */          { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Er */
Line 681  blk_exp_close(MACRO_PROT_ARGS)
Line 681  blk_exp_close(MACRO_PROT_ARGS)
                 mdoc->next = MDOC_NEXT_CHILD;                  mdoc->next = MDOC_NEXT_CHILD;
         }          }
   
         for (lastarg = ppos, flushed = j = 0; ; j++) {          for (flushed = j = 0; ; j++) {
                 lastarg = *pos;                  lastarg = *pos;
   
                 if (j == maxargs && ! flushed) {                  if (j == maxargs && ! flushed) {
Line 742  in_line(MACRO_PROT_ARGS)
Line 742  in_line(MACRO_PROT_ARGS)
          * usually because of reserved words) to squeak by.           * usually because of reserved words) to squeak by.
          */           */
         switch (tok) {          switch (tok) {
         case (MDOC_Nm):          case (MDOC_An):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
           case (MDOC_Ar):
                   /* FALLTHROUGH */
         case (MDOC_Fl):          case (MDOC_Fl):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Lk):          case (MDOC_Lk):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Ar):          case (MDOC_Nm):
                   /* FALLTHROUGH */
           case (MDOC_Pa):
                 nc = 1;                  nc = 1;
                 break;                  break;
         default:          default:
Line 756  in_line(MACRO_PROT_ARGS)
Line 760  in_line(MACRO_PROT_ARGS)
                 break;                  break;
         }          }
   
         for (la = ppos, arg = NULL;; ) {          for (arg = NULL;; ) {
                 la = *pos;                  la = *pos;
                 c = mdoc_argv(mdoc, line, tok, &arg, pos, buf);                  c = mdoc_argv(mdoc, line, tok, &arg, pos, buf);
   
Line 1042  blk_part_imp(MACRO_PROT_ARGS)
Line 1046  blk_part_imp(MACRO_PROT_ARGS)
   
         /* XXX - no known argument macros. */          /* XXX - no known argument macros. */
   
         for (lastarg = ppos;; ) {          for (;;) {
                 lastarg = *pos;                  lastarg = *pos;
                 c = mdoc_args(mdoc, line, pos, buf, tok, &p);                  c = mdoc_args(mdoc, line, pos, buf, tok, &p);
                 assert(ARGS_PHRASE != c);                  assert(ARGS_PHRASE != c);
Line 1103  blk_part_exp(MACRO_PROT_ARGS)
Line 1107  blk_part_exp(MACRO_PROT_ARGS)
         int               lastarg, flushed, j, c, maxargs;          int               lastarg, flushed, j, c, maxargs;
         char             *p;          char             *p;
   
         lastarg = ppos;  
         flushed = 0;          flushed = 0;
   
         /*          /*
Line 1239  in_line_argn(MACRO_PROT_ARGS)
Line 1242  in_line_argn(MACRO_PROT_ARGS)
                 break;                  break;
         }          }
   
         for (lastarg = ppos, arg = NULL;; ) {          for (arg = NULL;; ) {
                 lastarg = *pos;                  lastarg = *pos;
                 c = mdoc_argv(mdoc, line, tok, &arg, pos, buf);                  c = mdoc_argv(mdoc, line, tok, &arg, pos, buf);
   
Line 1385  obsolete(MACRO_PROT_ARGS)
Line 1388  obsolete(MACRO_PROT_ARGS)
 }  }
   
   
   /*
    * Phrases occur within `Bl -column' entries, separated by `Ta' or tabs.
    * They're unusual because they're basically free-form text until a
    * macro is encountered.
    */
 static int  static int
 phrase(struct mdoc *mdoc, int line, int ppos, char *buf)  phrase(struct mdoc *mdoc, int line, int ppos, char *buf)
 {  {
         int              i, la, c, quoted;          int               c, w, la, pos;
           char             *p;
   
         /*          for (pos = ppos; ; ) {
          * Parse over words in a phrase.  We have to handle this                  la = pos;
          * specially because we assume no calling context -- in normal  
          * circumstances, we switch argument parsing based on whether  
          * the parent macro accepts quotes, tabs, etc.  Here, anything  
          * goes.  
          */  
   
         for (i = ppos; buf[i]; ) {                  /* Note: no calling context! */
                 assert(' ' != buf[i]);                  w = mdoc_zargs(mdoc, line, &pos, buf, &p);
                 la = i;  
                 quoted = 0;  
   
                 /*                  if (ARGS_ERROR == w)
                  * Read to next token.  If quoted (check not escaped),                          return(0);
                  * scan ahead to next unescaped quote.  If not quoted or                  if (ARGS_EOLN == w)
                  * escape-quoted, then scan ahead to next space.                          break;
                  */  
   
                 if ((i && '\"' == buf[i] && '\\' != buf[i - 1]) ||                  c = ARGS_QWORD == w ? MDOC_MAX :
                                 (0 == i && '\"' == buf[i])) {                          mdoc_hash_find(mdoc->htab, p);
                         for (la = ++i; buf[i]; i++)  
                                 if ('\"' != buf[i])  
                                         continue;  
                                 else if ('\\' != buf[i - 1])  
                                         break;  
                         if (0 == buf[i])  
                                 return(mdoc_perr(mdoc, line, la, EQUOTPHR));  
                         quoted = 1;  
                 } else  
                         for ( ; buf[i]; i++)  
                                 if (i && ' ' == buf[i]) {  
                                         if ('\\' != buf[i - 1])  
                                                 break;  
                                 } else if (' ' == buf[i])  
                                         break;  
   
                 /* If not end-of-line, terminate argument. */                  if (MDOC_MAX != c && -1 != c) {
                           if ( ! mdoc_macro(mdoc, c, line, la, &pos, buf))
                 if (buf[i])  
                         buf[i++] = 0;  
   
                 /* Read to next argument. */  
   
                 for ( ; buf[i] && ' ' == buf[i]; i++)  
                         /* Spin. */ ;  
   
                 /*  
                  * If we're a non-quoted string, try to look up the  
                  * value as a macro and execute it, if found.  
                  */  
   
                 c = quoted ? MDOC_MAX :  
                         mdoc_hash_find(mdoc->htab, &buf[la]);  
   
                 if (MDOC_MAX != c) {  
                         if ( ! mdoc_macro(mdoc, c, line, la, &i, buf))  
                                 return(0);                                  return(0);
                         return(append_delims(mdoc, line, &i, buf));                          return(append_delims(mdoc, line, &pos, buf));
                 }                  } else if (-1 == c)
                           return(0);
   
                 /* A regular word or quoted string. */                  if ( ! mdoc_word_alloc(mdoc, line, la, p))
   
                 if ( ! mdoc_word_alloc(mdoc, line, la, &buf[la]))  
                         return(0);                          return(0);
                 mdoc->next = MDOC_NEXT_SIBLING;                  mdoc->next = MDOC_NEXT_SIBLING;
         }          }
   
         return(1);          return(1);
 }  }
   
   

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.27

CVSweb