Deleted Added
full compact
run.c (256281) run.c (272918)
1/****************************************************************
2Copyright (C) Lucent Technologies 1997
3All Rights Reserved
4
5Permission to use, copy, modify, and distribute this software and
6its documentation for any purpose and without fee is hereby
7granted, provided that the above copyright notice appear in all
8copies and that both that the copyright notice and this

--- 9 unchanged lines hidden (view full) ---

18SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
20IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
21ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
22THIS SOFTWARE.
23****************************************************************/
24
25#include <sys/cdefs.h>
1/****************************************************************
2Copyright (C) Lucent Technologies 1997
3All Rights Reserved
4
5Permission to use, copy, modify, and distribute this software and
6its documentation for any purpose and without fee is hereby
7granted, provided that the above copyright notice appear in all
8copies and that both that the copyright notice and this

--- 9 unchanged lines hidden (view full) ---

18SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
20IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
21ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
22THIS SOFTWARE.
23****************************************************************/
24
25#include <sys/cdefs.h>
26__FBSDID("$FreeBSD: stable/10/contrib/one-true-awk/run.c 244988 2013-01-03 07:25:30Z delphij $");
26__FBSDID("$FreeBSD: stable/10/contrib/one-true-awk/run.c 272918 2014-10-10 23:18:44Z pfg $");
27
28#define DEBUG
29#include <stdio.h>
30#include <ctype.h>
31#include <setjmp.h>
32#include <limits.h>
33#include <math.h>
34#include <string.h>

--- 1481 unchanged lines hidden (view full) ---

1516 nextarg = nextarg->nnext;
1517 }
1518 break;
1519 case FSYSTEM:
1520 fflush(stdout); /* in case something is buffered already */
1521 u = (Awkfloat) system(getsval(x)) / 256; /* 256 is unix-dep */
1522 break;
1523 case FRAND:
27
28#define DEBUG
29#include <stdio.h>
30#include <ctype.h>
31#include <setjmp.h>
32#include <limits.h>
33#include <math.h>
34#include <string.h>

--- 1481 unchanged lines hidden (view full) ---

1516 nextarg = nextarg->nnext;
1517 }
1518 break;
1519 case FSYSTEM:
1520 fflush(stdout); /* in case something is buffered already */
1521 u = (Awkfloat) system(getsval(x)) / 256; /* 256 is unix-dep */
1522 break;
1523 case FRAND:
1524 /* in principle, rand() returns something in 0..RAND_MAX */
1525 u = (Awkfloat) (rand() % RAND_MAX) / RAND_MAX;
1524 /* random() returns numbers in [0..2^31-1]
1525 * in order to get a number in [0, 1), divide it by 2^31
1526 */
1527 u = (Awkfloat) random() / (0x7fffffffL + 0x1UL);
1526 break;
1527 case FSRAND:
1528 if (isrec(x)) /* no argument provided */
1529 u = time((time_t *)0);
1530 else
1531 u = getfval(x);
1532 tmp = u;
1528 break;
1529 case FSRAND:
1530 if (isrec(x)) /* no argument provided */
1531 u = time((time_t *)0);
1532 else
1533 u = getfval(x);
1534 tmp = u;
1533 srand((unsigned int) u);
1535 srandom((unsigned long) u);
1534 u = srand_seed;
1535 srand_seed = tmp;
1536 break;
1537 case FTOUPPER:
1538 case FTOLOWER:
1539 buf = tostring(getsval(x));
1540 if (t == FTOUPPER) {
1541 for (p = buf; *p; p++)

--- 420 unchanged lines hidden ---
1536 u = srand_seed;
1537 srand_seed = tmp;
1538 break;
1539 case FTOUPPER:
1540 case FTOLOWER:
1541 buf = tostring(getsval(x));
1542 if (t == FTOUPPER) {
1543 for (p = buf; *p; p++)

--- 420 unchanged lines hidden ---