Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for libcfg+/src/shared.c between version 1.29 and 1.30

version 1.29, 2003/02/24 21:13:40 version 1.30, 2003/02/25 12:58:41
Line 16 
Line 16 
  * http://www.platon.sk/projects/libcfg+/   * http://www.platon.sk/projects/libcfg+/
  */   */
   
 /* $Platon: libcfg+/src/shared.c,v 1.28 2003/02/17 17:12:07 nepto Exp $ */  /* $Platon: libcfg+/src/shared.c,v 1.29 2003/02/24 21:13:40 nepto Exp $ */
   
 /* Includes {{{ */  /* Includes {{{ */
 #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
Line 689  store_single_arg(type, arg, where)
Line 689  store_single_arg(type, arg, where)
         register long          long_val   = 0;          register long          long_val   = 0;
         register unsigned long ulong_val  = 0;          register unsigned long ulong_val  = 0;
         register double        double_val = 0.0;          register double        double_val = 0.0;
           register int           f_integer  = 0; /* Searching for integer value? */
         char *end;          char *end;
   
         if (where == NULL)          if (where == NULL)
Line 703  store_single_arg(type, arg, where)
Line 704  store_single_arg(type, arg, where)
                 case CFG_INT:                  case CFG_INT:
                 case CFG_UINT:                  case CFG_UINT:
                 case CFG_LONG:                  case CFG_LONG:
                         long_val = strtol(arg, &end, 0);  
                         break;  
   
                 case CFG_ULONG:                  case CFG_ULONG:
                         ulong_val = strtoul(arg, &end, 0);                          f_integer = 1;
                         break;                          if (type == CFG_ULONG) {
                                   ulong_val = strtoul(arg, &end, 0);
                           } else {
                                   long_val = strtol(arg, &end, 0);
                           }
                           if (! (end == NULL || *end != '\0'))
                                   /* Decimal number conversion suceed */
                                   break;
   
                           /* If conversion for integer number failed, we are going to try
                              further integer number initialization in float-like style. */
   
                 case CFG_FLOAT:                  case CFG_FLOAT:
                 case CFG_DOUBLE:                  case CFG_DOUBLE:
Line 717  store_single_arg(type, arg, where)
Line 725  store_single_arg(type, arg, where)
                                 return CFG_ERROR_BADNUMBER;                                  return CFG_ERROR_BADNUMBER;
   
                         if (double_val == +HUGE_VAL || double_val == -HUGE_VAL)                          if (double_val == +HUGE_VAL || double_val == -HUGE_VAL)
                                 return CFG_ERROR_OVERFLOW;                                  return f_integer ? CFG_ERROR_BADNUMBER : CFG_ERROR_OVERFLOW;
 #if HAVE_ERRNO_H  #if HAVE_ERRNO_H
                         if (double_val == 0.0 && errno == ERANGE)                          if (double_val == 0.0 && errno == ERANGE)
 #else  #else
                                 if (double_val == 0.0 && end == arg)                                  if (double_val == 0.0 && end == arg)
 #endif  #endif
                                         return CFG_ERROR_OVERFLOW;                                          return f_integer ? CFG_ERROR_BADNUMBER : CFG_ERROR_OVERFLOW;
   
                           /* Validating coversion results */
                           if (end == NULL || *end != '\0')
                                   return CFG_ERROR_BADNUMBER;
   
                           if (! f_integer)
                                   break;
   
                           if (double_val - floor(double_val) != 0.0)
                                   return CFG_ERROR_BADNUMBER;
   
                           if (type == CFG_ULONG) {
                                   ulong_val = (unsigned long) double_val;
                           } else {
                                   long_val = (long) double_val;
                           }
                         break;                          break;
         }          }
   
         /* Validating coversion results. */  
         if (end == NULL || *end != '\0')  
                 return CFG_ERROR_BADNUMBER;  
   
         /* Range checking and value storing. */          /* Range checking and value storing. */
         switch (type) {          switch (type) {
                 default:                  default:

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top