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

Diff for /mandoc/man_validate.c between version 1.41 and 1.48

version 1.41, 2010/05/17 22:11:42 version 1.48, 2010/07/31 23:52:58
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>   * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 26 
Line 26 
 #include <limits.h>  #include <limits.h>
 #include <stdarg.h>  #include <stdarg.h>
 #include <stdlib.h>  #include <stdlib.h>
   #include <string.h>
   
 #include "mandoc.h"  #include "mandoc.h"
 #include "libman.h"  #include "libman.h"
 #include "libmandoc.h"  #include "libmandoc.h"
   
 #define CHKARGS   struct man *m, const struct man_node *n  #define CHKARGS   struct man *m, struct man_node *n
   
 typedef int     (*v_check)(CHKARGS);  typedef int     (*v_check)(CHKARGS);
   
Line 82  static const struct man_valid man_valids[MAN_MAX] = {
Line 83  static const struct man_valid man_valids[MAN_MAX] = {
         { NULL, NULL }, /* I */          { NULL, NULL }, /* I */
         { NULL, NULL }, /* IR */          { NULL, NULL }, /* IR */
         { NULL, NULL }, /* RI */          { NULL, NULL }, /* RI */
         { NULL, posts_eq0 }, /* na */          { NULL, posts_eq0 }, /* na */ /* FIXME: should warn only. */
         { NULL, NULL }, /* i */          { NULL, NULL }, /* i */
         { NULL, posts_le1 }, /* sp */          { NULL, posts_le1 }, /* sp */ /* FIXME: should warn only. */
         { pres_bline, posts_eq0 }, /* nf */          { pres_bline, posts_eq0 }, /* nf */
         { pres_bline, posts_eq0 }, /* fi */          { pres_bline, posts_eq0 }, /* fi */
         { NULL, NULL }, /* r */          { NULL, NULL }, /* r */
Line 93  static const struct man_valid man_valids[MAN_MAX] = {
Line 94  static const struct man_valid man_valids[MAN_MAX] = {
         { NULL, NULL }, /* DT */          { NULL, NULL }, /* DT */
         { NULL, NULL }, /* UC */          { NULL, NULL }, /* UC */
         { NULL, NULL }, /* PD */          { NULL, NULL }, /* PD */
         { NULL, posts_le1 }, /* Sp */          { NULL, posts_le1 }, /* Sp */ /* FIXME: should warn only. */
         { pres_bline, posts_le1 }, /* Vb */          { pres_bline, posts_le1 }, /* Vb */ /* FIXME: should warn only. */
         { pres_bline, posts_eq0 }, /* Ve */          { pres_bline, posts_eq0 }, /* Ve */
         { NULL, NULL }, /* AT */          { NULL, NULL }, /* AT */
           { NULL, NULL }, /* in */
 };  };
   
   
 int  int
 man_valid_pre(struct man *m, const struct man_node *n)  man_valid_pre(struct man *m, struct man_node *n)
 {  {
         v_check         *cp;          v_check         *cp;
   
Line 204  check_title(CHKARGS) 
Line 206  check_title(CHKARGS) 
 static int  static int
 check_text(CHKARGS)  check_text(CHKARGS)
 {  {
         const char      *p;          char            *p;
         int              pos, c;          int              pos, c;
           size_t           sz;
   
         assert(n->string);  
   
         for (p = n->string, pos = n->pos + 1; *p; p++, pos++) {          for (p = n->string, pos = n->pos + 1; *p; p++, pos++) {
                 if ('\\' == *p) {                  sz = strcspn(p, "\t\\");
                         c = mandoc_special(p);                  p += (int)sz;
                         if (c) {  
                                 p += c - 1;  
                                 pos += c - 1;  
                                 continue;  
                         }  
   
                         c = man_pmsg(m, n->line, pos, MANDOCERR_BADESCAPE);                  if ('\0' == *p)
                         if ( ! (MAN_IGN_ESCAPE & m->pflags) && ! c)                          break;
                                 return(c);  
                   pos += (int)sz;
   
                   if ('\t' == *p) {
                           if (MAN_LITERAL & m->flags)
                                   continue;
                           if (man_pmsg(m, n->line, pos, MANDOCERR_BADTAB))
                                   continue;
                           return(0);
                 }                  }
   
                 if ('\t' == *p || isprint((u_char)*p))                  /* Check the special character. */
   
                   c = mandoc_special(p);
                   if (c) {
                           p += c - 1;
                           pos += c - 1;
                         continue;                          continue;
                 if ( ! man_pmsg(m, n->line, pos, MANDOCERR_BADCHAR))                  }
                         return(0);  
                   c = man_pmsg(m, n->line, pos, MANDOCERR_BADESCAPE);
                   if ( ! (MAN_IGN_ESCAPE & m->pflags) && ! c)
                           return(c);
         }          }
   
         return(1);          return(1);

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.48

CVSweb