jot.c (e29b080f61ace809822075ff410d59213abc6de2) | jot.c (9d288406f538c1c8c580c6679a95b34869398988) |
---|---|
1/*- 2 * Copyright (c) 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 39 unchanged lines hidden (view full) --- 48 */ 49 50#include <ctype.h> 51#include <limits.h> 52#include <stdio.h> 53#include <stdlib.h> 54#include <string.h> 55#include <time.h> | 1/*- 2 * Copyright (c) 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 39 unchanged lines hidden (view full) --- 48 */ 49 50#include <ctype.h> 51#include <limits.h> 52#include <stdio.h> 53#include <stdlib.h> 54#include <string.h> 55#include <time.h> |
56#include <unistd.h> |
|
56 57#define REPS_DEF 100 58#define BEGIN_DEF 1 59#define ENDER_DEF 100 60#define STEP_DEF 1 61 62#define isdefault(s) (strcmp((s), "-") == 0) 63 --- 26 unchanged lines hidden (view full) --- 90 long id; 91 register double *x = &xd; 92 register double *y = &yd; 93 register long *i = &id; 94 95 getargs(argc, argv); 96 if (randomize) { 97 *x = (ender - begin) * (ender > begin ? 1 : -1); | 57 58#define REPS_DEF 100 59#define BEGIN_DEF 1 60#define ENDER_DEF 100 61#define STEP_DEF 1 62 63#define isdefault(s) (strcmp((s), "-") == 0) 64 --- 26 unchanged lines hidden (view full) --- 91 long id; 92 register double *x = &xd; 93 register double *y = &yd; 94 register long *i = &id; 95 96 getargs(argc, argv); 97 if (randomize) { 98 *x = (ender - begin) * (ender > begin ? 1 : -1); |
98 srandom((int) s); | 99 srandom((unsigned) s); |
99 for (*i = 1; *i <= reps || infinity; (*i)++) { | 100 for (*i = 1; *i <= reps || infinity; (*i)++) { |
100 *y = (double) random() / INT_MAX; | 101 *y = (double) random() / LONG_MAX; |
101 putdata(*y * *x + begin, reps - *i); 102 } 103 } 104 else 105 for (*i = 1, *x = begin; *i <= reps || infinity; (*i)++, *x += s) 106 putdata(*x, reps - *i); 107 if (!nofinalnl) 108 putchar('\n'); --- 135 unchanged lines hidden (view full) --- 244 begin = BEGIN_DEF; 245 mask = 014; 246 break; 247 case 011: 248 begin = BEGIN_DEF; 249 mask = 015; 250 break; 251 case 012: | 102 putdata(*y * *x + begin, reps - *i); 103 } 104 } 105 else 106 for (*i = 1, *x = begin; *i <= reps || infinity; (*i)++, *x += s) 107 putdata(*x, reps - *i); 108 if (!nofinalnl) 109 putchar('\n'); --- 135 unchanged lines hidden (view full) --- 245 begin = BEGIN_DEF; 246 mask = 014; 247 break; 248 case 011: 249 begin = BEGIN_DEF; 250 mask = 015; 251 break; 252 case 012: |
252 s = (randomize ? time(0) : STEP_DEF); | 253 s = (randomize ? time(NULL) ^ getpid() : STEP_DEF); |
253 mask = 013; 254 break; 255 case 013: 256 if (randomize) 257 begin = BEGIN_DEF; 258 else if (reps == 0) 259 error("Must specify begin if reps == 0", ""); 260 begin = ender - reps * s + s; 261 mask = 0; 262 break; 263 case 014: | 254 mask = 013; 255 break; 256 case 013: 257 if (randomize) 258 begin = BEGIN_DEF; 259 else if (reps == 0) 260 error("Must specify begin if reps == 0", ""); 261 begin = ender - reps * s + s; 262 mask = 0; 263 break; 264 case 014: |
264 s = (randomize ? time(0) : STEP_DEF); | 265 s = (randomize ? time(NULL) ^ getpid() : STEP_DEF); |
265 mask = 015; 266 break; 267 case 015: 268 if (randomize) 269 ender = ENDER_DEF; 270 else 271 ender = begin + reps * s - s; 272 mask = 0; 273 break; 274 case 016: 275 if (randomize) | 266 mask = 015; 267 break; 268 case 015: 269 if (randomize) 270 ender = ENDER_DEF; 271 else 272 ender = begin + reps * s - s; 273 mask = 0; 274 break; 275 case 016: 276 if (randomize) |
276 s = time(0); | 277 s = time(NULL) ^ getpid(); |
277 else if (reps == 0) 278 error("Infinite sequences cannot be bounded", 279 ""); 280 else if (reps == 1) 281 s = 0.0; 282 else 283 s = (ender - begin) / (reps - 1); 284 mask = 0; --- 109 unchanged lines hidden --- | 278 else if (reps == 0) 279 error("Infinite sequences cannot be bounded", 280 ""); 281 else if (reps == 1) 282 s = 0.0; 283 else 284 s = (ender - begin) / (reps - 1); 285 mask = 0; --- 109 unchanged lines hidden --- |