[BACK]Return to mdoc.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mandoc

Diff for /src/usr.bin/mandoc/mdoc.c between version 1.52 and 1.53

version 1.52, 2010/05/16 20:46:15 version 1.53, 2010/05/20 00:58:02
Line 146 
Line 146 
                                 enum mdoct, enum mdoc_type);                                  enum mdoct, enum mdoc_type);
 static  int               node_append(struct mdoc *,  static  int               node_append(struct mdoc *,
                                 struct mdoc_node *);                                  struct mdoc_node *);
 static  int               mdoc_ptext(struct mdoc *, int, char *);  static  int               mdoc_ptext(struct mdoc *, int, char *, int);
 static  int               mdoc_pmacro(struct mdoc *, int, char *);  static  int               mdoc_pmacro(struct mdoc *, int, char *, int);
 static  int               macrowarn(struct mdoc *, int, const char *);  static  int               macrowarn(struct mdoc *, int,
                                   const char *, int);
   
   
 const struct mdoc_node *  const struct mdoc_node *
Line 280 
Line 281 
  * the macro (mdoc_pmacro()) or text parser (mdoc_ptext()).   * the macro (mdoc_pmacro()) or text parser (mdoc_ptext()).
  */   */
 int  int
 mdoc_parseln(struct mdoc *m, int ln, char *buf)  mdoc_parseln(struct mdoc *m, int ln, char *buf, int offs)
 {  {
   
         if (MDOC_HALT & m->flags)          if (MDOC_HALT & m->flags)
                 return(0);                  return(0);
   
         m->flags |= MDOC_NEWLINE;          m->flags |= MDOC_NEWLINE;
         return(('.' == *buf || '\'' == *buf) ?          return(('.' == buf[offs] || '\'' == buf[offs]) ?
                         mdoc_pmacro(m, ln, buf) :                          mdoc_pmacro(m, ln, buf, offs) :
                         mdoc_ptext(m, ln, buf));                          mdoc_ptext(m, ln, buf, offs));
 }  }
   
   
