~mmach/netext73/lz4

« back to all changes in this revision

Viewing changes to tests/datagencli.c

  • Committer: mmach
  • Date: 2022-11-09 18:52:10 UTC
  • Revision ID: netbit73@gmail.com-20221109185210-w358idlhh0phq688
1.9.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
    datagencli.c
3
3
    compressible data command line generator
4
 
    Copyright (C) Yann Collet 2012-2016
 
4
    Copyright (C) Yann Collet 2012-2020
5
5
 
6
6
    GPL v2 License
7
7
 
34
34
 
35
35
 
36
36
/**************************************
 
37
*  Compiler specific
 
38
**************************************/
 
39
#ifdef _MSC_VER    /* Visual Studio */
 
40
#define strtoull    _strtoui64  /* https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strtoui64-wcstoui64-strtoui64-l-wcstoui64-l */
 
41
#endif
 
42
 
 
43
 
 
44
/**************************************
37
45
*  Constants
38
46
**************************************/
39
47
#define KB *(1 <<10)
103
111
                    return usage(programName);
104
112
                case 'g':
105
113
                    argument++;
106
 
                    size=0;
107
 
                    while ((*argument>='0') && (*argument<='9'))
108
 
                    {
109
 
                        size *= 10;
110
 
                        size += *argument - '0';
111
 
                        argument++;
112
 
                    }
 
114
                    size = strtoull(argument, &argument, 10);
113
115
                    if (*argument=='K') { size <<= 10; argument++; }
114
116
                    if (*argument=='M') { size <<= 20; argument++; }
115
117
                    if (*argument=='G') { size <<= 30; argument++; }
117
119
                    break;
118
120
                case 's':
119
121
                    argument++;
120
 
                    seed=0;
121
 
                    while ((*argument>='0') && (*argument<='9'))
122
 
                    {
123
 
                        seed *= 10;
124
 
                        seed += *argument - '0';
125
 
                        argument++;
126
 
                    }
 
122
                    seed = (U32) strtoul(argument, &argument, 10);
127
123
                    break;
128
124
                case 'P':
129
125
                    argument++;
130
 
                    proba=0.0;
131
 
                    while ((*argument>='0') && (*argument<='9'))
132
 
                    {
133
 
                        proba *= 10;
134
 
                        proba += *argument - '0';
135
 
                        argument++;
136
 
                    }
137
 
                    if (proba>100.) proba=100.;
 
126
                    proba = (double) strtoull(argument, &argument, 10);
138
127
                    proba /= 100.;
139
128
                    break;
140
129
                case 'L':   /* hidden argument : Literal distribution probability */
141
130
                    argument++;
142
 
                    litProba=0.;
143
 
                    while ((*argument>='0') && (*argument<='9'))
144
 
                    {
145
 
                        litProba *= 10;
146
 
                        litProba += *argument - '0';
147
 
                        argument++;
148
 
                    }
 
131
                    litProba = (double) strtoull(argument, &argument, 10);
149
132
                    if (litProba>100.) litProba=100.;
150
133
                    litProba /= 100.;
151
134
                    break;