mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
convert ASCII TABs to ASCII SPACEs
Converted all ASCII tabs to ASCII spaces using a 8 character tab stop, for all files, except for all Makefiles (plus rpm.mk). The `git diff -w` reports no changes.
This commit is contained in:
136
sample_rand.c
136
sample_rand.c
@@ -9,7 +9,7 @@
|
||||
*
|
||||
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details.
|
||||
*
|
||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
@@ -17,19 +17,19 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Under source code control: 1997/04/19 22:46:49
|
||||
* File existed as early as: 1997
|
||||
* Under source code control: 1997/04/19 22:46:49
|
||||
* File existed as early as: 1997
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
* usage:
|
||||
* test_random [[bits] seed_string]
|
||||
* test_random [[bits] seed_string]
|
||||
*
|
||||
* seed_string something for which we can seed (def: default seed)
|
||||
* bits number of bits to generate
|
||||
* seed_string something for which we can seed (def: default seed)
|
||||
* bits number of bits to generate
|
||||
*/
|
||||
|
||||
|
||||
@@ -42,78 +42,78 @@
|
||||
|
||||
|
||||
#include "errtbl.h"
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
#define DEF_CNT 128 /* default number of bits to generate */
|
||||
#define DEF_CNT 128 /* default number of bits to generate */
|
||||
|
||||
extern char *program; /* our name */
|
||||
extern char *program; /* our name */
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
RANDOM *prev_state; /* previous random number state */
|
||||
ZVALUE seed; /* seed for Blum-Blum-Shub */
|
||||
ZVALUE random_val; /* random number produced */
|
||||
long cnt; /* number of bits to generate */
|
||||
char *hexstr; /* random number as hex string */
|
||||
RANDOM *prev_state; /* previous random number state */
|
||||
ZVALUE seed; /* seed for Blum-Blum-Shub */
|
||||
ZVALUE random_val; /* random number produced */
|
||||
long cnt; /* number of bits to generate */
|
||||
char *hexstr; /* random number as hex string */
|
||||
|
||||
/*
|
||||
* parse args
|
||||
*/
|
||||
program = argv[0];
|
||||
switch (argc) {
|
||||
case 3:
|
||||
seed = convstr2z(argv[2]);
|
||||
cnt = strtol(argv[1], NULL, 0);
|
||||
break;
|
||||
case 2:
|
||||
seed = _zero_; /* use the default seed */
|
||||
cnt = strtol(argv[1], NULL, 0);
|
||||
break;
|
||||
case 1:
|
||||
seed = _zero_; /* use the default seed */
|
||||
cnt = DEF_CNT;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "usage: %s [[bits] seed_string]\n", program);
|
||||
exit(1);
|
||||
}
|
||||
if (cnt <= 0) {
|
||||
fprintf(stderr, "%s: cnt:%d must be > 0\n", program, (int)cnt);
|
||||
exit(2);
|
||||
}
|
||||
printf("seed= 0x%s\n", convz2hex(seed));
|
||||
/*
|
||||
* parse args
|
||||
*/
|
||||
program = argv[0];
|
||||
switch (argc) {
|
||||
case 3:
|
||||
seed = convstr2z(argv[2]);
|
||||
cnt = strtol(argv[1], NULL, 0);
|
||||
break;
|
||||
case 2:
|
||||
seed = _zero_; /* use the default seed */
|
||||
cnt = strtol(argv[1], NULL, 0);
|
||||
break;
|
||||
case 1:
|
||||
seed = _zero_; /* use the default seed */
|
||||
cnt = DEF_CNT;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "usage: %s [[bits] seed_string]\n", program);
|
||||
exit(1);
|
||||
}
|
||||
if (cnt <= 0) {
|
||||
fprintf(stderr, "%s: cnt:%d must be > 0\n", program, (int)cnt);
|
||||
exit(2);
|
||||
}
|
||||
printf("seed= 0x%s\n", convz2hex(seed));
|
||||
|
||||
/*
|
||||
* libcalc setup
|
||||
*/
|
||||
libcalc_call_me_first();
|
||||
/*
|
||||
* libcalc setup
|
||||
*/
|
||||
libcalc_call_me_first();
|
||||
|
||||
/*
|
||||
* seed the generator
|
||||
*/
|
||||
prev_state = zsrandom2(seed, _ten_);
|
||||
if (prev_state == NULL) {
|
||||
math_error("previous random state is NULL");
|
||||
not_reached();
|
||||
}
|
||||
/*
|
||||
* seed the generator
|
||||
*/
|
||||
prev_state = zsrandom2(seed, _ten_);
|
||||
if (prev_state == NULL) {
|
||||
math_error("previous random state is NULL");
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* generate random bits
|
||||
*/
|
||||
zrandom(cnt, &random_val);
|
||||
/*
|
||||
* generate random bits
|
||||
*/
|
||||
zrandom(cnt, &random_val);
|
||||
|
||||
/*
|
||||
* convert into hex string
|
||||
*/
|
||||
hexstr = convz2hex(random_val);
|
||||
printf("random= 0x%s\n", hexstr);
|
||||
/*
|
||||
* convert into hex string
|
||||
*/
|
||||
hexstr = convz2hex(random_val);
|
||||
printf("random= 0x%s\n", hexstr);
|
||||
|
||||
/*
|
||||
* all done
|
||||
*/
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
/*
|
||||
* all done
|
||||
*/
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user