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

Diff for /mandoc/mandoc.c between version 1.57 and 1.63

version 1.57, 2011/07/27 07:06:29 version 1.63, 2012/05/31 22:29:13
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
  *   *
  * 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 143  mandoc_escape(const char **end, const char **start, in
Line 143  mandoc_escape(const char **end, const char **start, in
                 break;                  break;
   
         /*          /*
            * The \z escape is supposed to output the following
            * character without advancing the cursor position.
            * Since we are mostly dealing with terminal mode,
            * let us just skip the next character.
            */
           case ('z'):
                   (*end)++;
                   return(ESCAPE_SKIPCHAR);
   
           /*
          * Handle all triggers matching \X(xy, \Xx, and \X[xxxx], where           * Handle all triggers matching \X(xy, \Xx, and \X[xxxx], where
          * 'X' is the trigger.  These have opaque sub-strings.           * 'X' is the trigger.  These have opaque sub-strings.
          */           */
Line 161  mandoc_escape(const char **end, const char **start, in
Line 171  mandoc_escape(const char **end, const char **start, in
         case ('V'):          case ('V'):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case ('Y'):          case ('Y'):
                 if (ESCAPE_ERROR == gly)                  gly = ESCAPE_IGNORE;
                         gly = ESCAPE_IGNORE;  
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case ('f'):          case ('f'):
                 if (ESCAPE_ERROR == gly)                  if (ESCAPE_ERROR == gly)
Line 222  mandoc_escape(const char **end, const char **start, in
Line 231  mandoc_escape(const char **end, const char **start, in
         case ('L'):          case ('L'):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case ('l'):          case ('l'):
                   gly = ESCAPE_NUMBERED;
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case ('N'):  
                 if (ESCAPE_ERROR == gly)  
                         gly = ESCAPE_NUMBERED;  
                 /* FALLTHROUGH */  
         case ('S'):          case ('S'):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case ('v'):          case ('v'):
Line 241  mandoc_escape(const char **end, const char **start, in
Line 247  mandoc_escape(const char **end, const char **start, in
                 term = numeric = '\'';                  term = numeric = '\'';
                 break;                  break;
   
           /*
            * Special handling for the numbered character escape.
            * XXX Do any other escapes need similar handling?
            */
           case ('N'):
                   if ('\0' == cp[i])
                           return(ESCAPE_ERROR);
                   *end = &cp[++i];
                   if (isdigit((unsigned char)cp[i-1]))
                           return(ESCAPE_IGNORE);
                   while (isdigit((unsigned char)**end))
                           (*end)++;
                   if (start)
                           *start = &cp[i];
                   if (sz)
                           *sz = *end - &cp[i];
                   if ('\0' != **end)
                           (*end)++;
                   return(ESCAPE_NUMBERED);
   
         /*          /*
          * Sizes get a special category of their own.           * Sizes get a special category of their own.
          */           */
Line 353  out:
Line 379  out:
   
         switch (gly) {          switch (gly) {
         case (ESCAPE_FONT):          case (ESCAPE_FONT):
                 if (1 != rlim)                  /*
                    * Pretend that the constant-width font modes are the
                    * same as the regular font modes.
                    */
                   if (2 == rlim && 'C' == *rstart)
                           rstart++;
                   else if (1 != rlim)
                         break;                          break;
   
                 switch (*rstart) {                  switch (*rstart) {
                 case ('3'):                  case ('3'):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
Line 600  mandoc_normdate(struct mparse *parse, char *in, int ln
Line 633  mandoc_normdate(struct mparse *parse, char *in, int ln
                 mandoc_msg(MANDOCERR_NODATE, parse, ln, pos, NULL);                  mandoc_msg(MANDOCERR_NODATE, parse, ln, pos, NULL);
                 time(&t);                  time(&t);
         }          }
           else if (a2time(&t, "%Y-%m-%d", in))
                   t = 0;
         else if (!a2time(&t, "$" "Mdocdate: %b %d %Y $", in) &&          else if (!a2time(&t, "$" "Mdocdate: %b %d %Y $", in) &&
             !a2time(&t, "%b %d, %Y", in) &&              !a2time(&t, "%b %d, %Y", in)) {
             !a2time(&t, "%Y-%m-%d", in)) {  
                 mandoc_msg(MANDOCERR_BADDATE, parse, ln, pos, NULL);                  mandoc_msg(MANDOCERR_BADDATE, parse, ln, pos, NULL);
                 t = 0;                  t = 0;
         }          }
Line 651  mandoc_eos(const char *p, size_t sz, int enclosed)
Line 685  mandoc_eos(const char *p, size_t sz, int enclosed)
         }          }
   
         return(found && !enclosed);          return(found && !enclosed);
 }  
   
 /*  
  * Choose whether to break at a hyphenated character (identified by the  
  * ASCII_HYPH value in the input string).  
  */  
 int  
 mandoc_hyph(const char *start, const char *c)  
 {  
         char            l, r;  
   
         l = *(c - 1);  
         r = *(c + 1);  
   
         /* Skip first/last character of buffer. */  
         if (c == start || '\0' == r)  
                 return(0);  
   
         /* Skip a number on either side of the hyphen. */  
         if (isdigit((unsigned char)r) || isdigit((unsigned char)l))  
                 return(0);  
   
         /* Skip first/last character of word. */  
         if ('\t' == r || '\t' == l)  
                 return(0);  
   
         if (' ' == r || ' ' == l)  
                 return(0);  
   
         /* Skip double invocations. */  
         if ('-' == r || '-' == l)  
                 return(0);  
   
         /* Skip escapes. */  
         if ('\\' == l)  
                 return(0);  
   
         return(1);  
 }  }
   
 /*  /*

Legend:
Removed from v.1.57  
changed lines
  Added in v.1.63

CVSweb