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

Diff for /mandoc/mdoc_argv.c between version 1.105 and 1.107

version 1.105, 2015/10/06 18:32:19 version 1.107, 2015/10/17 00:21:07
Line 447  static enum margserr
Line 447  static enum margserr
 args(struct roff_man *mdoc, int line, int *pos,  args(struct roff_man *mdoc, int line, int *pos,
                 char *buf, enum argsflag fl, char **v)                  char *buf, enum argsflag fl, char **v)
 {  {
         char            *p, *pp;          char            *p;
         int              pairs;          int              pairs;
         enum margserr    rc;  
   
         if ('\0' == buf[*pos]) {          if (buf[*pos] == '\0') {
                 if (MDOC_PPHRASE & mdoc->flags)                  if (mdoc->flags & MDOC_PHRASELIT &&
                         return ARGS_EOLN;                      ! (mdoc->flags & MDOC_PHRASE)) {
                 /*  
                  * If we're not in a partial phrase and the flag for  
                  * being a phrase literal is still set, the punctuation  
                  * is unterminated.  
                  */  
                 if (MDOC_PHRASELIT & mdoc->flags)  
                         mandoc_msg(MANDOCERR_ARG_QUOTE,                          mandoc_msg(MANDOCERR_ARG_QUOTE,
                             mdoc->parse, line, *pos, NULL);                              mdoc->parse, line, *pos, NULL);
                           mdoc->flags &= ~MDOC_PHRASELIT;
                 mdoc->flags &= ~MDOC_PHRASELIT;                  }
                 return ARGS_EOLN;                  return ARGS_EOLN;
         }          }
   
         *v = &buf[*pos];          *v = buf + *pos;
   
         if (ARGSFL_DELIM == fl)          if (fl == ARGSFL_DELIM && args_checkpunct(buf, *pos))
                 if (args_checkpunct(buf, *pos))                  return ARGS_PUNCT;
                         return ARGS_PUNCT;  
   
         /*          /*
          * First handle TABSEP items, restricted to `Bl -column'.  This           * Tabs in `It' lines in `Bl -column' can't be escaped.
          * ignores conventional token parsing and instead uses tabs or           * Phrases are reparsed for `Ta' and other macros later.
          * `Ta' macros to separate phrases.  Phrases are parsed again  
          * for arguments at a later phase.  
          */           */
   
         if (ARGSFL_TABSEP == fl) {          if (fl == ARGSFL_TABSEP) {
                 /* Scan ahead to tab (can't be escaped). */                  if ((p = strchr(*v, '\t')) != NULL) {
                 p = strchr(*v, '\t');  
                 pp = NULL;  
   
                 /* Scan ahead to unescaped `Ta'. */                          /*
                 if ( ! (MDOC_PHRASELIT & mdoc->flags))                           * Words right before and right after
                         for (pp = *v; ; pp++) {                           * tab characters are not parsed,
                                 if (NULL == (pp = strstr(pp, "Ta")))                           * unless there is a blank in between.
                                         break;                           */
                                 if (pp > *v && ' ' != *(pp - 1))  
                                         continue;  
                                 if (' ' == *(pp + 2) || '\0' == *(pp + 2))  
                                         break;  
                         }  
   
                 /* By default, assume a phrase. */                          if (p[-1] != ' ')
                 rc = ARGS_PHRASE;                                  mdoc->flags |= MDOC_PHRASEQL;
                           if (p[1] != ' ')
                                   mdoc->flags |= MDOC_PHRASEQN;
   
                 /*                          /*
                  * Adjust new-buffer position to be beyond delimiter                           * One or more blanks after a tab cause
                  * mark (e.g., Ta -> end + 2).                           * one leading blank in the next column.
                  */                           * So skip all but one of them.
                 if (p && pp) {                           */
                         *pos += pp < p ? 2 : 1;  
                         rc = pp < p ? ARGS_PHRASE : ARGS_PPHRASE;  
                         p = pp < p ? pp : p;  
                 } else if (p && ! pp) {  
                         rc = ARGS_PPHRASE;  
                         *pos += 1;  
                 } else if (pp && ! p) {  
                         p = pp;  
                         *pos += 2;  
                 } else {  
                         rc = ARGS_PEND;  
                         p = strchr(*v, 0);  
                 }  
   
                 /* Whitespace check for eoln case... */                          *pos += (int)(p - *v) + 1;
                 if ('\0' == *p && ' ' == *(p - 1))                          while (buf[*pos] == ' ' && buf[*pos + 1] == ' ')
                         mandoc_msg(MANDOCERR_SPACE_EOL, mdoc->parse,                                  (*pos)++;
                             line, *pos, NULL);  
   
                 *pos += (int)(p - *v);                          /*
                            * A tab at the end of an input line
                            * switches to the next column.
                            */
   
                 /* Strip delimiter's preceding whitespace. */                          if (buf[*pos] == '\0' || buf[*pos + 1] == '\0')
                 pp = p - 1;                                  mdoc->flags |= MDOC_PHRASEQN;
                 while (pp > *v && ' ' == *pp) {                  } else {
                         if (pp > *v && '\\' == *(pp - 1))                          p = strchr(*v, '\0');
                                 break;                          if (p[-1] == ' ')
                         pp--;                                  mandoc_msg(MANDOCERR_SPACE_EOL,
                                       mdoc->parse, line, *pos, NULL);
                           *pos += (int)(p - *v);
                 }                  }
                 *(pp + 1) = 0;  
   
                 /* Strip delimiter's proceeding whitespace. */                  /* Skip any trailing blank characters. */
                 for (pp = &buf[*pos]; ' ' == *pp; pp++, (*pos)++)                  while (p > *v && p[-1] == ' ' &&
                         /* Skip ahead. */ ;                      (p - 1 == *v || p[-2] != '\\'))
                           p--;
                   *p = '\0';
   
                 return rc;                  return ARGS_PHRASE;
         }          }
   
         /*          /*
Line 549  args(struct roff_man *mdoc, int line, int *pos,
Line 526  args(struct roff_man *mdoc, int line, int *pos,
          * Whitespace is NOT involved in literal termination.           * Whitespace is NOT involved in literal termination.
          */           */
   
         if (MDOC_PHRASELIT & mdoc->flags || '\"' == buf[*pos]) {          if (mdoc->flags & MDOC_PHRASELIT || buf[*pos] == '\"') {
                 if ( ! (MDOC_PHRASELIT & mdoc->flags))                  if ( ! (mdoc->flags & MDOC_PHRASELIT))
                         *v = &buf[++(*pos)];                          *v = &buf[++(*pos)];
   
                 if (MDOC_PPHRASE & mdoc->flags)                  if (mdoc->flags & MDOC_PHRASE)
                         mdoc->flags |= MDOC_PHRASELIT;                          mdoc->flags |= MDOC_PHRASELIT;
   
                 pairs = 0;                  pairs = 0;
Line 573  args(struct roff_man *mdoc, int line, int *pos,
Line 550  args(struct roff_man *mdoc, int line, int *pos,
                 if (pairs)                  if (pairs)
                         buf[*pos - pairs] = '\0';                          buf[*pos - pairs] = '\0';
   
                 if ('\0' == buf[*pos]) {                  if (buf[*pos] == '\0') {
                         if (MDOC_PPHRASE & mdoc->flags)                          if ( ! (mdoc->flags & MDOC_PHRASE))
                                 return ARGS_QWORD;                                  mandoc_msg(MANDOCERR_ARG_QUOTE,
                         mandoc_msg(MANDOCERR_ARG_QUOTE,                                      mdoc->parse, line, *pos, NULL);
                             mdoc->parse, line, *pos, NULL);  
                         return ARGS_QWORD;                          return ARGS_QWORD;
                 }                  }
   
Line 600  args(struct roff_man *mdoc, int line, int *pos,
Line 576  args(struct roff_man *mdoc, int line, int *pos,
         p = &buf[*pos];          p = &buf[*pos];
         *v = mandoc_getarg(mdoc->parse, &p, line, pos);          *v = mandoc_getarg(mdoc->parse, &p, line, pos);
   
           /*
            * After parsing the last word in this phrase,
            * tell lookup() whether or not to interpret it.
            */
   
           if (*p == '\0' && mdoc->flags & MDOC_PHRASEQL) {
                   mdoc->flags &= ~MDOC_PHRASEQL;
                   mdoc->flags |= MDOC_PHRASEQF;
           }
         return ARGS_WORD;          return ARGS_WORD;
 }  }
   

Legend:
Removed from v.1.105  
changed lines
  Added in v.1.107

CVSweb