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

Diff for /mandoc/out.c between version 1.52 and 1.55

version 1.52, 2014/10/14 02:16:06 version 1.55, 2014/12/23 03:28:01
Line 20 
Line 20 
 #include <sys/types.h>  #include <sys/types.h>
   
 #include <assert.h>  #include <assert.h>
 #include <ctype.h>  
 #include <stdio.h>  
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <time.h>  #include <time.h>
Line 39  static void tblcalc_number(struct rofftbl *, struct ro
Line 37  static void tblcalc_number(struct rofftbl *, struct ro
   
   
 /*  /*
  * Convert a `scaling unit' to a consistent form, or fail.  Scaling   * Parse the *src string and store a scaling unit into *dst.
  * units are documented in groff.7, mdoc.7, man.7.   * If the string doesn't specify the unit, use the default.
    * If no default is specified, fail.
    * Return 1 on success and 0 on failure.
  */   */
 int  int
 a2roffsu(const char *src, struct roffsu *dst, enum roffscale def)  a2roffsu(const char *src, struct roffsu *dst, enum roffscale def)
 {  {
         char             buf[BUFSIZ], hasd;          char            *endptr;
         int              i;          double           scale;
         enum roffscale   unit;          enum roffscale   unit;
   
         if ('\0' == *src)          scale = strtod(src, &endptr);
           if (endptr == src || (endptr[0] != '\0' && endptr[1] != '\0'))
                 return(0);                  return(0);
   
         i = hasd = 0;          switch (*endptr) {
   
         switch (*src) {  
         case '+':  
                 src++;  
                 break;  
         case '-':  
                 buf[i++] = *src++;  
                 break;  
         default:  
                 break;  
         }  
   
         if ('\0' == *src)  
                 return(0);  
   
         while (i < BUFSIZ) {  
                 if ( ! isdigit((unsigned char)*src)) {  
                         if ('.' != *src)  
                                 break;  
                         else if (hasd)  
                                 break;  
                         else  
                                 hasd = 1;  
                 }  
                 buf[i++] = *src++;  
         }  
   
         if (BUFSIZ == i || (*src && *(src + 1)))  
                 return(0);  
   
         buf[i] = '\0';  
   
         switch (*src) {  
         case 'c':          case 'c':
                 unit = SCALE_CM;                  unit = SCALE_CM;
                 break;                  break;
Line 110  a2roffsu(const char *src, struct roffsu *dst, enum rof
Line 78  a2roffsu(const char *src, struct roffsu *dst, enum rof
         case '\0':          case '\0':
                 if (SCALE_MAX == def)                  if (SCALE_MAX == def)
                         return(0);                          return(0);
                 unit = SCALE_EN;                  unit = def;
                 break;                  break;
         case 'u':          case 'u':
                 unit = SCALE_BU;                  unit = SCALE_BU;
Line 126  a2roffsu(const char *src, struct roffsu *dst, enum rof
Line 94  a2roffsu(const char *src, struct roffsu *dst, enum rof
         }          }
   
         /* FIXME: do this in the caller. */          /* FIXME: do this in the caller. */
         if ((dst->scale = atof(buf)) < 0.0)          if (scale < 0.0)
                 dst->scale = 0.0;                  scale = 0.0;
           dst->scale = scale;
         dst->unit = unit;          dst->unit = unit;
         return(1);          return(1);
 }  }
Line 158  tblcalc(struct rofftbl *tbl, const struct tbl_span *sp
Line 127  tblcalc(struct rofftbl *tbl, const struct tbl_span *sp
         tbl->cols = mandoc_calloc((size_t)sp->opts->cols,          tbl->cols = mandoc_calloc((size_t)sp->opts->cols,
             sizeof(struct roffcol));              sizeof(struct roffcol));
   
         for (maxcol = 0; sp; sp = sp->next) {          for (maxcol = -1; sp; sp = sp->next) {
                 if (TBL_SPAN_DATA != sp->pos)                  if (TBL_SPAN_DATA != sp->pos)
                         continue;                          continue;
                 spans = 1;                  spans = 1;

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

CVSweb