summaryrefslogtreecommitdiffstats
path: root/tests/datagencli.c
diff options
context:
space:
mode:
authorYann Collet <Cyan4973@users.noreply.github.com>2022-08-15 22:45:31 (GMT)
committerGitHub <noreply@github.com>2022-08-15 22:45:31 (GMT)
commit5ff839680134437dbf4678f3d0c7b371d84f4964 (patch)
tree939d919c3903b42ed637542a4799fb3f4fa8b5fc /tests/datagencli.c
parent416bc96faca629abcef42e56ecd2e20d26b79934 (diff)
parentcfd6ab32522280079c2e6d3ea995f172b9ae0312 (diff)
downloadlz4-5ff839680134437dbf4678f3d0c7b371d84f4964.zip
lz4-5ff839680134437dbf4678f3d0c7b371d84f4964.tar.gz
lz4-5ff839680134437dbf4678f3d0c7b371d84f4964.tar.bz2
Merge pull request #1138 from lz4/devv1.9.4release
stage v1.9.4
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 c985197..ccb27df 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;