|
|
e29994c |
--- bsd-games-2.17/arithmetic/arithmetic.c.orig 2004-12-07 05:34:21.000000000 -0800
|
|
|
e29994c |
+++ bsd-games-2.17/arithmetic/arithmetic.c 2017-02-18 12:01:57.930993440 -0800
|
|
|
e29994c |
@@ -84,7 +84,7 @@
|
|
|
e29994c |
#include <time.h>
|
|
|
e29994c |
#include <unistd.h>
|
|
|
e29994c |
|
|
|
e29994c |
-int getrandom(int, int, int);
|
|
|
e29994c |
+static int get_random(int, int, int);
|
|
|
e29994c |
void intr(int) __attribute__((__noreturn__));
|
|
|
e29994c |
int main(int, char *[]);
|
|
|
e29994c |
int opnum(int);
|
|
|
e29994c |
@@ -203,25 +203,25 @@
|
|
|
e29994c |
right = left = result = 0;
|
|
|
e29994c |
op = keys[random() % nkeys];
|
|
|
e29994c |
if (op != '/')
|
|
|
e29994c |
- right = getrandom(rangemax + 1, op, 1);
|
|
|
e29994c |
+ right = get_random(rangemax + 1, op, 1);
|
|
|
e29994c |
retry:
|
|
|
e29994c |
/* Get the operands. */
|
|
|
e29994c |
switch (op) {
|
|
|
e29994c |
case '+':
|
|
|
e29994c |
- left = getrandom(rangemax + 1, op, 0);
|
|
|
e29994c |
+ left = get_random(rangemax + 1, op, 0);
|
|
|
e29994c |
result = left + right;
|
|
|
e29994c |
break;
|
|
|
e29994c |
case '-':
|
|
|
e29994c |
- result = getrandom(rangemax + 1, op, 0);
|
|
|
e29994c |
+ result = get_random(rangemax + 1, op, 0);
|
|
|
e29994c |
left = right + result;
|
|
|
e29994c |
break;
|
|
|
e29994c |
case 'x':
|
|
|
e29994c |
- left = getrandom(rangemax + 1, op, 0);
|
|
|
e29994c |
+ left = get_random(rangemax + 1, op, 0);
|
|
|
e29994c |
result = left * right;
|
|
|
e29994c |
break;
|
|
|
e29994c |
case '/':
|
|
|
e29994c |
- right = getrandom(rangemax, op, 1) + 1;
|
|
|
e29994c |
- result = getrandom(rangemax + 1, op, 0);
|
|
|
e29994c |
+ right = get_random(rangemax, op, 1) + 1;
|
|
|
e29994c |
+ result = get_random(rangemax + 1, op, 0);
|
|
|
e29994c |
left = right * result + random() % right;
|
|
|
e29994c |
break;
|
|
|
e29994c |
}
|
|
|
e29994c |
@@ -326,8 +326,8 @@
|
|
|
e29994c |
* as a value, or represents a position in the penalty list. If the latter,
|
|
|
e29994c |
* we find the corresponding value and return that, decreasing its penalty.
|
|
|
e29994c |
*/
|
|
|
e29994c |
-int
|
|
|
e29994c |
-getrandom(maxval, op, operand)
|
|
|
e29994c |
+static int
|
|
|
e29994c |
+get_random(maxval, op, operand)
|
|
|
e29994c |
int maxval, op, operand;
|
|
|
e29994c |
{
|
|
|
e29994c |
int value;
|