Author: sebor Date: Tue Nov 7 08:52:26 2006 New Revision: 472162 URL: http://svn.apache.org/viewvc?view=rev&rev=472162 Log: 2006-11-07 Martin Sebor * cmdopt.cpp (eval_options): Set errno to 0 before calling strtol and testing its value to avoid false positives due to the variable being already set by another function. Modified: incubator/stdcxx/trunk/util/cmdopt.cpp Modified: incubator/stdcxx/trunk/util/cmdopt.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/cmdopt.cpp?view=diff&rev=472162&r1=472161&r2=472162 ============================================================================== --- incubator/stdcxx/trunk/util/cmdopt.cpp (original) +++ incubator/stdcxx/trunk/util/cmdopt.cpp Tue Nov 7 08:52:26 2006 @@ -58,11 +58,21 @@ const char default_path_sep = '/'; const char suffix_sep = '.'; const size_t exe_suffix_len = 0; +#if defined (_SC_CLK_TCK) +const float TICKS_PER_SEC = sysconf (_SC_CLK_TCK); +#elif defined (CLK_TCK) +const float TICKS_PER_SEC = CLK_TCK; +#elif defined (CLOCKS_PER_SEC) +const float TICKS_PER_SEC = CLOCKS_PER_SEC; +#else +# error Unable to determine number of clock ticks in a second. +#endif #else const char escape_code = '^'; const char default_path_sep = '\\'; const char suffix_sep = '.'; const size_t exe_suffix_len = 4; /* strlen(".exe") == 4 */ +const float TICKS_PER_SEC = 10000000; /* 100 nanosecond units in a second */ #endif static const char @@ -546,6 +556,8 @@ if (optarg) { if (!isdigit (*optarg)) bad_value (optname, optarg); + + errno = 0; defaults->timeout = strtol (optarg, &end, 10); if (*end || errno) bad_value (optname, optarg); @@ -592,6 +604,8 @@ if (optarg && *optarg) { if (!isdigit (*optarg)) bad_value (optname, optarg); + + errno = 0; const long code = strtol (optarg, &end, 10); if ('\0' == *end && !errno) exit (code); @@ -610,6 +624,8 @@ if (optarg && *optarg) { if (!isdigit (*optarg)) bad_value (optname, optarg); + + errno = 0; const long nsec = strtol (optarg, &end, 10); if ('\0' == *end && 0 <= nsec && !errno) { rw_sleep (nsec);