aboutsummaryrefslogtreecommitdiff
path: root/tests/datagencli.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/datagencli.c')
-rw-r--r--tests/datagencli.c43
1 files changed, 13 insertions, 30 deletions
diff --git a/tests/datagencli.c b/tests/datagencli.c
index c985197f..ccb27dfc 100644
--- a/tests/datagencli.c
+++ b/tests/datagencli.c
@@ -1,7 +1,7 @@
/*
datagencli.c
compressible data command line generator
- Copyright (C) Yann Collet 2012-2016
+ Copyright (C) Yann Collet 2012-2020
GPL v2 License
@@ -34,6 +34,14 @@
/**************************************
+* Compiler specific
+**************************************/
+#ifdef _MSC_VER /* Visual Studio */
+#define strtoull _strtoui64 /* https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strtoui64-wcstoui64-strtoui64-l-wcstoui64-l */
+#endif
+
+
+/**************************************
* Constants
**************************************/
#define KB *(1 <<10)
@@ -103,13 +111,7 @@ int main(int argc, char** argv)
return usage(programName);
case 'g':
argument++;
- size=0;
- while ((*argument>='0') && (*argument<='9'))
- {
- size *= 10;
- size += *argument - '0';
- argument++;
- }
+ size = strtoull(argument, &argument, 10);
if (*argument=='K') { size <<= 10; argument++; }
if (*argument=='M') { size <<= 20; argument++; }
if (*argument=='G') { size <<= 30; argument++; }
@@ -117,35 +119,16 @@ int main(int argc, char** argv)
break;
case 's':
argument++;
- seed=0;
- while ((*argument>='0') && (*argument<='9'))
- {
- seed *= 10;
- seed += *argument - '0';
- argument++;
- }
+ seed = (U32) strtoul(argument, &argument, 10);
break;
case 'P':
argument++;
- proba=0.0;
- while ((*argument>='0') && (*argument<='9'))
- {
- proba *= 10;
- proba += *argument - '0';
- argument++;
- }
- if (proba>100.) proba=100.;
+ proba = (double) strtoull(argument, &argument, 10);
proba /= 100.;
break;
case 'L': /* hidden argument : Literal distribution probability */
argument++;
- litProba=0.;
- while ((*argument>='0') && (*argument<='9'))
- {
- litProba *= 10;
- litProba += *argument - '0';
- argument++;
- }
+ litProba = (double) strtoull(argument, &argument, 10);
if (litProba>100.) litProba=100.;
litProba /= 100.;
break;