Line 626 
Line 627 
  * control character.   * control character.
  */   */
 static int  static int
 mdoc_ptext(struct mdoc *m, int line, char *buf)  mdoc_ptext(struct mdoc *m, int line, char *buf, int offs)
 {  {
         char            *c, *ws, *end;          char            *c, *ws, *end;
   
         /* Ignore bogus comments. */          /* Ignore bogus comments. */
   
         if ('\\' == buf[0] && '.' == buf[1] && '\"' == buf[2])          if ('\\' == buf[offs] &&
                 return(mdoc_pwarn(m, line, 0, EBADCOMMENT));                          '.' == buf[offs + 1] &&
                           '"' == buf[offs + 2])
                   return(mdoc_pwarn(m, line, offs, EBADCOMMENT));
   
         /* No text before an initial macro. */          /* No text before an initial macro. */
   
         if (SEC_NONE == m->lastnamed)          if (SEC_NONE == m->lastnamed)
                 return(mdoc_perr(m, line, 0, ETEXTPROL));                  return(mdoc_perr(m, line, offs, ETEXTPROL));
   
         /*          /*
          * Search for the beginning of unescaped trailing whitespace (ws)           * Search for the beginning of unescaped trailing whitespace (ws)
          * and for the first character not to be output (end).           * and for the first character not to be output (end).
          */           */
         ws = NULL;          ws = NULL;
         for (c = end = buf; *c; c++) {          for (c = end = buf + offs; *c; c++) {
                 switch (*c) {                  switch (*c) {
                 case ' ':                  case ' ':
                         if (NULL == ws)                          if (NULL == ws)
Line 683 
Line 686 
                 if ( ! mdoc_pwarn(m, line, (int)(ws-buf), ETAILWS))                  if ( ! mdoc_pwarn(m, line, (int)(ws-buf), ETAILWS))
                         return(0);                          return(0);
   
         if ('\0' == *buf && ! (MDOC_LITERAL & m->flags)) {          if ('\0' == buf[offs] && ! (MDOC_LITERAL & m->flags)) {
                 if ( ! mdoc_pwarn(m, line, (int)(c-buf), ENOBLANK))                  if ( ! mdoc_pwarn(m, line, (int)(c-buf), ENOBLANK))
                         return(0);                          return(0);
   
Line 692 
Line 695 
                  * blank lines aren't allowed, but enough manuals assume this                   * blank lines aren't allowed, but enough manuals assume this
                  * behaviour that we want to work around it.                   * behaviour that we want to work around it.
                  */                   */
                 if ( ! mdoc_elem_alloc(m, line, 0, MDOC_Pp, NULL))                  if ( ! mdoc_elem_alloc(m, line, offs, MDOC_Pp, NULL))
                         return(0);                          return(0);
   
                 m->next = MDOC_NEXT_SIBLING;                  m->next = MDOC_NEXT_SIBLING;
                 return(1);                  return(1);
         }          }
   
         if ( ! mdoc_word_alloc(m, line, 0, buf))          if ( ! mdoc_word_alloc(m, line, offs, buf+offs))
                 return(0);                  return(0);
   
         if (MDOC_LITERAL & m->flags)          if (MDOC_LITERAL & m->flags)
Line 713 
Line 716 
   
         assert(buf < end);          assert(buf < end);
   
         if (mandoc_eos(buf, (size_t)(end-buf)))          if (mandoc_eos(buf+offs, (size_t)(end-buf-offs)))
                 m->last->flags |= MDOC_EOS;                  m->last->flags |= MDOC_EOS;
   
         return(1);          return(1);
Line 721 
Line 724 
   
   
 static int  static int
 macrowarn(struct mdoc *m, int ln, const char *buf)  macrowarn(struct mdoc *m, int ln, const char *buf, int offs)
 {  {
         if ( ! (MDOC_IGN_MACRO & m->pflags))          if ( ! (MDOC_IGN_MACRO & m->pflags))
                 return(mdoc_verr(m, ln, 0, "unknown macro: %s%s",                  return(mdoc_verr(m, ln, offs, "unknown macro: %s%s",
                                 buf, strlen(buf) > 3 ? "..." : ""));                                  buf, strlen(buf) > 3 ? "..." : ""));
         return(mdoc_vwarn(m, ln, 0, "unknown macro: %s%s",          return(mdoc_vwarn(m, ln, offs, "unknown macro: %s%s",
                                 buf, strlen(buf) > 3 ? "..." : ""));                                  buf, strlen(buf) > 3 ? "..." : ""));
 }  }
   
Line 736 
Line 739 
  * character.   * character.
  */   */
 int  int
 mdoc_pmacro(struct mdoc *m, int ln, char *buf)  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs)
 {  {
         enum mdoct      tok;          enum mdoct      tok;
         int             i, j, sv;          int             i, j, sv;
Line 744 
Line 747 
   
         /* Empty lines are ignored. */          /* Empty lines are ignored. */
   
         if ('\0' == buf[1])          offs++;
   
           if ('\0' == buf[offs])
                 return(1);                  return(1);
   
         i = 1;          i = offs;
   
         /* Accept whitespace after the initial control char. */          /* Accept whitespace after the initial control char. */
   
Line 776 
Line 781 
                 return(mdoc_perr(m, ln, i, EPRINT));                  return(mdoc_perr(m, ln, i, EPRINT));
         }          }
   
         mac[j] = 0;          mac[j] = '\0';
   
         if (j == 4 || j < 2) {          if (j == 4 || j < 2) {
                 if ( ! macrowarn(m, ln, mac))                  if ( ! macrowarn(m, ln, mac, sv))
                         goto err;                          goto err;
                 return(1);                  return(1);
         }          }
   
         if (MDOC_MAX == (tok = mdoc_hash_find(mac))) {          if (MDOC_MAX == (tok = mdoc_hash_find(mac))) {
                 if ( ! macrowarn(m, ln, mac))                  if ( ! macrowarn(m, ln, mac, sv))
                         goto err;                          goto err;
                 return(1);                  return(1);
         }          }

Legend:
Removed from v.1.52  
changed lines
  Added in v.1.53