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

Diff for /src/usr.bin/mandoc/mandoc.c between version 1.14 and 1.15

version 1.14, 2010/06/26 17:56:43 version 1.15, 2010/07/16 00:34:33
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>   * 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 324 
Line 324 
   
   
 int  int
 mandoc_eos(const char *p, size_t sz)  mandoc_eos(const char *p, size_t sz, int enclosed)
 {  {
           const char *q;
           int found = 0;
   
         if (0 == sz)          if (0 == sz)
                 return(0);                  return(0);
Line 336 
Line 338 
          * propogate outward.           * propogate outward.
          */           */
   
         for ( ; sz; sz--) {          for (q = p + sz - 1; q >= p; q--) {
                 switch (p[(int)sz - 1]) {                  switch (*q) {
                 case ('\"'):                  case ('\"'):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case ('\''):                  case ('\''):
Line 345 
Line 347 
                 case (']'):                  case (']'):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (')'):                  case (')'):
                           if (0 == found)
                                   enclosed = 1;
                         break;                          break;
                 case ('.'):                  case ('.'):
                         /* Escaped periods. */  
                         if (sz > 1 && '\\' == p[(int)sz - 2])  
                                 return(0);  
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case ('!'):                  case ('!'):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case ('?'):                  case ('?'):
                         return(1);                          found = 1;
                           break;
                 default:                  default:
                         return(0);                          return(found && (!enclosed || isalnum(*q)));
                 }                  }
         }          }
   
         return(0);          return(found && !enclosed);
 }  }
   
   

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15